Rev 194 | Rev 242 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 194 | Rev 206 | ||
---|---|---|---|
Line 64... | Line 64... | ||
64 | bt $29, %edx # Test if long mode is supported. |
64 | bt $29, %edx # Test if long mode is supported. |
65 | jnc no_long_mode |
65 | jnc no_long_mode |
66 | 66 | ||
67 | # Load gdtr, idtr |
67 | # Load gdtr, idtr |
68 | lgdt gdtr_inst |
68 | lgdt gdtr_inst |
- | 69 | # Load idtr, but it contains mess - we should not get interrupt |
|
- | 70 | # anyway |
|
69 | lidt idtr_inst |
71 | lidt idtr_inst |
70 | 72 | ||
71 | movl %cr0,%eax |
73 | movl %cr0,%eax |
72 | orl $0x1,%eax |
74 | orl $0x1,%eax |
73 | movl %eax,%cr0 # switch to protected mode |
75 | movl %eax,%cr0 # switch to protected mode |
74 | 76 | ||
75 | jmpl $selector(KTEXT32_DES), $now_in_prot |
77 | jmpl $gdtselector(KTEXT32_DES), $now_in_prot |
76 | 78 | ||
77 | no_long_mode: |
79 | no_long_mode: |
78 | 1: |
80 | 1: |
79 | jmp 1b |
81 | jmp 1b |
80 | 82 | ||
81 | # Protected 16-bit. We want to reuse the code-seg descriptor, |
83 | # Protected 16-bit. We want to reuse the code-seg descriptor, |
82 | # the Default operand size must not be 1 when entering long mode |
84 | # the Default operand size must not be 1 when entering long mode |
83 | now_in_prot: |
85 | now_in_prot: |
84 | # Set up stack & data descriptors |
86 | # Set up stack & data descriptors |
85 | movw $selector(KDATA_DES), %ax |
87 | movw $gdtselector(KDATA_DES), %ax |
86 | movw %ax, %ds |
88 | movw %ax, %ds |
87 | movw %ax, %fs |
89 | movw %ax, %fs |
88 | movw %ax, %gs |
90 | movw %ax, %gs |
89 | movw %ax, %ss |
91 | movw %ax, %ss |
90 | 92 | ||
Line 108... | Line 110... | ||
108 | movl %cr0, %eax |
110 | movl %cr0, %eax |
109 | btsl $31, %eax |
111 | btsl $31, %eax |
110 | movl %eax, %cr0 |
112 | movl %eax, %cr0 |
111 | 113 | ||
112 | # At this point we are in compatibility mode |
114 | # At this point we are in compatibility mode |
113 | jmpl $selector(KTEXT_DES), $start64 |
115 | jmpl $gdtselector(KTEXT_DES), $start64 |
114 | 116 | ||
115 | .code64 |
117 | .code64 |
116 | start64: |
118 | start64: |
117 | movq START_STACK_64, %rsp |
119 | movq START_STACK_64, %rsp |
118 | 120 | ||
119 | lidt idtr_inst |
- | |
120 | - | ||
121 | call main_bsp # never returns |
121 | call main_bsp # never returns |
122 | 1: |
122 | 1: |
123 | jmp 1b |
123 | jmp 1b |
124 | 124 | ||
125 | - | ||
126 | .section K_DATA_START |
125 | .section K_DATA_START |
127 | .align 4096 |
126 | .align 4096 |
- | 127 | ||
- | 128 | # Identical mapping of first 16MB and the same of -2GB -> 0 |
|
128 | .global ptl_2 |
129 | .global ptl_2 |
129 | ptl_2: |
130 | ptl_2: |
130 | .quad 0x0 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE) |
131 | .quad 0x0 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE) |
131 | .quad 0x200000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE) |
132 | .quad 0x200000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE) |
132 | .quad 0x400000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE) |
133 | .quad 0x400000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE) |
Line 151... | Line 152... | ||
151 | .fill 510,8,0 |
152 | .fill 510,8,0 |
152 | .quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT) |
153 | .quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT) |
153 | 154 | ||
154 | .global gdtr_inst |
155 | .global gdtr_inst |
155 | gdtr_inst: |
156 | gdtr_inst: |
156 | .word selector(GDT_ITEMS) |
157 | .word gdtselector(GDT_ITEMS) |
157 | .long KA2PA(gdt) |
158 | .long KA2PA(gdt) |
158 | 159 | ||
159 | .global idtr_inst |
160 | .global idtr_inst |
160 | idtr_inst: |
161 | idtr_inst: |
161 | .word 0 |
162 | .word idtselector(IDT_ITEMS) |
162 | .long KA2PA(idt) |
163 | .long KA2PA(idt) |