Hi...
I am working on a memory manger. I am trying to get the amount of available memory FROM PROTECTED MODE. Any ideas?[/b]
getting the amount of avilable memory
-
- Posts: 11
- Joined: Sat Feb 05, 2005 12:00 am
getting the amount of avilable memory
Last edited by aymanmadkour on Thu Apr 28, 2005 11:00 pm, edited 1 time in total.
Re: getting the amount of avilable memory
Best ways to get RAM size is with the BIOS:
http://my.execpc.com/~geezer/osd/boot/biosmem.asm
Otherwise you can get it from CMOS, will only report up to 64mb, or by directly probing for memory.
When probing you simply write something at memroy positions like 0xdeadbeef at every megabyte, and then you read it and compare, if it's the same then the memory position exists.
Directly probing for memory won't work on machines where you might write your little test thing ( for ex. 0xdeadbeef) onto a "bad area" like memory mapped IO devices or hitting a memory hole.
/ Christoffer
http://my.execpc.com/~geezer/osd/boot/biosmem.asm
Otherwise you can get it from CMOS, will only report up to 64mb, or by directly probing for memory.
When probing you simply write something at memroy positions like 0xdeadbeef at every megabyte, and then you read it and compare, if it's the same then the memory position exists.
Directly probing for memory won't work on machines where you might write your little test thing ( for ex. 0xdeadbeef) onto a "bad area" like memory mapped IO devices or hitting a memory hole.
/ Christoffer
Last edited by bubach on Thu Apr 28, 2005 11:00 pm, edited 1 time in total.
-
- Posts: 11
- Joined: Sat Feb 05, 2005 12:00 am
Re: getting the amount of avilable memory
I used the direct memory probing solution... It is not the best one, but it worked.
Thanks
Thanks
Re: getting the amount of avilable memory
I dunno if there's a easy(and safe) way to do that in protected mode...because the usual way is to do BIOS calls. If you cannot get memory size while still in real mode and store in a variable, write a virtual-8086 monitor to call the BIOS services from protected mode.
This handles getting memory size from real mode. Works for me.
This is my code, so it may not work in other machines.
This handles getting memory size from real mode. Works for me.
Code: Select all
mov ax, 0xe801
int 15h
shl eax, 10
shl ebx, 16
add eax, 1 * BytesPerMega
add eax, ebx
mov [TotalMemory], eax
Last edited by beppe85 on Sun May 01, 2005 11:00 pm, edited 1 time in total.