Paging File Format or File System to handle it
Posted: Fri Mar 18, 2016 9:27 pm
I have been thinking that the reason why things like implementing paging and understanding the concept of higher-half is so difficult, is that there really isn't a clear idea for an existing standard and default paging map.
It look like without providing it, trying to implement it properly would be just like trying to invent a file format or a file system, so we would need to add default page mappings for Windows, Linux and other well-developed standard OS platforms.
If we were to draw a schematic showing where every paging region is and what it is (just like describing an image or an executable file format), how would the default paging map look for Windows or Linux, for being able to understand it at high level and also describing how to implement it at low level?
For example, when fully booting Linux or Windows, I imagine a paging memory structure like this:
- The very first, original goal of implementing paging would be having a very simple, raw kernel environment, and use it to allocate and deallocate memory easily and arbitrarily with simple API functions that do it and leave fragmentation to the kernel internals.
- Memory would in general be like a 4-Kilobyte disk.
- Just like a disk partition, but instead of having the partition structures at the start, we would keep them at the kernel.
- We would detect memory regions with BIOS service 0xE820 and by scanning PCI and their memory mappings through BARs (Base Address Registers).
- We would treat memory buffers, stacks, programs, paging and process structures, and other concrete first-level structures as files.
- It might be that hardware or software buffers start or end unaligned within the 4-Kilobyte pages, but we will always contain them like that and just have device drivers and programs get meaningful paged memory addresses.
- We could page everything, identity-map things that are vital, like kernel and system stacks and process/memory main structures, heaps, memory I/O (virtual paged address==physical address), and use meaningful and standard virtual paging addresses for everything else like device drivers, system or user programs.
- Probably we would only use a single page directory and apply the corresponding privilege ring levels to all pages.
- What use would a higher-half kernel have if we could use standarized paging addresses and make internal physical addresses, specially for the kernel itself, as standard as possible?
It look like without providing it, trying to implement it properly would be just like trying to invent a file format or a file system, so we would need to add default page mappings for Windows, Linux and other well-developed standard OS platforms.
If we were to draw a schematic showing where every paging region is and what it is (just like describing an image or an executable file format), how would the default paging map look for Windows or Linux, for being able to understand it at high level and also describing how to implement it at low level?
For example, when fully booting Linux or Windows, I imagine a paging memory structure like this:
- The very first, original goal of implementing paging would be having a very simple, raw kernel environment, and use it to allocate and deallocate memory easily and arbitrarily with simple API functions that do it and leave fragmentation to the kernel internals.
- Memory would in general be like a 4-Kilobyte disk.
- Just like a disk partition, but instead of having the partition structures at the start, we would keep them at the kernel.
- We would detect memory regions with BIOS service 0xE820 and by scanning PCI and their memory mappings through BARs (Base Address Registers).
- We would treat memory buffers, stacks, programs, paging and process structures, and other concrete first-level structures as files.
- It might be that hardware or software buffers start or end unaligned within the 4-Kilobyte pages, but we will always contain them like that and just have device drivers and programs get meaningful paged memory addresses.
- We could page everything, identity-map things that are vital, like kernel and system stacks and process/memory main structures, heaps, memory I/O (virtual paged address==physical address), and use meaningful and standard virtual paging addresses for everything else like device drivers, system or user programs.
- Probably we would only use a single page directory and apply the corresponding privilege ring levels to all pages.
- What use would a higher-half kernel have if we could use standarized paging addresses and make internal physical addresses, specially for the kernel itself, as standard as possible?