HI,
Seven11 wrote:Brendan: yes it will run with a static virtual addr. The reason why I want the physical addr to be dynamic is because ACPI 3.0 provides a mean to detect damaged RAM memory using the BIOS interrupts.
But you think it's unneccesary?
In this case, only the kernel code used before paging is enabled needs to be relocatable.
You could apply addressing fix-ups to the entire binary to suit it's physical address, and then apply addressing fix-ups to the entire binary again to suit it's linear address. This doesn't seem too effecient to me - doing twice as much addressuing fix-ups as necessary.
You could optimise this by having 2 areas (an "initialization" area that is used before paging is enabled and a "main" area that is used after paging is enabled). In this case you could apply addressing fix-ups to the initialization area to suit the physical address, and then apply addressing fix-ups to the main area to suit the linear address - that way you don't do things twice.
To optimize it more you could discard the initialization area after it's used to save some memory - it's not like this initialization code is needed after boot.
Because the main area lives at a static linear address, you could optimize this more by doing the addressing fix-ups for the main area before the code is run. This means it's done once by the OS developers rather than being done every time the OS boots.
After all of these optimisations you've got a "perfectly optimised" solution, but how could it be done in practice? The linker won't handle "partially relocatable" binaries, it might be hard to figure out what code is in the initialization area or the main area, and you'd probably need to write your own "post linking address fix-up" utility for the main area.
The solution is to shift the "initialization area" into another binary - either put it into your boot code or turn it into a completely seperate binary. That gives you the same optimizations but solves the practical problems.
Ironically, after all of this optimization you end up with a kernel that is statically linked for it's linear address, and some seperate initialization code that sets up paging.
Cheers,
Brendan