|
From: | Christian Franke |
Subject: | Re: [PATCH] Fix eisa_mmap evaluation, add memory existence check |
Date: | Fri, 09 Nov 2007 22:53:23 +0100 |
User-agent: | Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070802 SeaMonkey/1.1.4 |
Robert Millan wrote:
On Tue, Oct 23, 2007 at 09:06:16PM +0200, Christian Franke wrote:+/* Check memory address */ +static int +addr_is_valid (grub_addr_t addr) +{ + volatile unsigned char * p = (volatile unsigned char *)addr; + unsigned char x, y; + x = *p; + *p = x ^ 0xcf; + y = *p; + *p = x; + return y == (x ^ 0xcf); +} +I have a feeling this might be dangerous. Any comments on the warnings listed here: http://www.osdev.org/wiki/How_Do_I_Determine_The_Amount_Of_RAM#Counting_RAM_by_direct_probing ? Specially the bit about memory-mapped PCI.
This code does not check any memory-mapped PCI. It does only check the boundary returned by the BIOS memory map evaluation code (which didn't work in the E801 case).
Definitely not mandatory, but a IMO recommended assert-type check for experimental code.
Besides, if we really want it, perhaps it should be in a separate file so that other ports can use it if it's needed ?
Good point.
Ah, and why 0xcf instead of 0xff ?
... or 0xaa or 0x55. c.f. :-)
[Prev in Thread] | Current Thread | [Next in Thread] |