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.
Hey there, I'm at the awkward point where although I understand memory allocation principles (free-list, best/first-fit algorithms etc), I'm trying to work out how to implement it without accidentally writing into some memory-mapped device's I/O port. So detecting a memory map for the machine would seem like a good idea. However, quoting the wiki:
One of the most vital pieces of information that an OS needs in order to initialize itself is a map of the available RAM on a machine. Fundamentally, the best way (and really the only way) an OS can get that information is by using the BIOS.
and
Unfortunately, in Protected mode, almost all BIOS functions become unavailable
Does this mean that there is no reliable way to get a map of the available RAM from Protected Mode?
If you choose to get memory map from BIOS, you should do it in real mode (in early stage of boot process), or if you use things like GRUB it will do it for you.
However, I'm not sure on UEFI, which may support protected mode/long mode interfaces.
It means you need to retrieve a memory map before entering protected mode on a BIOS based system. Usually the memory map is retrieved by the bootloader and passed to the kernel in some fashion. The bootloader itself should also parse the memory map to make sure it can load the kernel in the first place.
bluemoon wrote:I'm not sure on UEFI, which may support protected mode/long mode interfaces
It supports only protected mode / long mode interfaces. Most of the services are available as Boot Services. It means that you cannot use them after control is transferred to your OS. There are also Runtime Services.
When it comes to the memory detection, it is a Boot Service. The OS loader (UEFI program) must handle it.