i come across a "fast" method to detect memory today(BeansOS). But i thought it has some problem,though it runs properly on all qemu,bochs,and vmware.
Code: Select all
void ram_detect(void) {
//write and verify from 8M ,every 4M has a read point.
volatile unsigned char* checkpoint = (char*)CHECKMEMBASE; //8M
volatile unsigned char tmp;
ram_size = 0;
while (1) {
//read
tmp = *checkpoint;
tmp = (~tmp);
//write
*checkpoint = tmp;
//verify
if (tmp != *checkpoint) { //check end.
ram_size = (unsigned long)checkpoint;
break;
}
checkpoint += CHECKMEMSTEP; //+4M
if ((unsigned long)checkpoint >= MAXRAMSIZE) {
//in this case, 2G-4M has check passed,so 0-(2G-1byte) can be use
ram_size = MAXRAMSIZE;
break;
}
}
max_ramaddr = ram_size-1;
printk('s', "ram detect finish ram_size is:");
printk('n', ram_size/1024/1024);
printk('s', "M\n");
}
And if not, is there any simple way to detect memory capicity?(it will be great if the reserved area is shown)
I've been always using int15h with ARDS.
thanks