Changing IRS's for a specified interrupt
Changing IRS's for a specified interrupt
I am not sure how to implement a way to set the appropriate ISR for specified interrupts and exceptions. I am no assembly expert, so I was wondering whats the simplest way to implement this.
Re:Changing IRS's for a specified interrupt
In pmode:
Set up an appropriate IDT with enough entries. For more information check 80386 programmers reference manual.
Im rmode:
Bios interrupts are set by default but if you want to hook your own interrupts then check a 8086 book to see how ivt entries are set. OR do google.
Good luck.
Set up an appropriate IDT with enough entries. For more information check 80386 programmers reference manual.
Im rmode:
Bios interrupts are set by default but if you want to hook your own interrupts then check a 8086 book to see how ivt entries are set. OR do google.
Good luck.
Re:Changing IRS's for a specified interrupt
you could write a function to load interrupts which acepts arguments as the ISR handler address, settings(user/kernel etc..) and the int no and then update the IDT using this
Only Human
Re:Changing IRS's for a specified interrupt
Hmm well I have this function that changes IRS's from the Flick OS.
Would anybody be able to breifly explain it?
Code: Select all
; boot/setup.asm
; Copyright (C) 2002 by Alexander Blessing <[email protected]>
;
; sets up the ISRs for various interrupts
[BITS 32] ; protected mode
[global changeISR] ; called by an extern function
[extern idt] ; the IDT table
; this function changes the Interrupt Service Routine
; for a specified interrupt
changeISR:
push ebx ; save
push edx ; registers
push eax ; that will
push ebp ; be changed
mov ebp, esp
mov ebx, [ss:ebp + 20] ; interrupt number
mov eax, [ss:ebp + 24] ; interrupt handler
mov edx, idt ; idt location
shl ebx, 3 ; need to multiply by 8
mov [edx + ebx], ax ; low offset
shr eax, 16
mov [edx + ebx + 6], ax ; high offset
pop ebp ; restore
pop eax ; registers
pop edx ; that
pop ebx ; were changed
ret ; return to caller
Re:Changing IRS's for a specified interrupt
Code: Select all
; boot/setup.asm
; Copyright (C) 2002 by Alexander Blessing <[email protected]>
;
; sets up the ISRs for various interrupts
[BITS 32]???; protected mode
[global changeISR]???; called by an extern function
[extern idt]???; the IDT table
; this function changes the Interrupt Service Routine
; for a specified interrupt
changeISR:
???push ebx???; save
???push edx???; registers
???push eax???; that will
???push ebp???; be changed
???mov ebp, esp
Code: Select all
???mov ebx, [ss:ebp + 20]???; interrupt number
???mov eax, [ss:ebp + 24]???; interrupt handler
???mov edx, idt???; idt location
Code: Select all
???shl ebx, 3???; need to multiply by 8
[pre](idt base address) + (idt entry)*8[/pre]
This presupposes that DS for both the calling code and IDT have the same base address.
Code: Select all
mov [edx + ebx], ax ; low offset
???shr eax, 16
???mov [edx + ebx + 6], ax???; high offset
Code: Select all
???pop ebp???; restore
???pop eax???; registers
???pop edx???; that
???pop ebx???; were changed???
???
???ret???; return to caller
Note:
I can't remember offhand if the IDT gets cached in the TLBs, if it does you'll need to invalidate the cached entries in a paged memory environment before the new IDT is used. Perhaps one of the gurus could answer that question.
Re:Changing IRS's for a specified interrupt
Thanks, I understand that alot better now. One more question though; is that the most common way to change ISR's?
Re:Changing IRS's for a specified interrupt
You have 2, and only 2 possibilities for changing an ISR.xxchrisxx wrote: Thanks, I understand that alot better now. One more question though; is that the most common way to change ISR's?
- Change address of the entry point indicated in the IDT
- Have your code replace that which appears at the existing entry point
Re:Changing IRS's for a specified interrupt
Strictly speaking you could also alter the GDT so the code pointer points to a different section of code, which is not changing the IDT entry nor changing the code which appears at the existing point (since you do not modify that which is there)Curufir wrote:You have 2, and only 2 possibilities for changing an ISR.xxchrisxx wrote: Thanks, I understand that alot better now. One more question though; is that the most common way to change ISR's?
Which you use is entirely up to you, although IMO altering the IDT itself is the more flexible method.
- Change address of the entry point indicated in the IDT
- Have your code replace that which appears at the existing entry point
Re:Changing IRS's for a specified interrupt
Err, nope, changing the GDT base address IS changing the code that appears at the address indicated by the IDT, that's why I specifically used the word "appears" .Candy wrote: Strictly speaking you could also alter the GDT so the code pointer points to a different section of code, which is not changing the IDT entry nor changing the code which appears at the existing point (since you do not modify that which is there)