OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Apr 16, 2024 2:07 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: PIC changing offset fails
PostPosted: Sun Oct 14, 2018 3:41 am 
Offline

Joined: Sat Jun 04, 2011 8:25 am
Posts: 1
Hi everyone. I have been playing around with a toy kernel for a while. Now, I have started adding interrupts. IDT is set up, ISR works, prints a line on the screen (although crashes after several hundred timer ticks, since it messes up the stack, I'll fix that later, I promise :D)

However, the timer interrupt only fires if I bind it to INT 0x8. I have added the PIC init code to the initialization sequence to remap the master PIC to INT 0x20, but the ISR runs only if I also bind it to INT 8.

I thought maybe I use C asm blocks incorrectly, so I moved the PIC init code to the ASM loader part of the kernel. Still, nothing changes, INT 8 fires, INT 0x20 doesn't. I use QEMU to run the kernel, I even thought about recompiling QEMU to add debug statements to the PIC emulation code, but it seems an unreasonable amount of work.

Could someone please proofread my PIC init asm code? I use NASM.

Code:
    mov al,0x11
    out 0x20,al
    out 0xa0,al
    mov al,0x20
    out 0x21,al
    mov al,0x28
    out 0xa1,al
    mov al,0x04
    out 0x21,al
    mov al,0x02
    out 0xa1,al
    mov al,01
    out 0x21,al
    out 0xa1,al

    mov al,0xfe
    out 0x21,al


Top
 Profile  
 
 Post subject: Re: PIC changing offset fails
PostPosted: Sun Oct 14, 2018 6:32 am 
Offline
Member
Member
User avatar

Joined: Wed Aug 08, 2012 6:39 am
Posts: 42
Location: New York, NY
I admit it's been a while since I programmed the PIC, but looking at my code I find it odd that you are trying to remap both PICs in parallel. IMO, separate out programming the master and the slave. Also, you are not masking the interrupts before programming the PIC which could be a bad thing.

For reference, the code I use:

Code:
  outportb(PIC0_DATA, 0xff);
  outportb(PIC1_DATA, 0xff);

  outportb(PIC0_CTRL, 0x11);
  outportb(PIC0_DATA, 0x20);
  outportb(PIC0_DATA, 0x04);
  outportb(PIC0_DATA, 0x01);

  outportb(PIC1_CTRL, 0x11);
  outportb(PIC1_DATA, 0x28);
  outportb(PIC1_DATA, 0x02);
  outportb(PIC1_DATA, 0x01);

  outportb(PIC0_DATA, 0x00);
  outportb(PIC1_DATA, 0x00);

_________________
Cheers,

Lev


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 478 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group