📄 asm.s
字号:
/* * linux/kernel/asm.s * * (C) 1991 Linus Torvalds *//* * asm.s contains the low-level code for most hardware faults. * page_exception is handled by the mm, so that isn't here. This * file also handles (hopefully) fpu-exceptions due to TS-bit, as * the fpu must be properly saved/resored. This hasn't been tested. */ /*全局函数的申明*/.globl _divide_error,_debug,_nmi,_int3,_overflow,_bounds,_invalid_op.globl _double_fault,_coprocessor_segment_overrun.globl _invalid_TSS,_segment_not_present,_stack_segment.globl _general_protection,_coprocessor_error,_irq13,_reserved /*异常处理*/_divide_error: /*被除0(除0,EAX容纳不了一个合法操作的结果)*/ pushl $_do_divide_errorno_error_code: /*p156的图*/ xchgl %eax,(%esp) pushl %ebx pushl %ecx pushl %edx pushl %edi pushl %esi pushl %ebp push %ds push %es push %fs pushl $0 # "error code" lea 44(%esp),%edx pushl %edx movl $0x10,%edx mov %dx,%ds mov %dx,%es mov %dx,%fs call *%eax addl $8,%esp pop %fs pop %es pop %ds popl %ebp popl %esi popl %edi popl %edx popl %ecx popl %ebx popl %eax iret_debug: /*debug调试中断入口,当EFLAGS中的TF位置位时引发*/ pushl $_do_int3 # _do_debug jmp no_error_code_nmi: /*非屏蔽中断调试入口(通常保留给极为重要的硬件事件,它处理时将忽略其它中断)*/ pushl $_do_nmi jmp no_error_code_int3: /*断点指令引起中断的入口点*/ pushl $_do_int3 jmp no_error_code_overflow: /*溢出出错(EFLAGS中的OF位置位)*/ pushl $_do_overflow jmp no_error_code_bounds: /*边界检查出错(操作数在有效范围以外时引发)*/ pushl $_do_bounds jmp no_error_code_invalid_op: /*无效操作指令*/ pushl $_do_invalid_op jmp no_error_code_coprocessor_segment_overrun: /*协处理器段超出出错中断入口点(协处理器出错保护)*/ pushl $_do_coprocessor_segment_overrun jmp no_error_code_reserved: /*其它intel保留中断的入口点*/ pushl $_do_reserved jmp no_error_code_irq13: /*当协处理器完成一个操作时就会发出IRQ13中断信号,以通知CPU,以下操作主要是为了确保在继续执行协处理器的任何指令之前,CPU响应本中断。*/ pushl %eax xorb %al,%al outb %al,$0xF0 movb $0x20,%al outb %al,$0x20 jmp 1f1: jmp 1f1: outb %al,$0xA0 popl %eax jmp _coprocessor_error_double_fault: /*双出错故障,当CPU在调用某个异常处理程序时又检测到一个新的异常,若CPU无法串行的处理两个异常,则引发该中断*/ pushl $_do_double_faulterror_code: xchgl %eax,4(%esp) # error code <-> %eax xchgl %ebx,(%esp) # &function <-> %ebx pushl %ecx pushl %edx pushl %edi pushl %esi pushl %ebp push %ds push %es push %fs pushl %eax # error code lea 44(%esp),%eax # offset pushl %eax movl $0x10,%eax mov %ax,%ds mov %ax,%es mov %ax,%fs call *%ebx addl $8,%esp pop %fs pop %es pop %ds popl %ebp popl %esi popl %edi popl %edx popl %ecx popl %ebx popl %eax iret_invalid_TSS: /*无效的TSS*/ pushl $_do_invalid_TSS jmp error_code_segment_not_present: /*段不存在*/ pushl $_do_segment_not_present jmp error_code_stack_segment: /*堆栈段错误(指令操作试图超出堆栈段范围)*/ pushl $_do_stack_segment jmp error_code_general_protection: /*一般保护性出错,不属于任何其它的错误*/ pushl $_do_general_protection jmp error_code
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -