Click to See Complete Forum and Search --> : "as 0x00, 0xff, or the low" MEMORY is empty, why?


muyu
04-16-2003, 08:26 AM
below snippet have some hard to understand.
Why? "as 0x00, 0xff, or the low" it's empty, like ROM(first byt is 0x55, the second 0xaa, and the third byte) , is these both of convention merely? who can explain it? thanks in advance.
/*
* If the tests above failed, we still don't know if it is ROM or
* empty. Since empty memory can appear as 0x00, 0xff, or the low
* address byte, we must probe multiple bytes: if at least one of
* them is different from these three values, then this is rom
* (though not boot rom).
*/
printk(KERN_INFO "%lx: ", add);
for (i=0; i<5; i++) {
unsigned long radd = add + 57*(i+1); /* a "random" value */
unsigned char val = readb (base + radd);
if (val && val != 0xFF && val != ((unsigned long) radd&0xFF))
break;
}
printk("%s\n", i==5 ? "empty" : "ROM");
}

bwkaz
04-16-2003, 10:21 AM
Originally posted by muyu
Since empty memory can appear as 0x00, 0xff, or the low address byte, we must probe multiple bytes: if at least one of them is different from these three values, then this is rom (though not boot rom). This piece of code is trying to decide whether a certain address has unused RAM or ROM sitting behind it.

Unused RAM, on whichever processor / OS this is, can take one of three values. It might be 0x00, it might be 0xff, and it might be the low byte of the address. Apparently the memory controller sometimes just spits back the low byte of the address that gets sent to it on this architecture. The 0x00 vs. 0xff thing is just whatever value got stored there last, or whatever the initial power-on value is. Perhaps this architecture allows some freedom for the memory chip makers to have either 0x00 or 0xff (that is, all bits low or all bits high) in an uninitialized RAM cell.

muyu
04-19-2003, 01:24 AM
you are warmhearted moderator :) thanks.