Hi.
How can detect memory size in PROTECTED MODE? Please dont say that you can detect in "Virtual Mode". I need this for memory management.
Thanks.
Detect Memory Size
Detect memory via BIOS in real mode and place information somewhere in memory, so from protected mode you can see it. I've done some real mode detections in this way. I've loaded my kernel @ 1st megabyte of ram, and palced all information in 640kbytes below the 1st megabyte and i'm happy. What's wrong? or in another way, you can write and read values to and from memory, but reading non-existing memory address will cause an exception so you'll get more job on your own
Reading non-existing memory will not cause any exception, it'll cause you to read random stuff. The locations also won't remember anything. Worst that can happen is that they DO function like memory, but aren't intended to be used as such - say, the registers your video card uses or its framebuffer.xsix wrote:Detect memory via BIOS in real mode and place information somewhere in memory, so from protected mode you can see it. I've done some real mode detections in this way. I've loaded my kernel @ 1st megabyte of ram, and palced all information in 640kbytes below the 1st megabyte and i'm happy. What's wrong? or in another way, you can write and read values to and from memory, but reading non-existing memory address will cause an exception so you'll get more job on your own
and in some cases, (admittedly rare), writing to non-existent 'memory' can permanently destroy your computerWorst that can happen is that they DO function like memory, but aren't intended to be used as such - say, the registers your video card uses or its framebuffer.
just a warning
there is, however, a way to detect memory in PMode, by querying the memory controller -- but this will require you to first write a driver for each memory controller you support -- meaning each north-bridge for Intel and older AMD systems, and each revision of each newer AMD CPU, will require its own memory detection code -- not recommended
Hi,
When this happens may be different for different OSs. For a monolithic kernel that always loads at 1 MB it could happen when the virtual memory manager is initialised (and could be after a lot of other things happen). For my OS the boot code dynamically allocates pages for "kernel modules", so it needs to happen before the kernel started.
Cheers,
Brendan
In general, you need to know which areas are usable RAM when your OS stops using statically allocated RAM in "safe" areas and starts using dynamically allocated RAM.Jabus wrote:This is just a side question. At what stage do you need to know the memory size. Is it only useful to know when you have a large kernel?
When this happens may be different for different OSs. For a monolithic kernel that always loads at 1 MB it could happen when the virtual memory manager is initialised (and could be after a lot of other things happen). For my OS the boot code dynamically allocates pages for "kernel modules", so it needs to happen before the kernel started.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.