Mem above 1 MB

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.
HardEnough

Mem above 1 MB

Post by HardEnough »

hi guys
is there is any mem above 1MB which i don't have to touch ???
Ushma

Re:Mem above 1 MB

Post by Ushma »

You mean mustn't touch? One way to find that out is to get a memory map, which will make holes and other hazards apparent. A simpler way would be to get the extended memory size, which would indicate the presence of that much memory past 1MB. A problem with this is that if there is a hole (like the 1MB at 15MB OS/2 thing), you will only get memory up to that hole, and could be missing memory past it.
HardEnough

Re:Mem above 1 MB

Post by HardEnough »

thus there exists memory after 1 MB which i mustn't touch ?
so how can the memory manager avoid this pieces of mem ???
if it's memory mapping, how can this be done ?
QuiTeVexat

Re:Mem above 1 MB

Post by QuiTeVexat »

The memory manager never allocates those pieces of memory (it only considers useable memory for allocation).

If you mean *you* mapping memory, just don't map any of those places into any address spaces.

If you mean things like memory mapped devices and the video memory, they won't show up as useable memory on the map.
HardEnough

Re:Mem above 1 MB

Post by HardEnough »

no i meant a memory map containing the unusable pieces of ram that shouldn't be used in any way , the memory map should also contain the pieces of ram that i can allocate.
how can i find the area that can't be done ?
below 1 MB : i always never touch
after 1MB: ???
QuiTeVexat

Re:Mem above 1 MB

Post by QuiTeVexat »

A memory map entry usually consists of a base, length, and type. Type will tell you whether it is useable.

Refer to this page:
http://www.osdev.org/osfaq2/index.php/H ... f%20RAM%3F
HardEnough

Re:Mem above 1 MB

Post by HardEnough »

i don't need to do so manually , i like to use grub to get the memory size and limit for both low, high mem, but how about the holes.
e.g. if memory @ 5 MB mark is used by a certian hardware device, how can i know it's reserved for this device and prevent the acess to it ??
QuiTeVexat

Re:Mem above 1 MB

Post by QuiTeVexat »

The extended memory size that grub gives you will not go through any holes. I have a machine with the option of making the 1 MB hole at 15MB. On that machine, with the option enabled, grub reports 14MB of extended memory. Without the option enabled, grub reports 127MB of extended memory (the full quantity).

Preventing access to it involves using the protection mechanisms. Not using the memory is as simple as that: don't allocate it, don't use it.
HardEnough

Re:Mem above 1 MB

Post by HardEnough »

i need to know where this hole to not use it
QuiTeVexat

Re:Mem above 1 MB

Post by QuiTeVexat »

I will repeat: The extended memory size that grub gives you will not go through any holes.

Thus, you can rest assured that there will be no holes from the 1MB mark + howevermuch extended memory grub reports. Note that the default is *lack* of useable memory, and that you should only use addresses that you know point to useable memory, rather than not use addresses that point to a hole. The memory manager should only consider known useable areas for allocation.
HardEnough

Re:Mem above 1 MB

Post by HardEnough »

so if grub reports that i've 64 MB which means the address from 0x100000 -> 64 MB can be used normally without any holes in the middle?
AR

Re:Mem above 1 MB

Post by AR »

yes, but to do it properly and work your way around holes you must use the memory map from the BIOS (Which GRUB kindly gets for you and gives you a pointer to in the multiboot info structure).
Tora OS

Re:Mem above 1 MB

Post by Tora OS »

just out of curiosity...what would happen if you did write to one of these holes?
AR

Re:Mem above 1 MB

Post by AR »

It will either cause "undefined behaviour" on the device mapped in that space, or if there is no device it will just cause the bus to float. (When the bus floats, the last value written gets "stuck", you can read it back but the value will be lost when another value is written IIRC)
Freanan

Re:Mem above 1 MB

Post by Freanan »

Having to use the memory map is bad...
Because out of some reason the flag in the multiboot structure that indicates the validity of those maps is always set to null and i only get one small memory area if i try to read the map anyway
(and yes, the multiboot struct as a whole is valid, i can print the right commandline and the lower/upper memory from grub in my kernel).

I am using bochs and i heard that some things just don't work in bochs.
Is the memory map one of them?
Post Reply