Page 2 of 2

Re:amount of memory

Posted: Sun Dec 22, 2002 4:46 am
by pskyboy
I don't plan on running my OS on anything lower then PIII - Athlon based systems but i also want to port it to some of the latest RISC chips and how portable will it be if i use bios calls to determine the amount of memory.

Peter

Re:amount of memory

Posted: Sun Dec 22, 2002 2:51 pm
by K.J.
how portable will it be if i use bios calls to determine the amount of memory.
Just as portable as using assembly.

It's not hard to code functions to determine amounts of memory.

K.J.

Re:amount of memory

Posted: Thu Dec 26, 2002 1:16 pm
by Tim
pskyboy wrote:and how portable will it be if i use bios calls to determine the amount of memory.
Not at all, but neither is using Open Firmware or the ARC bootstrap. Each platform has its own low-level way of doing these things. There's nothing wrong with recoding parts of the kernel to support different architectures; in fact, isn't this why you're writing a kernel -- to abstract the hardware to keep the applications portable.

Interesting point: a lot of the NT kernel (not just the HAL) was rewritten for the various architectures. The HAL is there to support minor differences in hardware on one platform; there is a lot of architecture-specific code inside the kernel too.

Re:amount of memory

Posted: Mon Feb 03, 2003 6:11 am
by peters_bar
Paul wrote: If you are in protected mode, just probe the memory directly.... Start at 0x100000 and write a known byte sequence to memory and try reading it back to see if it changed. Once you can no longer write something and read the same thing back, you must have hit the end of memory. It's good to write two different values to make sure the first value wasn't already there. So like write 0x00ff00ff and then 0xff00ff00 to every dword.

Paul
Hello.
How can i write into memory without causing a tripple fault? should i create a 4GB descriptor or is it possible to write(read) directly into mem?

Sorry for my bad english, i'm german.

Re:amount of memory

Posted: Mon Feb 03, 2003 7:46 am
by Perica
..

Re:amount of memory

Posted: Mon Feb 03, 2003 8:18 am
by Pype.Clicker
a possible trick to find the amount of memory is to use an exponential search combined with a dichotomic technique:

q=0;p=1; found=false; high=false;

while(!found) {
// ([0..q[ is valid RAM) && ( !high || ]h..4GB] is not mapped.
if (mem.Check(p) && mem.Check(p+1)) {
q=p; // p was in valid RAM area --> go further
if (!high)p=p*2;
else p=(p+h)/2;
continue;
}
if (!mem.Chech(p) && !mem.Check(p+1)) {
high=true; h=p;
p=(q+p)/2;
continue;
}
if (mem.Check(p) && !mem.Check(p+1))found = true;
}