You set IRQs vector offset to 0x20 . That means IRQ0 is mapped to interrupt 0x20 IRQ1 to interrupt 0x21 etc. However, you set your irq handlers to be executed when interrupts 0x00 and 0x01 occur. That's how you should set IDR.
Up vote 0 down vote favorite share g+ share fb share tw.
I am not being able to get IDT working because my Interrupt routines are not getting called, especially the keyboard related one when I press a key on keyboard. I am passing the IDT table's special 48 bit pointer's address. I am doing it like dt_ptr idt_ptr; // defining the pointer loadidt(dt_ptr *a); // how I am passing the pointer's address to assembly routine I also don't know whether at least GDT is working or not.
1) what shall I do to get my IDT working. I saw few tutorials too but didn't help 2) How can I verify whether GDT works properly? Thanks in advance.
EDIT: I am doing this for my own OS. I am doubtful whether my assembly routine is able to properly receive the pointer's address. So I also tried to do lidt using inline assembly but didn't help.
I don't know what is wrong. Any clues, idea? Void remap_irqs(void) { outb(0x20, 0x11); outb(0xA0, 0x11); outb(0x21, 0x20); outb(0xA1, 0x28); outb(0x21, 0x04); outb(0xA1, 0x02); outb(0x21, 0x01); outb(0xA1, 0x01); outb(0x21, 0x0); outb(0xA1, 0x0); outbyte('a'); } void set_idt_gate(uint8 num, unsigned long base, word sel, uint8 flags) { IDTnum.
Offset_low = (base & 0xFFFF); IDTnum. Offset_high = (base >> 16) & 0xFFFF; IDTnum. Selector = sel; IDTnum.
Zero = 0; IDTnum. Type_attrs = flags; } void init_idt() { outbyte('M'); idt_ptr. Limit = (sizeof (idt_entry) * 256) - 1; idt_ptr.
Base =(uint32) &IDT; memset((uint8 *)&IDT, 0, sizeof(idt_entry) * 256); remap_irqs(); set_idt_gate(0, (unsigned) irq_0, 0x08, 0x8E); set_idt_gate(1, (unsigned) irq_1, 0x08, 0x8E); //install_isrs(); //install_irqs(); //idt_load(); //print_message(); lidt(&IDT,idt_ptr. Limit); _LIDT(&idt_ptr); loadidt(&idt_ptr); } void lidt( void * base, unsigned short size ) { struct { unsigned short length; unsigned long base; } __attribute__((__packed__)) IDTR; IDTR. Length = size; IDTR.
Base = (unsigned long)base; asm( "lidt (%0)" : : "p"(&IDTR) ); } void _LIDT(dt_ptr *ptr) { asm("lidt (%0)" : :"p"(ptr)); outbyte('n'); } void irq_0() { //before_interrupt(); ticks+=1; if(ticks%18==0) { outbyte('+'); outbyte('1'); } //after_interrupt(); } void irq_1() { outbyte('a'); //before_interrupt(); irq1_keyb(); //after_interrupt(); } typedef struct { uint16 offset_low; // The lower 16 bits of the address to jump to when this interrupt occures:// offset 0-15 uint16 selector; // Kernel segment selector in IDT uint8 zero; // This must always be zero. Uint8 type_attrs; //gate types, atttribute types etc. uint16 offset_high; // The upper 16 bits of the address to jump to. Offset 16-31 } __attribute__((__packed__)) idt_entry; typedef struct { uint16 limit; uint32 base; // The address of the first element in IDT array.
} __attribute__((__packed__)) dt_ptr; global loadidt loadidt: push ebp mov ebp,esp mov eax,ebp+8 lidt eax pop ebp ret c operating-system interrupt-handling interrupts keyboardinterrupt link|improve this question edited Apr 5 at 1:54 asked Apr 4 at 14:57Manu Hegde676 70% accept rate.
3 For interrupt issues it would be helpful to tell your platform and maybe your operating system. – Matthias Apr 4 at 15:03 My own operating system. – Manu Hegde Apr 4 at 15:08 ...and your platform (i.e.
, which processor, and in case of interrupt considerations, interrupt controller, if any) – Matthias Apr 4 at 15:10 phenom x2. 2 cores. – Manu Hegde Apr 4 at 15:11 We need more information.
Show us how IDT is created, exact loadidt code and dt_ptr definition. – Pawe? Dziepak Apr 4 at 16:38.
You set IRQs vector offset to 0x20. That means IRQ0 is mapped to interrupt 0x20, IRQ1 to interrupt 0x21, etc. However, you set your irq handlers to be executed when interrupts 0x00 and 0x01 occur. That's how you should set IDR: set_idt_gate(0x20, (unsigned) irq_0, 0x08, 0x8E); set_idt_gate(0x21, (unsigned) irq_1, 0x08, 0x8E); You can find more information regarding PIC here (section Initialization explains exactly what you are doing in remap_irqs function.
Thank you. Something may be wrong with gdt. As whole no improvement.
– Manu Hegde yesterday.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.