ISR Help?
Posted: Sat May 03, 2003 12:56 pm
Hi all!
Ok, I've the IDT loaded and to prove to myself it worked I invoke int 0xD...however it does not do anything...
here's the code...
patch_idts:
mov esi, ISRTable
mov cx, 34
mov edi, idt
fill_idts:
mov ax, [esi]
mov [edi], ax
shr ax, 16
mov [edi+6], ax
add esi, 2
add edi, 8
loop fill_idts
xor ebx, ebx
mov bx, cs
shl ebx, 4
mov eax, idt
add eax, ebx
mov [idtr+2], eax
lidt [idtr]
retn;
cpu_exception13:
cli
SAVE_REGS ; macro to pushad, push ds, es, fs, gs
push cs
mov eax, CODE_SELECTOR
push eax
pop cs
mov eax, DATA_SELECTOR
mov ds, eax
mov fs, eax
mov gs, eax
mov ss, eax
xor eax, eax
mov ah, 0x1b
mov al, 'D'
mov ebx, 1 ; Column
mov edx, 15 ; Row
push ebx
push edx
push eax
call WriteChar32
pop cs
sti
RESTORE_REGS ; Macro to pop gs, fs, es, ds, popad
WriteChar32:
pop esi ; Pop Callee's return address
mov eax, 0xb8000
mov es, eax
pop ebx ; Attribute/Char
mov [Attr], bx ; save it for now
pop ecx ; Row
dec cx
mov [YPos], cx
pop eax ; Column
push esi ; Push Callee's return address
dec ax
mov [XPos], ax
xor edx, edx
mov dl, cl
mov bx, dx
shl dx, 6
shl bx, 4
add dx, bx
xor edi, edi
add edi, edx
mov bx, [XPos]
add edi, bx
shl edi, 1
mov eax, [Attr]
stosd
retn
in data section I have
ISRTable
dw cpu_exception0 ; INT 0x0
dw .....
dw cpu_exception15 ; INT 0xF
dw reserved ; From INT's 0x10->0x1F
dw ....
dw isr_irq0 ; INT 0x20
dw isr_irq1 ; INT 0x21
Question is, is my isr correct? What I'm expecting is a 'D' to appear at line 15, column 1...this is decremented by 1 to cater for offset 0 in video memory. Any pointers to where I'm going wrong. Funny thing is a) it aint triple faulting or anything b) I have WriteChar code as 16 bit (identical with 16bit registers and it works fine!)
Thanks,
Tommie.
Ok, I've the IDT loaded and to prove to myself it worked I invoke int 0xD...however it does not do anything...
here's the code...
patch_idts:
mov esi, ISRTable
mov cx, 34
mov edi, idt
fill_idts:
mov ax, [esi]
mov [edi], ax
shr ax, 16
mov [edi+6], ax
add esi, 2
add edi, 8
loop fill_idts
xor ebx, ebx
mov bx, cs
shl ebx, 4
mov eax, idt
add eax, ebx
mov [idtr+2], eax
lidt [idtr]
retn;
cpu_exception13:
cli
SAVE_REGS ; macro to pushad, push ds, es, fs, gs
push cs
mov eax, CODE_SELECTOR
push eax
pop cs
mov eax, DATA_SELECTOR
mov ds, eax
mov fs, eax
mov gs, eax
mov ss, eax
xor eax, eax
mov ah, 0x1b
mov al, 'D'
mov ebx, 1 ; Column
mov edx, 15 ; Row
push ebx
push edx
push eax
call WriteChar32
pop cs
sti
RESTORE_REGS ; Macro to pop gs, fs, es, ds, popad
WriteChar32:
pop esi ; Pop Callee's return address
mov eax, 0xb8000
mov es, eax
pop ebx ; Attribute/Char
mov [Attr], bx ; save it for now
pop ecx ; Row
dec cx
mov [YPos], cx
pop eax ; Column
push esi ; Push Callee's return address
dec ax
mov [XPos], ax
xor edx, edx
mov dl, cl
mov bx, dx
shl dx, 6
shl bx, 4
add dx, bx
xor edi, edi
add edi, edx
mov bx, [XPos]
add edi, bx
shl edi, 1
mov eax, [Attr]
stosd
retn
in data section I have
ISRTable
dw cpu_exception0 ; INT 0x0
dw .....
dw cpu_exception15 ; INT 0xF
dw reserved ; From INT's 0x10->0x1F
dw ....
dw isr_irq0 ; INT 0x20
dw isr_irq1 ; INT 0x21
Question is, is my isr correct? What I'm expecting is a 'D' to appear at line 15, column 1...this is decremented by 1 to cater for offset 0 in video memory. Any pointers to where I'm going wrong. Funny thing is a) it aint triple faulting or anything b) I have WriteChar code as 16 bit (identical with 16bit registers and it works fine!)
Thanks,
Tommie.