/* functions for the 8259 pic. test */ #include FIO stdout; /* external variables */ int base = 0x60; /* remove when in mult3 prog */ char level = 'y'; /* level or edge triggered */ char addint = 's'; /* address interval */ char single = 'y'; /* single or multiple */ char icw4 = 'n'; /* icw4 needed */ char fulnst = 'n'; /* fully nested mode */ char buffed = 'n'; /* buffered or sp/en mode */ char ms = 'm'; /* master/slave */ char aeoi = 'n'; /* automatic end of interrupt */ unsigned char jtable[128] = 0; /* jump table */ unsigned char *addr = 0; /* 32 byte boundry address */ main() { intint(); /* initialize interrupt chip */ } intint() /* initialize interrupter */ { int icw1,icw2,ocw1; jumploc(); /* locate addr of jump table */ icw1 = (unsigned)(addr) & 0xe0; /* mask off 5 lsbs */ if(icw4 == 'y') /* is icw4 needed */ icw1 |= 1; /* set bit 0 high */ if(single == 'y') /* is this the only pic */ icw1 |= 2; /* set bit 1 high */ if(addint == 's') /* short or long interval */ icw1 |= 4; /* set bit 2 high */ if(level == 'y') /* level triggered */ icw1 |= 8; /* set bit 3 high */ icw1 |= 0x10; /* set bit 4 high for icw1 */ icw2 = (unsigned)(addr) >> 8; /* set up icw2 */ out(base+4,icw1); /* issue first icw */ out(base+5,icw2); /* issue second icw */ ocw1 = 0xff; /* mask off all interrupts */ out(base+5,ocw1); /* issue first ocw */ } int1() /* first interrupt routine */ { } int2() /* second interrupt routine */ { } int3() /* third interrupt routine */ { } int4() /* forth interrupt routine */ { } int5() /* fifth interrupt routine */ { } int6() /* sixth interrupt routine */ { } int7() /* seventh interrupt routine */ { } int8() /* eighth interrupt routine */ { } jumploc() /* locate the 32 byte boundry in the array jtable */ { int i; int routine[8]; unsigned char *rout; routine[0] = int1; /* load int1 addr in routine[0] */ routine[1] = int2; /* load int2 addr in routine[1] */ routine[2] = int3; /* load int3 addr in routine[2] */ routine[3] = int4; /* load int4 addr in routine[3] */ routine[4] = int5; /* load int5 addr in routine[4] */ routine[5] = int6; /* load int6 addr in routine[5] */ routine[6] = int7; /* load int7 addr in routine[6] */ routine[7] = int8; /* load int8 addr in routine[7] */ addr = (unsigned)(jtable) & 0x3f; /* check for 32 byte bound */ if(addr == 0x20) addr = jtable; else addr = ((unsigned)(jtable) & ~0x1f) + 0x20; /* force it */ for( i = 0 ; i < 8 ; ++i) { rout = addr +(i * 4); *rout = 0xc3; /* jump machine code */ *(rout+1) = routine[i] & 0xff; /* low addr of jump */ *(rout+2) = routine[i] >> 8; /* high addr of jump */ } for( i = 0; i < 8; ++i) { putfmt("jump=%h ",addr[i * 4]); putfmt("low addr=%h ",addr[(i * 4) + 1]); putfmt("high addr=%h\n",addr[(i * 4) + 2]); } }