atabasedevice: data transfers to host.

This commit is contained in:
Maxim Poliakovski 2023-11-22 17:00:19 +01:00
parent 4f76a4ead2
commit f2558cd379
3 changed files with 13 additions and 6 deletions

View File

@ -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;

View File

@ -90,7 +90,6 @@ protected:
uint16_t *data_ptr = nullptr;
uint8_t data_buf[512] = {};
int data_pos = 0;
int xfer_cnt = 0;
};

View File

@ -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();