In my bootloader code there is a section in which we switch the cpu to protected mode by loading the GDT and enabling the control register bit.
This is the portion of bootloader code:
init_pm:
...
cli
lgdt [GDT_descriptor]
mov eax, cr0
or eax, 1
mov cr0, eax
; far jump
jmp CODE_SEG:start_protected_mode
[bits 32]
start_protected_mode:
...
and these are the constants:
CODE_SEG equ code_descriptor - GDT_start
DATA_SEG equ data_descriptor - GDT_start
So my questions are the following:
what is a far jump ?
what exactly does moving to protected mode do to the cpu ?
what is CODE_SEG and why we use it with the offset start_protected_mode ? Can't we just do a normal jump like
jmp start_protected_mode
? I know it's the location of code descriptor in GDT but does this automatically get recognised by the cpu as the location of the bootloader code ?