
/* Misc. PIC definitions */

#define NUMBER_PICS      3   // Tricord has 3 PICs

#define NUM_IRQ_PER_PIC  8
#define NUM_IRQ          (NUMBER_PICS * NUM_IRQ_PER_PIC)
#define MAX_IRQ          32
#define PIC_SLAVE_IRQ    2
#define PIC3_SLAVE_IRQ   5    // for third PIC for tricrd

#define PIC1_BASE        0x50
#define PIC2_BASE        0x70
#define PIC3_BASE        0x30  // Tricord 3rd PIC

#define ICW1             (ICW1_ICW | ICW1_EDGE_TRIG | ICW1_INTERVAL8 | \
                          ICW1_CASCADE | ICW1_ICW4_NEEDED)

#define MASTER_ICW2      (PIC1_BASE)
#define SLAVE_ICW2       (PIC2_BASE)
#define PIC3_ICW2        (PIC3_BASE)

// Tricord use IRQ 2 and IRQ 5 to cascade

#define MASTER_ICW3      (1 << PIC_SLAVE_IRQ) | (1 << PIC3_SLAVE_IRQ)
#define SLAVE_ICW3       (PIC_SLAVE_IRQ)
#define PIC3_ICW3        (PIC3_SLAVE_IRQ)

#define ICW4             (ICW4_NOT_SPEC_FULLY_NESTED | ICW4_NON_BUF_MODE | \
                          ICW4_NORM_EOI | ICW4_8086_MODE)

#define PIC3_ICW4        (ICW4_NOT_SPEC_FULLY_NESTED | ICW4_BUF_MODE_SLAVE | \
                          ICW4_NORM_EOI | ICW4_8086_MODE)

/* PIC port definitions */

#define PIC1_PORT0     0x20          // Master PIC
#define PIC1_PORT1     0x21
#define PIC2_PORT0     0xA0          // Slave PIC
#define PIC2_PORT1     0xA1

#define PIC3_PORT0   0xCC0           // Tricord 3rd PIC
#define PIC3_PORT1   0xCC1

/* Initialization control words equates for the PIC */

#define ICW1_ICW4_NEEDED            0x01
#define ICW1_NO_ICW4_NEEDED         0x00
#define ICW1_SINGLE                 0x02
#define ICW1_CASCADE                0x00
#define ICW1_INTERVAL4              0x04
#define ICW1_INTERVAL8              0x00
#define ICW1_LEVEL_TRIG             0x08
#define ICW1_EDGE_TRIG              0x00
#define ICW1_ICW                    0x10

#define ICW4_8086_MODE              0x01
#define ICW4_8085_MODE              0x00
#define ICW4_AUTO_EOI               0x02
#define ICW4_NORM_EOI               0x00
#define ICW4_NON_BUF_MODE           0x00
#define ICW4_BUF_MODE_SLAVE         0x08
#define ICW4_BUF_MODE_MASTER        0x0C
#define ICW4_SPEC_FULLY_NESTED      0x10
#define ICW4_NOT_SPEC_FULLY_NESTED  0x00


/* Output Control Words for the 8259 PIC */

#define OCW2_NON_SPECIFIC_EOI        0x20
#define OCW2_SPECIFIC_EOI            0x60
#define OCW2_SET_PRIORITY            0xC0

#define OCW3_READ_IRR                0x0A
#define OCW3_READ_ISR                0x0B

/* IRQ Numbers */

#define IRQ0   0
#define IRQ1   1
#define IRQ2   2
#define IRQ3   3
#define IRQ4   4
#define IRQ5   5
#define IRQ6   6
#define IRQ7   7

#define IRQ8   8
#define IRQ9   9
#define IRQA   10
#define IRQB   11
#define IRQC   12
#define IRQD   13
#define IRQE   14
#define IRQF   15

#define IRQ10  16
#define IRQ11  17
#define IRQ12  18
#define IRQ13  19
#define IRQ14  20
#define IRQ15  21
#define IRQ16  22
#define IRQ17  23

#define IRQ18  24
#define IRQ19  25
#define IRQ1A  26
#define IRQ1B  27
#define IRQ1C  28
#define IRQ1D  29
#define IRQ1E  30
#define IRQ1F  31

