irq

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
User avatar
packet50071
Member
Member
Posts: 43
Joined: Sat Dec 22, 2007 2:27 pm
Location: canada

irq

Post by packet50071 »

I was reading the code from the tutorial from http://osdever.net/bkerndev/Docs/irqs.htm

but i cannot understand what this code does ?
any help can be help full -- I understand y its used but i cannot understand the code itself for ex 'outb 0x20, 0x11;' why is it used ?? etc

Code: Select all

 
void irq_remap(void)
{
    outportb(0x20, 0x11);
    outportb(0xA0, 0x11);
    outportb(0x21, 0x20);
    outportb(0xA1, 0x28);
    outportb(0x21, 0x04);
    outportb(0xA1, 0x02);
    outportb(0x21, 0x01);
    outportb(0xA1, 0x01);
    outportb(0x21, 0x0);
    outportb(0xA1, 0x0);
}
:?
Technology is here to make things easier not harder.
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Post by bewing »

The code is for "remapping the PIC".
When a PC is first booted, IRQs from hardware devices end up having the same interrupt numbers as CPU exception codes. This is completely unworkable. Fortunately, the Programmable Interrupt Controller chip is programmable. So you can change (to some degree) which IRQs map into which CPU interrupt numbers, by sending some codes to the PIC chip. You don't want to use any of the first 32 CPU interrupts. But the next 16 are free for you to use for IRQs. So that is what this code does. It uses PIC-specific commands (in the form of special bytes to particular IO ports) to tell the PIC to map the 16 IRQs to CPU interrupt numbers 0x20 to 0x2f.
User avatar
packet50071
Member
Member
Posts: 43
Joined: Sat Dec 22, 2007 2:27 pm
Location: canada

Post by packet50071 »

thx bewing

But what does PIC-specific commands Do ??
Or do i don't have to know that !

thx for future help
Technology is here to make things easier not harder.
User avatar
packet50071
Member
Member
Posts: 43
Joined: Sat Dec 22, 2007 2:27 pm
Location: canada

Post by packet50071 »

I have another question - i am looking at various tutorials and OS examples but they all end up looking alike - did they copy from a tutorial or do the actually think same !!
Technology is here to make things easier not harder.
blound
Member
Member
Posts: 70
Joined: Sat Dec 01, 2007 1:36 pm

Post by blound »

when I was wondering the same thing this really helped:

http://www.brokenthorn.com/Resources/OSDevPic.html

you should read the whole thing but if you want a quick answer look for the section:

8259A Commands
User avatar
packet50071
Member
Member
Posts: 43
Joined: Sat Dec 22, 2007 2:27 pm
Location: canada

Post by packet50071 »

thx for showing me that :D
Technology is here to make things easier not harder.
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Post by bewing »

packet50071 wrote:I have another question - i am looking at various tutorials and OS examples but they all end up looking alike - did they copy from a tutorial or do the actually think same !!
The manufacturer of a device intends for it to be used in one fairly specific way. You can change the comments a little if you want, but there is really only one possible set of commands you can send -- unless you do it wrong. There are many many ways to do it wrong.
User avatar
packet50071
Member
Member
Posts: 43
Joined: Sat Dec 22, 2007 2:27 pm
Location: canada

Post by packet50071 »

nah i am not talking about this - i am talking about the name of the functions used in all their code and stuff like that . any way forget about it
:wink:
Technology is here to make things easier not harder.
blound
Member
Member
Posts: 70
Joined: Sat Dec 01, 2007 1:36 pm

Post by blound »

packet50071 wrote:nah i am not talking about this - i am talking about the name of the functions used in all their code and stuff like that . any way forget about it
:wink:
I have noticed this alot too. It actually has advantages b/c some people are lazy with comments and others have way too many and the combination usually lets you figure out what the code is doing.

Also if you ever see hardcoded numbers used in the middle you can usually google: <the #> osdev

and find another tutorial explaining where it came from :P
Post Reply