Code: Select all
irq_0_stub:
cli
push 1234
push 0
pushad
push ds
push es
push fs
push gs
mov ax,$08
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov eax,esp
push eax
mov eax,IRQHandlers
call [eax]
pop eax
pop gs
pop fs
pop es
pop ds
popad
add esp,8
iret
Code: Select all
procedure NullInterrupt(pRegs: PInterruptSavedRegisters); pascal;
begin
if pRegs^.lwErrorCode = 1234 then
begin
if pRegs^.lwISRIndex > 7 then
OutToPort($A0,Byte($20));
OutToPort($20,Byte($20));
end;
end;
Code: Select all
InitializeIRQs($10,$8E,$20);
WriteLn(PChar('Kernel IRQ handling is initialized.'));
The peculiar thing that happens is this: IRQ0 is triggered after I enable IRQs, the stub runs and calls the proper handler (NullInterrupt()), NullInterrupt() returns, and a General Protection Fault occurs on the "pop ds" in the stub up there.
Code: Select all
The basic exceptions are installed and so is the Interrupt Descriptor Table.
The Programmable Interrupt Controllers have been remapped to put IRQs $00-$0F at
IDT entries $20-$28.
Kernel IRQ handling is initialized.
IRQs/interrupts are enabled.
gs: $8
fs: $8
es: $8
ds: $8
edi: $2CFDC
esi: $2CFDB
ebp: $1213B8
ebx: $0
edx: $20
ecx: $1B
eax: $8
int #: $D
error code: $CFDC
eip: $1004E9
cs: $10
eflags: $10097
useresp: $2CFDC
ss: $2CFDB
General Protection Fault Exception