3 * 8259 programmable interrupt controller test program.
4 * (C) 2009-2012 Jonathan Campbell.
5 * Hackipedia DOS library.
7 * This code is licensed under the LGPL.
8 * <insert LGPL legal text here>
10 * Compiles for intended target environments:
11 * - MS-DOS [pure DOS mode, or Windows or OS/2 DOS Box] */
13 /* NTS: As of 2011/02/27 the 8254 routines no longer do cli/sti for us, we are expected
14 * to do them ourself. This is for performance reasons as well as for sanity reasons
15 * should we ever need to use the subroutines from within an interrupt handler */
18 #include <conio.h> /* this is where Open Watcom hides the outp() etc. functions */
24 #include <hw/8259/8259.h>
27 unsigned char ann[128],anni,cc;
30 printf("Polling test. Interrupts that occur will be announced. Hit ESC to exit.\n");
39 if (anni >= sizeof(anni)) break;
47 ann[anni++] = (cc & 7) + 8;
48 if (anni >= sizeof(anni)) break;
56 /* we ate interrupts, so we need to reissue them */
57 for (cc=0;cc < anni;cc++) {
60 case 0: just_int86(0x08,®s,®s); break;
61 case 1: just_int86(0x09,®s,®s); break;
62 case 2: just_int86(0x0A,®s,®s); break;
63 case 3: just_int86(0x0B,®s,®s); break;
64 case 4: just_int86(0x0C,®s,®s); break;
65 case 5: just_int86(0x0D,®s,®s); break;
66 case 6: just_int86(0x0E,®s,®s); break;
67 case 7: just_int86(0x0F,®s,®s); break;
69 case 8: just_int86(0x70,®s,®s); break;
70 case 9: just_int86(0x71,®s,®s); break;
71 case 10: just_int86(0x72,®s,®s); break;
72 case 11: just_int86(0x73,®s,®s); break;
73 case 12: just_int86(0x74,®s,®s); break;
74 case 13: just_int86(0x75,®s,®s); break;
75 case 14: just_int86(0x76,®s,®s); break;
76 case 15: just_int86(0x77,®s,®s); break;
82 for (cc=0;cc < anni;cc++) printf("%u ",ann[cc]);
94 unsigned short irr,isr;
96 printf("Reading IRR/ISR hit ESC to quit\n");
105 irr = p8259_read_IRR(0);
106 irr |= p8259_read_IRR(8) << 8;
107 isr = p8259_read_ISR(0);
108 isr |= p8259_read_ISR(8) << 8;
109 } while ((irr|isr) == 0);
112 if ((irr|isr) != 0) printf("IRR=%04x ISR=%04x\n",irr,isr);
119 printf("8259 test program\n");
121 printf("There does not appear to be a PIC on your system\n");
124 printf("Slave PIC: %s\n",p8259_slave_present ? "yes" : "no");
127 printf(" 1: 8259 poll test\n");
128 printf(" 2: 8259 IRR/ISR\n");
129 printf("ESC: quit\n");