3 # Created on: Nov 19, 2009
10 .align 4 # The config variables are passed here...
22 .short 0x1000 # 0x08: small CS selector
26 .short 0x1000 # 0x10: small DS selector
30 .short 0xffff # 0x18: 4GB CS selector
34 .short 0xffff # 0x20: 4GB DS selector
44 mov
%cs
, %ax
# Find out where the code resides
47 leal gdt
(%eax
), %ebx
# Load physical address of 32-bit gdt
48 movl
%ebx
, gdtr+
2 # Set up 32-bit gdt address
49 leal kick
(%eax
), %ebx
# Load physical address of flat-mode code
50 movl
%ebx
, target
# Set up entry address
51 movw
%ax
, gdt+
10 # Set base address of 32-bit code segment (bits 0:15)
52 movw
%ax
, gdt+
18 # Set base address of 32-bit data segment (bits 0:15)
54 movb
%al
, gdt+
12 # Set base address of 32-bit code segment (bits 16:23)
55 movb
%al
, gdt+
20 # Set base address of 32-bit data segment (bits 16:23)
56 ADDR32 DATA32 lgdt gdtr
# Load gdt
57 movl
%cr0, %eax
# Enter protected mode
60 ljmp $
0x8, $boot32
# Please note that the %cs segment selector has to have it's base address properly adjusted
63 boot32
: movw $
0x10, %ax
# Setup the temporary 32-bit data selector
65 movw $
0x20, %ax
# Set stack to large 32-bit data segment
67 movl sp
, %esp
# Load stack pointer
68 movl arg4
, %ebx
# Prepare arguments for the C entry point
76 movl ip
, %ebx
# Prepare entry address
79 kick
: mov
%ax
, %ds
# Switch to large data segments
82 call
*%ebx
# Jump to the C entry point