Installing the IDT in Assembly

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
HitmanYesman
Member
Member
Posts: 47
Joined: Fri Apr 23, 2010 8:27 am

Installing the IDT in Assembly

Post by HitmanYesman »

I'm having trouble creating the IDT in Assembly. This is what I have so far for my IDT.inc file:

Code:

Code: Select all

;***************************************;
;   IDT.inc                        ;
;***************************************;
bits   32

;=======================================;
;   Include Files                  ;
;=======================================;


;=======================================;
;   Install_IDT                     ;
;=======================================;
Install_IDT:
   pusha
   lidt         [IDT_Desc]
   popa
   ret

;=======================================;
;   IDT - Interrupt Descriptor Table   ;
;=======================================;
IDT_General:
   mov         ax, 0x12
   call         Set_Text_Color
   call      ClrScr32
   mov         ax, 0x01F
   call      GotoXY
   mov         ebx, msg
   call      Puts32
   
   jmp         $

IDT_End:

IDT_Desc:   
   dw         IDT_General - IDT_End - 1
   dd         IDT_General

;=======================================;
;   Data                        ;
;=======================================;
msg   db "*** [i86 Hal] i86_default_handler: Unhandled Exception", 0x0A, 0x00
IDT_General is going to be the general exception handler for the interrupts I haven't covered yet. I'm pretty sure I have that set up right. But what I'm really confused about is how to set that to all 256 descriptors so it can cover them all.

I'm not sure what to do next in it to get it working. I'm looking at different tutorials about the IDT and I know what they're saying but implementing it is harder than I thought. It's because they're all in C/C++. If you know one in Assembly please let me know. And please don't (if your going to help me here) just give me the code, I want to work this out on my own.
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: Installing the IDT in Assembly

Post by thepowersgang »

May I suggest you look at the tutorials on the wiki, because you have no clue about how the IDT works. The IDT descriptor points to an array of 8-byte entries that describe the handlers for each of the 256 interrupts, not to a general handler.
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
HitmanYesman
Member
Member
Posts: 47
Joined: Fri Apr 23, 2010 8:27 am

Re: Installing the IDT in Assembly

Post by HitmanYesman »

I am well aware that you don't use a general one. It is simply a test to see if it would work. And I read this other tutorial that used a general ISR for all the interrupts that weren't covered yet. I'll look it up on the wiki and see if I can figure this out.
TylerH
Member
Member
Posts: 285
Joined: Tue Apr 13, 2010 8:00 pm
Contact:

Re: Installing the IDT in Assembly

Post by TylerH »

No, seriously, go read the wiki. You are way off. The IDT(the stuff you have between IDT_General and IDT_End) shouldn't even contain code at all. It's similar to the IVT, it only tells the processor where it can find the code to handle the interrupt. You IDT should contain a bunch of descriptors that will point to the code(similar to how the GDT works) and have some other info about the function of the interrupt such as what ring the ISR is to be run in.
Post Reply