Changes in kernel/arch/amd64/src/asm.S [1b20da0:a35b458] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/amd64/src/asm.S
r1b20da0 ra35b458 60 60 FUNCTION_BEGIN(memcpy_to_uspace) 61 61 movq MEMCPY_DST, %rax 62 62 63 63 movq MEMCPY_SIZE, %rcx 64 64 shrq $3, %rcx /* size / 8 */ 65 65 66 66 rep movsq /* copy as much as possible word by word */ 67 67 68 68 movq MEMCPY_SIZE, %rcx 69 69 andq $7, %rcx /* size % 8 */ 70 70 jz 0f 71 71 72 72 rep movsb /* copy the rest byte by byte */ 73 73 74 74 0: 75 75 ret /* return MEMCPY_SRC, success */ … … 92 92 popq %rax 93 93 movq %rax, %rdx 94 94 95 95 /* Flip the ID bit */ 96 96 xorl $RFLAGS_ID, %edx 97 97 98 98 /* Store RFLAGS */ 99 99 pushq %rdx 100 100 popfq 101 101 pushfq 102 102 103 103 /* Get the ID bit again */ 104 104 popq %rdx 105 105 andl $RFLAGS_ID, %eax 106 106 andl $RFLAGS_ID, %edx 107 107 108 108 /* 0 if not supported, 1 if supported */ 109 109 xorl %edx, %eax … … 114 114 /* Preserve %rbx across function calls */ 115 115 movq %rbx, %r10 116 116 117 117 /* Load the command into %eax */ 118 118 movl %edi, %eax 119 119 120 120 cpuid 121 121 movl %eax, 0(%rsi) … … 123 123 movl %ecx, 8(%rsi) 124 124 movl %edx, 12(%rsi) 125 125 126 126 movq %r10, %rbx 127 127 ret … … 161 161 * code. 162 162 */ 163 163 164 164 .iflt \i-32 165 165 .if (1 << \i) & ERROR_WORD_INTERRUPT_LIST … … 180 180 subq $(ISTATE_SOFT_SIZE + 8), %rsp 181 181 .endif 182 182 183 183 /* 184 184 * Save the general purpose registers. … … 230 230 movq $(\i), %rdi /* pass intnum in the first argument */ 231 231 movq %rsp, %rsi /* pass istate address in the second argument */ 232 232 233 233 cld 234 234 … … 250 250 movq ISTATE_OFFSET_R10(%rsp), %r10 251 251 movq ISTATE_OFFSET_R11(%rsp), %r11 252 252 253 253 /* $8 = Skip error word */ 254 254 addq $(ISTATE_SOFT_SIZE + 8), %rsp … … 288 288 /* Switch to hidden %gs */ 289 289 swapgs 290 290 291 291 movq %rsp, %gs:KSEG_OFFSET_USTACK_RSP /* save this thread's user RSP */ 292 292 movq %gs:KSEG_OFFSET_KSTACK_RSP, %rsp /* set this thread's kernel RSP */ … … 346 346 swapgs 347 347 sti 348 348 349 349 /* Copy the 4th argument where it is expected */ 350 350 movq %r10, %rcx … … 364 364 365 365 cli 366 366 367 367 /* 368 368 * Restore registers needed for return via the SYSRET instruction and … … 394 394 callq fault_from_uspace 395 395 /* not reached */ 396 396 397 397 bad_rip_msg: 398 398 .asciz "Invalid instruction pointer." … … 414 414 FUNCTION_BEGIN(early_putchar) 415 415 #if ((defined(CONFIG_EGA)) && (!defined(CONFIG_FB))) 416 416 417 417 /* Prologue, save preserved registers */ 418 418 pushq %rbp 419 419 movq %rsp, %rbp 420 420 pushq %rbx 421 421 422 422 movq %rdi, %rsi 423 423 movq $(PA2KA(0xb8000)), %rdi /* base of EGA text mode memory */ 424 424 xorl %eax, %eax 425 425 426 426 /* Read bits 8 - 15 of the cursor address */ 427 427 movw $0x3d4, %dx 428 428 movb $0xe, %al 429 429 outb %al, %dx 430 430 431 431 movw $0x3d5, %dx 432 432 inb %dx, %al 433 433 shl $8, %ax 434 434 435 435 /* Read bits 0 - 7 of the cursor address */ 436 436 movw $0x3d4, %dx 437 437 movb $0xf, %al 438 438 outb %al, %dx 439 439 440 440 movw $0x3d5, %dx 441 441 inb %dx, %al 442 442 443 443 /* Sanity check for the cursor on screen */ 444 444 cmp $2000, %ax 445 445 jb early_putchar_cursor_ok 446 446 447 447 movw $1998, %ax 448 448 449 449 early_putchar_cursor_ok: 450 450 451 451 movw %ax, %bx 452 452 shl $1, %rax 453 453 addq %rax, %rdi 454 454 455 455 movq %rsi, %rax 456 456 457 457 cmp $0x0a, %al 458 458 jne early_putchar_backspace 459 459 460 460 /* Interpret newline */ 461 461 462 462 movw %bx, %ax /* %bx -> %dx:%ax */ 463 463 xorw %dx, %dx 464 464 465 465 movw $80, %cx 466 466 idivw %cx, %ax /* %dx = %bx % 80 */ 467 467 468 468 /* %bx <- %bx + 80 - (%bx % 80) */ 469 469 addw %cx, %bx 470 470 subw %dx, %bx 471 471 472 472 jmp early_putchar_skip 473 473 474 474 early_putchar_backspace: 475 475 476 476 cmp $0x08, %al 477 477 jne early_putchar_print 478 478 479 479 /* Interpret backspace */ 480 480 481 481 cmp $0x0000, %bx 482 482 je early_putchar_skip 483 483 484 484 dec %bx 485 485 jmp early_putchar_skip 486 486 487 487 early_putchar_print: 488 488 489 489 /* Print character */ 490 490 491 491 movb $0x0e, %ah /* black background, yellow foreground */ 492 492 stosw 493 493 inc %bx 494 494 495 495 early_putchar_skip: 496 496 497 497 /* Sanity check for the cursor on the last line */ 498 498 cmp $2000, %bx 499 499 jb early_putchar_no_scroll 500 500 501 501 /* Scroll the screen (24 rows) */ 502 502 movq $(PA2KA(0xb80a0)), %rsi … … 504 504 movl $480, %ecx 505 505 rep movsq 506 506 507 507 /* Clear the 24th row */ 508 508 xorl %eax, %eax 509 509 movl $20, %ecx 510 510 rep stosq 511 511 512 512 /* Go to row 24 */ 513 513 movw $1920, %bx 514 514 515 515 early_putchar_no_scroll: 516 516 517 517 /* Write bits 8 - 15 of the cursor address */ 518 518 movw $0x3d4, %dx 519 519 movb $0xe, %al 520 520 outb %al, %dx 521 521 522 522 movw $0x3d5, %dx 523 523 movb %bh, %al 524 524 outb %al, %dx 525 525 526 526 /* Write bits 0 - 7 of the cursor address */ 527 527 movw $0x3d4, %dx 528 528 movb $0xf, %al 529 529 outb %al, %dx 530 530 531 531 movw $0x3d5, %dx 532 532 movb %bl, %al 533 533 outb %al, %dx 534 534 535 535 /* Epilogue, restore preserved registers */ 536 536 popq %rbx 537 537 leave 538 538 539 539 #endif 540 540 541 541 ret 542 542 FUNCTION_END(early_putchar)
Note:
See TracChangeset
for help on using the changeset viewer.