Detecting the Total Amound of Installed 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.
Post Reply
astrocrep

Detecting the Total Amound of Installed Memory?

Post by astrocrep »

I am reading Memory Management 1 by Tim Robinson, and its stated that we need to find out the total amount of installed ram in the system, we can get up to 64mb by reading cmos... or by intting 15 in realmode... well I am using GRUB, I check the multiboot header specs... but I honestly can make heads or tails out of it... Is there an absolute way to detect the total amound of ram installing in a system?

I was thinking someting along the lines of psuedo code:

pointer to 2mb mark...
write 'a'
read 'a'
failure break from loop
else add 1mb to pointer and try again...

but my code must be sloppy and it goes through an inft loop.

Thanks for the help.

Rich P.
cxsnew

Re:Detecting the Total Amound of Installed Memory?

Post by cxsnew »

Some newer bios call maybe can do some help for you when detect the installed RAM in the system,but this will depend on the mother board.
Another method is detect the RAM directly, you can get more details about this in www.mega-tokyo.com/os
Hopes help for you.
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

Re:Detecting the Total Amound of Installed Memory?

Post by bubach »

but if your code goes to, let's say 128 mb and then tries to write to 129 mb (which we say don't exist), what happends then? doesn't your os hang or something?

/ Christoffer
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Detecting the Total Amound of Installed Memory?

Post by Candy »

bubach wrote: but if your code goes to, let?s say 128 mb and then tries to write to 129 mb (witch we say don?t exist), what happends then? does?nt your os hang or something?

/ Christoffer
the method does work. The OS will not crash or anything. But, you DO have other things that may exhibit a memory function that you may never use as memory. Say, your acpi tables or your PCI configuration.

Use int15/e820 or int15/e801. Just about all computers have them and they're easy to code, let alone that I've heard grub provides e820-ish output anyway..
ASHLEY4

Re:Detecting the Total Amound of Installed Memory?

Post by ASHLEY4 »

I would not use probing memory at 1mb intervils,as i have read that it can DAMAGE your's or someone else's system.

"However, your BIOS knows things you ignore about your motherboard and PCI devices. Probing memory-mapped PCI devices may have unpredictable results and possibly damage your system, "

ASHLEY4.
User avatar
Neo
Member
Member
Posts: 842
Joined: Wed Oct 18, 2006 9:01 am

Re:Detecting the Total Amound of Installed Memory?

Post by Neo »

you can either write your own bootloader to get the memory map from the BIOS or, as you are using GRUB see the example kernel that comes with it to see how you can use the memory map info supplied by it.
I haven't tried this as yet as i use my own bootloader. but i read somewhere that GRUB comes with a simple kernel showing you its features.
Only Human
bradd

Re:Detecting the Total Amound of Installed Memory?

Post by bradd »

I found a nice little ASM program that detects memory, trying 3 different ways.. Right now it just prints the blocks, but I've adapted it to store the blocks somehwere in memory where my C program can then read the blocks and do whatnot with them.

Heres the link:
http://my.execpc.com/~geezer/osd/boot/biosmem.asm
Post Reply