I am trying to understand how a machine goes from power on to running a kernel. From what I've gathered, it is useful to switch into protected mode during boot up in order to gain access to more addressable memory even if we will eventually switch to a more conventional virtual memory plan with page directories and page tables and segmentation turned off.
It seems that to switch into protected mode 3 things must be done:
- Set up a global descriptor table (gdt) and load it using the
lgdt
instruction - Set the PE flag/bit in the control register CR0 to enabled (ie. to the value 1)
- Execute a long jump with
ljmp
I am wondering about the logic for translating a segment register and instruction pointer into an index and offset for use with the gdt. Is this logic accomplished by hardware? If so which piece of hardware and why is the execution of a ljmp
part of the process? Why not simply set the PE flag in CR0 to enable protected mode (with no following ljmp
)?
protected mode
in the Intel® 64 and IA-32 Architectures Software Developer’s Manual and what is your research effort and why are you asking, what problem are you trying to solve/understand? BTW: did you know that frequent answer to similar questions is: read wiki.osdev.org ? – Extinguisher