我定义我的共同ISR存根:x86的中断服务程序的原因一般保护错误
isr_common_stub:
pusha ; Pushes edi,esi,ebp,esp,ebx,edx,ecx,eax
mov ax, ds ; Lower 16-bits of eax = ds.
push eax ; save the data segment descriptor
mov ax, 0x10 ; load the kernel data segment descriptor
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
call isr_handler
;call saySomething
pop ebx ; reload the original data segment descriptor
mov ds, bx
mov es, bx
mov fs, bx
mov gs, bx
;call saySomething
popa ; Pops edi,esi,ebp...
;add esp, 8 ; Cleans up the pushed error code and pushed ISR number
;sti
;call saySomething
;iret ; pops 5 things at once: CS, EIP, EFLAGS, SS, and ESP
ret ;Return to the caller. Iret and interrupt enabling is handled within caller.
此代码从每个称为中断如下:
%macro ISR_NOERRCODE 1
global isr%1
isr%1:
cli ; Disable interrupts firstly.
push byte 0 ; Push a dummy error code.
push byte %1 ; Push the interrupt number.
jmp isr_common_stub ; Go to our common handler code.
sub esp, 2 ;Removes 2 bytes from stack
;sti ;Iret enables interrupts again
iret ;Return from interrupt
%endmacro
此代码调用外部处理方法适当,但是从外部处理方法返回后导致gpf中断。
此外,我已经映射我的gdt覆盖整个4G地址空间与0特权级别的数据和代码描述符(和空描述符)。任何帮助表示赞赏。
在ISR中做“sti”并不是一个好主意。典型的中断在ISR中被禁用。在“iret”之前的“sti”只能为一个指令启用中断,因为“iret”将恢复“中断使能”位的旧状态。 – 2014-08-28 05:20:50
在从中断返回之前,未将中断信号的结束(OCW 2 的EOI位4)发送到主PIC命令寄存器(端口20h)。 – 2014-08-28 05:51:47
@DirkWolfgangGlomp isrs是否需要isrs?我认为这只会需要irqs。 – 2014-08-28 06:37:09