Add ATAPI commands, clean up formatting.

This commit is contained in:
Maxim Poliakovski 2023-05-15 17:53:00 +02:00
parent 0f8e68d4bf
commit e36150a5ca
3 changed files with 59 additions and 44 deletions

View File

@ -44,27 +44,41 @@ enum {
/** ATA register offsets. */ /** ATA register offsets. */
enum ATA_Reg : int { enum ATA_Reg : int {
DATA = 0x0, DATA = 0x00, // 16-bit data (read & write)
ERROR = 0x1, // error (read) ERROR = 0x01, // error (read)
FEATURES = 0x1, // features (write) FEATURES = 0x01, // features (write)
SEC_COUNT = 0x2, // sector count SEC_COUNT = 0x02, // sector count
SEC_NUM = 0x3, // sector number SEC_NUM = 0x03, // sector number
CYL_LOW = 0x4, // cylinder low CYL_LOW = 0x04, // cylinder low
CYL_HIGH = 0x5, // cylinder high CYL_HIGH = 0x05, // cylinder high
DEVICE_HEAD = 0x6, // device/head DEVICE_HEAD = 0x06, // device/head
STATUS = 0x7, // status (read) STATUS = 0x07, // status (read)
COMMAND = 0x7, // command (write) COMMAND = 0x07, // 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 // Apple ASIC specific timing configuration TIME_CONFIG = 0x20 // Apple ASIC specific timing configuration
};
/** ATAPI specific register offsets. */
enum ATAPI_Reg : int {
INT_REASON = 0x2, // interrupt reason (read-only)
BYTE_COUNT_LO = 0x4, // byte count (bits 0-7)
BYTE_COUNT_HI = 0x5, // byte count (bits 8-15)
};
/** ATAPI Interrupt Reason bits. */
enum ATAPI_Int_Reason : uint8_t {
CoD = 1 << 0,
IO = 1 << 1,
RELEASE = 1 << 2,
}; };
/** Status register bits. */ /** Status register bits. */
enum ATA_Status : int { enum ATA_Status : uint8_t {
ERR = 0x1, ERR = 0x01,
IDX = 0x2, IDX = 0x02,
CORR = 0x4, CORR = 0x04,
DRQ = 0x8, DRQ = 0x08,
DSC = 0x10, DSC = 0x10,
DWF = 0x20, DWF = 0x20,
DRDY = 0x40, DRDY = 0x40,
@ -72,28 +86,28 @@ enum ATA_Status : int {
}; };
/** Error register bits. */ /** Error register bits. */
enum ATA_Error : int { enum ATA_Error : uint8_t {
ANMF = 0x1, //no address mark ANMF = 0x01, //no address mark
TK0NF = 0x2, //track 0 not found TK0NF = 0x02, //track 0 not found
ABRT = 0x4, //abort command ABRT = 0x04, //abort command
MCR = 0x8, MCR = 0x08,
IDNF = 0x10, //id mark not found IDNF = 0x10, //id mark not found
MC = 0x20, //media change request MC = 0x20, //media change request
UNC = 0x40, UNC = 0x40,
BBK = 0x80 //bad block BBK = 0x80, //bad block
}; };
/** Bit definition for the device control register. */ /** Bit definition for the device control register. */
enum ATA_CTRL : int{ enum ATA_CTRL : uint8_t {
IEN = 0x2, IEN = 0x02,
SRST = 0x4, SRST = 0x04,
HOB = 0x80, HOB = 0x80,
}; };
/* ATA commands. */ /* ATA commands. */
enum ATA_Cmd : int { enum ATA_Cmd : uint8_t {
NOP = 0x00, NOP = 0x00,
RESET_ATAPI = 0x08, ATAPI_SOFT_RESET = 0x08,
RECALIBRATE = 0x10, RECALIBRATE = 0x10,
READ_SECTOR = 0x20, READ_SECTOR = 0x20,
READ_SECTOR_NR = 0x21, READ_SECTOR_NR = 0x21,
@ -107,8 +121,9 @@ enum ATA_Cmd : int {
IDE_SEEK = 0x70, IDE_SEEK = 0x70,
DIAGNOSTICS = 0x90, DIAGNOSTICS = 0x90,
INIT_DEV_PARAM = 0x91, INIT_DEV_PARAM = 0x91,
PACKET = 0xA0, ATAPI_PACKET = 0xA0,
IDFY_PKT_DEV = 0xA1, ATAPI_IDFY_DEV = 0xA1,
ATAPI_SERVICE = 0xA2,
READ_MULTIPLE = 0xC4, READ_MULTIPLE = 0xC4,
WRITE_MULTIPLE = 0xC5, WRITE_MULTIPLE = 0xC5,
READ_DMA = 0xC8, READ_DMA = 0xC8,
@ -116,6 +131,7 @@ enum ATA_Cmd : int {
WRITE_BUFFER_DMA = 0xE9, WRITE_BUFFER_DMA = 0xE9,
READ_BUFFER_DMA = 0xEB, READ_BUFFER_DMA = 0xEB,
IDENTIFY_DEVICE = 0xEC, IDENTIFY_DEVICE = 0xEC,
SET_FEATURES = 0xEF,
}; };
}; // namespace ata_interface }; // namespace ata_interface

View File

@ -55,9 +55,6 @@ int AtaHardDisk::perform_command()
switch (this->r_command) { switch (this->r_command) {
case NOP: case NOP:
break; break;
case RESET_ATAPI:
device_reset(true);
break;
case RECALIBRATE: case RECALIBRATE:
hdd_img.seekg(0, std::ios::beg); hdd_img.seekg(0, std::ios::beg);
this->r_error = 0; this->r_error = 0;

View File

@ -1,6 +1,6 @@
/* /*
DingusPPC - The Experimental PowerPC Macintosh emulator DingusPPC - The Experimental PowerPC Macintosh emulator
Copyright (C) 2018-22 divingkatae and maximum Copyright (C) 2018-23 divingkatae and maximum
(theweirdo) spatium (theweirdo) spatium
(Contact divingkatae#1017 or powermax#2286 on Discord for more info) (Contact divingkatae#1017 or powermax#2286 on Discord for more info)
@ -84,21 +84,22 @@ enum ScsiMsg : int {
MESSAGE_END, MESSAGE_END,
}; };
enum ScsiCommand : int { enum ScsiCommand : uint8_t {
TEST_UNIT_READY = 0x0, TEST_UNIT_READY = 0x00,
REWIND = 0x1, REWIND = 0x01,
REQ_SENSE = 0x3, REQ_SENSE = 0x03,
FORMAT = 0x4, FORMAT = 0x04,
READ_BLK_LIMITS = 0x5, READ_BLK_LIMITS = 0x05,
READ_6 = 0x8, READ_6 = 0x08,
WRITE_6 = 0xA, WRITE_6 = 0x0A,
SEEK_6 = 0xB, SEEK_6 = 0x0B,
INQUIRY = 0x12, INQUIRY = 0x12,
VERIFY_6 = 0x13, VERIFY_6 = 0x13,
MODE_SELECT_6 = 0x15, MODE_SELECT_6 = 0x15,
RELEASE_UNIT = 0x17, RELEASE_UNIT = 0x17,
ERASE_6 = 0x19, ERASE_6 = 0x19,
MODE_SENSE_6 = 0x1A, MODE_SENSE_6 = 0x1A,
START_STOP_UNIT = 0x1B,
DIAG_RESULTS = 0x1C, DIAG_RESULTS = 0x1C,
SEND_DIAGS = 0x1D, SEND_DIAGS = 0x1D,
PREVENT_ALLOW_MEDIUM_REMOVAL = 0x1E, PREVENT_ALLOW_MEDIUM_REMOVAL = 0x1E,
@ -107,6 +108,7 @@ enum ScsiCommand : int {
WRITE_10 = 0x2A, WRITE_10 = 0x2A,
VERIFY_10 = 0x2F, VERIFY_10 = 0x2F,
READ_LONG_10 = 0x35, READ_LONG_10 = 0x35,
READ_12 = 0xA8,
// CD-ROM specific commands // CD-ROM specific commands
READ_TOC = 0x43, READ_TOC = 0x43,