Rev 1806 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1806 | Rev 1809 | ||
---|---|---|---|
1 | # |
1 | # |
2 | # Copyright (C) 2001-2004 Jakub Jermar |
2 | # Copyright (C) 2001-2004 Jakub Jermar |
3 | # Copyright (C) 2005-2006 Martin Decky |
3 | # Copyright (C) 2005-2006 Martin Decky |
4 | # All rights reserved. |
4 | # All rights reserved. |
5 | # |
5 | # |
6 | # Redistribution and use in source and binary forms, with or without |
6 | # Redistribution and use in source and binary forms, with or without |
7 | # modification, are permitted provided that the following conditions |
7 | # modification, are permitted provided that the following conditions |
8 | # are met: |
8 | # are met: |
9 | # |
9 | # |
10 | # - Redistributions of source code must retain the above copyright |
10 | # - Redistributions of source code must retain the above copyright |
11 | # notice, this list of conditions and the following disclaimer. |
11 | # notice, this list of conditions and the following disclaimer. |
12 | # - Redistributions in binary form must reproduce the above copyright |
12 | # - Redistributions in binary form must reproduce the above copyright |
13 | # notice, this list of conditions and the following disclaimer in the |
13 | # notice, this list of conditions and the following disclaimer in the |
14 | # documentation and/or other materials provided with the distribution. |
14 | # documentation and/or other materials provided with the distribution. |
15 | # - The name of the author may not be used to endorse or promote products |
15 | # - The name of the author may not be used to endorse or promote products |
16 | # derived from this software without specific prior written permission. |
16 | # derived from this software without specific prior written permission. |
17 | # |
17 | # |
18 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
19 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
20 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
21 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
22 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
23 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
27 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 | # |
28 | # |
29 | 29 | ||
30 | #include <arch/boot/boot.h> |
30 | #include <arch/boot/boot.h> |
31 | #include <arch/mm/page.h> |
31 | #include <arch/mm/page.h> |
32 | #include <arch/pm.h> |
32 | #include <arch/pm.h> |
33 | 33 | ||
34 | .section __xen_guest |
34 | .section __xen_guest |
35 | .ascii "GUEST_OS=HelenOS," |
35 | .ascii "GUEST_OS=HelenOS," |
36 | .ascii "XEN_VER=xen-3.0," |
36 | .ascii "XEN_VER=xen-3.0," |
37 | .ascii "HYPERCALL_PAGE=0x2," |
37 | .ascii "HYPERCALL_PAGE=0x2," |
38 | .ascii "LOADER=generic," |
38 | .ascii "LOADER=generic," |
39 | .ascii "PT_MODE_WRITABLE" |
39 | .ascii "PT_MODE_WRITABLE" |
40 | .byte 0 |
40 | .byte 0 |
41 | 41 | ||
42 | #define START_STACK (BOOT_OFFSET - BOOT_STACK_SIZE) |
- | |
43 | - | ||
44 | .section K_TEXT_START, "ax" |
42 | .section K_TEXT_START, "ax" |
45 | 43 | ||
46 | KTEXT=8 |
44 | KTEXT=8 |
47 | KDATA=16 |
45 | KDATA=16 |
48 | 46 | ||
49 | .code32 |
47 | .code32 |
50 | .align 4 |
48 | .align 4 |
51 | .global multiboot_image_start |
49 | .global kernel_image_start |
52 | multiboot_header: |
- | |
53 | .long MULTIBOOT_HEADER_MAGIC |
- | |
54 | .long MULTIBOOT_HEADER_FLAGS |
- | |
55 | .long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) # checksum |
- | |
56 | .long multiboot_header |
- | |
57 | .long unmapped_ktext_start |
- | |
58 | .long 0 |
- | |
59 | .long 0 |
- | |
60 | .long multiboot_image_start |
- | |
61 | 50 | ||
62 | multiboot_image_start: |
51 | kernel_image_start: |
63 | movl $START_STACK, %esp # initialize stack pointer |
- | |
64 | lgdt KA2PA(bootstrap_gdtr) # initialize Global Descriptor Table register |
52 | lgdt KA2PA(bootstrap_gdtr) # initialize Global Descriptor Table register |
65 | 53 | ||
66 | movw $KDATA, %cx |
54 | movw $KDATA, %cx |
67 | movw %cx, %es |
55 | movw %cx, %es |
68 | movw %cx, %fs |
56 | movw %cx, %fs |
69 | movw %cx, %gs |
57 | movw %cx, %gs |
70 | movw %cx, %ds # kernel data + stack |
58 | movw %cx, %ds # kernel data + stack |
71 | movw %cx, %ss |
59 | movw %cx, %ss |
72 | 60 | ||
73 | jmpl $KTEXT, $multiboot_meeting_point |
61 | jmpl $KTEXT, $multiboot_meeting_point |
74 | multiboot_meeting_point: |
62 | multiboot_meeting_point: |
75 | 63 | ||
76 | pushl %ebx # save parameters from GRUB |
64 | pushl %ebx # save parameters from GRUB |
77 | pushl %eax |
65 | pushl %eax |
78 | 66 | ||
79 | #ifdef CONFIG_FB |
67 | #ifdef CONFIG_FB |
80 | mov $vesa_init, %esi |
68 | mov $vesa_init, %esi |
81 | mov $VESA_INIT_SEGMENT << 4, %edi |
69 | mov $VESA_INIT_SEGMENT << 4, %edi |
82 | mov $e_vesa_init - vesa_init, %ecx |
70 | mov $e_vesa_init - vesa_init, %ecx |
83 | cld |
71 | cld |
84 | rep movsb |
72 | rep movsb |
85 | 73 | ||
86 | mov $VESA_INIT_SEGMENT << 4, %edi |
74 | mov $VESA_INIT_SEGMENT << 4, %edi |
87 | jmpl %edi |
75 | jmpl %edi |
88 | 76 | ||
89 | vesa_meeting_point: |
77 | vesa_meeting_point: |
90 | 78 | ||
91 | mov %esi, KA2PA(vesa_ph_addr) |
79 | mov %esi, KA2PA(vesa_ph_addr) |
92 | mov %di, KA2PA(vesa_height) |
80 | mov %di, KA2PA(vesa_height) |
93 | shr $16, %edi |
81 | shr $16, %edi |
94 | mov %di, KA2PA(vesa_width) |
82 | mov %di, KA2PA(vesa_width) |
95 | mov %bx, KA2PA(vesa_scanline) |
83 | mov %bx, KA2PA(vesa_scanline) |
96 | shr $16, %ebx |
84 | shr $16, %ebx |
97 | mov %bx, KA2PA(vesa_bpp) |
85 | mov %bx, KA2PA(vesa_bpp) |
98 | #endif |
86 | #endif |
99 | 87 | ||
100 | call map_kernel # map kernel and turn paging on |
88 | call map_kernel # map kernel and turn paging on |
101 | 89 | ||
102 | popl %eax |
90 | popl %eax |
103 | popl %ebx |
91 | popl %ebx |
104 | cmpl $MULTIBOOT_LOADER_MAGIC, %eax # compare GRUB signature |
- | |
105 | je valid_boot |
- | |
106 | - | ||
107 | xorl %ecx, %ecx # no memory size or map available |
- | |
108 | movl %ecx, e801memorysize |
- | |
109 | movl %ecx, e820counter |
- | |
110 | - | ||
111 | jmp invalid_boot |
- | |
112 | - | ||
113 | valid_boot: |
- | |
114 | - | ||
115 | movl (%ebx), %eax # ebx = physical address of struct multiboot_info |
- | |
116 | - | ||
117 | bt $0, %eax # mbi->flags[0] (mem_lower, mem_upper valid) |
- | |
118 | jc mem_valid |
- | |
119 | - | ||
120 | xorl %ecx, %ecx |
- | |
121 | jmp mem_invalid |
- | |
122 | - | ||
123 | mem_valid: |
- | |
124 | movl 4(%ebx), %ecx # mbi->mem_lower |
- | |
125 | addl 8(%ebx), %ecx # mbi->mem_upper |
- | |
126 | - | ||
127 | mem_invalid: |
- | |
128 | movl %ecx, e801memorysize |
- | |
129 | - | ||
130 | bt $3, %eax # mbi->flags[3] (mods_count, mods_addr valid) |
- | |
131 | jc mods_valid |
- | |
132 | - | ||
133 | xorl %ecx, %ecx |
- | |
134 | movl %ecx, init |
- | |
135 | jmp mods_end |
- | |
136 | - | ||
137 | mods_valid: |
- | |
138 | - | ||
139 | movl 20(%ebx), %ecx # mbi->mods_count |
- | |
140 | movl %ecx, init |
- | |
141 | - | ||
142 | cmpl $0, %ecx |
- | |
143 | je mods_end |
- | |
144 | - | ||
145 | movl 24(%ebx), %esi # mbi->mods_addr |
- | |
146 | movl $init, %edi |
- | |
147 | - | ||
148 | mods_loop: |
- | |
149 | - | ||
150 | movl 0(%esi), %edx # mods->mod_start |
- | |
151 | addl $0x80000000, %edx |
- | |
152 | movl %edx, 4(%edi) |
- | |
153 | - | ||
154 | movl 4(%esi), %edx |
- | |
155 | subl 0(%esi), %edx # mods->mod_end - mods->mod_start |
- | |
156 | movl %edx, 8(%edi) |
- | |
157 | - | ||
158 | addl $16, %esi |
- | |
159 | addl $8 , %edi |
- | |
160 | - | ||
161 | loop mods_loop |
- | |
162 | - | ||
163 | mods_end: |
- | |
164 | - | ||
165 | invalid_boot: |
- | |
166 | - | ||
167 | #ifdef CONFIG_SMP |
- | |
168 | - | ||
169 | # copy AP bootstrap routines below 1 MB |
- | |
170 | - | ||
171 | movl $BOOT_OFFSET, %esi |
- | |
172 | movl $AP_BOOT_OFFSET, %edi |
- | |
173 | movl $_hardcoded_unmapped_size, %ecx |
- | |
174 | cld |
- | |
175 | rep movsb |
- | |
176 | - | ||
177 | #endif |
- | |
178 | 92 | ||
179 | call main_bsp # never returns |
93 | call main_bsp # never returns |
180 | 94 | ||
181 | cli |
95 | cli |
182 | hlt |
96 | hlt |
183 | 97 | ||
184 | .global map_kernel |
98 | .global map_kernel |
185 | map_kernel: |
99 | map_kernel: |
186 | # |
100 | # |
187 | # Here we setup mapping for both the unmapped and mapped sections of the kernel. |
101 | # Here we setup mapping for both the unmapped and mapped sections of the kernel. |
188 | # For simplicity, we map the entire 4G space. |
102 | # For simplicity, we map the entire 4G space. |
189 | # |
103 | # |
190 | movl %cr4, %ecx |
104 | movl %cr4, %ecx |
191 | orl $(1<<4), %ecx |
105 | orl $(1<<4), %ecx |
192 | movl %ecx, %cr4 # turn PSE on |
106 | movl %ecx, %cr4 # turn PSE on |
193 | 107 | ||
194 | movl $(page_directory+0), %esi |
108 | movl $(page_directory+0), %esi |
195 | movl $(page_directory+2048), %edi |
109 | movl $(page_directory+2048), %edi |
196 | xorl %ecx, %ecx |
110 | xorl %ecx, %ecx |
197 | xorl %ebx, %ebx |
111 | xorl %ebx, %ebx |
198 | 0: |
112 | 0: |
199 | movl $((1<<7)|(1<<0)), %eax |
113 | movl $((1<<7)|(1<<0)), %eax |
200 | orl %ebx, %eax |
114 | orl %ebx, %eax |
201 | movl %eax, (%esi,%ecx,4) # mapping 0x00000000+%ecx*4M => 0x00000000+%ecx*4M |
115 | movl %eax, (%esi,%ecx,4) # mapping 0x00000000+%ecx*4M => 0x00000000+%ecx*4M |
202 | movl %eax, (%edi,%ecx,4) # mapping 0x80000000+%ecx*4M => 0x00000000+%ecx*4M |
116 | movl %eax, (%edi,%ecx,4) # mapping 0x80000000+%ecx*4M => 0x00000000+%ecx*4M |
203 | addl $(4*1024*1024), %ebx |
117 | addl $(4*1024*1024), %ebx |
204 | 118 | ||
205 | incl %ecx |
119 | incl %ecx |
206 | cmpl $512, %ecx |
120 | cmpl $512, %ecx |
207 | jl 0b |
121 | jl 0b |
208 | 122 | ||
209 | movl %esi, %cr3 |
123 | movl %esi, %cr3 |
210 | 124 | ||
211 | # turn paging on |
125 | # turn paging on |
212 | movl %cr0, %ebx |
126 | movl %cr0, %ebx |
213 | orl $(1<<31), %ebx |
127 | orl $(1<<31), %ebx |
214 | movl %ebx, %cr0 |
128 | movl %ebx, %cr0 |
215 | ret |
129 | ret |
216 | 130 | ||
217 | #ifdef CONFIG_FB |
131 | #ifdef CONFIG_FB |
218 | vesa_init: |
132 | vesa_init: |
219 | jmp $selector(VESA_INIT_DES), $vesa_init_real - vesa_init |
133 | jmp $selector(VESA_INIT_DES), $vesa_init_real - vesa_init |
220 | 134 | ||
221 | .code16 |
135 | .code16 |
222 | vesa_init_real: |
136 | vesa_init_real: |
223 | 137 | ||
224 | mov %cr0, %eax |
138 | mov %cr0, %eax |
225 | and $~1, %eax |
139 | and $~1, %eax |
226 | mov %eax, %cr0 |
140 | mov %eax, %cr0 |
227 | 141 | ||
228 | jmp $VESA_INIT_SEGMENT, $vesa_init_real2 - vesa_init |
142 | jmp $VESA_INIT_SEGMENT, $vesa_init_real2 - vesa_init |
229 | 143 | ||
230 | vesa_init_real2: |
144 | vesa_init_real2: |
231 | 145 | ||
232 | mov $VESA_INIT_SEGMENT, %bx |
146 | mov $VESA_INIT_SEGMENT, %bx |
233 | 147 | ||
234 | mov %bx, %es |
148 | mov %bx, %es |
235 | mov %bx, %fs |
149 | mov %bx, %fs |
236 | mov %bx, %gs |
150 | mov %bx, %gs |
237 | mov %bx, %ds |
151 | mov %bx, %ds |
238 | mov %bx, %ss |
152 | mov %bx, %ss |
239 | 153 | ||
240 | movl %esp, %eax |
154 | movl %esp, %eax |
241 | movl $0x0000fffc, %esp |
155 | movl $0x0000fffc, %esp |
242 | movl $0x0000fffc, %ebp |
156 | movl $0x0000fffc, %ebp |
243 | pushl %eax |
157 | pushl %eax |
244 | 158 | ||
245 | #define VESA_INFO_SIZE 1024 |
159 | #define VESA_INFO_SIZE 1024 |
246 | 160 | ||
247 | #define VESA_MODE_LIST_PTR_OFFSET 14 |
161 | #define VESA_MODE_LIST_PTR_OFFSET 14 |
248 | #define VESA_MODE_WIDTH_OFFSET 18 |
162 | #define VESA_MODE_WIDTH_OFFSET 18 |
249 | #define VESA_MODE_HEIGHT_OFFSET 20 |
163 | #define VESA_MODE_HEIGHT_OFFSET 20 |
250 | #define VESA_MODE_BPP_OFFSET 25 |
164 | #define VESA_MODE_BPP_OFFSET 25 |
251 | #define VESA_MODE_SCANLINE_OFFSET 16 |
165 | #define VESA_MODE_SCANLINE_OFFSET 16 |
252 | #define VESA_MODE_PHADDR_OFFSET 40 |
166 | #define VESA_MODE_PHADDR_OFFSET 40 |
253 | 167 | ||
254 | #define VESA_END_OF_MODES 0xffff |
168 | #define VESA_END_OF_MODES 0xffff |
255 | 169 | ||
256 | #define VESA_OK 0x4f |
170 | #define VESA_OK 0x4f |
257 | 171 | ||
258 | #define VESA_GET_INFO 0x4f00 |
172 | #define VESA_GET_INFO 0x4f00 |
259 | #define VESA_GET_MODE_INFO 0x4f01 |
173 | #define VESA_GET_MODE_INFO 0x4f01 |
260 | #define VESA_SET_MODE 0x4f02 |
174 | #define VESA_SET_MODE 0x4f02 |
261 | 175 | ||
262 | #define CONFIG_VESA_BPP_a 255 |
176 | #define CONFIG_VESA_BPP_a 255 |
263 | 177 | ||
264 | #if CONFIG_VESA_BPP == 24 |
178 | #if CONFIG_VESA_BPP == 24 |
265 | #undef CONFIG_VESA_BPP_a |
179 | #undef CONFIG_VESA_BPP_a |
266 | #define CONFIG_VESA_BPP_a 32 |
180 | #define CONFIG_VESA_BPP_a 32 |
267 | #endif |
181 | #endif |
268 | 182 | ||
269 | mov $VESA_GET_INFO, %ax |
183 | mov $VESA_GET_INFO, %ax |
270 | mov $e_vesa_init - vesa_init, %di |
184 | mov $e_vesa_init - vesa_init, %di |
271 | push %di |
185 | push %di |
272 | int $0x10 |
186 | int $0x10 |
273 | 187 | ||
274 | pop %di |
188 | pop %di |
275 | cmp $VESA_OK, %al |
189 | cmp $VESA_OK, %al |
276 | jnz 0f |
190 | jnz 0f |
277 | 191 | ||
278 | mov 2 + VESA_MODE_LIST_PTR_OFFSET(%di), %si |
192 | mov 2 + VESA_MODE_LIST_PTR_OFFSET(%di), %si |
279 | mov %si, %gs |
193 | mov %si, %gs |
280 | mov VESA_MODE_LIST_PTR_OFFSET(%di), %si |
194 | mov VESA_MODE_LIST_PTR_OFFSET(%di), %si |
281 | 195 | ||
282 | add $VESA_INFO_SIZE, %di |
196 | add $VESA_INFO_SIZE, %di |
283 | 197 | ||
284 | 1:# Try next mode |
198 | 1:# Try next mode |
285 | mov %gs:(%si), %cx |
199 | mov %gs:(%si), %cx |
286 | cmp $VESA_END_OF_MODES, %cx |
200 | cmp $VESA_END_OF_MODES, %cx |
287 | jz 0f |
201 | jz 0f |
288 | 202 | ||
289 | inc %si |
203 | inc %si |
290 | inc %si |
204 | inc %si |
291 | push %cx |
205 | push %cx |
292 | push %di |
206 | push %di |
293 | push %si |
207 | push %si |
294 | mov $VESA_GET_MODE_INFO, %ax |
208 | mov $VESA_GET_MODE_INFO, %ax |
295 | int $0x10 |
209 | int $0x10 |
296 | 210 | ||
297 | pop %si |
211 | pop %si |
298 | pop %di |
212 | pop %di |
299 | pop %cx |
213 | pop %cx |
300 | cmp $VESA_OK, %al |
214 | cmp $VESA_OK, %al |
301 | jnz 0f |
215 | jnz 0f |
302 | 216 | ||
303 | mov $CONFIG_VESA_WIDTH, %ax |
217 | mov $CONFIG_VESA_WIDTH, %ax |
304 | cmp VESA_MODE_WIDTH_OFFSET(%di), %ax |
218 | cmp VESA_MODE_WIDTH_OFFSET(%di), %ax |
305 | jnz 1b |
219 | jnz 1b |
306 | 220 | ||
307 | mov $CONFIG_VESA_HEIGHT,%ax |
221 | mov $CONFIG_VESA_HEIGHT,%ax |
308 | cmp VESA_MODE_HEIGHT_OFFSET(%di), %ax |
222 | cmp VESA_MODE_HEIGHT_OFFSET(%di), %ax |
309 | jnz 1b |
223 | jnz 1b |
310 | 224 | ||
311 | mov $CONFIG_VESA_BPP, %al |
225 | mov $CONFIG_VESA_BPP, %al |
312 | cmp VESA_MODE_BPP_OFFSET(%di), %al |
226 | cmp VESA_MODE_BPP_OFFSET(%di), %al |
313 | jz 2f |
227 | jz 2f |
314 | 228 | ||
315 | mov $CONFIG_VESA_BPP_a, %al |
229 | mov $CONFIG_VESA_BPP_a, %al |
316 | cmp VESA_MODE_BPP_OFFSET(%di), %al |
230 | cmp VESA_MODE_BPP_OFFSET(%di), %al |
317 | jnz 1b |
231 | jnz 1b |
318 | 232 | ||
319 | 2: |
233 | 2: |
320 | 234 | ||
321 | mov %cx, %bx |
235 | mov %cx, %bx |
322 | or $0xc000, %bx |
236 | or $0xc000, %bx |
323 | push %di |
237 | push %di |
324 | mov $VESA_SET_MODE, %ax |
238 | mov $VESA_SET_MODE, %ax |
325 | int $0x10 |
239 | int $0x10 |
326 | 240 | ||
327 | pop %di |
241 | pop %di |
328 | cmp $VESA_OK, %al |
242 | cmp $VESA_OK, %al |
329 | jnz 0f |
243 | jnz 0f |
330 | 244 | ||
331 | mov VESA_MODE_PHADDR_OFFSET(%di), %esi |
245 | mov VESA_MODE_PHADDR_OFFSET(%di), %esi |
332 | mov VESA_MODE_WIDTH_OFFSET(%di), %ax |
246 | mov VESA_MODE_WIDTH_OFFSET(%di), %ax |
333 | shl $16, %eax |
247 | shl $16, %eax |
334 | mov VESA_MODE_HEIGHT_OFFSET(%di), %ax |
248 | mov VESA_MODE_HEIGHT_OFFSET(%di), %ax |
335 | mov VESA_MODE_BPP_OFFSET(%di), %bl |
249 | mov VESA_MODE_BPP_OFFSET(%di), %bl |
336 | xor %bh, %bh |
250 | xor %bh, %bh |
337 | shl $16, %ebx |
251 | shl $16, %ebx |
338 | mov VESA_MODE_SCANLINE_OFFSET(%di), %bx |
252 | mov VESA_MODE_SCANLINE_OFFSET(%di), %bx |
339 | mov %eax, %edi |
253 | mov %eax, %edi |
340 | 254 | ||
341 | 8: |
255 | 8: |
342 | 256 | ||
343 | mov %cr0, %eax |
257 | mov %cr0, %eax |
344 | or $1, %eax |
258 | or $1, %eax |
345 | mov %eax, %cr0 |
259 | mov %eax, %cr0 |
346 | 260 | ||
347 | jmp 9f |
261 | jmp 9f |
348 | 9: |
262 | 9: |
349 | 263 | ||
350 | ljmpl $KTEXT, $(vesa_init_protect - vesa_init + VESA_INIT_SEGMENT << 4) |
264 | ljmpl $KTEXT, $(vesa_init_protect - vesa_init + VESA_INIT_SEGMENT << 4) |
351 | 265 | ||
352 | 0:# No prefered mode found |
266 | 0:# No prefered mode found |
353 | mov $0x111, %cx |
267 | mov $0x111, %cx |
354 | push %di |
268 | push %di |
355 | push %cx |
269 | push %cx |
356 | mov $VESA_GET_MODE_INFO, %ax |
270 | mov $VESA_GET_MODE_INFO, %ax |
357 | int $0x10 |
271 | int $0x10 |
358 | 272 | ||
359 | pop %cx |
273 | pop %cx |
360 | pop %di |
274 | pop %di |
361 | cmp $VESA_OK, %al |
275 | cmp $VESA_OK, %al |
362 | jnz 1f |
276 | jnz 1f |
363 | jz 2b # Force relative jump |
277 | jz 2b # Force relative jump |
364 | 278 | ||
365 | 1: |
279 | 1: |
366 | mov $0x0003, %ax |
280 | mov $0x0003, %ax |
367 | int $0x10 |
281 | int $0x10 |
368 | mov $0xffffffff, %edi # EGA text mode used, because of problems with VESA |
282 | mov $0xffffffff, %edi # EGA text mode used, because of problems with VESA |
369 | xor %ax, %ax |
283 | xor %ax, %ax |
370 | jz 8b # Force relative jump |
284 | jz 8b # Force relative jump |
371 | 285 | ||
372 | 286 | ||
373 | .code32 |
287 | .code32 |
374 | vesa_init_protect: |
288 | vesa_init_protect: |
375 | popl %esp |
289 | popl %esp |
376 | 290 | ||
377 | movw $KDATA, %cx |
291 | movw $KDATA, %cx |
378 | movw %cx, %es |
292 | movw %cx, %es |
379 | movw %cx, %fs |
293 | movw %cx, %fs |
380 | movw %cx, %gs |
294 | movw %cx, %gs |
381 | movw %cx, %ds # kernel data + stack |
295 | movw %cx, %ds # kernel data + stack |
382 | movw %cx, %ss |
296 | movw %cx, %ss |
383 | 297 | ||
384 | jmpl $KTEXT, $vesa_meeting_point |
298 | jmpl $KTEXT, $vesa_meeting_point |
385 | 299 | ||
386 | .align 4 |
300 | .align 4 |
387 | e_vesa_init: |
301 | e_vesa_init: |
388 | #endif |
302 | #endif |
389 | 303 | ||
390 | .section K_DATA_START, "aw", @progbits |
304 | .section K_DATA_START, "aw", @progbits |
391 | 305 | ||
392 | .align 4096 |
306 | .align 4096 |
393 | page_directory: |
307 | page_directory: |
394 | .space 4096, 0 |
308 | .space 4096, 0 |
395 | 309 |