123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354 |
- #include"../common/asm.h"
- .code64
- R15 = 0x00
- R14 = 0x08
- R13 = 0x10
- R12 = 0x18
- R11 = 0x20
- R10 = 0x28
- R9 = 0x30
- R8 = 0x38
- RBX = 0x40
- RCX = 0x48
- RDX = 0x50
- RSI = 0x58
- RDI = 0x60
- RBP = 0x68
- DS = 0x70
- ES = 0x78
- RAX = 0x80
- FUNC = 0x88
- ERRCODE = 0x90
- RIP = 0x98
- CS = 0xa0
- RFLAGS = 0xa8
- OLD_RSP = 0xb0
- OLDSS = 0xb8
- Restore_all:
-
- popq %r15
- popq %r14
- popq %r13
- popq %r12
- popq %r11
- popq %r10
- popq %r9
- popq %r8
- popq %rbx
- popq %rcx
- popq %rdx
- popq %rsi
- popq %rdi
- popq %rbp
- popq %rax
- movq %rax, %ds
- popq %rax
- movq %rax, %es
- popq %rax
- addq $0x10, %rsp
-
- sti
- iretq
- ret_from_exception:
-
- ENTRY(ret_from_intr)
- jmp Restore_all
-
- Err_Code:
-
- pushq %rax
- movq %es, %rax
- pushq %rax
- movq %ds, %rax
- pushq %rax
- xorq %rax, %rax
- pushq %rbp
- pushq %rdi
- pushq %rsi
- pushq %rdx
- pushq %rcx
- pushq %rbx
- pushq %r8
- pushq %r9
- pushq %r10
- pushq %r11
- pushq %r12
- pushq %r13
- pushq %r14
- pushq %r15
- cld
-
- movq ERRCODE(%rsp), %rsi
- movq FUNC(%rsp), %rdx
-
- movq $0x10, %rdi
- movq %rdi, %ds
- movq %rdi, %es
- movq %rsp, %rdi
-
- callq *%rdx
- jmp ret_from_exception
- ENTRY(system_call)
-
-
- subq $0x38, %rsp
-
- cld;
-
- pushq %rax
- movq %es, %rax
- pushq %rax
- movq %ds, %rax
- pushq %rax
- pushq %rbp
- pushq %rdi
- pushq %rsi
- pushq %rdx
- pushq %rcx
- pushq %rbx
- pushq %r8
- pushq %r9
- pushq %r10
- pushq %r11
- pushq %r12
- pushq %r13
- pushq %r14
- pushq %r15
- movq $0x10, %rdx
- movq %rdx, %ds
- movq %rdx, %es
-
- movq %rsp, %rdi
-
- callq system_call_function
- ENTRY(ret_from_system_call)
- popq %r15
- popq %r14
- popq %r13
- popq %r12
- popq %r11
- popq %r10
- popq %r9
- popq %r8
- popq %rbx
- popq %rcx
- popq %rdx
- popq %rsi
- popq %rdi
- popq %rbp
- popq %rax
- movq %rax, %ds
- popq %rax
- movq %rax, %es
- popq %rax
- addq $0x10, %rsp
- sti
- iretq
-
- ENTRY(divide_error)
-
- pushq $0
- pushq %rax
- leaq do_divide_error(%rip), %rax
-
- xchgq %rax, (%rsp)
- jmp Err_Code
- ENTRY(debug)
- pushq $0
- pushq %rax
- leaq do_debug(%rip), %rax
- xchgq %rax, (%rsp)
- jmp Err_Code
- ENTRY(nmi)
-
-
- pushq $0
- pushq %rax
- leaq do_nmi(%rip), %rax
- xchgq %rax, (%rsp)
- jmp Err_Code
- ENTRY(int3)
- pushq $0
- pushq %rax
- leaq do_int3(%rip), %rax
- xchgq %rax, (%rsp)
- jmp Err_Code
- ENTRY(overflow)
- pushq $0
- pushq %rax
- leaq do_overflow(%rip), %rax
- xchgq %rax, (%rsp)
- jmp Err_Code
- ENTRY(bounds)
- pushq $0
- pushq %rax
- leaq do_bounds(%rip), %rax
- xchgq %rax, (%rsp)
- jmp Err_Code
- ENTRY(undefined_opcode)
- pushq $0
- pushq %rax
- leaq do_undefined_opcode(%rip), %rax
- xchgq %rax, (%rsp)
- jmp Err_Code
- ENTRY(dev_not_avaliable)
- pushq $0
- pushq %rax
- leaq do_dev_not_avaliable(%rip), %rax
- xchgq %rax, (%rsp)
- jmp Err_Code
- ENTRY(double_fault)
- pushq %rax
- leaq do_double_fault(%rip), %rax
- xchgq %rax, (%rsp)
- jmp Err_Code
- ENTRY(coprocessor_segment_overrun)
- pushq $0
- pushq %rax
- leaq do_coprocessor_segment_overrun(%rip), %rax
- xchgq %rax, (%rsp)
- jmp Err_Code
- ENTRY(invalid_TSS)
-
-
- pushq %rax
- leaq do_invalid_TSS(%rip), %rax
- xchgq %rax, (%rsp)
- jmp Err_Code
- ENTRY(segment_not_exists)
- pushq %rax
- leaq do_segment_not_exists(%rip), %rax
- xchgq %rax, (%rsp)
- jmp Err_Code
- ENTRY(stack_segment_fault)
- pushq %rax
- leaq do_stack_segment_fault(%rip), %rax
- xchgq %rax, (%rsp)
- jmp Err_Code
- ENTRY(general_protection)
- pushq %rax
- leaq do_general_protection(%rip), %rax
- xchgq %rax, (%rsp)
- jmp Err_Code
- ENTRY(page_fault)
-
-
- pushq %rax
- leaq do_page_fault(%rip), %rax
- xchgq %rax, (%rsp)
- jmp Err_Code
- ENTRY(x87_FPU_error)
- pushq $0
- pushq %rax
- leaq do_x87_FPU_error(%rip), %rax
- xchgq %rax, (%rsp)
- jmp Err_Code
- ENTRY(alignment_check)
- pushq %rax
- leaq do_alignment_check(%rip), %rax
- xchgq %rax, (%rsp)
- jmp Err_Code
- ENTRY(machine_check)
- pushq $0
- pushq %rax
- leaq do_machine_check(%rip), %rax
- xchgq %rax, (%rsp)
- jmp Err_Code
- ENTRY(SIMD_exception)
- pushq $0
- pushq %rax
- leaq do_SIMD_exception(%rip), %rax
- xchgq %rax, (%rsp)
- jmp Err_Code
- ENTRY(virtualization_exception)
- pushq $0
- pushq %rax
- leaq do_virtualization_exception(%rip), %rax
- xchgq %rax, (%rsp)
- jmp Err_Code
- ENTRY(syscall_int)
- pushq $0
- pushq %rax
- leaq do_syscall_int(%rip), %rax
- xchgq %rax, (%rsp)
- jmp Err_Code
|