Changeset 873c681 in mainline
- Timestamp:
- 2010-07-01T16:29:48Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 90ed058
- Parents:
- 99718a2e
- Location:
- kernel/arch
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/amd64/src/boot/boot.S
r99718a2e r873c681 1 # 2 #Copyright (c) 2005 Ondrej Palkovsky3 #Copyright (c) 2006 Martin Decky4 #Copyright (c) 2008 Jakub Jermar5 #All rights reserved.6 # 7 #Redistribution and use in source and binary forms, with or without8 #modification, are permitted provided that the following conditions9 #are met:10 # 11 #- Redistributions of source code must retain the above copyright12 #notice, this list of conditions and the following disclaimer.13 #- Redistributions in binary form must reproduce the above copyright14 #notice, this list of conditions and the following disclaimer in the15 #documentation and/or other materials provided with the distribution.16 #- The name of the author may not be used to endorse or promote products17 #derived from this software without specific prior written permission.18 # 19 #THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR20 #IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES21 #OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.22 #IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,23 #INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT24 #NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,25 #DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY26 #THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT27 #(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF28 #THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.29 # 1 /* 2 * Copyright (c) 2005 Ondrej Palkovsky 3 * Copyright (c) 2006 Martin Decky 4 * Copyright (c) 2008 Jakub Jermar 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 11 * - Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * - Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * - The name of the author may not be used to endorse or promote products 17 * derived from this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 30 31 31 #include <arch/boot/boot.h> … … 37 37 #include <arch/cpuid.h> 38 38 39 #define START_STACK 39 #define START_STACK (BOOT_OFFSET - BOOT_STACK_SIZE) 40 40 41 41 .section K_TEXT_START, "ax" 42 42 43 43 .code32 44 45 .macro pm_error msg 46 movl \msg, %esi 47 jmp pm_error_halt 48 .endm 49 50 .macro pm_status msg 51 #ifdef CONFIG_EGA 52 pushl %esi 53 movl \msg, %esi 54 call pm_early_puts 55 popl %esi 56 #endif 57 .endm 58 59 .macro pm2_status msg 60 #ifndef CONFIG_FB 61 pm_status \msg 62 #endif 63 .endm 64 44 65 .align 4 45 66 .global multiboot_image_start … … 47 68 .long MULTIBOOT_HEADER_MAGIC 48 69 .long MULTIBOOT_HEADER_FLAGS 49 .long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) # checksum70 .long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) /* checksum */ 50 71 .long multiboot_header 51 72 .long unmapped_ktext_start … … 56 77 multiboot_image_start: 57 78 cld 58 movl $START_STACK, %esp # initialize stack pointer 59 lgdtl bootstrap_gdtr # initialize Global Descriptor Table register 60 79 80 /* Initialize stack pointer */ 81 movl $START_STACK, %esp 82 83 /* Initialize Global Descriptor Table register */ 84 lgdtl bootstrap_gdtr 85 86 /* Kernel data + stack */ 61 87 movw $gdtselector(KDATA_DES), %cx 62 88 movw %cx, %es 63 movw %cx, %ds # kernel data + stack89 movw %cx, %ds 64 90 movw %cx, %ss 65 91 66 # 67 # Simics seems to remove hidden part of GS on entering user mode 68 # when _visible_ part of GS does not point to user-mode segment. 69 # 70 92 /* 93 * Simics seems to remove hidden part of GS on entering user mode 94 * when _visible_ part of GS does not point to user-mode segment. 95 */ 71 96 movw $gdtselector(UDATA_DES), %cx 72 97 movw %cx, %fs … … 76 101 multiboot_meeting_point: 77 102 78 movl %eax, grub_eax # save parameters from GRUB 103 /* Save GRUB arguments */ 104 movl %eax, grub_eax 79 105 movl %ebx, grub_ebx 80 106 81 # 82 # Protected 32-bit. We want to reuse the code-seg descriptor, 83 # the Default operand size must not be 1 when entering long mode. 84 # 107 pm_status $status_prot 85 108 86 109 movl $(INTEL_CPUID_EXTENDED), %eax … … 89 112 ja extended_cpuid_supported 90 113 91 movl $extended_cpuid_msg, %esi 92 jmp error_halt 114 pm_error $err_extended_cpuid 93 115 94 116 extended_cpuid_supported: … … 99 121 jc long_mode_supported 100 122 101 movl $long_mode_msg, %esi 102 jmp error_halt 123 pm_error $err_long_mode 103 124 104 125 long_mode_supported: … … 107 128 jc noexecute_supported 108 129 109 movl $noexecute_msg, %esi 110 jmp error_halt 130 pm_error $err_noexecute 111 131 112 132 noexecute_supported: … … 117 137 jc fx_supported 118 138 119 movl $fx_msg, %esi 120 jmp error_halt 139 pm_error $err_fx 121 140 122 141 fx_supported: … … 125 144 jc sse2_supported 126 145 127 movl $sse2_msg, %esi 128 jmp error_halt 146 pm_error $err_sse2 129 147 130 148 sse2_supported: 131 149 132 150 #include "vesa_prot.inc" 133 134 # 135 # Enable 64-bit page translation entries - CR4.PAE = 1. 136 # Paging is not enabled until after long mode is enabled. 137 # 151 152 /* 153 * Protected 32-bit. We want to reuse the code-seg descriptor, 154 * the Default operand size must not be 1 when entering long mode. 155 */ 156 157 pm2_status $status_prot2 158 159 /* 160 * Enable 64-bit page translation entries - CR4.PAE = 1. 161 * Paging is not enabled until after long mode is enabled. 162 */ 138 163 139 164 movl %cr4, %eax … … 141 166 movl %eax, %cr4 142 167 143 # set up paging tables 144 168 /* Set up paging tables */ 145 169 leal ptl_0, %eax 146 170 movl %eax, %cr3 147 171 148 # enable long mode 149 150 movl $EFER_MSR_NUM, %ecx # EFER MSR number 151 rdmsr # read EFER 152 btsl $AMD_LME_FLAG, %eax # set LME = 1 153 wrmsr # write EFER 154 155 # enable paging to activate long mode (set CR0.PG = 1) 156 172 /* Enable long mode */ 173 movl $EFER_MSR_NUM, %ecx 174 rdmsr /* read EFER */ 175 btsl $AMD_LME_FLAG, %eax /* set LME = 1 */ 176 wrmsr 177 178 /* Enable paging to activate long mode (set CR0.PG = 1) */ 157 179 movl %cr0, %eax 158 180 btsl $31, %eax 159 181 movl %eax, %cr0 160 182 161 # at this point we are in compatibility mode 162 183 /* At this point we are in compatibility mode */ 163 184 jmpl $gdtselector(KTEXT_DES), $start64 164 185 186 /** Print string to EGA display (in light red) and halt. 187 * 188 * Should be executed from 32 bit protected mode with paging 189 * turned off. Stack is not required. This routine is used even 190 * if CONFIG_EGA is not enabled. Since we are going to halt the 191 * CPU anyway, it is always better to at least try to print 192 * some hints. 193 * 194 * @param %esi NULL-terminated string to print. 195 * 196 */ 197 pm_error_halt: 198 movl $0xb8000, %edi /* base of EGA text mode memory */ 199 xorl %eax, %eax 200 201 /* Read bits 8 - 15 of the cursor address */ 202 movw $0x3d4, %dx 203 movb $0xe, %al 204 outb %al, %dx 205 206 movw $0x3d5, %dx 207 inb %dx, %al 208 shl $8, %ax 209 210 /* Read bits 0 - 7 of the cursor address */ 211 movw $0x3d4, %dx 212 movb $0xf, %al 213 outb %al, %dx 214 215 movw $0x3d5, %dx 216 inb %dx, %al 217 218 /* Sanity check for the cursor on screen */ 219 cmp $2000, %ax 220 jb err_cursor_ok 221 222 movw $1998, %ax 223 224 err_cursor_ok: 225 226 movw %ax, %bx 227 shl $1, %eax 228 addl %eax, %edi 229 230 err_ploop: 231 lodsb 232 233 cmp $0, %al 234 je err_ploop_end 235 236 movb $0x0c, %ah /* black background, light red foreground */ 237 stosw 238 239 /* Sanity check for the cursor on the last line */ 240 inc %bx 241 cmp $2000, %bx 242 jb err_ploop 243 244 /* Scroll the screen (24 rows) */ 245 movl %esi, %edx 246 movl $0xb80a0, %esi 247 movl $0xb8000, %edi 248 movl $1920, %ecx 249 rep movsw 250 251 /* Clear the 24th row */ 252 xorl %eax, %eax 253 movl $80, %ecx 254 rep stosw 255 256 /* Go to row 24 */ 257 movl %edx, %esi 258 movl $0xb8f00, %edi 259 movw $1920, %bx 260 261 jmp err_ploop 262 err_ploop_end: 263 264 /* Write bits 8 - 15 of the cursor address */ 265 movw $0x3d4, %dx 266 movb $0xe, %al 267 outb %al, %dx 268 269 movw $0x3d5, %dx 270 movb %bh, %al 271 outb %al, %dx 272 273 /* Write bits 0 - 7 of the cursor address */ 274 movw $0x3d4, %dx 275 movb $0xf, %al 276 outb %al, %dx 277 278 movw $0x3d5, %dx 279 movb %bl, %al 280 outb %al, %dx 281 282 cli 283 hlt1: 284 hlt 285 jmp hlt1 286 287 /** Print string to EGA display (in light green). 288 * 289 * Should be called from 32 bit protected mode with paging 290 * turned off. A stack space of at least 24 bytes is required, 291 * but the function does not establish a stack frame. 292 * 293 * Macros such as pm_status and pm2_status take care that 294 * this function is used only when CONFIG_EGA is enabled 295 * and CONFIG_FB is disabled. 296 * 297 * @param %esi NULL-terminated string to print. 298 * 299 */ 300 pm_early_puts: 301 pushl %eax 302 pushl %ebx 303 pushl %ecx 304 pushl %edx 305 pushl %edi 306 307 movl $0xb8000, %edi /* base of EGA text mode memory */ 308 xorl %eax, %eax 309 310 /* Read bits 8 - 15 of the cursor address */ 311 movw $0x3d4, %dx 312 movb $0xe, %al 313 outb %al, %dx 314 315 movw $0x3d5, %dx 316 inb %dx, %al 317 shl $8, %ax 318 319 /* Read bits 0 - 7 of the cursor address */ 320 movw $0x3d4, %dx 321 movb $0xf, %al 322 outb %al, %dx 323 324 movw $0x3d5, %dx 325 inb %dx, %al 326 327 /* Sanity check for the cursor on screen */ 328 cmp $2000, %ax 329 jb pm_puts_cursor_ok 330 331 movw $1998, %ax 332 333 pm_puts_cursor_ok: 334 335 movw %ax, %bx 336 shl $1, %eax 337 addl %eax, %edi 338 339 pm_puts_ploop: 340 lodsb 341 342 cmp $0, %al 343 je pm_puts_ploop_end 344 345 movb $0x0a, %ah /* black background, light green foreground */ 346 stosw 347 348 /* Sanity check for the cursor on the last line */ 349 inc %bx 350 cmp $2000, %bx 351 jb pm_puts_ploop 352 353 /* Scroll the screen (24 rows) */ 354 movl %esi, %edx 355 movl $0xb80a0, %esi 356 movl $0xb8000, %edi 357 movl $1920, %ecx 358 rep movsw 359 360 /* Clear the 24th row */ 361 xorl %eax, %eax 362 movl $80, %ecx 363 rep stosw 364 365 /* Go to row 24 */ 366 movl %edx, %esi 367 movl $0xb8f00, %edi 368 movw $1920, %bx 369 370 jmp pm_puts_ploop 371 pm_puts_ploop_end: 372 373 /* Write bits 8 - 15 of the cursor address */ 374 movw $0x3d4, %dx 375 movb $0xe, %al 376 outb %al, %dx 377 378 movw $0x3d5, %dx 379 movb %bh, %al 380 outb %al, %dx 381 382 /* Write bits 0 - 7 of the cursor address */ 383 movw $0x3d4, %dx 384 movb $0xf, %al 385 outb %al, %dx 386 387 movw $0x3d5, %dx 388 movb %bl, %al 389 outb %al, %dx 390 391 popl %edi 392 popl %edx 393 popl %ecx 394 popl %ebx 395 popl %eax 396 397 ret 398 165 399 .code64 400 401 .macro long_status msg 402 pushq %rdi 403 movq \msg, %rdi 404 call early_puts 405 popq %rdi 406 .endm 407 166 408 start64: 409 410 /* 411 * Long mode. 412 */ 413 167 414 movq $(PA2KA(START_STACK)), %rsp 168 415 169 # call arch_pre_main(grub_eax, grub_ebx) 416 /* Create the first stack frame */ 417 pushq $0 418 movq %rsp, %rbp 419 420 long_status $status_long 421 422 /* Call arch_pre_main(grub_eax, grub_ebx) */ 170 423 xorq %rdi, %rdi 171 424 movl grub_eax, %edi … … 176 429 callq *%rax 177 430 178 # create the first stack frame 179 pushq $0 180 movq %rsp, %rbp 181 431 long_status $status_main 432 433 /* Call main_bsp() */ 182 434 movabsq $main_bsp, %rax 183 435 call *%rax 184 436 185 # not reached 186 437 /* Not reached */ 187 438 cli 188 439 hlt0: … … 190 441 jmp hlt0 191 442 192 # Print string from %esi to EGA display (in red) and halt 193 error_halt: 194 movl $0xb8000, %edi # base of EGA text mode memory 195 xorl %eax, %eax 196 197 movw $0x3d4, %dx # read bits 8 - 15 of the cursor address 443 /** Print string to EGA display. 444 * 445 * Should be called from long mode (with paging enabled 446 * and stack established). This function is ABI compliant 447 * (without red-zone). 448 * 449 * If CONFIG_EGA is undefined or CONFIG_FB is defined 450 * then this function does nothing. 451 * 452 * @param %rdi NULL-terminated string to print. 453 * 454 */ 455 early_puts: 456 457 #if ((defined(CONFIG_EGA)) && (!defined(CONFIG_FB))) 458 459 /* Prologue, save preserved registers */ 460 pushq %rbp 461 movq %rsp, %rbp 462 pushq %rbx 463 464 movq %rdi, %rsi 465 movq $(PA2KA(0xb8000)), %rdi /* base of EGA text mode memory */ 466 xorq %rax, %rax 467 468 /* Read bits 8 - 15 of the cursor address */ 469 movw $0x3d4, %dx 198 470 movb $0xe, %al 199 471 outb %al, %dx … … 203 475 shl $8, %ax 204 476 205 movw $0x3d4, %dx # read bits 0 - 7 of the cursor address 477 /* Read bits 0 - 7 of the cursor address */ 478 movw $0x3d4, %dx 206 479 movb $0xf, %al 207 480 outb %al, %dx … … 210 483 inb %dx, %al 211 484 212 cmp $1920, %ax 213 jbe cursor_ok 214 215 movw $1920, %ax # sanity check for the cursor on the last line 216 217 cursor_ok: 485 /* Sanity check for the cursor on screen */ 486 cmp $2000, %ax 487 jb early_puts_cursor_ok 488 489 movw $1998, %ax 490 491 early_puts_cursor_ok: 218 492 219 493 movw %ax, %bx 220 shl $1, %eax 221 addl %eax, %edi 222 223 movw $0x0c00, %ax # black background, light red foreground 224 225 ploop: 494 shl $1, %rax 495 addq %rax, %rdi 496 497 early_puts_ploop: 226 498 lodsb 499 227 500 cmp $0, %al 228 je ploop_end 501 je early_puts_ploop_end 502 503 movb $0x0e, %ah /* black background, yellow foreground */ 229 504 stosw 505 506 /* Sanity check for the cursor on the last line */ 230 507 inc %bx 231 jmp ploop 232 ploop_end: 233 234 movw $0x3d4, %dx # write bits 8 - 15 of the cursor address 508 cmp $2000, %bx 509 jb early_puts_ploop 510 511 /* Scroll the screen (24 rows) */ 512 movq %rsi, %rdx 513 movq $(PA2KA(0xb80a0)), %rsi 514 movq $(PA2KA(0xb8000)), %rdi 515 movq $1920, %rcx 516 rep movsw 517 518 /* Clear the 24th row */ 519 xorq %rax, %rax 520 movq $80, %rcx 521 rep stosw 522 523 /* Go to row 24 */ 524 movq %rdx, %rsi 525 movq $(PA2KA(0xb8f00)), %rdi 526 movw $1920, %bx 527 528 jmp early_puts_ploop 529 early_puts_ploop_end: 530 531 /* Write bits 8 - 15 of the cursor address */ 532 movw $0x3d4, %dx 235 533 movb $0xe, %al 236 534 outb %al, %dx … … 240 538 outb %al, %dx 241 539 242 movw $0x3d4, %dx # write bits 0 - 7 of the cursor address 540 /* Write bits 0 - 7 of the cursor address */ 541 movw $0x3d4, %dx 243 542 movb $0xf, %al 244 543 outb %al, %dx … … 248 547 outb %al, %dx 249 548 250 cli 251 hlt1: 252 hlt 253 jmp hlt1 549 /* Epilogue, restore preserved registers */ 550 popq %rbx 551 leave 552 553 #endif 554 555 ret 254 556 255 557 #include "vesa_real.inc" … … 257 559 .section K_INI_PTLS, "aw", @progbits 258 560 259 # 260 # Macro for generating initial page table contents. 261 # @param cnt Number of entries to generate. Must be multiple of 8. 262 # @param g Number of GB that will be added to the mapping. 263 # 561 /** Generate initial page table contents. 562 * 563 * @param cnt Number of entries to generate. Must be multiple of 8. 564 * @param g Number of GB that will be added to the mapping. 565 * 566 */ 264 567 .macro ptl2gen cnt g 265 568 .if \cnt … … 276 579 .endm 277 580 278 # Page table for pages in the 1st gigabyte. 581 /* Page table for pages in the 1st gigabyte. */ 279 582 .align 4096 280 583 ptl_2_0g: 281 584 ptl2gen 512 0 282 585 283 # Page table for pages in the 2nd gigabyte. 586 /* Page table for pages in the 2nd gigabyte. */ 284 587 .align 4096 285 588 ptl_2_1g: 286 589 ptl2gen 512 1 287 590 288 # Page table for pages in the 3rd gigabyte. 591 /* Page table for pages in the 3rd gigabyte. */ 289 592 .align 4096 290 593 ptl_2_2g: 291 594 ptl2gen 512 2 292 595 293 # Page table for pages in the 4th gigabyte. 596 /* Page table for pages in the 4th gigabyte. */ 294 597 .align 4096 295 598 ptl_2_3g: 296 599 ptl2gen 512 3 297 600 298 # Page table for pages in the 5th gigabyte. 601 /* Page table for pages in the 5th gigabyte. */ 299 602 .align 4096 300 603 ptl_2_4g: 301 604 ptl2gen 512 3 302 605 303 # Page table for pages in the 6th gigabyte. 606 /* Page table for pages in the 6th gigabyte. */ 304 607 .align 4096 305 608 ptl_2_5g: 306 609 ptl2gen 512 3 307 610 308 # Page table for pages in the 7th gigabyte. 611 /* Page table for pages in the 7th gigabyte. */ 309 612 .align 4096 310 613 ptl_2_6g: 311 614 ptl2gen 512 3 312 615 313 # Page table for pages in the 8th gigabyte. 616 /* Page table for pages in the 8th gigabyte. */ 314 617 .align 4096 315 618 ptl_2_7g: … … 318 621 .align 4096 319 622 ptl_1: 320 # Identity mapping for [0; 8G)623 /* Identity mapping for [0; 8G) */ 321 624 .quad ptl_2_0g + (PTL_WRITABLE | PTL_PRESENT) 322 625 .quad ptl_2_1g + (PTL_WRITABLE | PTL_PRESENT) … … 350 653 .long 0 351 654 352 e xtended_cpuid_msg:655 err_extended_cpuid: 353 656 .asciz "Error: Extended CPUID not supported -- CPU is not 64-bit. System halted." 354 long_mode_msg:657 err_long_mode: 355 658 .asciz "Error: 64-bit long mode not supported. System halted." 356 noexecute_msg:659 err_noexecute: 357 660 .asciz "Error: No-execute pages not supported. System halted." 358 fx_msg:661 err_fx: 359 662 .asciz "Error: FXSAVE/FXRESTORE instructions not supported. System halted." 360 sse2_msg:663 err_sse2: 361 664 .asciz "Error: SSE2 instructions not supported. System halted." 665 666 status_prot: 667 .asciz "[prot] " 668 status_vesa_copy: 669 .asciz "[vesa_copy] " 670 status_grub_cmdline: 671 .asciz "[grub_cmdline] " 672 status_vesa_real: 673 .asciz "[vesa_real] " 674 status_prot2: 675 .asciz "[prot2] " 676 status_long: 677 .asciz "[long] " 678 status_main: 679 .asciz "[main] " -
kernel/arch/amd64/src/boot/vesa_ret.inc
r99718a2e r873c681 1 1 .code32 2 2 vesa_init_protected: 3 cld 4 5 /* Initialize stack pointer */ 6 movl $START_STACK, %esp 7 8 /* Kernel data + stack */ 3 9 movw $gdtselector(KDATA_DES), %cx 4 10 movw %cx, %es 5 movw %cx, %ds # kernel data + stack11 movw %cx, %ds 6 12 movw %cx, %ss 7 13 8 #9 #Simics seems to remove hidden part of GS on entering user mode10 #when _visible_ part of GS does not point to user-mode segment.11 #14 /* 15 * Simics seems to remove hidden part of GS on entering user mode 16 * when _visible_ part of GS does not point to user-mode segment. 17 */ 12 18 13 19 movw $gdtselector(UDATA_DES), %cx … … 15 21 movw %cx, %gs 16 22 17 movl $START_STACK, %esp # initialize stack pointer18 19 23 jmpl $gdtselector(KTEXT32_DES), $vesa_meeting_point -
kernel/arch/ia32/src/boot/boot.S
r99718a2e r873c681 1 # 2 # Copyright (c) 2001-2004Jakub Jermar3 # Copyright (c) 2005-2006Martin Decky4 #All rights reserved.5 # 6 #Redistribution and use in source and binary forms, with or without7 #modification, are permitted provided that the following conditions8 #are met:9 # 10 #- Redistributions of source code must retain the above copyright11 #notice, this list of conditions and the following disclaimer.12 #- Redistributions in binary form must reproduce the above copyright13 #notice, this list of conditions and the following disclaimer in the14 #documentation and/or other materials provided with the distribution.15 #- The name of the author may not be used to endorse or promote products16 #derived from this software without specific prior written permission.17 # 18 #THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR19 #IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES20 #OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.21 #IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,22 #INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT23 #NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,24 #DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY25 #THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT26 #(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF27 #THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.28 # 1 /* 2 * Copyright (c) 2001 Jakub Jermar 3 * Copyright (c) 2005 Martin Decky 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 10 * - Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * - Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 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 16 * derived from this software without specific prior written permission. 17 * 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 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 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 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 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 29 30 30 #include <arch/boot/boot.h> … … 34 34 #include <arch/cpuid.h> 35 35 36 #define START_STACK (BOOT_OFFSET - BOOT_STACK_SIZE)36 #define START_STACK (BOOT_OFFSET - BOOT_STACK_SIZE) 37 37 38 38 .section K_TEXT_START, "ax" 39 39 40 40 .code32 41 42 .macro pm_error msg 43 movl \msg, %esi 44 jmp pm_error_halt 45 .endm 46 47 .macro pm_status msg 48 #ifdef CONFIG_EGA 49 pushl %esi 50 movl \msg, %esi 51 call pm_early_puts 52 popl %esi 53 #endif 54 .endm 55 56 .macro pm2_status msg 57 pushl \msg 58 call early_puts 59 .endm 60 41 61 .align 4 42 62 .global multiboot_image_start … … 44 64 .long MULTIBOOT_HEADER_MAGIC 45 65 .long MULTIBOOT_HEADER_FLAGS 46 .long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) # checksum66 .long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) /* checksum */ 47 67 .long multiboot_header 48 68 .long unmapped_ktext_start … … 53 73 multiboot_image_start: 54 74 cld 55 movl $START_STACK, %esp # initialize stack pointer 56 lgdt KA2PA(bootstrap_gdtr) # initialize Global Descriptor Table register 57 75 76 /* Initialize stack pointer */ 77 movl $START_STACK, %esp 78 79 /* Initialize Global Descriptor Table register */ 80 lgdtl KA2PA(bootstrap_gdtr) 81 82 /* Kernel data + stack */ 58 83 movw $gdtselector(KDATA_DES), %cx 59 84 movw %cx, %es 60 85 movw %cx, %fs 61 86 movw %cx, %gs 62 movw %cx, %ds # kernel data + stack87 movw %cx, %ds 63 88 movw %cx, %ss 64 89 … … 66 91 multiboot_meeting_point: 67 92 68 movl %eax, grub_eax # save parameters from GRUB 93 /* Save GRUB arguments */ 94 movl %eax, grub_eax 69 95 movl %ebx, grub_ebx 96 97 pm_status $status_prot 70 98 71 99 movl $(INTEL_CPUID_LEVEL), %eax 72 100 cpuid 73 cmp $0x0, %eax # any function > 0?101 cmp $0x0, %eax /* any function > 0? */ 74 102 jbe pse_unsupported 75 103 … … 80 108 81 109 pse_unsupported: 82 movl $pse_msg, %esi83 jmp error_halt110 111 pm_error $err_pse 84 112 85 113 pse_supported: 86 114 87 115 #include "vesa_prot.inc" 88 89 # map kernel and turn paging on116 117 /* Map kernel and turn paging on */ 90 118 call map_kernel 91 119 92 # call arch_pre_main(grub_eax, grub_ebx) 120 /* Create the first stack frame */ 121 pushl $0 122 movl %esp, %ebp 123 124 pm2_status $status_prot2 125 126 /* Call arch_pre_main(grub_eax, grub_ebx) */ 93 127 pushl grub_ebx 94 128 pushl grub_eax 95 129 call arch_pre_main 96 97 # Create the first stack frame 98 pushl $0 99 movl %esp, %ebp 100 130 131 pm2_status $status_main 132 133 /* Call main_bsp() */ 101 134 call main_bsp 102 135 103 # not reached136 /* Not reached */ 104 137 cli 105 138 hlt0: … … 107 140 jmp hlt0 108 141 142 /** Setup mapping for the kernel. 143 * 144 * Setup mapping for both the unmapped and mapped sections 145 * of the kernel. For simplicity, we map the entire 4G space. 146 * 147 */ 109 148 .global map_kernel 110 149 map_kernel: 111 #112 # Here we setup mapping for both the unmapped and mapped sections of the kernel.113 # For simplicity, we map the entire 4G space.114 #115 150 movl %cr4, %ecx 116 orl $(1 << 4), %ecx # turn PSE on117 andl $(~(1 << 5)), %ecx # turn PAE off151 orl $(1 << 4), %ecx /* PSE on */ 152 andl $(~(1 << 5)), %ecx /* PAE off */ 118 153 movl %ecx, %cr4 119 154 … … 126 161 movl $((1 << 7) | (1 << 1) | (1 << 0)), %eax 127 162 orl %ebx, %eax 128 movl %eax, (%esi, %ecx, 4) # mapping 0x00000000 + %ecx * 4M => 0x00000000 + %ecx * 4M 129 movl %eax, (%edi, %ecx, 4) # mapping 0x80000000 + %ecx * 4M => 0x00000000 + %ecx * 4M 163 /* Mapping 0x00000000 + %ecx * 4M => 0x00000000 + %ecx * 4M */ 164 movl %eax, (%esi, %ecx, 4) 165 /* Mapping 0x80000000 + %ecx * 4M => 0x00000000 + %ecx * 4M */ 166 movl %eax, (%edi, %ecx, 4) 130 167 addl $(4 * 1024 * 1024), %ebx 131 168 … … 137 174 138 175 movl %cr0, %ebx 139 orl $(1 << 31), %ebx # turn paging on176 orl $(1 << 31), %ebx /* paging on */ 140 177 movl %ebx, %cr0 141 178 ret 142 179 143 # Print string from %esi to EGA display (in red) and halt 144 error_halt: 145 movl $0xb8000, %edi # base of EGA text mode memory 180 /** Print string to EGA display (in light red) and halt. 181 * 182 * Should be executed from 32 bit protected mode with paging 183 * turned off. Stack is not required. This routine is used even 184 * if CONFIG_EGA is not enabled. Since we are going to halt the 185 * CPU anyway, it is always better to at least try to print 186 * some hints. 187 * 188 * @param %esi NULL-terminated string to print. 189 * 190 */ 191 pm_error_halt: 192 movl $0xb8000, %edi /* base of EGA text mode memory */ 146 193 xorl %eax, %eax 147 194 148 movw $0x3d4, %dx # read bits 8 - 15 of the cursor address 195 /* Read bits 8 - 15 of the cursor address */ 196 movw $0x3d4, %dx 149 197 movb $0xe, %al 150 198 outb %al, %dx … … 154 202 shl $8, %ax 155 203 156 movw $0x3d4, %dx # read bits 0 - 7 of the cursor address 204 /* Read bits 0 - 7 of the cursor address */ 205 movw $0x3d4, %dx 157 206 movb $0xf, %al 158 207 outb %al, %dx … … 161 210 inb %dx, %al 162 211 163 cmp $1920, %ax 164 jbe cursor_ok 165 166 movw $1920, %ax # sanity check for the cursor on the last line 167 168 cursor_ok: 212 /* Sanity check for the cursor on screen */ 213 cmp $2000, %ax 214 jb err_cursor_ok 215 216 movw $1998, %ax 217 218 err_cursor_ok: 169 219 170 220 movw %ax, %bx … … 172 222 addl %eax, %edi 173 223 174 movw $0x0c00, %ax # black background, light red foreground 175 176 ploop: 224 err_ploop: 177 225 lodsb 226 178 227 cmp $0, %al 179 je ploop_end 228 je err_ploop_end 229 230 movb $0x0c, %ah /* black background, light red foreground */ 180 231 stosw 232 233 /* Sanity check for the cursor on the last line */ 181 234 inc %bx 182 jmp ploop 183 ploop_end: 184 185 movw $0x3d4, %dx # write bits 8 - 15 of the cursor address 235 cmp $2000, %bx 236 jb err_ploop 237 238 /* Scroll the screen (24 rows) */ 239 movl %esi, %edx 240 movl $0xb80a0, %esi 241 movl $0xb8000, %edi 242 movl $1920, %ecx 243 rep movsw 244 245 /* Clear the 24th row */ 246 xorl %eax, %eax 247 movl $80, %ecx 248 rep stosw 249 250 /* Go to row 24 */ 251 movl %edx, %esi 252 movl $0xb8f00, %edi 253 movw $1920, %bx 254 255 jmp err_ploop 256 err_ploop_end: 257 258 /* Write bits 8 - 15 of the cursor address */ 259 movw $0x3d4, %dx 186 260 movb $0xe, %al 187 261 outb %al, %dx … … 191 265 outb %al, %dx 192 266 193 movw $0x3d4, %dx # write bits 0 - 7 of the cursor address 267 /* Write bits 0 - 7 of the cursor address */ 268 movw $0x3d4, %dx 194 269 movb $0xf, %al 195 270 outb %al, %dx … … 204 279 jmp hlt1 205 280 281 /** Print string to EGA display (in light green). 282 * 283 * Should be called from 32 bit protected mode with paging 284 * turned off. A stack space of at least 24 bytes is required, 285 * but the function does not establish a stack frame. 286 * 287 * Macros such as pm_status take care that this function 288 * is used only when CONFIG_EGA is enabled. 289 * 290 * @param %esi NULL-terminated string to print. 291 * 292 */ 293 pm_early_puts: 294 pushl %eax 295 pushl %ebx 296 pushl %ecx 297 pushl %edx 298 pushl %edi 299 300 movl $0xb8000, %edi /* base of EGA text mode memory */ 301 xorl %eax, %eax 302 303 /* Read bits 8 - 15 of the cursor address */ 304 movw $0x3d4, %dx 305 movb $0xe, %al 306 outb %al, %dx 307 308 movw $0x3d5, %dx 309 inb %dx, %al 310 shl $8, %ax 311 312 /* Read bits 0 - 7 of the cursor address */ 313 movw $0x3d4, %dx 314 movb $0xf, %al 315 outb %al, %dx 316 317 movw $0x3d5, %dx 318 inb %dx, %al 319 320 /* Sanity check for the cursor on screen */ 321 cmp $2000, %ax 322 jb pm_puts_cursor_ok 323 324 movw $1998, %ax 325 326 pm_puts_cursor_ok: 327 328 movw %ax, %bx 329 shl $1, %eax 330 addl %eax, %edi 331 332 pm_puts_ploop: 333 lodsb 334 335 cmp $0, %al 336 je pm_puts_ploop_end 337 338 movb $0x0a, %ah /* black background, light green foreground */ 339 stosw 340 341 /* Sanity check for the cursor on the last line */ 342 inc %bx 343 cmp $2000, %bx 344 jb pm_puts_ploop 345 346 /* Scroll the screen (24 rows) */ 347 movl %esi, %edx 348 movl $0xb80a0, %esi 349 movl $0xb8000, %edi 350 movl $1920, %ecx 351 rep movsw 352 353 /* Clear the 24th row */ 354 xorl %eax, %eax 355 movl $80, %ecx 356 rep stosw 357 358 /* Go to row 24 */ 359 movl %edx, %esi 360 movl $0xb8f00, %edi 361 movw $1920, %bx 362 363 jmp pm_puts_ploop 364 pm_puts_ploop_end: 365 366 /* Write bits 8 - 15 of the cursor address */ 367 movw $0x3d4, %dx 368 movb $0xe, %al 369 outb %al, %dx 370 371 movw $0x3d5, %dx 372 movb %bh, %al 373 outb %al, %dx 374 375 /* Write bits 0 - 7 of the cursor address */ 376 movw $0x3d4, %dx 377 movb $0xf, %al 378 outb %al, %dx 379 380 movw $0x3d5, %dx 381 movb %bl, %al 382 outb %al, %dx 383 384 popl %edi 385 popl %edx 386 popl %ecx 387 popl %ebx 388 popl %eax 389 390 ret 391 392 /** Print string to EGA display. 393 * 394 * Should be called from 32 bit protected mode (with paging 395 * enabled and stack established). This function is ABI compliant. 396 * 397 * If CONFIG_EGA is undefined or CONFIG_FB is defined 398 * then this function does nothing. 399 * 400 * @param %ebp+0x08 NULL-terminated string to print. 401 * 402 */ 403 early_puts: 404 405 #if ((defined(CONFIG_EGA)) && (!defined(CONFIG_FB))) 406 407 /* Prologue, save preserved registers */ 408 pushl %ebp 409 movl %esp, %ebp 410 pushl %ebx 411 pushl %esi 412 pushl %edi 413 414 movl 0x08(%ebp), %esi 415 movl $(PA2KA(0xb8000)), %edi /* base of EGA text mode memory */ 416 xorl %eax, %eax 417 418 /* Read bits 8 - 15 of the cursor address */ 419 movw $0x3d4, %dx 420 movb $0xe, %al 421 outb %al, %dx 422 423 movw $0x3d5, %dx 424 inb %dx, %al 425 shl $8, %ax 426 427 /* Read bits 0 - 7 of the cursor address */ 428 movw $0x3d4, %dx 429 movb $0xf, %al 430 outb %al, %dx 431 432 movw $0x3d5, %dx 433 inb %dx, %al 434 435 /* Sanity check for the cursor on screen */ 436 cmp $2000, %ax 437 jb early_puts_cursor_ok 438 439 movw $1998, %ax 440 441 early_puts_cursor_ok: 442 443 movw %ax, %bx 444 shl $1, %eax 445 addl %eax, %edi 446 447 early_puts_ploop: 448 lodsb 449 450 cmp $0, %al 451 je early_puts_ploop_end 452 453 movb $0x0e, %ah /* black background, yellow foreground */ 454 stosw 455 456 /* Sanity check for the cursor on the last line */ 457 inc %bx 458 cmp $2000, %bx 459 jb early_puts_ploop 460 461 /* Scroll the screen (24 rows) */ 462 movl %esi, %edx 463 movl $(PA2KA(0xb80a0)), %esi 464 movl $(PA2KA(0xb8000)), %edi 465 movl $1920, %ecx 466 rep movsw 467 468 /* Clear the 24th row */ 469 xorl %eax, %eax 470 movl $80, %ecx 471 rep stosw 472 473 /* Go to row 24 */ 474 movl %edx, %esi 475 movl $(PA2KA(0xb8f00)), %edi 476 movw $1920, %bx 477 478 jmp early_puts_ploop 479 early_puts_ploop_end: 480 481 /* Write bits 8 - 15 of the cursor address */ 482 movw $0x3d4, %dx 483 movb $0xe, %al 484 outb %al, %dx 485 486 movw $0x3d5, %dx 487 movb %bh, %al 488 outb %al, %dx 489 490 /* Write bits 0 - 7 of the cursor address */ 491 movw $0x3d4, %dx 492 movb $0xf, %al 493 outb %al, %dx 494 495 movw $0x3d5, %dx 496 movb %bl, %al 497 outb %al, %dx 498 499 /* Epilogue, restore preserved registers */ 500 popl %edi 501 popl %esi 502 popl %ebx 503 leave 504 505 #endif 506 507 ret 508 206 509 #include "vesa_real.inc" 207 510 … … 218 521 .long 0 219 522 220 pse_msg:523 err_pse: 221 524 .asciz "Page Size Extension not supported. System halted." 222 525 526 status_prot: 527 .asciz "[prot] " 528 status_vesa_copy: 529 .asciz "[vesa_copy] " 530 status_grub_cmdline: 531 .asciz "[grub_cmdline] " 532 status_vesa_real: 533 .asciz "[vesa_real] " 534 status_prot2: 535 .asciz "[prot2] " 536 status_main: 537 .asciz "[main] " -
kernel/arch/ia32/src/boot/vesa_prot.inc
r99718a2e r873c681 5 5 #define MBINFO_OFFSET_CMDLINE 16 6 6 7 # copy real mode VESA initialization code 7 /* Copy real mode VESA initialization code */ 8 9 pm_status $status_vesa_copy 8 10 9 11 mov $vesa_init, %esi … … 12 14 rep movsb 13 15 14 # check for GRUB command line 16 /* Check for GRUB command line */ 17 18 pm_status $status_grub_cmdline 15 19 16 20 mov grub_eax, %eax … … 23 27 jnc no_cmdline 24 28 25 # skip the kernel path in command line29 /* Skip the kernel path in command line */ 26 30 27 31 mov MBINFO_OFFSET_CMDLINE(%ebx), %esi … … 52 56 space_loop_done: 53 57 54 # copy at most 23 characters from command line58 /* Copy at most 23 characters from command line */ 55 59 56 60 mov $VESA_INIT_SEGMENT << 4, %edi … … 68 72 cmd_loop_done: 69 73 70 # zero termination74 /* Zero termination */ 71 75 72 76 xor %eax, %eax … … 75 79 no_cmdline: 76 80 77 # jump to the real mode 81 /* Jump to the real mode */ 82 83 pm_status $status_vesa_real 78 84 79 85 mov $VESA_INIT_SEGMENT << 4, %edi … … 81 87 82 88 vesa_meeting_point: 83 # returned back to protected mode89 /* Returned back to protected mode */ 84 90 85 91 mov %ax, KA2PA(vesa_scanline) -
kernel/arch/ia32/src/boot/vesa_real.inc
r99718a2e r873c681 31 31 vesa_init: 32 32 jmp $gdtselector(VESA_INIT_DES), $vesa_init_real - vesa_init 33 33 34 34 .code16 35 35 vesa_init_real: … … 55 55 pushl %eax 56 56 57 # parse default mode string57 /* Parse default mode string */ 58 58 59 59 mov $default_mode - vesa_init, %di … … 65 65 mov (%di), %al 66 66 67 # check for digit67 /* Check for digit */ 68 68 69 69 cmp $'0', %al … … 75 75 sub $'0', %al 76 76 77 # multiply default_width by 10 and add digit77 /* Multiply default_width by 10 and add digit */ 78 78 79 79 mov default_width - vesa_init, %bx … … 96 96 mov (%di), %al 97 97 98 # check for digit98 /* Check for digit */ 99 99 100 100 cmp $'0', %al … … 106 106 sub $'0', %al 107 107 108 # multiply default_height by 10 and add digit108 /* Multiply default_height by 10 and add digit */ 109 109 110 110 mov default_height - vesa_init, %bx … … 127 127 mov (%di), %al 128 128 129 # check for digit129 /* Check for digit */ 130 130 131 131 cmp $'0', %al … … 137 137 sub $'0', %al 138 138 139 # multiply default_bpp by 10 and add digit139 /* Multiply default_bpp by 10 and add digit */ 140 140 141 141 mov default_bpp - vesa_init, %bx … … 167 167 168 168 next_mode: 169 # try next mode 169 /* Try next mode */ 170 170 171 mov %gs:(%si), %cx 171 172 cmp $VESA_END_OF_MODES, %cx … … 186 187 jne no_mode 187 188 188 # check for proper attributes (supported, color, graphics, linear framebuffer) 189 /* 190 * Check for proper attributes (supported, 191 * color, graphics, linear framebuffer). 192 */ 189 193 190 194 mov VESA_MODE_ATTRIBUTES_OFFSET(%di), %ax … … 193 197 jne next_mode 194 198 195 # check for proper resolution199 /* Check for proper resolution */ 196 200 197 201 mov default_width - vesa_init, %ax … … 203 207 jne next_mode 204 208 205 # check for proper bpp209 /* Check for proper bpp */ 206 210 207 211 mov default_bpp - vesa_init, %al … … 213 217 jne next_mode 214 218 215 # for 24 bpp modes accept also 32 bit bpp219 /* For 24 bpp modes accept also 32 bit bpp */ 216 220 217 221 mov $32, %al … … 230 234 jnz no_mode 231 235 232 # set 3:2:3 VGA palette236 /* Set 3:2:3 VGA palette */ 233 237 234 238 mov VESA_MODE_BPP_OFFSET(%di), %al … … 241 245 mov $0x100, %ecx 242 246 243 bt $5, %ax # test if VGA compatible registers are present 247 /* Test if VGA compatible registers are present */ 248 bt $5, %ax 244 249 jnc vga_compat 245 250 246 # try VESA routine to set palette 251 /* Use VESA routine to set the palette */ 252 247 253 mov $VESA_SET_PALETTE, %ax 248 254 xor %bl, %bl … … 254 260 255 261 vga_compat: 256 # try VGA registers to set palette 257 movw $0x3c6, %dx # set palette mask 262 263 /* Use VGA registers to set the palette */ 264 265 movw $0x3c6, %dx /* set palette mask */ 258 266 movb $0xff, %al 259 267 outb %al, %dx 260 268 261 movw $0x3c8, %dx # first index to set269 movw $0x3c8, %dx /* first index to set */ 262 270 xor %al, %al 263 271 outb %al, %dx 264 272 265 movw $0x3c9, %dx # data port273 movw $0x3c9, %dx /* data port */ 266 274 267 275 vga_loop: … … 284 292 vga_not_set: 285 293 286 # store mode parameters 287 # eax = bpp[8] scanline[16] 288 # ebx = width[16] height[16] 289 # edx = red_mask[8] red_pos[8] green_mask[8] green_pos[8] 290 # esi = blue_mask[8] blue_pos[8] 291 # edi = linear frame buffer 294 /* 295 * Store mode parameters: 296 * eax = bpp[8] scanline[16] 297 * ebx = width[16] height[16] 298 * edx = red_mask[8] red_pos[8] green_mask[8] green_pos[8] 299 * esi = blue_mask[8] blue_pos[8] 300 * edi = linear frame buffer 301 */ 292 302 293 303 mov VESA_MODE_BPP_OFFSET(%di), %al … … 328 338 329 339 no_mode: 330 # no prefered mode found 340 341 /* No prefered mode found */ 342 331 343 mov $0x111, %cx 332 344 push %di … … 339 351 cmp $VESA_OK, %al 340 352 jnz text_mode 341 jz set_mode # force relative jump353 jz set_mode /* force relative jump */ 342 354 343 355 text_mode: 344 # reset to EGA text mode (because of problems with VESA) 356 357 /* Reset to EGA text mode (because of problems with VESA) */ 358 345 359 mov $0x0003, %ax 346 360 int $0x10 347 361 mov $0xffffffff, %edi 348 362 xor %ax, %ax 349 jz vesa_leave_real # force relative jump363 jz vesa_leave_real /* force relative jump */ 350 364 351 365 vga323: -
kernel/arch/ia32/src/boot/vesa_ret.inc
r99718a2e r873c681 1 1 .code32 2 2 vesa_init_protected: 3 cld 4 5 /* Initialize stack pointer */ 6 movl $START_STACK, %esp 7 8 /* Kernel data + stack */ 3 9 movw $gdtselector(KDATA_DES), %cx 4 10 movw %cx, %es 5 11 movw %cx, %fs 6 12 movw %cx, %gs 7 movw %cx, %ds # kernel data + stack13 movw %cx, %ds 8 14 movw %cx, %ss 9 15 10 movl $START_STACK, %esp # initialize stack pointer11 12 16 jmpl $gdtselector(KTEXT_DES), $vesa_meeting_point
Note:
See TracChangeset
for help on using the changeset viewer.