amount of memory

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
pskyboy

Re:amount of memory

Post 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
K.J.

Re:amount of memory

Post 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.
Tim

Re:amount of memory

Post 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.
peters_bar

Re:amount of memory

Post 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.
Perica
Member
Member
Posts: 454
Joined: Sat Nov 25, 2006 12:50 am

Re:amount of memory

Post by Perica »

..
Last edited by Perica on Sun Dec 03, 2006 8:47 pm, edited 1 time in total.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:amount of memory

Post 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;
}
Post Reply