|
|
| version 1.9, 2003/12/25 19:58:24 | version 1.15, 2004/03/05 04:39:59 |
|---|---|
| Line 6 | Line 6 |
| static const _PICITEM def_master = { | static const _PICITEM def_master = { |
| 0, {0, 0, 0, 0, 0, 0, 0, 0}, | 0, {0, 0, 0, 0, 0, 0, 0, 0}, |
| 0, {0, 0, 0, 0, 0, 0, 0, 0}, | |
| {7, 6, 5, 4, 3, 2, 1, 0}, | {7, 6, 5, 4, 3, 2, 1, 0}, |
| {0, 0x08, 0x00, 0}, | {0, 0x08, 0x00, 0}, |
| 0x7d, 0, 0, 0, | 0x7d, 0, 0, 0, |
| Line 14 static const _PICITEM def_master = { | Line 13 static const _PICITEM def_master = { |
| static const _PICITEM def_slave = { | static const _PICITEM def_slave = { |
| 0, {0, 0, 0, 0, 0, 0, 0, 0}, | 0, {0, 0, 0, 0, 0, 0, 0, 0}, |
| 0, {0, 0, 0, 0, 0, 0, 0, 0}, | |
| {7, 6, 5, 4, 3, 2, 1, 0}, | {7, 6, 5, 4, 3, 2, 1, 0}, |
| {0, 0x10, 0x07, 0}, | {0, 0x10, 0x07, 0}, |
| 0x70, 0, 0, 0, | 0x71, 0, 0, 0, |
| 0, 0, 0, 0}; | 0, 0, 0, 0}; |
| // ------------------------------------------------------------ ext. interrupt | // ---- |
| // 外部でISRを待避する割り込み対策 | |
| void extirq_push(void) { | |
| PIC p; | |
| p = &pic; | |
| if (!p->ext_irq) { | |
| p->ext_irq = 1; | |
| p->pi[0].levelsbak = p->pi[0].levels; | |
| *(UINT32 *)(p->pi[0].levelbak+0) = *(UINT32 *)(p->pi[0].level+0); | |
| *(UINT32 *)(p->pi[0].levelbak+4) = *(UINT32 *)(p->pi[0].level+4); | |
| p->pi[0].isrbak = p->pi[0].isr; | |
| p->pi[1].levelsbak = p->pi[1].levels; | |
| *(UINT32 *)(p->pi[1].levelbak+0) = *(UINT32 *)(p->pi[1].level+0); | |
| *(UINT32 *)(p->pi[1].levelbak+4) = *(UINT32 *)(p->pi[1].level+4); | |
| p->pi[1].isrbak = p->pi[1].isr; | |
| } | |
| } | |
| void extirq_pop(void) { | |
| PIC p; | |
| p = &pic; | |
| if (p->ext_irq) { | |
| p->ext_irq = 0; | |
| p->pi[0].levels = p->pi[0].levelsbak; | |
| *(UINT32 *)(p->pi[0].level+0) = *(UINT32 *)(p->pi[0].levelbak+0); | |
| *(UINT32 *)(p->pi[0].level+4) = *(UINT32 *)(p->pi[0].levelbak+4); | |
| p->pi[0].isr = p->pi[0].isrbak; | |
| p->pi[1].levels = p->pi[1].levelsbak; | |
| *(UINT32 *)(p->pi[1].level+0) = *(UINT32 *)(p->pi[1].levelbak+0); | |
| *(UINT32 *)(p->pi[1].level+4) = *(UINT32 *)(p->pi[1].levelbak+4); | |
| p->pi[1].isr = p->pi[1].isrbak; | |
| } | |
| } | |
| // --------------------------- | |
| static void pic_rolpry(PICITEM pi) { | static void pic_rolpry(PICITEM pi) { |
| Line 121 void pic_irq(void) { | Line 73 void pic_irq(void) { |
| p = &pic; | p = &pic; |
| // 割込み許可で 要求あり? | // 割込み許可で 要求あり? |
| if ((CPU_isEI) && (!p->ext_irq) && | if ((CPU_isEI) && |
| ((p->pi[0].irr & (~p->pi[0].imr)) || | ((p->pi[0].irr & (~p->pi[0].imr)) || |
| (p->pi[1].irr & (~p->pi[1].imr)))) { | (p->pi[1].irr & (~p->pi[1].imr)))) { |
| // マスターの処理 | // マスターの処理 |
| Line 161 void pic_irq(void) { | Line 113 void pic_irq(void) { |
| // マスタの割込 | // マスタの割込 |
| if (irq != sirq) { | if (irq != sirq) { |
| if (targetbit) { | if (targetbit) { |
| if (p->pi[0].ext & targetbit) { // ver0.30 | |
| extirq_push(); | |
| } | |
| p->pi[0].isr |= targetbit; | p->pi[0].isr |= targetbit; |
| p->pi[0].irr &= ~targetbit; | p->pi[0].irr &= ~targetbit; |
| p->pi[0].level[p->pi[0].levels++] = irq; | p->pi[0].level[p->pi[0].levels++] = irq; |
| Line 200 void pic_irq(void) { | Line 149 void pic_irq(void) { |
| // スレーヴの割込 | // スレーヴの割込 |
| if (targetbit) { | if (targetbit) { |
| if (!(p->pi[0].icw[2] & targetbit)) { | if (!(p->pi[0].icw[2] & targetbit)) { |
| if (p->pi[1].ext & targetbit) { // ver0.30 | |
| extirq_push(); | |
| } | |
| p->pi[1].isr |= targetbit; | p->pi[1].isr |= targetbit; |
| p->pi[1].irr &= ~targetbit; | p->pi[1].irr &= ~targetbit; |
| p->pi[1].level[p->pi[1].levels++] = irq; | p->pi[1].level[p->pi[1].levels++] = irq; |
| Line 245 void pic_setirq(REG8 irq) { | Line 191 void pic_setirq(REG8 irq) { |
| if ((pit.mode[0] & 0x0c) == 0x04) { | if ((pit.mode[0] & 0x0c) == 0x04) { |
| SINT32 cnt; // ver0.29 | SINT32 cnt; // ver0.29 |
| if (pit.value[0] > 8) { | if (pit.value[0] > 8) { |
| cnt = pc.multiple * pit.value[0]; | cnt = pccore.multiple * pit.value[0]; |
| cnt >>= 2; | cnt >>= 2; |
| } | } |
| else { | else { |
| cnt = pc.multiple << (16 - 2); | cnt = pccore.multiple << (16 - 2); |
| } | } |
| nevent_set(NEVENT_PICMASK, cnt, picmask, NEVENT_ABSOLUTE); | nevent_set(NEVENT_PICMASK, cnt, picmask, NEVENT_ABSOLUTE); |
| } | } |
| Line 275 void pic_resetirq(REG8 irq) { | Line 221 void pic_resetirq(REG8 irq) { |
| pi->irr &= ~(1 << (irq & 7)); | pi->irr &= ~(1 << (irq & 7)); |
| } | } |
| void pic_registext(REG8 irq) { | |
| PICITEM pi; | |
| pi = pic.pi + ((irq >> 3) & 1); | |
| pi->ext |= (1 << (irq & 7)); | |
| } | |
| // ---- I/O | // ---- I/O |
| Line 337 static void IOOUTCALL pic_o00(UINT port, | Line 275 static void IOOUTCALL pic_o00(UINT port, |
| } | } |
| } | } |
| #if defined(TRACE) | |
| extern int piccnt; | |
| #endif | |
| static void IOOUTCALL pic_o02(UINT port, REG8 dat) { | static void IOOUTCALL pic_o02(UINT port, REG8 dat) { |
| PICITEM picp; | PICITEM picp; |
| Line 348 static void IOOUTCALL pic_o02(UINT port, | Line 282 static void IOOUTCALL pic_o02(UINT port, |
| // TRACEOUT(("pic %x %x", port, dat)); | // TRACEOUT(("pic %x %x", port, dat)); |
| picp = &pic.pi[(port >> 3) & 1]; | picp = &pic.pi[(port >> 3) & 1]; |
| if (!picp->writeicw) { | if (!picp->writeicw) { |
| #if 1 // マスクのセットだけなら nevent_forceexit()をコールしない | #if 1 |
| if ((CPU_isDI) || (pic.ext_irq) || | UINT8 set; |
| ((picp->imr & dat) == picp->imr)) { | set = picp->imr & (~dat); |
| picp->imr = dat; | |
| return; | |
| } | |
| // リセットされたビットは割り込みある? | // リセットされたビットは割り込みある? |
| if (!(picp->irr & (picp->imr & (~dat)))) { | if ((CPU_isDI) || (!(picp->irr & set))) { |
| picp->imr = dat; | picp->imr = dat; |
| return; | return; |
| } | } |
| #endif | #endif |
| picp->imr = dat; | picp->imr = dat; |
| #if defined(TRACE) | |
| piccnt++; | |
| #endif | |
| } | } |
| else { | else { |
| picp->icw[picp->writeicw] = dat; | picp->icw[picp->writeicw] = dat; |
| Line 413 void pic_reset(void) { | Line 341 void pic_reset(void) { |
| pic.pi[0] = def_master; | pic.pi[0] = def_master; |
| pic.pi[1] = def_slave; | pic.pi[1] = def_slave; |
| pic.ext_irq = 0; | |
| } | } |
| void pic_bind(void) { | void pic_bind(void) { |