RAM or "empty"?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In  subsection "Probing for ISA Memory" of section Using I/O Memory 
( http://www.xml.com/ldd/chapter/book/ch08.html#t4 ) of Device Drivers
Book, by Rubini, there is a code that reads a byte from memory, change
this byte by a know pattern (it toggles every bit of the byte), write
this changed byte to memory and read, ever in the same memory position.
Then it unchanged the new-read byte to see if it is equal to old-read
byte. If it is equal, then the book concludes that the memory  region is 
RAM. Else book concludes the memory region is "empty". 

What does mean an "empty" region of memory? Why and how can a
non-existing memory region be mapped? (below is the code in rubini's
book):

oldval = readb (base + add);  /* Read a byte */
writeb (oldval^0xff, base + add);
mb();
newval = readb (base + add);
writeb (oldval, base + add);
restore_flags(flags);

if ((oldval^newval) == 0xff) {  /* we reread our
change: it's RAM */
	printk(KERN_INFO "%lx: RAM\n", add);
	continue;
}
if ((oldval^newval) != 0) {  /*
								random bits changed: it's empty
							  */
	printk(KERN_INFO "%lx:
		   empty\n", add);
	continue;
}


Regards,
Ribamar


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux