0

I am writting an OS and trying to use the PIT. I have a handler written and wrote an ISR entry for the IRQ0 (Interrupt 32). The handler is not being called at all. I am pretty sure I am not putting the ISR entry in right. Any suggestions? Here is my ASM code

mov dword EAX, irq_common_stub
        mov byte [_NATIVE_IDT_Contents + 0x100], AL
        mov byte [_NATIVE_IDT_Contents + 0x101], AH
        mov byte [_NATIVE_IDT_Contents + 0x102], 0x8
        mov byte [_NATIVE_IDT_Contents + 0x105], 0x8E
        shr dword EAX, 0x10
        mov byte [_NATIVE_IDT_Contents + 0x106], AL
        mov byte [_NATIVE_IDT_Contents + 0x107], AH

My code to init the PIT is

     public static void PIT_Init(uint frequency)
    {
        uint divisor = 1193180 / frequency;
        GruntyOS.IO.Ports.Outb(0x43, 0x36);
        byte l = (byte)(divisor & 0xFF);
        byte h = (byte)((divisor >> 8) & 0xFF);
        GruntyOS.IO.Ports.Outb(0x40, l);
        GruntyOS.IO.Ports.Outb(0x40, h);
    }

The handler is

public static void HandlePIT()
    {
        GruntyOS.IO.Ports.Outb(0xA0, 0x20);
        GruntyOS.IO.Ports.Outb(0x20, 0x20);

        print("Tick: " + Tick.ToString());
        Tick++;
    }

Which is called from

irq_common_stub:
pusha                  

mov ax, ds              
push eax                 

mov ax, 0x10 
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax

call System_Void__GruntyOS_Entry_HandlePIT__

pop ebx       
mov ds, bx
mov es, bx
mov fs, bx
mov gs, bx

popa                  
add esp, 8     
sti
iret          
Macmade
  • 52,708
  • 13
  • 106
  • 123
user1454902
  • 750
  • 9
  • 24
  • This can't be answered. We can't just guess how you are trying to achieve this. Please provide more details if you want help. – Macmade Sep 02 '12 at 03:06
  • I am simply writing to the IDT and then I have my code to initialize it. My code is in C# (There is a project called Cosmos which lets you write native C# code that gets converted to x86) I included the code in the question. That gets called after the ISR has been assigned. – user1454902 Sep 02 '12 at 03:09
  • Now at least we know you are targeting x86... Don't you think this kind of info may be useful? – Macmade Sep 02 '12 at 03:11
  • I do , I just wasn't thinking and I really do not know that many platforms besides ARM that are not x86. – user1454902 Sep 02 '12 at 03:45

1 Answers1

0

Maybe this might help. Its a simple kernel that is capable of handling IRQs and Exceptions.

http://www.osdever.net/bkerndev/Docs/irqs.htm

http://www.ni.com/white-paper/2874/en

Software_Designer
  • 8,490
  • 3
  • 24
  • 28