Page 2 of 2

Re: Where to go from here?

Posted: Thu Mar 13, 2025 4:00 am
by rdos
nullplan wrote: Tue Mar 11, 2025 2:25 pm
Kaius wrote: Tue Mar 11, 2025 12:07 pm Thanks for the help everybody. Sorry for bombarding the forum with questions, but I've got one more: is there anything wrong with using uint64_t when I'm only in 32-bit protected mode?
Physical address space can exceed 4GB, and with PAE you can address all of that space even in 32-bit mode. Even if you don't intend to use PAE, it seems to me like you are attempting a premature optimization that will end up hobbling you in the long run. Just use the 64-bit integers; it's what the memory map comes in, and if you can't use anything above 4GB right now you still might at some point.
I'd go one step further and claim that several hardware platforms I support require PAE. I've seen PCI devices being mapped far above 4GB. Therefore, I think the time when a 32-bit operating system could rely on only 32-bit paging is gone, at least if you target modern hardware.

Another issue is that a lot of modern PCs only boot with EFI, and this is 64-bit EFI. Therefore, a 32-bit OS needs a means to switch from long mode into protected mode when booted this way.

Re: Where to go from here?

Posted: Fri Mar 14, 2025 11:27 am
by Kaius
Thanks again for the input, everybody. I've taken all of this into consideration and am now designing a kmalloc() and other related mem functions.

When it comes to taking in a mmap, at some point I'm going to need a maximum buffer size, due to the way my code is structured. Is 64 a good maximum value for the amount of mmap entries to look at?

Re: Where to go from here?

Posted: Mon Mar 17, 2025 7:44 pm
by sounds
Assuming you have 4K pages, there are 512 * 4K page table entries in a single page directory. The concepts are similar outside of X86 CPUs so call it the last level paging bits and your question becomes something like --

If the last level paging bits are grouped into an array of mmap entries of 512 entries each, should you support more than 512 * 4K in a single call to kmalloc()? That's 2MB for what it's worth.

Do you plan to support frame buffers larger than 2MB? 1920 * 1080 = 2,073,600 and once you factor in the number of bits per pixel you might want to go larger.