I have read the 8295 wiki page wiki page. I have also read through the 8259 datasheet, with particular emphases on the Initialization Control Word (ICW) sequence (see pg 10). The sequence can be distilled down to the following writes:
Master:
- ICW1 = 0x11 (cmd)
ICW2 = offset (data)
ICW3 = 0x04 (data)
ICW4 = 0x01 (data)
- ICW1 = 0x11 (cmd)
ICW2 = offset (data)
ICW3 = 0x02 (data)
ICW4 = 0x01 (data)
For ICW2, write the desired offset keeping in mind the lower three bits are not used.
For ICW3, write 4 to the master PIC (indicating a slave is connected to IRQ2) and write 2 to the slave (setting its slave ID)
For ICW4, D0 is set to configure the 8259 to run in 8086 mode
My code does exactly that (pic_outb wraps outb):
Code: Select all
#define PIC8259_MASTER_CMD 0x20
#define PIC8259_MASTER_DATA 0x21
#define PIC8259_SLAVE_CMD 0xa0
#define PIC8259_SLAVE_DATA 0xa1
#define ICW1_IC4_NEEDED (1 << 0)
#define ICW1_D4_BEGIN_ICW (1 << 4)
#define ICW4_uPM_8086 (1 << 0)
/* ICW1: Edge triggered (default), cascade mode (deafult), ICW4 is needed */
pic_outb(PIC8259_MASTER_CMD, ICW1_D4_BEGIN_ICW | ICW1_IC4_NEEDED);
pic_outb(PIC8259_SLAVE_CMD, ICW1_D4_BEGIN_ICW | ICW1_IC4_NEEDED);
/* ICW2: Fully nexted mode (default), vector offset (rebase) */
pic_outb(PIC8259_MASTER_DATA, moffset);
pic_outb(PIC8259_SLAVE_DATA, soffset);
pic_outb(PIC8259_MASTER_DATA, (1 << 2));
pic_outb(PIC8259_SLAVE_DATA, 2);
/* ICW4: Non-buffered mode (default), EOI required (default), 8086 mode */
pic_outb(PIC8259_MASTER_DATA, ICW4_uPM_8086);
pic_outb(PIC8259_SLAVE_DATA, ICW4_uPM_8086);
Any ideas?