Rev 1037 | Rev 1288 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1037 | Rev 1287 | ||
---|---|---|---|
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/boot/memmap.h> |
31 | #include <arch/boot/memmap.h> |
32 | #include <arch/mm/page.h> |
32 | #include <arch/mm/page.h> |
33 | #include <arch/pm.h> |
33 | #include <arch/pm.h> |
34 | 34 | ||
35 | #define START_STACK (BOOT_OFFSET - BOOT_STACK_SIZE) |
35 | #define START_STACK (BOOT_OFFSET - BOOT_STACK_SIZE) |
36 | 36 | ||
- | 37 | ||
- | 38 | ||
- | 39 | ||
- | 40 | ||
- | 41 | ||
- | 42 | ||
- | 43 | ||
- | 44 | ||
37 | .section K_TEXT_START, "ax" |
45 | .section K_TEXT_START, "ax" |
38 | 46 | ||
39 | KTEXT=8 |
47 | KTEXT=8 |
40 | KDATA=16 |
48 | KDATA=16 |
41 | 49 | ||
42 | .code32 |
50 | .code32 |
43 | .align 4 |
51 | .align 4 |
44 | .global multiboot_image_start |
52 | .global multiboot_image_start |
45 | multiboot_header: |
53 | multiboot_header: |
46 | .long MULTIBOOT_HEADER_MAGIC |
54 | .long MULTIBOOT_HEADER_MAGIC |
47 | .long MULTIBOOT_HEADER_FLAGS |
55 | .long MULTIBOOT_HEADER_FLAGS |
48 | .long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) # checksum |
56 | .long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) # checksum |
49 | .long multiboot_header |
57 | .long multiboot_header |
50 | .long unmapped_ktext_start |
58 | .long unmapped_ktext_start |
51 | .long 0 |
59 | .long 0 |
52 | .long 0 |
60 | .long 0 |
53 | .long multiboot_image_start |
61 | .long multiboot_image_start |
54 | 62 | ||
55 | multiboot_image_start: |
63 | multiboot_image_start: |
56 | movl $START_STACK, %esp # initialize stack pointer |
64 | movl $START_STACK, %esp # initialize stack pointer |
57 | lgdt KA2PA(bootstrap_gdtr) # initialize Global Descriptor Table register |
65 | lgdt KA2PA(bootstrap_gdtr) # initialize Global Descriptor Table register |
58 | 66 | ||
59 | movw $KDATA, %cx |
67 | movw $KDATA, %cx |
60 | movw %cx, %es |
68 | movw %cx, %es |
61 | movw %cx, %gs |
69 | movw %cx, %gs |
62 | movw %cx, %fs |
70 | movw %cx, %fs |
63 | movw %cx, %ds # kernel data + stack |
71 | movw %cx, %ds # kernel data + stack |
64 | movw %cx, %ss |
72 | movw %cx, %ss |
65 | 73 | ||
66 | jmpl $KTEXT, $multiboot_meeting_point |
74 | jmpl $KTEXT, $multiboot_meeting_point |
67 | multiboot_meeting_point: |
75 | multiboot_meeting_point: |
68 | 76 | ||
69 | pushl %ebx # save parameters from GRUB |
77 | pushl %ebx # save parameters from GRUB |
70 | pushl %eax |
78 | pushl %eax |
- | 79 | ||
- | 80 | #ifdef CONFIG_FB |
|
- | 81 | mov $vesa_init,%esi; |
|
- | 82 | mov $VESA_INIT_SEGMENT<<4,%edi; |
|
- | 83 | mov $e_vesa_init-vesa_init,%ecx; |
|
- | 84 | cld; |
|
- | 85 | rep movsb; |
|
- | 86 | ||
- | 87 | mov $VESA_INIT_SEGMENT<<4,%edi; |
|
- | 88 | call *%edi; |
|
- | 89 | mov %esi,KA2PA(vesa_ph_addr); |
|
- | 90 | mov %di,KA2PA(vesa_height); |
|
- | 91 | shr $16,%edi; |
|
- | 92 | mov %di,KA2PA(vesa_width); |
|
- | 93 | mov %bx,KA2PA(vesa_scanline); |
|
- | 94 | shr $16,%ebx; |
|
- | 95 | mov %bx,KA2PA(vesa_bpp); |
|
- | 96 | #endif |
|
71 | 97 | ||
72 | call map_kernel # map kernel and turn paging on |
98 | call map_kernel # map kernel and turn paging on |
73 | 99 | ||
74 | popl %eax |
100 | popl %eax |
75 | popl %ebx |
101 | popl %ebx |
76 | cmpl $MULTIBOOT_LOADER_MAGIC, %eax # compare GRUB signature |
102 | cmpl $MULTIBOOT_LOADER_MAGIC, %eax # compare GRUB signature |
77 | je valid_boot |
103 | je valid_boot |
78 | 104 | ||
79 | xorl %ecx, %ecx # no memory size or map available |
105 | xorl %ecx, %ecx # no memory size or map available |
80 | movl %ecx, e801memorysize |
106 | movl %ecx, e801memorysize |
81 | movl %ecx, e820counter |
107 | movl %ecx, e820counter |
82 | 108 | ||
83 | jmp invalid_boot |
109 | jmp invalid_boot |
84 | 110 | ||
85 | valid_boot: |
111 | valid_boot: |
86 | 112 | ||
87 | movl (%ebx), %eax # ebx = physical address of struct multiboot_info |
113 | movl (%ebx), %eax # ebx = physical address of struct multiboot_info |
88 | 114 | ||
89 | bt $0, %eax # mbi->flags[0] (mem_lower, mem_upper valid) |
115 | bt $0, %eax # mbi->flags[0] (mem_lower, mem_upper valid) |
90 | jc mem_valid |
116 | jc mem_valid |
91 | 117 | ||
92 | xorl %ecx, %ecx |
118 | xorl %ecx, %ecx |
93 | jmp mem_invalid |
119 | jmp mem_invalid |
94 | 120 | ||
95 | mem_valid: |
121 | mem_valid: |
96 | movl 4(%ebx), %ecx # mbi->mem_lower |
122 | movl 4(%ebx), %ecx # mbi->mem_lower |
97 | addl 8(%ebx), %ecx # mbi->mem_upper |
123 | addl 8(%ebx), %ecx # mbi->mem_upper |
98 | 124 | ||
99 | mem_invalid: |
125 | mem_invalid: |
100 | movl %ecx, e801memorysize |
126 | movl %ecx, e801memorysize |
101 | 127 | ||
102 | bt $3, %eax # mbi->flags[3] (mods_count, mods_addr valid) |
128 | bt $3, %eax # mbi->flags[3] (mods_count, mods_addr valid) |
103 | jc mods_valid |
129 | jc mods_valid |
104 | 130 | ||
105 | xorl %ecx, %ecx |
131 | xorl %ecx, %ecx |
106 | movl %ecx, init |
132 | movl %ecx, init |
107 | jmp mods_end |
133 | jmp mods_end |
108 | 134 | ||
109 | mods_valid: |
135 | mods_valid: |
110 | 136 | ||
111 | movl 20(%ebx), %ecx # mbi->mods_count |
137 | movl 20(%ebx), %ecx # mbi->mods_count |
112 | movl %ecx, init |
138 | movl %ecx, init |
113 | 139 | ||
114 | cmpl $0, %ecx |
140 | cmpl $0, %ecx |
115 | je mods_end |
141 | je mods_end |
116 | 142 | ||
117 | movl 24(%ebx), %esi # mbi->mods_addr |
143 | movl 24(%ebx), %esi # mbi->mods_addr |
118 | movl $init, %edi |
144 | movl $init, %edi |
119 | 145 | ||
120 | mods_loop: |
146 | mods_loop: |
121 | 147 | ||
122 | movl 0(%esi), %edx # mods->mod_start |
148 | movl 0(%esi), %edx # mods->mod_start |
123 | addl $0x80000000, %edx |
149 | addl $0x80000000, %edx |
124 | movl %edx, 4(%edi) |
150 | movl %edx, 4(%edi) |
125 | 151 | ||
126 | movl 4(%esi), %edx |
152 | movl 4(%esi), %edx |
127 | subl 0(%esi), %edx # mods->mod_end - mods->mod_start |
153 | subl 0(%esi), %edx # mods->mod_end - mods->mod_start |
128 | movl %edx, 8(%edi) |
154 | movl %edx, 8(%edi) |
129 | 155 | ||
130 | addl $16, %esi |
156 | addl $16, %esi |
131 | addl $8 , %edi |
157 | addl $8 , %edi |
132 | 158 | ||
133 | loop mods_loop |
159 | loop mods_loop |
134 | 160 | ||
135 | mods_end: |
161 | mods_end: |
136 | 162 | ||
137 | bt $6, %eax # mbi->flags[6] (mmap_length, mmap_addr valid) |
163 | bt $6, %eax # mbi->flags[6] (mmap_length, mmap_addr valid) |
138 | jc mmap_valid |
164 | jc mmap_valid |
139 | 165 | ||
140 | xorl %edx, %edx |
166 | xorl %edx, %edx |
141 | jmp mmap_invalid |
167 | jmp mmap_invalid |
142 | 168 | ||
143 | mmap_valid: |
169 | mmap_valid: |
144 | movl 44(%ebx), %ecx # mbi->mmap_length |
170 | movl 44(%ebx), %ecx # mbi->mmap_length |
145 | movl 48(%ebx), %esi # mbi->mmap_addr |
171 | movl 48(%ebx), %esi # mbi->mmap_addr |
146 | movl $e820table, %edi |
172 | movl $e820table, %edi |
147 | xorl %edx, %edx |
173 | xorl %edx, %edx |
148 | 174 | ||
149 | mmap_loop: |
175 | mmap_loop: |
150 | cmpl $0, %ecx |
176 | cmpl $0, %ecx |
151 | jle mmap_end |
177 | jle mmap_end |
152 | 178 | ||
153 | movl 4(%esi), %eax # mmap->base_addr_low |
179 | movl 4(%esi), %eax # mmap->base_addr_low |
154 | movl %eax, (%edi) |
180 | movl %eax, (%edi) |
155 | 181 | ||
156 | movl 8(%esi), %eax # mmap->base_addr_high |
182 | movl 8(%esi), %eax # mmap->base_addr_high |
157 | movl %eax, 4(%edi) |
183 | movl %eax, 4(%edi) |
158 | 184 | ||
159 | movl 12(%esi), %eax # mmap->length_low |
185 | movl 12(%esi), %eax # mmap->length_low |
160 | movl %eax, 8(%edi) |
186 | movl %eax, 8(%edi) |
161 | 187 | ||
162 | movl 16(%esi), %eax # mmap->length_high |
188 | movl 16(%esi), %eax # mmap->length_high |
163 | movl %eax, 12(%edi) |
189 | movl %eax, 12(%edi) |
164 | 190 | ||
165 | movl 20(%esi), %eax # mmap->type |
191 | movl 20(%esi), %eax # mmap->type |
166 | movl %eax, 16(%edi) |
192 | movl %eax, 16(%edi) |
167 | 193 | ||
168 | movl (%esi), %eax # mmap->size |
194 | movl (%esi), %eax # mmap->size |
169 | addl $0x4, %eax |
195 | addl $0x4, %eax |
170 | addl %eax, %esi |
196 | addl %eax, %esi |
171 | subl %eax, %ecx |
197 | subl %eax, %ecx |
172 | addl $MEMMAP_E820_RECORD_SIZE, %edi |
198 | addl $MEMMAP_E820_RECORD_SIZE, %edi |
173 | incl %edx |
199 | incl %edx |
174 | jmp mmap_loop |
200 | jmp mmap_loop |
175 | 201 | ||
176 | mmap_end: |
202 | mmap_end: |
177 | 203 | ||
178 | mmap_invalid: |
204 | mmap_invalid: |
179 | movl %edx, e820counter |
205 | movl %edx, e820counter |
180 | 206 | ||
181 | invalid_boot: |
207 | invalid_boot: |
182 | 208 | ||
183 | #ifdef CONFIG_SMP |
209 | #ifdef CONFIG_SMP |
184 | 210 | ||
185 | # copy AP bootstrap routines below 1 MB |
211 | # copy AP bootstrap routines below 1 MB |
186 | 212 | ||
187 | movl $BOOT_OFFSET, %esi |
213 | movl $BOOT_OFFSET, %esi |
188 | movl $AP_BOOT_OFFSET, %edi |
214 | movl $AP_BOOT_OFFSET, %edi |
189 | movl $_hardcoded_unmapped_size, %ecx |
215 | movl $_hardcoded_unmapped_size, %ecx |
190 | cld |
216 | cld |
191 | rep movsb |
217 | rep movsb |
192 | 218 | ||
193 | #endif |
219 | #endif |
194 | 220 | ||
195 | call main_bsp # never returns |
221 | call main_bsp # never returns |
196 | 222 | ||
197 | cli |
223 | cli |
198 | hlt |
224 | hlt |
199 | 225 | ||
200 | .global map_kernel |
226 | .global map_kernel |
201 | map_kernel: |
227 | map_kernel: |
202 | # |
228 | # |
203 | # Here we setup mapping for both the unmapped and mapped sections of the kernel. |
229 | # Here we setup mapping for both the unmapped and mapped sections of the kernel. |
204 | # For simplicity, we map the entire 4G space. |
230 | # For simplicity, we map the entire 4G space. |
205 | # |
231 | # |
206 | movl %cr4, %ecx |
232 | movl %cr4, %ecx |
207 | orl $(1<<4), %ecx |
233 | orl $(1<<4), %ecx |
208 | movl %ecx, %cr4 # turn PSE on |
234 | movl %ecx, %cr4 # turn PSE on |
209 | 235 | ||
210 | movl $(page_directory+0), %esi |
236 | movl $(page_directory+0), %esi |
211 | movl $(page_directory+2048), %edi |
237 | movl $(page_directory+2048), %edi |
212 | xorl %ecx, %ecx |
238 | xorl %ecx, %ecx |
213 | xorl %ebx, %ebx |
239 | xorl %ebx, %ebx |
214 | 0: |
240 | 0: |
215 | movl $((1<<7)|(1<<0)), %eax |
241 | movl $((1<<7)|(1<<0)), %eax |
216 | orl %ebx, %eax |
242 | orl %ebx, %eax |
217 | movl %eax, (%esi,%ecx,4) # mapping 0x00000000+%ecx*4M => 0x00000000+%ecx*4M |
243 | movl %eax, (%esi,%ecx,4) # mapping 0x00000000+%ecx*4M => 0x00000000+%ecx*4M |
218 | movl %eax, (%edi,%ecx,4) # mapping 0x80000000+%ecx*4M => 0x00000000+%ecx*4M |
244 | movl %eax, (%edi,%ecx,4) # mapping 0x80000000+%ecx*4M => 0x00000000+%ecx*4M |
219 | addl $(4*1024*1024), %ebx |
245 | addl $(4*1024*1024), %ebx |
220 | 246 | ||
221 | incl %ecx |
247 | incl %ecx |
222 | cmpl $512, %ecx |
248 | cmpl $512, %ecx |
223 | jl 0b |
249 | jl 0b |
224 | 250 | ||
225 | movl %esi, %cr3 |
251 | movl %esi, %cr3 |
226 | 252 | ||
227 | # turn paging on |
253 | # turn paging on |
228 | movl %cr0, %ebx |
254 | movl %cr0, %ebx |
229 | orl $(1<<31), %ebx |
255 | orl $(1<<31), %ebx |
230 | movl %ebx, %cr0 |
256 | movl %ebx, %cr0 |
231 | ret |
257 | ret |
232 | 258 | ||
- | 259 | #ifdef CONFIG_FB |
|
- | 260 | vesa_init: |
|
- | 261 | jmp $selector(VESA_INIT_DES),$vesa_init_real-vesa_init; |
|
- | 262 | .code16 |
|
- | 263 | vesa_init_real: |
|
- | 264 | ||
- | 265 | mov %cr0,%eax; |
|
- | 266 | and $~1,%eax; |
|
- | 267 | mov %eax,%cr0; |
|
- | 268 | ||
- | 269 | ||
- | 270 | jmp $VESA_INIT_SEGMENT,$vesa_init_real2-vesa_init; |
|
- | 271 | ||
- | 272 | vesa_init_real2: |
|
- | 273 | ||
- | 274 | ||
- | 275 | mov %esp,%ebp; |
|
- | 276 | mov %ss,%cx; |
|
- | 277 | mov $VESA_INIT_SEGMENT,%bx; |
|
- | 278 | mov %bx,%ss; |
|
- | 279 | mov $0x0000fffc,%esp; |
|
- | 280 | push %ds; |
|
- | 281 | push %es; |
|
- | 282 | push %fs; |
|
- | 283 | push %gs; |
|
- | 284 | push %ebp; |
|
- | 285 | push %cx; |
|
- | 286 | ||
- | 287 | mov %bx,%ds; |
|
- | 288 | mov %bx,%es; |
|
- | 289 | mov %bx,%fs; |
|
- | 290 | mov %bx,%gs; |
|
- | 291 | ||
- | 292 | ||
- | 293 | mov $vesa_idt-vesa_init,%ebx; |
|
- | 294 | lidtl (%ebx); |
|
- | 295 | ||
- | 296 | #define VESA_INFO_SIZE 1024 |
|
- | 297 | ||
- | 298 | #define VESA_MODE_LIST_PTR_OFFSET 14 |
|
- | 299 | #define VESA_MODE_WIDTH_OFFSET 18 |
|
- | 300 | #define VESA_MODE_HEIGHT_OFFSET 20 |
|
- | 301 | #define VESA_MODE_BPP_OFFSET 25 |
|
- | 302 | #define VESA_MODE_SCANLINE_OFFSET 16 |
|
- | 303 | #define VESA_MODE_PHADDR_OFFSET 40 |
|
- | 304 | ||
- | 305 | #define VESA_END_OF_MODES 0xffff |
|
- | 306 | ||
- | 307 | #define VESA_OK 0x4f |
|
- | 308 | ||
- | 309 | #define VESA_GET_INFO 0x4f00 |
|
- | 310 | #define VESA_GET_MODE_INFO 0x4f01 |
|
- | 311 | #define VESA_SET_MODE 0x4f02 |
|
- | 312 | ||
- | 313 | #define CONFIG_VESA_BPP_a 255 |
|
- | 314 | ||
- | 315 | #if CONFIG_VESA_BPP==24 |
|
- | 316 | #undef CONFIG_VESA_BPP_a |
|
- | 317 | #define CONFIG_VESA_BPP_a 32 |
|
- | 318 | #endif |
|
- | 319 | ||
- | 320 | ||
- | 321 | mov $VESA_GET_INFO,%ax; |
|
- | 322 | mov $e_vesa_init-vesa_init,%di |
|
- | 323 | push %di; |
|
- | 324 | int $0x10; |
|
- | 325 | pop %di; |
|
- | 326 | cmp $VESA_OK,%al; |
|
- | 327 | jnz 0f; |
|
- | 328 | mov 2+VESA_MODE_LIST_PTR_OFFSET(%di),%si; |
|
- | 329 | mov %si,%gs; |
|
- | 330 | mov VESA_MODE_LIST_PTR_OFFSET(%di),%si; |
|
- | 331 | ||
- | 332 | add $VESA_INFO_SIZE,%di; |
|
- | 333 | ||
- | 334 | 1:# Try next mode |
|
- | 335 | mov %gs:(%si),%cx; |
|
- | 336 | cmp $VESA_END_OF_MODES,%cx; |
|
- | 337 | jz 0f; |
|
- | 338 | inc %si; |
|
- | 339 | inc %si; |
|
- | 340 | push %cx; |
|
- | 341 | push %di; |
|
- | 342 | push %si; |
|
- | 343 | mov $VESA_GET_MODE_INFO,%ax; |
|
- | 344 | int $0x10; |
|
- | 345 | pop %si; |
|
- | 346 | pop %di; |
|
- | 347 | pop %cx; |
|
- | 348 | cmp $VESA_OK,%al; |
|
- | 349 | jnz 0f; |
|
- | 350 | ||
- | 351 | ||
- | 352 | mov $CONFIG_VESA_WIDTH,%ax; |
|
- | 353 | cmp VESA_MODE_WIDTH_OFFSET(%di),%ax; |
|
- | 354 | jnz 1b; |
|
- | 355 | mov $CONFIG_VESA_HEIGHT,%ax; |
|
- | 356 | cmp VESA_MODE_HEIGHT_OFFSET(%di),%ax; |
|
- | 357 | jnz 1b; |
|
- | 358 | mov $CONFIG_VESA_BPP,%al; |
|
- | 359 | cmp VESA_MODE_BPP_OFFSET(%di),%al; |
|
- | 360 | jz 2f; |
|
- | 361 | mov $CONFIG_VESA_BPP_a,%al; |
|
- | 362 | cmp VESA_MODE_BPP_OFFSET(%di),%al; |
|
- | 363 | jnz 1b; |
|
- | 364 | ||
- | 365 | 2: |
|
- | 366 | ||
- | 367 | mov %cx,%bx; |
|
- | 368 | or $0xC000,%bx; |
|
- | 369 | push %di; |
|
- | 370 | mov $VESA_SET_MODE,%ax; |
|
- | 371 | int $0x10; |
|
- | 372 | pop %di; |
|
- | 373 | cmp $VESA_OK,%al; |
|
- | 374 | jnz 0f; |
|
- | 375 | ||
- | 376 | mov VESA_MODE_PHADDR_OFFSET(%di),%esi; |
|
- | 377 | mov VESA_MODE_WIDTH_OFFSET(%di),%ax; |
|
- | 378 | shl $16,%eax; |
|
- | 379 | mov VESA_MODE_HEIGHT_OFFSET(%di),%ax; |
|
- | 380 | mov VESA_MODE_BPP_OFFSET(%di),%bl; |
|
- | 381 | xor %bh,%bh; |
|
- | 382 | shl $16,%ebx; |
|
- | 383 | mov VESA_MODE_SCANLINE_OFFSET(%di),%bx; |
|
- | 384 | mov %eax,%edi; |
|
- | 385 | ||
- | 386 | ||
- | 387 | ||
- | 388 | 8: |
|
- | 389 | ||
- | 390 | mov %cr0,%eax; |
|
- | 391 | or $1,%eax; |
|
- | 392 | mov %eax,%cr0; |
|
- | 393 | ||
- | 394 | jmp 9f; |
|
- | 395 | 9: |
|
- | 396 | ||
- | 397 | pop %cx; |
|
- | 398 | pop %ebp; |
|
- | 399 | pop %gs; |
|
- | 400 | pop %fs; |
|
- | 401 | pop %es; |
|
- | 402 | pop %ds; |
|
- | 403 | mov %cx,%ss; |
|
- | 404 | mov %ebp,%esp; |
|
- | 405 | ||
- | 406 | ljmpl $KTEXT,$(vesa_init_protect-vesa_init+VESA_INIT_SEGMENT<<4); |
|
- | 407 | ||
- | 408 | vesa_init_protect: |
|
- | 409 | .code32 |
|
- | 410 | ret; |
|
- | 411 | ||
- | 412 | 0: #Error no Prefered mode found |
|
- | 413 | ||
- | 414 | mov $0x111,%cx; |
|
- | 415 | push %di; |
|
- | 416 | push %cx; |
|
- | 417 | mov $VESA_GET_MODE_INFO,%ax; |
|
- | 418 | int $0x10; |
|
- | 419 | pop %cx; |
|
- | 420 | pop %di; |
|
- | 421 | cmp $VESA_OK,%al; |
|
- | 422 | jnz 1f; |
|
- | 423 | jmp 2b; |
|
- | 424 | ||
- | 425 | 1:mov $0x0003,%ax; |
|
- | 426 | int $0x10; |
|
- | 427 | mov $0xffffffff,%edi; /* EGA text mode used, because of problems with VESA */ |
|
- | 428 | jmp 8; |
|
- | 429 | ||
- | 430 | ||
- | 431 | vesa_idt: |
|
- | 432 | .word 0x03ff |
|
- | 433 | .long 0 |
|
- | 434 | .align 4 |
|
- | 435 | e_vesa_init: |
|
- | 436 | #endif |
|
- | 437 | ||
- | 438 | ||
233 | 439 | ||
234 | .section K_DATA_START, "aw", @progbits |
440 | .section K_DATA_START, "aw", @progbits |
235 | 441 | ||
- | 442 | ||
- | 443 | ||
236 | .align 4096 |
444 | .align 4096 |
237 | page_directory: |
445 | page_directory: |
238 | .space 4096, 0 |
446 | .space 4096, 0 |
239 | 447 |