1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-27 01:31:42 +00:00

Starts trying to make sense of interrupts.

This commit is contained in:
Thomas Harte 2019-10-23 23:09:49 -04:00
parent f09a240e6c
commit 77f14fa638
2 changed files with 68 additions and 4 deletions

View File

@ -26,10 +26,18 @@ uint8_t MFP68901::read(int address) {
case 0x02:
LOG("Read: data direction " << PADHEX(2) << int(gpip_direction_));
return gpip_direction_;
case 0x03: LOG("Read: interrupt enable A"); break;
case 0x04: LOG("Read: interrupt enable B"); break;
case 0x05: LOG("Read: interrupt pending A"); break;
case 0x06: LOG("Read: interrupt pending B"); break;
case 0x03:
LOG("Read: interrupt enable A");
return interrupt_enable_[0];
case 0x04:
LOG("Read: interrupt enable B");
return interrupt_enable_[1];
case 0x05:
LOG("Read: interrupt pending A");
return interrupt_pending_[0];
case 0x06:
LOG("Read: interrupt pending B");
return interrupt_pending_[1];
case 0x07: LOG("Read: interrupt in-service A"); break;
case 0x08: LOG("Read: interrupt in-service B"); break;
case 0x09: LOG("Read: interrupt mask A"); break;
@ -209,3 +217,18 @@ void MFP68901::reevaluate_gpip_interrupts() {
}
gpip_interrupt_state_ = gpip_state;
}
// MARK: - Interrupts
void MFP68901::begin_interrupt(Interrupt interrupt) {
// In service is always set.
interrupt_in_service_[interrupt >> 3] |= 1 << (interrupt & 7);
// Pending is set only if the interrupt is enabled.
// interrupt_pending_[interrupt >> 3] |=
}
void MFP68901::end_interrupt(Interrupt interrupt) {
// Reset in-service and pending.
}

View File

@ -63,6 +63,47 @@ class MFP68901 {
uint8_t gpip_interrupt_state_ = 0;
void reevaluate_gpip_interrupts();
// MARK: - Interrupts
// Ad hoc documentation: there seems to be a four-stage process here.
// This is my current understanding:
//
// Interrupt in-service refers to whether the signal that would cause an
// interrupt is active.
//
// If the interrupt is in-service and enabled, it will be listed as pending.
//
// If a pending interrupt is enabled in the interrupt mask, it will generate
// a processor interrupt.
//
// So, the designers seem to have wanted to allow for polling and interrupts,
// and then also decided to have some interrupts be able to be completely
// disabled, so that don't even show up for polling.
uint8_t interrupt_in_service_[2] = {0, 0};
uint8_t interrupt_enable_[2] = {0, 0};
uint8_t interrupt_pending_[2] = {0, 0};
uint8_t interrupt_mask_[2] = {0, 0};
enum Interrupt {
GPIP0 = 0,
GPIP1,
GPIP2,
GPIP3,
TimerD,
TimerC,
GPIP4,
GPIP5,
TimerB,
TransmitError,
TransmitBufferEmpty,
ReceiveError,
ReceiveBufferFull,
GPIP6,
GPIP7
};
void begin_interrupt(Interrupt interrupt);
void end_interrupt(Interrupt interrupt);
};
}