backing in empty or ram subject.

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

 



skull code of rubini's book -- http://www.xml.com/ldd/chapter/book/ch08.html#t4  --
usbsection Probing for ISA Memory (listed at end of this mail)  -- probe all ISA 
memory range. It can reach:
1- Memory allocated. 
2- RAM memory.
3- empty memory.
(or 4-ROM yet, but i think we can ignore this fact here)

But i think one possibility is missing: if is there  a ISA hardware whose
driver wasn't loaded yet? Since the driver wasn't uploaded yet, code
does not reach a Memory allocated region. I think such region is nor a RAM region
neither an empty region (because there is a hardware)... Where am I
wrong? When code reach such region, what does it think is that region?
RAM or empty memory?

TIA.
-Riba

Code Listing:


unsigned char oldval, newval; /* values read from memory   */
unsigned long flags;          /* used to hold system flags */
unsigned long add, i;
void *base;
    
/* Use ioremap to get a handle on our region */
base = ioremap(ISA_REGION_BEGIN, ISA_REGION_END - ISA_REGION_BEGIN);
base -= ISA_REGION_BEGIN;  /* Do the offset once */
    
/* probe all the memory hole in 2-KB steps */
for (add = ISA_REGION_BEGIN; add < ISA_REGION_END; add += STEP) {
   /*
    * Check for an already allocated region.
	*/
   if (check_mem_region (add, 2048)) {
          printk(KERN_INFO "%lx: Allocated\n", add);
          continue;
   }
   /*
    * Read and write the beginning of the region and see what happens.
    */
   save_flags(flags); 
   cli();
   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;
   }


--
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