How to setup 8259A (reprogram the interrupt)?

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
SCSoft
Posts: 11
Joined: Tue Jan 31, 2006 12:00 am

How to setup 8259A (reprogram the interrupt)?

Post by SCSoft »

How to setup 8259A (reprogram the interrupt)?
I've seen Linus' source code, but i cannot understand it.

Who has information about I/O port?
User avatar
JAAman
Member
Member
Posts: 879
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Re: How to setup 8259A (reprogram the interrupt)?

Post by JAAman »

for I/O port information (about older parts) check the RBIL, for newer parts use any ports and can be different on each computer -- you must detect it at run-time

for reprogramming the PIC check the MT FAQ
or more specifically: remapping the PIC



## ---- ----- RBIL
SCSoft
Posts: 11
Joined: Tue Jan 31, 2006 12:00 am

Re: How to setup 8259A (reprogram the interrupt)?

Post by SCSoft »

Thank you
digo_rp
Member
Member
Posts: 233
Joined: Sun Jun 05, 2005 11:00 pm

Re: How to setup 8259A (reprogram the interrupt)?

Post by digo_rp »

is something like that ->
void remap_pics(int pic1, int pic2) {
byte a1, a2;

a1=inportb(PIC1_DATA);
a2=inportb(PIC2_DATA);

outportb(PIC1_COMMAND, ICW1_INIT+ICW1_ICW4);
outportb(PIC2_COMMAND, ICW1_INIT+ICW1_ICW4);
outportb(PIC1_DATA, pic1);
outportb(PIC2_DATA, pic2);
outportb(PIC1_DATA, 4);
outportb(PIC2_DATA, 2);
outportb(PIC1_DATA, ICW4_8086 /* | ICW4_AUTO */);
outportb(PIC2_DATA, ICW4_8086 /* | ICW4_AUTO */);

outportb(PIC1_DATA, a1);
outportb(PIC2_DATA, a2);
};

you should call this function somethig like that:

remap_pics(0x20, 0x28);
digo_rp
Member
Member
Posts: 233
Joined: Sun Jun 05, 2005 11:00 pm

Re: How to setup 8259A (reprogram the interrupt)?

Post by digo_rp »

I forgot to print the included file;

#define PIC1 0x20
#define PIC2 0xA0
#define PIC1_COMMAND PIC1
#define PIC1_DATA (PIC1+1)
#define PIC2_COMMAND PIC2
#define PIC2_DATA (PIC2+1)
#define PIC_EOI 0x20
#define ICW1_ICW4 0x01 /* ICW4 (not) needed */
#define ICW1_SINGLE 0x02 /* Single (cascade) mode */
#define ICW1_INTERVAL4 0x04 /* Call address interval 4 (8) */
#define ICW1_LEVEL 0x08 /* Level triggered (edge) mode */
#define ICW1_INIT 0x10 /* Initialization - required! */
#define ICW4_8086 0x01 /* 8086/88 (MCS-80/85) mode */
#define ICW4_AUTO 0x02 /* Auto (normal) EOI */
#define ICW4_BUF_SLAVE 0x08 /* Buffered mode/slave */
#define ICW4_BUF_MASTER 0x0C /* Buffered mode/master */
#define ICW4_SFNM 0x10 /* Special fully nested (not) */
SCSoft
Posts: 11
Joined: Tue Jan 31, 2006 12:00 am

Re: How to setup 8259A (reprogram the interrupt)?

Post by SCSoft »

Is a1 a OCW1 for PIC1?
digo_rp
Member
Member
Posts: 233
Joined: Sun Jun 05, 2005 11:00 pm

Re: How to setup 8259A (reprogram the interrupt)?

Post by digo_rp »

yes
Post Reply