Changes in kernel/arch/ia32/src/boot/multiboot.S [a35b458:e02bfb4] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia32/src/boot/multiboot.S
ra35b458 re02bfb4 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
Note:
See TracChangeset
for help on using the changeset viewer.