Changeset 8565a42 in mainline for kernel/arch/ia32/src/boot
- Timestamp:
- 2018-03-02T20:34:50Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a1a81f69, d5e5fd1
- Parents:
- 3061bc1 (diff), 34e1206 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:34:50)
- git-committer:
- GitHub <noreply@…> (2018-03-02 20:34:50)
- Location:
- kernel/arch/ia32/src/boot
- Files:
-
- 5 edited
-
multiboot.S (modified) (21 diffs)
-
multiboot2.S (modified) (10 diffs)
-
vesa_prot.inc (modified) (2 diffs)
-
vesa_real.inc (modified) (14 diffs)
-
vesa_ret.inc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia32/src/boot/multiboot.S
r3061bc1 r8565a42 77 77 cli 78 78 cld 79 79 80 80 /* Initialize stack pointer */ 81 81 movl $START_STACK, %esp 82 82 83 83 /* 84 84 * Initialize Global Descriptor Table and … … 87 87 lgdtl bootstrap_gdtr 88 88 lidtl bootstrap_idtr 89 89 90 90 /* Kernel data + stack */ 91 91 movw $GDT_SELECTOR(KDATA_DES), %cx … … 95 95 movw %cx, %ds 96 96 movw %cx, %ss 97 97 98 98 jmpl $GDT_SELECTOR(KTEXT_DES), $multiboot_meeting_point 99 99 multiboot_meeting_point: 100 100 101 101 /* Save multiboot arguments */ 102 102 movl %eax, multiboot_eax 103 103 movl %ebx, multiboot_ebx 104 104 105 105 pm_status $status_prot 106 106 107 107 #include "vesa_prot.inc" 108 108 109 109 #ifndef PROCESSOR_i486 110 110 111 111 pm_status $status_prot2 112 112 113 113 movl $(INTEL_CPUID_LEVEL), %eax 114 114 cpuid 115 115 cmp $0x0, %eax /* any function > 0? */ 116 116 jbe pse_unsupported 117 117 118 118 movl $(INTEL_CPUID_STANDARD), %eax 119 119 cpuid 120 120 bt $(INTEL_PSE), %edx 121 121 jnc pse_unsupported 122 122 123 123 /* Map kernel and turn paging on */ 124 124 pm_status $status_pse 125 125 call map_kernel_pse 126 126 jmp stack_init 127 127 128 128 #endif /* PROCESSOR_i486 */ 129 129 130 130 pse_unsupported: 131 131 132 132 /* Map kernel and turn paging on */ 133 133 pm_status $status_non_pse 134 134 call map_kernel_non_pse 135 135 136 136 stack_init: 137 137 138 138 /* Create the first stack frame */ 139 139 pushl $0 140 140 movl %esp, %ebp 141 141 142 142 pm2_status $status_prot3 143 143 144 144 /* Call ia32_pre_main(multiboot_eax, multiboot_ebx) */ 145 145 pushl multiboot_ebx 146 146 pushl multiboot_eax 147 147 call ia32_pre_main 148 148 149 149 pm2_status $status_main 150 150 151 151 /* Call main_bsp() */ 152 152 call main_bsp 153 153 154 154 /* Not reached */ 155 155 cli … … 170 170 andl $~CR4_PAE, %ecx /* PAE off */ 171 171 movl %ecx, %cr4 172 172 173 173 movl $(page_directory + 0), %esi 174 174 movl $(page_directory + 2048), %edi 175 175 xorl %ecx, %ecx 176 176 xorl %ebx, %ebx 177 177 178 178 floop_pse: 179 179 movl $(PDE_4M | PDE_RW | PDE_P), %eax … … 184 184 movl %eax, (%edi, %ecx, 4) 185 185 addl $(4 * 1024 * 1024), %ebx 186 186 187 187 incl %ecx 188 188 cmpl $512, %ecx 189 189 jl floop_pse 190 190 191 191 movl %esi, %cr3 192 192 193 193 movl %cr0, %ebx 194 194 orl $CR0_PG, %ebx /* paging on */ … … 208 208 andl $~CR4_PAE, %ecx /* PAE off */ 209 209 movl %ecx, %cr4 210 210 211 211 call calc_kernel_end 212 212 call find_mem_for_pt 213 213 214 214 mov kernel_end, %esi 215 215 mov free_area, %ecx 216 216 217 217 cmpl %esi, %ecx 218 218 jbe use_kernel_end 219 219 220 220 mov %ecx, %esi 221 221 222 222 /* Align address down to 4k */ 223 223 andl $(~(PAGE_SIZE - 1)), %esi 224 224 225 225 use_kernel_end: 226 226 227 227 /* Align address to 4k */ 228 228 addl $(PAGE_SIZE - 1), %esi 229 229 andl $(~(PAGE_SIZE - 1)), %esi 230 230 231 231 /* Allocate space for page tables */ 232 232 movl %esi, pt_loc 233 233 movl $KA2PA(ballocs), %edi 234 234 235 235 movl %esi, (%edi) 236 236 addl $4, %edi 237 237 movl $(2 * 1024 * 1024), (%edi) 238 238 239 239 /* Fill page tables */ 240 240 xorl %ecx, %ecx 241 241 xorl %ebx, %ebx 242 242 243 243 floop_pt: 244 244 movl $(PTE_RW | PTE_P), %eax … … 246 246 movl %eax, (%esi, %ecx, 4) 247 247 addl $PAGE_SIZE, %ebx 248 248 249 249 incl %ecx 250 250 cmpl $(512 * 1024), %ecx 251 251 252 252 jl floop_pt 253 253 254 254 /* Fill page directory */ 255 255 movl $(page_directory + 0), %esi … … 257 257 xorl %ecx, %ecx 258 258 movl pt_loc, %ebx 259 259 260 260 floop: 261 261 movl $(PDE_RW | PDE_P), %eax 262 262 orl %ebx, %eax 263 263 264 264 /* Mapping 0x00000000 + %ecx * 4M => 0x00000000 + %ecx * 4M */ 265 265 movl %eax, (%esi, %ecx, 4) 266 266 267 267 /* Mapping 0x80000000 + %ecx * 4M => 0x00000000 + %ecx * 4M */ 268 268 movl %eax, (%edi, %ecx, 4) 269 269 addl $PAGE_SIZE, %ebx 270 270 271 271 incl %ecx 272 272 cmpl $512, %ecx 273 273 274 274 jl floop 275 275 276 276 movl %esi, %cr3 277 277 278 278 movl %cr0, %ebx 279 279 orl $CR0_PG, %ebx /* paging on */ 280 280 movl %ebx, %cr0 281 281 282 282 ret 283 283 FUNCTION_END(map_kernel_non_pse) … … 288 288 movl (%edi), %esi 289 289 leal KA2PA(0)(%esi), %esi 290 290 291 291 movl $KA2PA(hardcoded_ktext_size), %edi 292 292 addl (%edi), %esi 293 293 leal KA2PA(0)(%esi), %esi 294 294 295 295 movl $KA2PA(hardcoded_kdata_size), %edi 296 296 addl (%edi), %esi 297 297 leal KA2PA(0)(%esi), %esi 298 298 movl %esi, kernel_end 299 299 300 300 ret 301 301 … … 305 305 cmpl $MULTIBOOT_LOADER_MAGIC, multiboot_eax 306 306 je check_multiboot_map 307 307 308 308 ret 309 309 310 310 check_multiboot_map: 311 311 312 312 /* Copy address of the multiboot info to ebx */ 313 313 movl multiboot_ebx, %ebx 314 314 315 315 /* Check if memory map flag is present */ 316 316 movl (%ebx), %edx 317 317 andl $MULTIBOOT_INFO_FLAGS_MMAP, %edx 318 318 jnz use_multiboot_map 319 319 320 320 ret 321 321 322 322 use_multiboot_map: 323 323 324 324 /* Copy address of the memory map to edx */ 325 325 movl MULTIBOOT_INFO_OFFSET_MMAP_ADDR(%ebx), %edx 326 326 movl %edx, %ecx 327 327 328 328 addl MULTIBOOT_INFO_OFFSET_MMAP_LENGTH(%ebx), %ecx 329 329 330 330 /* Find a free region at least 2M in size */ 331 331 check_memmap_loop: 332 332 333 333 /* Is this a free region? */ 334 334 cmpl $MEMMAP_MEMORY_AVAILABLE, MULTIBOOT_MEMMAP_OFFSET_MM_INFO + E820MEMMAP_OFFSET_TYPE(%edx) 335 335 jnz next_region 336 336 337 337 /* Check size */ 338 338 cmpl $0, MULTIBOOT_MEMMAP_OFFSET_MM_INFO + E820MEMMAP_OFFSET_SIZE + 4(%edx) … … 340 340 cmpl $(2 * 1024 * 1024 + PAGE_SIZE), MULTIBOOT_MEMMAP_OFFSET_MM_INFO + E820MEMMAP_OFFSET_SIZE(%edx) 341 341 jbe next_region 342 342 343 343 cmpl $0, MULTIBOOT_MEMMAP_OFFSET_MM_INFO + E820MEMMAP_OFFSET_BASE_ADDRESS + 4(%edx) 344 344 jz found_region 345 345 346 346 next_region: 347 347 348 348 cmp %ecx, %edx 349 349 jbe next_region_do 350 350 351 351 ret 352 352 353 353 next_region_do: 354 354 355 355 addl MULTIBOOT_MEMMAP_OFFSET_SIZE(%edx), %edx 356 356 addl $MULTIBOOT_MEMMAP_SIZE_SIZE, %edx 357 357 jmp check_memmap_loop 358 358 359 359 found_region: 360 360 361 361 /* Use end of the found region */ 362 362 mov MULTIBOOT_MEMMAP_OFFSET_MM_INFO + E820MEMMAP_OFFSET_BASE_ADDRESS(%edx), %ecx … … 364 364 sub $(2 * 1024 * 1024), %ecx 365 365 mov %ecx, free_area 366 366 367 367 ret 368 368 … … 381 381 movl $0xb8000, %edi /* base of EGA text mode memory */ 382 382 xorl %eax, %eax 383 383 384 384 /* Read bits 8 - 15 of the cursor address */ 385 385 movw $0x3d4, %dx 386 386 movb $0xe, %al 387 387 outb %al, %dx 388 388 389 389 movw $0x3d5, %dx 390 390 inb %dx, %al 391 391 shl $8, %ax 392 392 393 393 /* Read bits 0 - 7 of the cursor address */ 394 394 movw $0x3d4, %dx 395 395 movb $0xf, %al 396 396 outb %al, %dx 397 397 398 398 movw $0x3d5, %dx 399 399 inb %dx, %al 400 400 401 401 /* Sanity check for the cursor on screen */ 402 402 cmp $2000, %ax 403 403 jb err_cursor_ok 404 404 405 405 movw $1998, %ax 406 406 407 407 err_cursor_ok: 408 408 409 409 movw %ax, %bx 410 410 shl $1, %eax 411 411 addl %eax, %edi 412 412 413 413 err_ploop: 414 414 lodsb 415 415 416 416 cmp $0, %al 417 417 je err_ploop_end 418 418 419 419 movb $0x0c, %ah /* black background, light red foreground */ 420 420 stosw 421 421 422 422 /* Sanity check for the cursor on the last line */ 423 423 inc %bx 424 424 cmp $2000, %bx 425 425 jb err_ploop 426 426 427 427 /* Scroll the screen (24 rows) */ 428 428 movl %esi, %edx … … 431 431 movl $960, %ecx 432 432 rep movsl 433 433 434 434 /* Clear the 24th row */ 435 435 xorl %eax, %eax 436 436 movl $40, %ecx 437 437 rep stosl 438 438 439 439 /* Go to row 24 */ 440 440 movl %edx, %esi 441 441 movl $0xb8f00, %edi 442 442 movw $1920, %bx 443 443 444 444 jmp err_ploop 445 445 err_ploop_end: 446 446 447 447 /* Write bits 8 - 15 of the cursor address */ 448 448 movw $0x3d4, %dx 449 449 movb $0xe, %al 450 450 outb %al, %dx 451 451 452 452 movw $0x3d5, %dx 453 453 movb %bh, %al 454 454 outb %al, %dx 455 455 456 456 /* Write bits 0 - 7 of the cursor address */ 457 457 movw $0x3d4, %dx 458 458 movb $0xf, %al 459 459 outb %al, %dx 460 460 461 461 movw $0x3d5, %dx 462 462 movb %bl, %al 463 463 outb %al, %dx 464 464 465 465 cli 466 466 hlt1: … … 486 486 pushl %edx 487 487 pushl %edi 488 488 489 489 movl $0xb8000, %edi /* base of EGA text mode memory */ 490 490 xorl %eax, %eax 491 491 492 492 /* Read bits 8 - 15 of the cursor address */ 493 493 movw $0x3d4, %dx 494 494 movb $0xe, %al 495 495 outb %al, %dx 496 496 497 497 movw $0x3d5, %dx 498 498 inb %dx, %al 499 499 shl $8, %ax 500 500 501 501 /* Read bits 0 - 7 of the cursor address */ 502 502 movw $0x3d4, %dx 503 503 movb $0xf, %al 504 504 outb %al, %dx 505 505 506 506 movw $0x3d5, %dx 507 507 inb %dx, %al 508 508 509 509 /* Sanity check for the cursor on screen */ 510 510 cmp $2000, %ax 511 511 jb pm_puts_cursor_ok 512 512 513 513 movw $1998, %ax 514 514 515 515 pm_puts_cursor_ok: 516 516 517 517 movw %ax, %bx 518 518 shl $1, %eax 519 519 addl %eax, %edi 520 520 521 521 pm_puts_ploop: 522 522 lodsb 523 523 524 524 cmp $0, %al 525 525 je pm_puts_ploop_end 526 526 527 527 movb $0x0a, %ah /* black background, light green foreground */ 528 528 stosw 529 529 530 530 /* Sanity check for the cursor on the last line */ 531 531 inc %bx 532 532 cmp $2000, %bx 533 533 jb pm_puts_ploop 534 534 535 535 /* Scroll the screen (24 rows) */ 536 536 movl %esi, %edx … … 539 539 movl $960, %ecx 540 540 rep movsl 541 541 542 542 /* Clear the 24th row */ 543 543 xorl %eax, %eax 544 544 movl $40, %ecx 545 545 rep stosl 546 546 547 547 /* Go to row 24 */ 548 548 movl %edx, %esi 549 549 movl $0xb8f00, %edi 550 550 movw $1920, %bx 551 551 552 552 jmp pm_puts_ploop 553 553 pm_puts_ploop_end: 554 554 555 555 /* Write bits 8 - 15 of the cursor address */ 556 556 movw $0x3d4, %dx 557 557 movb $0xe, %al 558 558 outb %al, %dx 559 559 560 560 movw $0x3d5, %dx 561 561 movb %bh, %al 562 562 outb %al, %dx 563 563 564 564 /* Write bits 0 - 7 of the cursor address */ 565 565 movw $0x3d4, %dx 566 566 movb $0xf, %al 567 567 outb %al, %dx 568 568 569 569 movw $0x3d5, %dx 570 570 movb %bl, %al 571 571 outb %al, %dx 572 572 573 573 popl %edi 574 574 popl %edx … … 576 576 popl %ebx 577 577 popl %eax 578 578 579 579 ret 580 580 … … 591 591 */ 592 592 early_puts: 593 593 594 594 #if ((defined(CONFIG_EGA)) && (!defined(CONFIG_FB))) 595 595 596 596 /* Prologue, save preserved registers */ 597 597 pushl %ebp … … 600 600 pushl %esi 601 601 pushl %edi 602 602 603 603 movl 0x08(%ebp), %esi 604 604 movl $(PA2KA(0xb8000)), %edi /* base of EGA text mode memory */ 605 605 xorl %eax, %eax 606 606 607 607 /* Read bits 8 - 15 of the cursor address */ 608 608 movw $0x3d4, %dx 609 609 movb $0xe, %al 610 610 outb %al, %dx 611 611 612 612 movw $0x3d5, %dx 613 613 inb %dx, %al 614 614 shl $8, %ax 615 615 616 616 /* Read bits 0 - 7 of the cursor address */ 617 617 movw $0x3d4, %dx 618 618 movb $0xf, %al 619 619 outb %al, %dx 620 620 621 621 movw $0x3d5, %dx 622 622 inb %dx, %al 623 623 624 624 /* Sanity check for the cursor on screen */ 625 625 cmp $2000, %ax 626 626 jb early_puts_cursor_ok 627 627 628 628 movw $1998, %ax 629 629 630 630 early_puts_cursor_ok: 631 631 632 632 movw %ax, %bx 633 633 shl $1, %eax 634 634 addl %eax, %edi 635 635 636 636 early_puts_ploop: 637 637 lodsb 638 638 639 639 cmp $0, %al 640 640 je early_puts_ploop_end 641 641 642 642 movb $0x0e, %ah /* black background, yellow foreground */ 643 643 stosw 644 644 645 645 /* Sanity check for the cursor on the last line */ 646 646 inc %bx 647 647 cmp $2000, %bx 648 648 jb early_puts_ploop 649 649 650 650 /* Scroll the screen (24 rows) */ 651 651 movl %esi, %edx … … 654 654 movl $960, %ecx 655 655 rep movsl 656 656 657 657 /* Clear the 24th row */ 658 658 xorl %eax, %eax 659 659 movl $40, %ecx 660 660 rep stosl 661 661 662 662 /* Go to row 24 */ 663 663 movl %edx, %esi 664 664 movl $(PA2KA(0xb8f00)), %edi 665 665 movw $1920, %bx 666 666 667 667 jmp early_puts_ploop 668 668 early_puts_ploop_end: 669 669 670 670 /* Write bits 8 - 15 of the cursor address */ 671 671 movw $0x3d4, %dx 672 672 movb $0xe, %al 673 673 outb %al, %dx 674 674 675 675 movw $0x3d5, %dx 676 676 movb %bh, %al 677 677 outb %al, %dx 678 678 679 679 /* Write bits 0 - 7 of the cursor address */ 680 680 movw $0x3d4, %dx 681 681 movb $0xf, %al 682 682 outb %al, %dx 683 683 684 684 movw $0x3d5, %dx 685 685 movb %bl, %al 686 686 outb %al, %dx 687 687 688 688 /* Epilogue, restore preserved registers */ 689 689 popl %edi … … 691 691 popl %ebx 692 692 leave 693 693 694 694 #endif 695 695 696 696 ret 697 697 -
kernel/arch/ia32/src/boot/multiboot2.S
r3061bc1 r8565a42 45 45 .long multiboot2_header_end - multiboot2_header_start 46 46 .long -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT2_HEADER_ARCH_I386 + (multiboot2_header_end - multiboot2_header_start)) 47 47 48 48 /* Information request tag */ 49 49 .align 8 … … 59 59 #endif 60 60 tag_info_req_end: 61 61 62 62 /* Address tag */ 63 63 .align 8 … … 71 71 .long 0 72 72 tag_address_end: 73 73 74 74 /* Entry address tag */ 75 75 .align 8 … … 80 80 .long multiboot2_image_start 81 81 tag_entry_address_end: 82 82 83 83 /* Flags tag */ 84 84 .align 8 … … 89 89 .long MULTIBOOT2_FLAGS_CONSOLE 90 90 tag_flags_end: 91 91 92 92 #ifdef CONFIG_FB 93 93 /* Framebuffer tag */ … … 102 102 tag_framebuffer_end: 103 103 #endif 104 104 105 105 /* Module alignment tag */ 106 106 .align 8 … … 111 111 .long 0 112 112 tag_module_align_end: 113 113 114 114 /* Tag terminator */ 115 115 .align 8 … … 124 124 cli 125 125 cld 126 126 127 127 /* Initialize stack pointer */ 128 128 movl $START_STACK, %esp 129 129 130 130 /* 131 131 * Initialize Global Descriptor Table and … … 134 134 lgdtl bootstrap_gdtr 135 135 lidtl bootstrap_idtr 136 136 137 137 /* Kernel data + stack */ 138 138 movw $GDT_SELECTOR(KDATA_DES), %cx … … 142 142 movw %cx, %ds 143 143 movw %cx, %ss 144 144 145 145 jmpl $GDT_SELECTOR(KTEXT_DES), $multiboot2_meeting_point 146 146 multiboot2_meeting_point: 147 147 148 148 /* Save multiboot arguments */ 149 149 movl %eax, multiboot_eax 150 150 movl %ebx, multiboot_ebx 151 151 152 152 #ifndef PROCESSOR_i486 153 153 154 154 movl $(INTEL_CPUID_LEVEL), %eax 155 155 cpuid 156 156 cmp $0x0, %eax /* any function > 0? */ 157 157 jbe pse_unsupported 158 158 159 159 movl $(INTEL_CPUID_STANDARD), %eax 160 160 cpuid 161 161 bt $(INTEL_PSE), %edx 162 162 jnc pse_unsupported 163 163 164 164 /* Map kernel and turn paging on */ 165 165 call map_kernel_pse 166 166 jmp stack_init 167 167 168 168 #endif /* PROCESSOR_i486 */ 169 169 170 170 pse_unsupported: 171 171 172 172 /* Map kernel and turn paging on */ 173 173 call map_kernel_non_pse 174 174 175 175 stack_init: 176 176 177 177 /* Create the first stack frame */ 178 178 pushl $0 179 179 movl %esp, %ebp 180 180 181 181 /* Call ia32_pre_main(multiboot_eax, multiboot_ebx) */ 182 182 pushl multiboot_ebx 183 183 pushl multiboot_eax 184 184 call ia32_pre_main 185 185 186 186 /* Call main_bsp() */ 187 187 call main_bsp 188 188 189 189 /* Not reached */ 190 190 cli -
kernel/arch/ia32/src/boot/vesa_prot.inc
r3061bc1 r8565a42 5 5 6 6 /* Copy real mode VESA initialization code */ 7 7 8 8 pm_status $status_vesa_copy 9 9 10 10 mov $vesa_init, %esi 11 11 mov $VESA_INIT_SEGMENT << 4, %edi 12 12 mov $e_vesa_init - vesa_init, %ecx 13 13 rep movsb 14 14 15 15 /* Check for multiboot command line */ 16 16 17 17 pm_status $status_multiboot_cmdline 18 18 19 19 mov multiboot_eax, %eax 20 20 cmp $MULTIBOOT_LOADER_MAGIC, %eax 21 21 jne no_cmdline 22 22 23 23 mov multiboot_ebx, %ebx 24 24 mov (%ebx), %eax 25 25 bt $MBINFO_BIT_CMDLINE, %eax 26 26 jnc no_cmdline 27 27 28 28 /* Skip the kernel path in command line */ 29 29 30 30 mov MBINFO_OFFSET_CMDLINE(%ebx), %esi 31 31 32 32 skip_loop: 33 33 lodsb 34 34 35 35 cmp $0, %al 36 36 je no_cmdline 37 37 38 38 cmp $' ', %al 39 39 je skip_loop_done 40 40 41 41 jmp skip_loop 42 42 skip_loop_done: 43 43 44 44 space_loop: 45 45 mov (%esi), %al 46 46 47 47 cmp $0, %al 48 48 je no_cmdline 49 49 50 50 cmp $' ', %al 51 51 jne space_loop_done 52 52 53 53 inc %esi 54 54 jmp space_loop 55 55 space_loop_done: 56 56 57 57 /* Copy at most 23 characters from command line */ 58 58 59 59 mov $VESA_INIT_SEGMENT << 4, %edi 60 60 add $default_mode - vesa_init, %edi 61 61 mov $23, %ecx 62 62 63 63 cmd_loop: 64 64 lodsb 65 65 stosb 66 66 67 67 cmp $0, %al 68 68 je cmd_loop_done 69 69 70 70 loop cmd_loop 71 71 cmd_loop_done: 72 72 73 73 /* Zero termination */ 74 74 75 75 xor %eax, %eax 76 76 stosb 77 77 78 78 no_cmdline: 79 79 80 80 /* Jump to the real mode */ 81 81 82 82 pm_status $status_vesa_real 83 83 84 84 mov $VESA_INIT_SEGMENT << 4, %edi 85 85 jmpl *%edi 86 86 87 87 vesa_meeting_point: 88 88 /* Returned back to protected mode */ 89 89 90 90 /* 91 91 * Initialize Global Descriptor Table and … … 94 94 lgdtl bootstrap_gdtr 95 95 lidtl bootstrap_idtr 96 96 97 97 movzx %ax, %ecx 98 98 mov %ecx, KA2PA(bfb_scanline) 99 99 100 100 shr $16, %eax 101 101 mov %ax, KA2PA(bfb_bpp) 102 102 103 103 movzx %bx, %ecx 104 104 mov %ecx, KA2PA(bfb_height) 105 105 106 106 shr $16, %ebx 107 107 mov %ebx, KA2PA(bfb_width) 108 108 109 109 mov %dl, KA2PA(bfb_green_pos) 110 110 111 111 shr $8, %edx 112 112 mov %dl, KA2PA(bfb_green_size) 113 113 114 114 shr $8, %edx 115 115 mov %dl, KA2PA(bfb_red_pos) 116 116 117 117 shr $8, %edx 118 118 mov %dl, KA2PA(bfb_red_size) 119 119 120 120 mov %esi, %edx 121 121 mov %dl, KA2PA(bfb_blue_pos) 122 122 123 123 shr $8, %edx 124 124 mov %dl, KA2PA(bfb_blue_size) 125 125 126 126 mov %edi, KA2PA(bfb_addr) 127 127 #endif -
kernel/arch/ia32/src/boot/vesa_real.inc
r3061bc1 r8565a42 31 31 vesa_init: 32 32 lidtl vesa_idtr 33 33 34 34 mov $GDT_SELECTOR(VESA_INIT_DATA_DES), %bx 35 35 36 36 mov %bx, %es 37 37 mov %bx, %fs … … 39 39 mov %bx, %ds 40 40 mov %bx, %ss 41 41 42 42 jmp $GDT_SELECTOR(VESA_INIT_CODE_DES), $vesa_init_real - vesa_init 43 43 … … 51 51 and $~CR0_PE, %eax 52 52 mov %eax, %cr0 53 53 54 54 jmp $VESA_INIT_SEGMENT, $vesa_init_real2 - vesa_init 55 55 56 56 vesa_init_real2: 57 57 mov $VESA_INIT_SEGMENT, %bx 58 58 59 59 mov %bx, %es 60 60 mov %bx, %fs … … 62 62 mov %bx, %ds 63 63 mov %bx, %ss 64 64 65 65 movl %esp, %eax 66 66 movl $0x0000fffc, %esp 67 67 movl $0x0000fffc, %ebp 68 68 pushl %eax 69 69 70 70 /* Parse default mode string */ 71 71 72 72 mov $default_mode - vesa_init, %di 73 73 xor %eax, %eax 74 74 xor %ebx, %ebx 75 75 76 76 mov $8, %ecx 77 77 parse_width: 78 78 mov (%di), %al 79 79 80 80 /* Check for digit */ 81 81 82 82 cmp $'0', %al 83 83 jb parse_width_done 84 84 85 85 cmp $'9', %al 86 86 ja parse_width_done 87 87 88 88 sub $'0', %al 89 89 90 90 /* Multiply default_width by 10 and add digit */ 91 91 92 92 mov default_width - vesa_init, %bx 93 93 lea (%ebx, %ebx, 4), %ebx … … 95 95 add %ax, %bx 96 96 mov %bx, default_width - vesa_init 97 97 98 98 inc %di 99 99 loop parse_width 100 100 parse_width_done: 101 101 102 102 mov (%di), %al 103 103 cmp $0, %al 104 104 jz parse_done 105 105 inc %di 106 106 107 107 mov $8, %ecx 108 108 parse_height: 109 109 mov (%di), %al 110 110 111 111 /* Check for digit */ 112 112 113 113 cmp $'0', %al 114 114 jb parse_height_done 115 115 116 116 cmp $'9', %al 117 117 ja parse_height_done 118 118 119 119 sub $'0', %al 120 120 121 121 /* Multiply default_height by 10 and add digit */ 122 122 123 123 mov default_height - vesa_init, %bx 124 124 lea (%ebx, %ebx, 4), %ebx … … 126 126 add %ax, %bx 127 127 mov %bx, default_height - vesa_init 128 128 129 129 inc %di 130 130 loop parse_height 131 131 parse_height_done: 132 132 133 133 mov (%di), %al 134 134 cmp $0, %al 135 135 jz parse_done 136 136 inc %di 137 137 138 138 mov $4, %ecx 139 139 parse_bpp: 140 140 mov (%di), %al 141 141 142 142 /* Check for digit */ 143 143 144 144 cmp $'0', %al 145 145 jb parse_bpp_done 146 146 147 147 cmp $'9', %al 148 148 ja parse_bpp_done 149 149 150 150 sub $'0', %al 151 151 152 152 /* Multiply default_bpp by 10 and add digit */ 153 153 154 154 mov default_bpp - vesa_init, %bx 155 155 lea (%ebx, %ebx, 4), %ebx … … 157 157 add %ax, %bx 158 158 mov %bx, default_bpp - vesa_init 159 159 160 160 inc %di 161 161 loop parse_bpp 162 162 parse_bpp_done: 163 163 164 164 parse_done: 165 165 166 166 mov $VESA_GET_INFO, %ax 167 167 mov $e_vesa_init - vesa_init, %di … … 178 178 movl $0x32454256, (%di) 179 179 int $0x10 180 180 181 181 pop %di 182 182 cmp $VESA_OK, %al 183 183 jnz no_mode 184 184 185 185 mov 2 + VESA_MODE_LIST_PTR_OFFSET(%di), %si 186 186 mov %si, %gs 187 187 mov VESA_MODE_LIST_PTR_OFFSET(%di), %si 188 188 189 189 add $VESA_INFO_SIZE, %di 190 190 191 191 next_mode: 192 192 /* Try next mode */ 193 193 194 194 mov %gs:(%si), %cx 195 195 cmp $VESA_END_OF_MODES, %cx 196 196 je no_mode 197 197 198 198 inc %si 199 199 inc %si … … 203 203 mov $VESA_GET_MODE_INFO, %ax 204 204 int $0x10 205 205 206 206 pop %si 207 207 pop %di … … 209 209 cmp $VESA_OK, %al 210 210 jne no_mode 211 211 212 212 /* 213 213 * Check for proper attributes (supported, 214 214 * color, graphics, linear framebuffer). 215 215 */ 216 216 217 217 mov VESA_MODE_ATTRIBUTES_OFFSET(%di), %ax 218 218 and $0x99, %ax 219 219 cmp $0x99, %ax 220 220 jne next_mode 221 221 222 222 /* Check for proper resolution */ 223 223 224 224 mov default_width - vesa_init, %ax 225 225 cmp VESA_MODE_WIDTH_OFFSET(%di), %ax 226 226 jne next_mode 227 227 228 228 mov default_height - vesa_init, %ax 229 229 cmp VESA_MODE_HEIGHT_OFFSET(%di), %ax 230 230 jne next_mode 231 231 232 232 /* Check for proper bpp */ 233 233 234 234 mov default_bpp - vesa_init, %al 235 235 cmp VESA_MODE_BPP_OFFSET(%di), %al 236 236 je set_mode 237 237 238 238 mov $24, %al 239 239 cmp default_bpp - vesa_init, %al 240 240 jne next_mode 241 241 242 242 /* For 24 bpp modes accept also 32 bit bpp */ 243 243 244 244 mov $32, %al 245 245 cmp VESA_MODE_BPP_OFFSET(%di), %al 246 246 jne next_mode 247 247 248 248 set_mode: 249 249 mov %cx, %bx … … 252 252 mov $VESA_SET_MODE, %ax 253 253 int $0x10 254 254 255 255 pop %di 256 256 cmp $VESA_OK, %al 257 257 jnz no_mode 258 258 259 259 /* Set 3:2:3 VGA palette */ 260 260 261 261 mov VESA_MODE_BPP_OFFSET(%di), %al 262 262 cmp $8, %al 263 263 jnz vga_not_set 264 264 265 265 mov VESA_MODE_ATTRIBUTES_OFFSET(%di), %ax 266 266 push %di 267 267 mov $vga323 - vesa_init, %di 268 268 mov $0x100, %ecx 269 269 270 270 /* Test if VGA compatible registers are present */ 271 271 bt $5, %ax 272 272 jnc vga_compat 273 273 274 274 /* Use VESA routine to set the palette */ 275 275 276 276 mov $VESA_SET_PALETTE, %ax 277 277 xor %bl, %bl 278 278 xor %dx, %dx 279 279 int $0x10 280 280 281 281 cmp $0x00, %ah 282 282 je vga_not_compat 283 283 284 284 vga_compat: 285 285 286 286 /* Use VGA registers to set the palette */ 287 287 288 288 movw $0x3c6, %dx /* set palette mask */ 289 289 movb $0xff, %al 290 290 outb %al, %dx 291 291 292 292 movw $0x3c8, %dx /* first index to set */ 293 293 xor %al, %al 294 294 outb %al, %dx 295 295 296 296 movw $0x3c9, %dx /* data port */ 297 297 298 298 vga_loop: 299 299 movb %es:2(%di), %al 300 300 outb %al, %dx 301 301 302 302 movb %es:1(%di), %al 303 303 outb %al, %dx 304 304 305 305 movb %es:(%di), %al 306 306 outb %al, %dx 307 307 308 308 addw $4, %di 309 309 loop vga_loop 310 310 311 311 vga_not_compat: 312 312 313 313 pop %di 314 314 315 315 vga_not_set: 316 316 317 317 /* 318 318 * Store mode parameters: … … 323 323 * edi = linear frame buffer 324 324 */ 325 325 326 326 mov VESA_MODE_BPP_OFFSET(%di), %al 327 327 xor %ah, %ah 328 328 shl $16, %eax 329 329 mov VESA_MODE_SCANLINE_OFFSET(%di), %ax 330 330 331 331 mov VESA_MODE_WIDTH_OFFSET(%di), %bx 332 332 shl $16, %ebx 333 333 mov VESA_MODE_HEIGHT_OFFSET(%di), %bx 334 334 335 335 mov VESA_MODE_BLUE_MASK_OFFSET(%di), %dl 336 336 shl $8, %edx 337 337 mov VESA_MODE_BLUE_POS_OFFSET(%di), %dl 338 338 mov %edx, %esi 339 339 340 340 mov VESA_MODE_RED_MASK_OFFSET(%di), %dl 341 341 shl $8, %edx 342 342 mov VESA_MODE_RED_POS_OFFSET(%di), %dl 343 343 344 344 shl $8, %edx 345 345 mov VESA_MODE_GREEN_MASK_OFFSET(%di), %dl 346 346 shl $8, %edx 347 347 mov VESA_MODE_GREEN_POS_OFFSET(%di), %dl 348 348 349 349 mov VESA_MODE_PHADDR_OFFSET(%di), %edi 350 350 351 351 vesa_leave_real: 352 352 353 353 mov %cr0, %ecx 354 354 or $CR0_PE, %ecx 355 355 mov %ecx, %cr0 356 356 357 357 jmp vesa_leave_real2 358 358 359 359 vesa_leave_real2: 360 360 361 361 ljmpl $GDT_SELECTOR(KTEXT32_DES), $(vesa_init_protected - vesa_init + VESA_INIT_SEGMENT << 4) 362 362 363 363 no_mode: 364 364 365 365 /* No prefered mode found */ 366 366 367 367 mov $0x111, %cx 368 368 push %di … … 370 370 mov $VESA_GET_MODE_INFO, %ax 371 371 int $0x10 372 372 373 373 pop %cx 374 374 pop %di … … 376 376 jnz text_mode 377 377 jz set_mode /* force relative jump */ 378 378 379 379 text_mode: 380 380 381 381 /* Reset to EGA text mode (because of problems with VESA) */ 382 382 383 383 mov $0x0003, %ax 384 384 int $0x10 385 385 386 386 xor %eax, %eax 387 387 xor %ebx, %ebx 388 388 xor %edx, %edx 389 389 xor %edi, %edi 390 390 391 391 jz vesa_leave_real /* force relative jump */ 392 392 -
kernel/arch/ia32/src/boot/vesa_ret.inc
r3061bc1 r8565a42 3 3 cli 4 4 cld 5 5 6 6 /* Initialize stack pointer */ 7 7 movl $START_STACK, %esp 8 8 9 9 /* Kernel data + stack */ 10 10 movw $GDT_SELECTOR(KDATA_DES), %cx … … 14 14 movw %cx, %ds 15 15 movw %cx, %ss 16 16 17 17 jmpl $GDT_SELECTOR(KTEXT_DES), $vesa_meeting_point
Note:
See TracChangeset
for help on using the changeset viewer.
