1 /* Yeah, i finally figure it out with a half day debugging.
2 * when an interrupt happened with no pri changed, process wouldn't
3 * push the OLD SS and OLD ESP in the following stack fragment. And
4 * that also happened to WITH_ERROR_CODE interrupt.
6 * So, if when we at pri ZERO, and do a var_a = var_b / 0 that ivoke
7 * a divide_error interrupt, and it just push the the flag regsiter and
8 * and cs register with eip where the interrupt happened. There is NO
9 * OLD SS and OLD ESP, then the final handler die() will put wrong
10 * information that the the value of SS:ESP is random and no rule.
15 * no ERROR_code fragment
49 | error_code(=0) |0x04 that's the para needed to pass to handler function
51 | ptr_to_eip |0x00 the protype of handler is do_xxx(eip_addr, err_code)
57 pushl $do_divide_error
60 /* push all the reg first to protect data */
73 lea
0x30(%esp
), %eax
# get the addr of eip as para ofdo_xx
75 movl
0x30(%esp
), %eax
# another para of do_xxx
81 addl $
8,%esp
# pop the two para
94 addl $
4,%esp
# pop the handler address
99 pushl $do_int3
# _do_debug
127 .globl coprocessor_segment_overrun
128 coprocessor_segment_overrun
:
129 pushl $do_coprocessor_segment_overrun
147 # jmp coprocessor_error
152 * with ERROR_code fragment
188 | error_code |0x04 that's the para needed to pass to handler function
190 | ptr_to_eip |0x00 the protype of handler is do_xxx(eip_addr, err_code)
197 pushl $do_double_fault
211 movl
0x30(%esp
), %eax
# erro code
213 lea
0x34(%esp
), %eax
# ptr to eip
220 movl
0x30(%esp
), %eax
239 pushl $do_invalid_TSS
242 .globl segment_not_present
244 pushl $do_segment_not_present
249 pushl $do_stack_segment
252 .globl general_protection
254 pushl $do_general_protection
264 /* i'm tried to make the timer work correct, so i move the
265 interrupt handle here. hope it works. :)
268 .globl timer_interrupt
282 movb $
0x20,%al
# EOI to interrupt controller #1
302 .globl floppy_interrupt
315 movl $0x4142434445, %eax
320 movb $0x20,%al # EOI to interrupt controller #1
327 movl $unexpected_floppy_interrupt,%eax