1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-02-16 18:30:32 +00:00

Attempt to support the DMA interface.

This commit is contained in:
Thomas Harte 2022-08-31 15:33:48 -04:00
parent d460f40b13
commit df29a50738
3 changed files with 52 additions and 10 deletions

View File

@ -33,14 +33,10 @@ void NCR5380::write(int address, uint8_t value, bool) {
switch(address & 7) {
case 0:
LOG("[SCSI 0] Set current SCSI bus state to " << PADHEX(2) << int(value));
data_bus_ = value;
data_bus_ = value;
if(dma_request_ && dma_operation_ == DMAOperation::Send) {
// printf("w %02x\n", value);
dma_acknowledge_ = true;
dma_request_ = false;
update_control_output();
bus_.set_device_output(device_id_, bus_output_);
dma_acknowledge(value);
}
break;
@ -143,10 +139,7 @@ uint8_t NCR5380::read(int address, bool) {
LOG("[SCSI 0] Get current SCSI bus state: " << PADHEX(2) << (bus_.get_state() & 0xff));
if(dma_request_ && dma_operation_ == DMAOperation::InitiatorReceive) {
dma_acknowledge_ = true;
dma_request_ = false;
update_control_output();
bus_.set_device_output(device_id_, bus_output_);
return dma_acknowledge();
}
return uint8_t(bus_.get_state());
@ -324,3 +317,27 @@ void NCR5380::set_execution_state(ExecutionState state) {
size_t NCR5380::scsi_id() {
return device_id_;
}
bool NCR5380::dma_request() {
return dma_request_;
}
uint8_t NCR5380::dma_acknowledge() {
const uint8_t bus_state = uint8_t(bus_.get_state());
dma_acknowledge_ = true;
dma_request_ = false;
update_control_output();
bus_.set_device_output(device_id_, bus_output_);
return bus_state;
}
void NCR5380::dma_acknowledge(uint8_t value) {
data_bus_ = value;
dma_acknowledge_ = true;
dma_request_ = false;
update_control_output();
bus_.set_device_output(device_id_, bus_output_);
}

View File

@ -33,6 +33,15 @@ class NCR5380 final: public SCSI::Bus::Observer {
/*! @returns The SCSI ID assigned to this device. */
size_t scsi_id();
/*! @return @c true if DMA request is active; @c false otherwise. */
bool dma_request();
/*! Signals DMA acknowledge with a simultaneous read. */
uint8_t dma_acknowledge();
/*! Signals DMA acknowledge with a simultaneous write. */
void dma_acknowledge(uint8_t);
private:
SCSI::Bus &bus_;

View File

@ -103,6 +103,15 @@ void SCSICard::perform_bus_operation(Select select, bool is_read, uint16_t addre
}
break;
case 0x8:
// DMA acknowledge.
if(is_read) {
*value = ncr5380_.dma_acknowledge();
} else {
ncr5380_.dma_acknowledge(*value);
}
break;
case 0xa:
// RAM and ROM select.
if(!is_read) {
@ -114,6 +123,13 @@ void SCSICard::perform_bus_operation(Select select, bool is_read, uint16_t addre
}
break;
case 0xe:
// DRQ in b7.
if(is_read) {
*value = ncr5380_.dma_request() ? 0x80 : 0x00;
}
break;
default:
printf("Unhandled: %04x %c %02x\n", address, is_read ? 'r' : 'w', *value);
break;