When initializing my kernel, I have several things that should happen: 1) paging must be enabled, 2) the physical memory manager must analyze the memory card from grub, and 3) the startup code needs to be accessed to access data that should remain there later ( e.g. GDT, IDT, memory management structures).
The dependencies between these steps drive me crazy. With a higher half, the kernel is associated with its virtual address, and therefore the parameters that I came up with are: 1) enable paging in the assembly, which will use all the multitasking pointers (in the assembly) so that they are still accessible in the dispatcher physical memory, and then decoupling them all, 2) associate the launch code with its physical address, and then do some manipulations with pointers to access the kernel structures at their physical addresses, or 3) do not use the higher half of the kernel.
The boot manager of physical memory is also involved, not knowing the amount of physical memory at compile time. I'm sure I should either carefully avoid all multiboot structures when distributing the first structures, or use them all first and then not worry about rewriting them (although I still have to deal with modules, and this approach probably includes copying multiboot tables to a known place that I need when setting up the physical memory manager).
These problems are why I have so far avoided a higher kernel level. Does anyone have a good system to solve these dependencies? Perhaps this is a variant of this GDT trick for accessing the kernel on its linked / virtual address and multiboot tables at their physical address or using some predefined page of the table that avoids the problems above, possibly involving PSE?
source
share