memory polling to determine memory size startup?

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
Ben_3D

memory polling to determine memory size startup?

Post by Ben_3D »

Hi, I was just wondering, if theres a way to determine how much asm is plugged into the computer without using the bios etc....sort of just write and read back blocks of bytes etc till they come back wrong?
I have a feeling writing to memory locations that are inaccecible causes memory acceptions and crashes....of course this is all done in a mini os I'm playing with :)

Not sure if this is allowed or if theres a method which is the norm on how to determine memory...I jsut remember on my old pc at startup it would count through memory or checking memory at bootup :)

Any info or advice would be great.

Thanks a great deal.

Ben
AR

Re:memory polling to determine memory size startup?

Post by AR »

You can probe memory manually like that but it is highly recommended that you use the BIOS as your memory probe may write to a memory mapped device causing weird things to happen.
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:memory polling to determine memory size startup?

Post by distantvoices »

I daresay, you've posted this in the wrong board. *gg*

Might a mod move this to "os development" board? Thx :-)

As of your question, I'm not sure if I understand right - but yes, by writing something to some memory loco to get the total amount of memory installed, you might get trouble (unless you save the previous value and restore it after the testing action.)

There are more reliable and less dangerous methods to find the amount of memory installed: you may ask the bios (recent boards deliver quite accurate values) you may take the value grub delivers, etx ...
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:memory polling to determine memory size startup?

Post by Solar »

beyond infinity wrote: As of your question, I'm not sure if I understand right - but yes, by writing something to some memory loco to get the total amount of memory installed, you might get trouble (unless you save the previous value and restore it after the testing action.)
Even then. Your write might have triggered something in a device mapped to that memory area. "Undefined behaviour". (The experienced ASM/C coder runs for cover...)
Every good solution is obvious once you've found it.
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:memory polling to determine memory size startup?

Post by df »

-- Stu --
mystran

Re:memory polling to determine memory size startup?

Post by mystran »

The possibility of accidentally hitting something important is made much worse by the fact that since all of normal RAM need not be continuous, you can't simply stop after you get wrong values first time, unless you are happy with only part of the memory.

Another big problem is that if you hit a video framebuffer, you will probably read the same value that you wrote, but if you then think that it's RAM, you will have really slow applications, and possibly fancy visuals as well. :)

In short: just use the BIOS.
Post Reply