rellermeyer / course_os

CS 439 course OS
BSD 3-Clause "New" or "Revised" License
38 stars 26 forks source link

Memory detection #55

Closed jdonszelmann closed 3 years ago

jdonszelmann commented 4 years ago

This PR adds the ability for the kernel to scan the address space in O(log(n)) time to find how much it has available. It does so in memory.s. It passes this size to void start() in start.c so it can be used.

This system executes before jumping to the higher half kernel.

Todos:

NULLx76 commented 4 years ago

You already mentioned to me personally that you plan to change this to actual log(n), that is nice to have before merging.

I'm also wondering what happens when you write tot non-existing memory, it just doesn't work or does it actually page fault?

jdonszelmann commented 4 years ago

It's already log(n).

jdonszelmann commented 4 years ago

Writing to non existing memory is entirely legal and won't cause any data abort handlers. Only when virtual memory is enabled it will. The only way you can notice you write to non existent memory is by reading it again (which must always return 0 on arm) meaning that if you write something nonzero before and read back a zero you found the end.

jdonszelmann commented 4 years ago

There's also still a small bug I just found out where with a size of 1G it reports a size that's actually a few kilobytes less. Though this isn't that big of an issue (if it's always less it'll always work, just with a little less memory available) we should resolve it. For 512M it is spot on.

jdonszelmann commented 4 years ago

apparently the algorithm reporting a bit less is accurate. For some reason it's getting a bit less from qemu.

NULLx76 commented 4 years ago

Maybe add a TODO somewhere indicating PMM doesn't use it and merge it for next years students?