intermezzOS / kernel

A hobby operating system, in Rust
http://intermezzos.github.io/
Apache License 2.0
1.39k stars 90 forks source link

Missing memory probing #114

Open steveej opened 7 years ago

steveej commented 7 years ago

In order to manage the memory, the OS should know how much it has. Extra information about reserved addresses and memory holes (maybe these are the same, I don't know yet), should also be taken into account.

steveklabnik commented 7 years ago

Yup, this is absolutely something that would have to happen for https://github.com/intermezzOS/kernel/issues/96 and https://github.com/intermezzOS/kernel/issues/81

dato commented 7 years ago

An expedient option would be to get the information from the bootloader. The multiboot specification includes information on how much memory the system has.

This would make the dependency on grub/multiboot a hard one, though; but might be a good start.

steveklabnik commented 7 years ago

@dato big đź‘Ť on that, multiboot should have all the info. I am fine with this.

steveej commented 7 years ago

@dato do you by chance know how this is handled in (U)EFI systems?

dato commented 7 years ago

I’m still using BIOS for my x86_64 OS work, but it’s a similar story as Multiboot: it’s handed to you directly (in this case by EFI firmware), no need to do a special dance with BIOS services and interrupts to get it.

You want, in particular, the GetMemoryMap() service. There is example code in this excellent StackOverflow answer. For those reading along, here’s an overall description.

-d