VIA: public method for asserting control lines.

This commit is contained in:
Maxim Poliakovski 2022-01-21 11:08:32 +01:00
parent d8c3cfc38e
commit 4867a68e11
2 changed files with 33 additions and 1 deletions

View File

@ -70,6 +70,7 @@ ViaCuda::ViaCuda() {
// PRAM is part of Cuda // PRAM is part of Cuda
this->pram_obj = std::unique_ptr<NVram> (new NVram("pram.bin", 256)); this->pram_obj = std::unique_ptr<NVram> (new NVram("pram.bin", 256));
// ADB bus is driven by Cuda
this->adb_bus = std::unique_ptr<ADB_Bus> (new ADB_Bus()); this->adb_bus = std::unique_ptr<ADB_Bus> (new ADB_Bus());
this->cuda_init(); this->cuda_init();
@ -138,6 +139,7 @@ void ViaCuda::write(int reg, uint8_t value) {
LOG_F(9, "VIA_ACR = 0x%X", value); LOG_F(9, "VIA_ACR = 0x%X", value);
break; break;
case VIA_IFR: case VIA_IFR:
// for each "1" in value clear the corresponding flags
this->_via_ifr &= ~value; this->_via_ifr &= ~value;
update_irq(); update_irq();
break; break;
@ -222,6 +224,27 @@ void ViaCuda::assert_t2_int() {
update_irq(); update_irq();
} }
void ViaCuda::assert_ctrl_line(ViaLine line)
{
switch (line) {
case ViaLine::CA1:
this->_via_ifr |= VIA_IF_CA1;
break;
case ViaLine::CA2:
this->_via_ifr |= VIA_IF_CA2;
break;
case ViaLine::CB1:
this->_via_ifr |= VIA_IF_CB1;
break;
case ViaLine::CB2:
this->_via_ifr |= VIA_IF_CB1;
break;
default:
ABORT_F("Assertion of unknown VIA line requested!");
}
update_irq();
}
void ViaCuda::schedule_sr_int(uint64_t timeout_ns) { void ViaCuda::schedule_sr_int(uint64_t timeout_ns) {
if (this->sr_timer_on) { if (this->sr_timer_on) {
TimerManager::get_instance()->cancel_timer(this->sr_timer_id); TimerManager::get_instance()->cancel_timer(this->sr_timer_id);
@ -281,7 +304,7 @@ void ViaCuda::write(uint8_t new_state) {
if (this->in_count < 16) { if (this->in_count < 16) {
this->in_buf[this->in_count++] = this->via_regs[VIA_SR]; this->in_buf[this->in_count++] = this->via_regs[VIA_SR];
// tell the system we've read the byte after 71 usecs // tell the system we've read the byte after 71 usecs
schedule_sr_int(USECS_TO_NSECS(71)); schedule_sr_int(USECS_TO_NSECS(71));
//assert_sr_int(); //assert_sr_int();
} else { } else {
LOG_F(WARNING, "Cuda input buffer too small. Truncating data!"); LOG_F(WARNING, "Cuda input buffer too small. Truncating data!");

View File

@ -84,6 +84,13 @@ enum {
VIA_IF_T1 = 1 << 6 VIA_IF_T1 = 1 << 6
}; };
enum class ViaLine {
CA1,
CA2,
CB1,
CB2
};
/** Cuda communication signals. */ /** Cuda communication signals. */
enum { enum {
CUDA_TIP = 0x20, /* transaction in progress: 0 - true, 1 - false */ CUDA_TIP = 0x20, /* transaction in progress: 0 - true, 1 - false */
@ -154,6 +161,8 @@ public:
uint8_t read(int reg); uint8_t read(int reg);
void write(int reg, uint8_t value); void write(int reg, uint8_t value);
void assert_ctrl_line(ViaLine line);
private: private:
// VIA virtual HW registers // VIA virtual HW registers
uint8_t via_regs[16]; uint8_t via_regs[16];