Fix Cuda response protocol.

This commit is contained in:
Maxim Poliakovski 2023-02-08 21:26:11 +01:00
parent 7e5451a97d
commit 094b3b5312
2 changed files with 8 additions and 17 deletions

View File

@ -93,8 +93,8 @@ int ViaCuda::device_postinit()
} }
void ViaCuda::cuda_init() { void ViaCuda::cuda_init() {
this->old_tip = 0; this->old_tip = 1;
this->old_byteack = 0; this->old_byteack = 1;
this->treq = 1; this->treq = 1;
this->in_count = 0; this->in_count = 0;
this->out_count = 0; this->out_count = 0;
@ -260,10 +260,6 @@ void ViaCuda::update_irq()
} }
} }
inline bool ViaCuda::ready() {
return ((this->via_regs[VIA_DIRB] & 0x38) == 0x30);
}
void ViaCuda::assert_sr_int() { void ViaCuda::assert_sr_int() {
this->sr_timer_on = false; this->sr_timer_on = false;
this->_via_ifr |= VIA_IF_SR; this->_via_ifr |= VIA_IF_SR;
@ -322,11 +318,6 @@ void ViaCuda::schedule_sr_int(uint64_t timeout_ns) {
} }
void ViaCuda::write(uint8_t new_state) { void ViaCuda::write(uint8_t new_state) {
if (!ready()) {
LOG_F(WARNING, "Cuda not ready!");
return;
}
int new_tip = !!(new_state & CUDA_TIP); int new_tip = !!(new_state & CUDA_TIP);
int new_byteack = !!(new_state & CUDA_BYTEACK); int new_byteack = !!(new_state & CUDA_BYTEACK);
@ -348,8 +339,12 @@ void ViaCuda::write(uint8_t new_state) {
process_packet(); process_packet();
/* start response transaction */ /* start response transaction */
this->via_regs[VIA_B] &= ~CUDA_TREQ; /* assert TREQ */ TimerManager::get_instance()->add_oneshot_timer(
this->treq = 0; USECS_TO_NSECS(13), // delay TREQ assertion for New World
[this]() {
this->via_regs[VIA_B] &= ~CUDA_TREQ; // assert TREQ
this->treq = 0;
});
} }
this->in_count = 0; this->in_count = 0;
@ -362,7 +357,6 @@ void ViaCuda::write(uint8_t new_state) {
} }
// send dummy byte as idle acknowledge or attention // send dummy byte as idle acknowledge or attention
//assert_sr_int();
schedule_sr_int(USECS_TO_NSECS(61)); schedule_sr_int(USECS_TO_NSECS(61));
} else { } else {
if (this->via_regs[VIA_ACR] & 0x10) { /* data transfer: Host --> Cuda */ if (this->via_regs[VIA_ACR] & 0x10) { /* data transfer: Host --> Cuda */
@ -370,13 +364,11 @@ void ViaCuda::write(uint8_t new_state) {
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();
} else { } else {
LOG_F(WARNING, "Cuda input buffer too small. Truncating data!"); LOG_F(WARNING, "Cuda input buffer too small. Truncating data!");
} }
} else { /* data transfer: Cuda --> Host */ } else { /* data transfer: Cuda --> Host */
(this->*out_handler)(); (this->*out_handler)();
//assert_sr_int();
// tell the system we've written next byte after 88 usecs // tell the system we've written next byte after 88 usecs
schedule_sr_int(USECS_TO_NSECS(88)); schedule_sr_int(USECS_TO_NSECS(88));
} }

View File

@ -237,7 +237,6 @@ private:
// CUDA methods // CUDA methods
void cuda_init(); void cuda_init();
bool ready();
void write(uint8_t new_state); void write(uint8_t new_state);
void response_header(uint32_t pkt_type, uint32_t pkt_flag); void response_header(uint32_t pkt_type, uint32_t pkt_flag);
void error_response(uint32_t error); void error_response(uint32_t error);