From the beginning of the code:
cld
- clear direction flag.
cli
- clear interrupt flag to mask interrupts.
lgdt gdt_desr
- loads the value of gdt_desr
into gdt
. Look for gdt_desr
in the source code to find out the value loaded to gdt
.
" mov $"STR(SEL_DATA32)",%ax \n"
" mov %ax,%ds \n"
" mov %ax,%es \n"
" mov %ax,%fs \n"
" mov %ax,%gs \n"
" mov %ax,%ss \n"
Store the value STR(SEL_DATA32)
into ax
, and then from ax
to ds
, es
, fs
, gs
and ss
(to all segment registers except cs
).
" ljmp $"STR(SEL_CODE32)",$1f \n"
Does a long jump / far jump to STR(SEL_CODE32):0x1f
, practically sets cs
to STR(SEL_CODE32)
and eip
to 0x1f
.
If this is a a 32-bit code segment, the processor goes into 32-bit protected mode. See Stackoverflow question: bootloader - switching processor to protected mode. However, I don't see here the code used to set the PE
bit of cr0
register as in the above example and in Wikipedia article on protected mode.
After that line of code cs:eip
moves to that address (STR(SEL_CODE32):0x1f
) not shown in this piece of code, so I can't say what happens then. It may continue on the next line too if cs:eip
points there (if that's the jump address). Anyway, the rest of the code and comments looks like the code used to switch from protected mode back to real mode.
Intruction lidt 1f-trampoline_start
loads the value of 1f-trampoline_start
into idt
, so to get to know the actual value used, search the source for if-trampoline_start
.