Changeset a35b458 in mainline for kernel/arch/ia32/src/asm.S
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia32/src/asm.S
r3061bc1 ra35b458 63 63 movl %edi, %edx /* save %edi */ 64 64 movl %esi, %eax /* save %esi */ 65 65 66 66 movl MEMCPY_SIZE(%esp), %ecx 67 67 shrl $2, %ecx /* size / 4 */ 68 68 69 69 movl MEMCPY_DST(%esp), %edi 70 70 movl MEMCPY_SRC(%esp), %esi 71 71 72 72 /* Copy whole words */ 73 73 rep movsl 74 74 75 75 movl MEMCPY_SIZE(%esp), %ecx 76 76 andl $3, %ecx /* size % 4 */ 77 77 jz 0f 78 78 79 79 /* Copy the rest byte by byte */ 80 80 rep movsb 81 81 82 82 0: 83 83 84 84 movl %edx, %edi 85 85 movl %eax, %esi 86 86 87 87 /* MEMCPY_DST(%esp), success */ 88 88 movl MEMCPY_DST(%esp), %eax … … 99 99 movl %edx, %edi 100 100 movl %eax, %esi 101 101 102 102 /* Return 0, failure */ 103 103 xorl %eax, %eax … … 112 112 movl %cr0, %edx 113 113 orl $CR0_PG, %edx /* paging on */ 114 114 115 115 /* Clear Cache Disable and not Write Though */ 116 116 andl $~(CR0_CD | CR0_NW), %edx 117 117 movl %edx, %cr0 118 118 jmp 0f 119 119 120 120 0: 121 121 ret … … 174 174 movl %edi, ISTATE_OFFSET_EDI(%esp) /* observability; not needed */ 175 175 movl %ebp, ISTATE_OFFSET_EBP(%esp) /* observability; not needed */ 176 176 177 177 /* 178 178 * Fake up the stack trace linkage. … … 190 190 movl $(GDT_SELECTOR(VREG_DES)), %eax 191 191 movl %eax, %gs 192 192 193 193 /* 194 194 * Sanitize EFLAGS. … … 207 207 208 208 call syscall_handler 209 209 210 210 /* 211 211 * Prepare return address and userspace stack for SYSEXIT. … … 252 252 movl %es, %ecx 253 253 movl %ds, %edx 254 254 255 255 movl %ecx, ISTATE_OFFSET_ES(%esp) 256 256 movl %edx, ISTATE_OFFSET_DS(%esp) … … 264 264 movl $(GDT_SELECTOR(VREG_DES)), %eax 265 265 movl %eax, %gs 266 266 267 267 movl $0, ISTATE_OFFSET_EBP_FRAME(%esp) 268 268 movl ISTATE_OFFSET_EIP(%esp), %eax 269 269 movl %eax, ISTATE_OFFSET_EIP_FRAME(%esp) 270 270 leal ISTATE_OFFSET_EBP_FRAME(%esp), %ebp 271 271 272 272 cld 273 273 274 274 /* Call syscall_handler(edx, ecx, ebx, esi, edi, ebp, eax) */ 275 275 call syscall_handler 276 276 277 277 /* 278 278 * Restore the segment registers. … … 286 286 movl ISTATE_OFFSET_ES(%esp), %ecx 287 287 movl ISTATE_OFFSET_DS(%esp), %edx 288 288 289 289 movl %ecx, %es 290 290 movl %edx, %ds 291 291 292 292 /* 293 293 * Restore the preserved registers the handler cloberred itself … … 295 295 */ 296 296 movl ISTATE_OFFSET_EBP(%esp), %ebp 297 297 298 298 addl $(ISTATE_SOFT_SIZE + 4), %esp 299 299 iret 300 300 301 301 /** 302 302 * Mask for interrupts 0 - 31 (bits 0 - 31) where 0 means that int … … 333 333 subl $(ISTATE_SOFT_SIZE + 4), %esp 334 334 .endif 335 335 336 336 /* 337 337 * Save the general purpose registers. … … 344 344 movl %esi, ISTATE_OFFSET_ESI(%esp) 345 345 movl %ebp, ISTATE_OFFSET_EBP(%esp) 346 346 347 347 /* 348 348 * Save the segment registers. … … 356 356 movl %es, %ecx 357 357 movl %ds, %edx 358 358 359 359 movl %ecx, ISTATE_OFFSET_ES(%esp) 360 360 movl %edx, ISTATE_OFFSET_DS(%esp) 361 361 362 362 /* 363 363 * Switch to kernel selectors. … … 368 368 movl $(GDT_SELECTOR(VREG_DES)), %eax 369 369 movl %eax, %gs 370 370 371 371 /* 372 372 * Imitate a regular stack frame linkage. … … 387 387 movl %eax, ISTATE_OFFSET_EIP_FRAME(%esp) 388 388 leal ISTATE_OFFSET_EBP_FRAME(%esp), %ebp 389 389 390 390 cld 391 391 392 392 pushl %esp /* pass istate address */ 393 393 pushl $(\i) /* pass intnum */ 394 394 395 395 /* Call exc_dispatch(intnum, istate) */ 396 396 call exc_dispatch 397 397 398 398 addl $8, %esp /* clear arguments from the stack */ 399 399 400 400 /* 401 401 * Restore the selector registers. … … 409 409 movl ISTATE_OFFSET_ES(%esp), %ecx 410 410 movl ISTATE_OFFSET_DS(%esp), %edx 411 411 412 412 movl %ecx, %es 413 413 movl %edx, %ds 414 414 415 415 /* 416 416 * Restore the scratch registers and the preserved … … 422 422 movl ISTATE_OFFSET_EDX(%esp), %edx 423 423 movl ISTATE_OFFSET_EBP(%esp), %ebp 424 424 425 425 addl $(ISTATE_SOFT_SIZE + 4), %esp 426 426 iret … … 452 452 */ 453 453 FUNCTION_BEGIN(early_putchar) 454 454 455 455 #if ((defined(CONFIG_EGA)) && (!defined(CONFIG_FB))) 456 456 457 457 /* Prologue, save preserved registers */ 458 458 pushl %ebp … … 461 461 pushl %esi 462 462 pushl %edi 463 463 464 464 movl $(PA2KA(0xb8000)), %edi /* base of EGA text mode memory */ 465 465 xorl %eax, %eax 466 466 467 467 /* Read bits 8 - 15 of the cursor address */ 468 468 movw $0x3d4, %dx 469 469 movb $0xe, %al 470 470 outb %al, %dx 471 471 472 472 movw $0x3d5, %dx 473 473 inb %dx, %al 474 474 shl $8, %ax 475 475 476 476 /* Read bits 0 - 7 of the cursor address */ 477 477 movw $0x3d4, %dx 478 478 movb $0xf, %al 479 479 outb %al, %dx 480 480 481 481 movw $0x3d5, %dx 482 482 inb %dx, %al 483 483 484 484 /* Sanity check for the cursor on screen */ 485 485 cmp $2000, %ax 486 486 jb early_putchar_cursor_ok 487 487 488 488 movw $1998, %ax 489 489 490 490 early_putchar_cursor_ok: 491 491 492 492 movw %ax, %bx 493 493 shl $1, %eax 494 494 addl %eax, %edi 495 495 496 496 movl 0x08(%ebp), %eax 497 497 498 498 cmp $0x0a, %al 499 499 jne early_putchar_backspace 500 500 501 501 /* Interpret newline */ 502 502 503 503 movw %bx, %ax /* %bx -> %dx:%ax */ 504 504 xorw %dx, %dx 505 505 506 506 movw $80, %cx 507 507 idivw %cx, %ax /* %dx = %bx % 80 */ 508 508 509 509 /* %bx <- %bx + 80 - (%bx % 80) */ 510 510 addw %cx, %bx 511 511 subw %dx, %bx 512 512 513 513 jmp early_putchar_skip 514 514 515 515 early_putchar_backspace: 516 516 517 517 cmp $0x08, %al 518 518 jne early_putchar_print 519 519 520 520 /* Interpret backspace */ 521 521 522 522 cmp $0x0000, %bx 523 523 je early_putchar_skip 524 524 525 525 dec %bx 526 526 jmp early_putchar_skip 527 527 528 528 early_putchar_print: 529 529 530 530 /* Print character */ 531 531 532 532 movb $0x0e, %ah /* black background, yellow foreground */ 533 533 stosw 534 534 inc %bx 535 535 536 536 early_putchar_skip: 537 537 538 538 /* Sanity check for the cursor on the last line */ 539 539 cmp $2000, %bx 540 540 jb early_putchar_no_scroll 541 541 542 542 /* Scroll the screen (24 rows) */ 543 543 movl $(PA2KA(0xb80a0)), %esi … … 545 545 movl $960, %ecx 546 546 rep movsl 547 547 548 548 /* Clear the 24th row */ 549 549 xorl %eax, %eax 550 550 movl $40, %ecx 551 551 rep stosl 552 552 553 553 /* Go to row 24 */ 554 554 movw $1920, %bx 555 555 556 556 early_putchar_no_scroll: 557 557 558 558 /* Write bits 8 - 15 of the cursor address */ 559 559 movw $0x3d4, %dx 560 560 movb $0xe, %al 561 561 outb %al, %dx 562 562 563 563 movw $0x3d5, %dx 564 564 movb %bh, %al 565 565 outb %al, %dx 566 566 567 567 /* Write bits 0 - 7 of the cursor address */ 568 568 movw $0x3d4, %dx 569 569 movb $0xf, %al 570 570 outb %al, %dx 571 571 572 572 movw $0x3d5, %dx 573 573 movb %bl, %al 574 574 outb %al, %dx 575 575 576 576 /* Epilogue, restore preserved registers */ 577 577 popl %edi … … 579 579 popl %ebx 580 580 leave 581 581 582 582 #endif 583 583 584 584 ret 585 585 FUNCTION_END(early_putchar)
Note:
See TracChangeset
for help on using the changeset viewer.