0

How to create an IDT using LIDT I work on Intel-Atom 32bits (Assembly AT&T). I am using the MocroC OSII as an OS, i did this but it doesn,t work:

    Load_IDT:
push    %ebp    //save the context to swith back
mov     %esp,%ebp

movw    $256*8, -6(%esp) //256 ISR possible
movl    $IDT, -4(%esp)   //IDT is a table of 256*8bytes
lidt    -6(%esp)

pop     %ebp //Return to the calling function
ret



    static void fill_interrupt(unsigned char num, unsigned int base, unsigned short sel, unsigned char flags)
{
    unsigned short *Interrupt_Address;

    /*address = idt_ptr.base + num * 8 byte*/
    Interrupt_Address = (unsigned short *)(idt_ptr.base + num*8);

    *(Interrupt_Address) = base&0xFFFF;
    *(Interrupt_Address+1) = sel;
    *(Interrupt_Address+1) = (flags>>4)&0xFF00;
    *(Interrupt_Address+1) = (base>>16)&0xFFFF;

}


/*Change the address of idt_entries table */
fill_interrupt(ISR_Nbr,(unsigned int) isr33, 0x08, 0x8E);
5
  • 1
    What exactly doesn't work? What exactly happens and when (hang/crash/something else, inside this routine/after calling it)? What does your code do after this routine? Are interrupts enabled (EFLAGS.IF=1) prior to calling this routine? What's inside IDT? Sep 29, 2011 at 22:06
  • @Alex : the IF=1, when it comes to pop %epb, it crashes !!!, and i have CPU Error (I use Eclipse:Helios) Sep 30, 2011 at 13:55
  • You must keep interrupts disabled until the moment when the IDT and IDTR are properly set up. Don't set IF to 1 until you're done with IDT/IDTR (use CLI to reset it to 0). Also, make sure all segment registers (CS,DS,ES,SS,FS,GS) are loaded with valid protected mode selector values (you may load 0 if you don't use a register) prior to enabling interrupts. Returning from ISRs will typically restore them from the stack and if there was garbage before, restoring it will result in a crash. Sep 30, 2011 at 19:45
  • now it doesnt crash after the pop %ebp, but whee I call int $33 (I mean the ISR 33) it crashes again Sep 30, 2011 at 19:52
  • @Alex : some update: I found out that there is a BIOS on the Atom board, so I checked for the IDT and GDT "/*Read the IDTR*/sidt (idt_ptr) /*Read the GDTR*/sgdt (gdt_ptr)" and they existe, it seems like the BIOS made them. I tried to use them (see above the function fill_interrupt), after that i used "int $0x20", PFFFF the code crashed again..... :-(....any clue or remark or question ??? Oct 4, 2011 at 18:11

1 Answer 1

0

Resolved :), as there is a BIOS, it already built the GDT/IDT.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.