mirror of
https://github.com/dingusdev/dingusppc.git
synced 2024-07-31 00:28:58 +00:00
atabasedevice: add ATAPI signature at device reset.
This commit is contained in:
parent
52bb87b72a
commit
dee225ee8f
@ -38,7 +38,7 @@ AtaBaseDevice::AtaBaseDevice(const std::string name)
|
|||||||
device_reset();
|
device_reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtaBaseDevice::device_reset()
|
void AtaBaseDevice::device_reset(const uint8_t dev_head_val)
|
||||||
{
|
{
|
||||||
this->r_error = 1; // Device 0 passed, Device 1 passed or not present
|
this->r_error = 1; // Device 0 passed, Device 1 passed or not present
|
||||||
|
|
||||||
@ -46,12 +46,18 @@ void AtaBaseDevice::device_reset()
|
|||||||
this->r_sect_num = 1;
|
this->r_sect_num = 1;
|
||||||
this->r_dev_ctrl = 0;
|
this->r_dev_ctrl = 0;
|
||||||
|
|
||||||
// set ATA protocol signature
|
// set protocol signature
|
||||||
|
if (this->device_type == DEVICE_TYPE_ATAPI) {
|
||||||
|
this->r_cylinder_lo = 0x14;
|
||||||
|
this->r_cylinder_hi = 0xEB;
|
||||||
|
this->r_dev_head = dev_head_val;
|
||||||
|
} else { // assume ATA by default
|
||||||
this->r_cylinder_lo = 0;
|
this->r_cylinder_lo = 0;
|
||||||
this->r_cylinder_hi = 0;
|
this->r_cylinder_hi = 0;
|
||||||
this->r_dev_head = 0; // TODO: ATAPI devices shouldn't change this reg!
|
this->r_dev_head = 0;
|
||||||
this->r_status = DRDY | DSC;
|
this->r_status = DRDY | DSC;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint16_t AtaBaseDevice::read(const uint8_t reg_addr) {
|
uint16_t AtaBaseDevice::read(const uint8_t reg_addr) {
|
||||||
switch (reg_addr) {
|
switch (reg_addr) {
|
||||||
|
@ -42,13 +42,14 @@ public:
|
|||||||
|
|
||||||
int get_device_id() { return this->my_dev_id; };
|
int get_device_id() { return this->my_dev_id; };
|
||||||
|
|
||||||
void device_reset();
|
void device_reset(const uint8_t dev_head_val = 0);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool is_selected() { return ((this->r_dev_head >> 4) & 1) == this->my_dev_id; };
|
bool is_selected() { return ((this->r_dev_head >> 4) & 1) == this->my_dev_id; };
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint8_t my_dev_id = 0; // my IDE device ID configured by the host
|
uint8_t my_dev_id = 0; // my IDE device ID configured by the host
|
||||||
|
uint8_t device_type = ata_interface::DEVICE_TYPE_UNKNOWN;
|
||||||
|
|
||||||
// IDE aka task file registers
|
// IDE aka task file registers
|
||||||
uint8_t r_error;
|
uint8_t r_error;
|
||||||
|
@ -35,6 +35,13 @@ enum {
|
|||||||
DEVICE_ID_ONE = 1
|
DEVICE_ID_ONE = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Device types. */
|
||||||
|
enum {
|
||||||
|
DEVICE_TYPE_UNKNOWN = -1,
|
||||||
|
DEVICE_TYPE_ATA = 0,
|
||||||
|
DEVICE_TYPE_ATAPI = 1,
|
||||||
|
};
|
||||||
|
|
||||||
/** ATA register offsets. */
|
/** ATA register offsets. */
|
||||||
enum ATA_Reg : int {
|
enum ATA_Reg : int {
|
||||||
DATA = 0x0,
|
DATA = 0x0,
|
||||||
@ -49,7 +56,7 @@ enum ATA_Reg : int {
|
|||||||
COMMAND = 0x7, // command (write)
|
COMMAND = 0x7, // command (write)
|
||||||
ALT_STATUS = 0x16, // alt status (read)
|
ALT_STATUS = 0x16, // alt status (read)
|
||||||
DEV_CTRL = 0x16, // device control (write)
|
DEV_CTRL = 0x16, // device control (write)
|
||||||
TIME_CONFIG = 0x20
|
TIME_CONFIG = 0x20 // Apple ASIC specific timing configuration
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Status register bits. */
|
/** Status register bits. */
|
||||||
|
@ -41,7 +41,7 @@ void AtaHardDisk::insert_image(std::string filename) {
|
|||||||
if (!rc) {
|
if (!rc) {
|
||||||
this->img_size = stat_buf.st_size;
|
this->img_size = stat_buf.st_size;
|
||||||
} else {
|
} else {
|
||||||
ABORT_F("ScsiHardDisk: could not determine file size using stat()");
|
ABORT_F("AtaHardDisk: could not determine file size using stat()");
|
||||||
}
|
}
|
||||||
this->hdd_img.seekg(0, std::ios_base::beg);
|
this->hdd_img.seekg(0, std::ios_base::beg);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user