diff --git a/devices/common/ata/atabasedevice.cpp b/devices/common/ata/atabasedevice.cpp index 6b1ed2d..86e623c 100644 --- a/devices/common/ata/atabasedevice.cpp +++ b/devices/common/ata/atabasedevice.cpp @@ -62,8 +62,16 @@ void AtaBaseDevice::device_set_signature() { uint16_t AtaBaseDevice::read(const uint8_t reg_addr) { switch (reg_addr) { case ATA_Reg::DATA: - LOG_F(WARNING, "Retrieving data from %s", this->name.c_str()); - return 0xFFFFU; + if (this->has_data()) { + uint16_t ret_data = this->get_data(); + this->xfer_cnt -= 2; + if (this->xfer_cnt <= 0) { + this->r_status &= ~DRQ; + } + return ret_data; + } else { + return 0xFFFFU; + } case ATA_Reg::ERROR: return this->r_error; case ATA_Reg::SEC_COUNT: @@ -77,7 +85,7 @@ uint16_t AtaBaseDevice::read(const uint8_t reg_addr) { case ATA_Reg::DEVICE_HEAD: return this->r_dev_head; case ATA_Reg::STATUS: - // TODO: clear pending interrupt + this->update_intrq(0); return this->r_status; case ATA_Reg::ALT_STATUS: return this->r_status; @@ -90,7 +98,8 @@ uint16_t AtaBaseDevice::read(const uint8_t reg_addr) { void AtaBaseDevice::write(const uint8_t reg_addr, const uint16_t value) { switch (reg_addr) { case ATA_Reg::DATA: - LOG_F(WARNING, "Pushing data to %s", this->name.c_str()); + if (this->has_data()) + LOG_F(WARNING, "Pushing data to %s", this->name.c_str()); break; case ATA_Reg::FEATURES: this->r_features = value; diff --git a/devices/common/ata/atabasedevice.h b/devices/common/ata/atabasedevice.h index 320e8ce..3472986 100644 --- a/devices/common/ata/atabasedevice.h +++ b/devices/common/ata/atabasedevice.h @@ -90,7 +90,6 @@ protected: uint16_t *data_ptr = nullptr; uint8_t data_buf[512] = {}; - int data_pos = 0; int xfer_cnt = 0; }; diff --git a/devices/common/ata/atapibasedevice.cpp b/devices/common/ata/atapibasedevice.cpp index a267234..85c9788 100644 --- a/devices/common/ata/atapibasedevice.cpp +++ b/devices/common/ata/atapibasedevice.cpp @@ -162,7 +162,6 @@ int AtapiBaseDevice::perform_command() { this->data_buf[0] = 0xC0; this->data_buf[1] = 0x85; this->data_ptr = (uint16_t *)this->data_buf; - this->data_pos = 0; this->xfer_cnt = 512; this->status_expected = false; this->data_out_phase();