--- np2/cbus/ideio.h 2004/08/06 15:03:50 1.4 +++ np2/cbus/ideio.h 2005/04/06 16:46:07 1.10 @@ -1,8 +1,21 @@ #define IDEIO_MULTIPLE_MAX 0 +#define IDEIO_BUFSIZE_MAX 4096 + +#define IDEIO_MEDIA_EJECTABLE (1 << 7) +#define IDEIO_MEDIA_PREVENT (1 << 6) +#define IDEIO_MEDIA_PERSIST (1 << 5) +// (1 << 4) +#define IDEIO_MEDIA_AUDIO (1 << 3) +#define IDEIO_MEDIA_DATA (1 << 2) +#define IDEIO_MEDIA_CHANGED (1 << 1) +#define IDEIO_MEDIA_LOADED (1 << 0) + +#define IDEIO_MEDIA_COMBINE (IDEIO_MEDIA_DATA|IDEIO_MEDIA_AUDIO) typedef struct { UINT8 sxsidrv; + UINT8 wp; UINT8 dr; UINT8 hd; @@ -19,15 +32,34 @@ typedef struct { UINT8 surfaces; UINT8 sectors; UINT8 bufdir; + UINT8 buftc; + // for ATA multiple mode UINT8 mulcnt; UINT8 multhr; UINT8 mulmode; - UINT8 dmy; + // for ATAPI + UINT8 media; + UINT8 sk; // sense key + UINT16 asc; // additional sense code (LSB) & qualifer (MSB) + + UINT32 sector; // アクセスセクタ (LBA) + UINT32 nsectors; // 総セクタ数 + UINT16 secsize; // セクタサイズ + UINT16 dmy; + + // buffer management UINT bufpos; UINT bufsize; - BYTE buf[512]; + UINT8 buf[IDEIO_BUFSIZE_MAX]; + + // audio + UINT daflag; + UINT32 dacurpos; + UINT32 dalength; + UINT dabufrem; + UINT8 dabuf[2352]; } _IDEDRV, *IDEDRV; typedef struct { @@ -37,7 +69,8 @@ typedef struct { typedef struct { UINT8 bank[2]; - UINT8 padding[2]; + UINT8 daplaying; + UINT8 padding; _IDEDEV dev[2]; } IDEIO; @@ -51,11 +84,14 @@ enum { IDEDIR_NONE = 0, IDEDIR_OUT = 1, - IDEDIR_IN = 2 + IDEDIR_IN = 2, + + IDETC_TRANSFEREND = 0, + IDETC_ATAPIREAD = 1 }; // error -// bit7: Bad Block detected +// bit7: Bad Block detected // bit6: Data ECC error // bit4: ID Not Found // bit2: Aborted command @@ -71,13 +107,20 @@ enum { IDEERR_AMNF = 0x01 }; -enum { - IDEINTR_IO = 0x02, - IDEINTR_CD = 0x01 +// interrupt reason (sector count) +// bit7-3: tag +// bit2: bus release +// bit1: input/output +// bit0: command/data +// +enum { + IDEINTR_REL = 0x04, + IDEINTR_IO = 0x02, // 0: host->device, 1: device->host + IDEINTR_CD = 0x01 // 0: data, 1: command }; // status -// bit7: Busy +// bit7: Busy // bit6: Drive Ready // bit5: Drive Write Fault // bit4: Drive Seek Complete @@ -94,16 +137,25 @@ enum { IDESTAT_DRQ = 0x08, IDESTAT_CORR = 0x04, IDESTAT_INDX = 0x02, - IDESTAT_ERR = 0x01 + IDESTAT_ERR = 0x01, + + // for ATAPI PACKET + IDESTAT_DMRD = 0x20, // DMA Ready + IDESTAT_SERV = 0x10, // Service + IDESTAT_CHK = 0x01 }; +// device/head +// bit6: LBA (for read/write sector(s)/multiple) +// bit4: master/slave device select + enum { IDEDEV_LBA = 0x40, IDEDEV_DEV = 0x10 }; // control -// bit2: Software Reset +// bit2: Software Reset // bit1: ~Interrupt Enable enum { @@ -112,7 +164,6 @@ enum { }; - #ifdef __cplusplus extern "C" { #endif @@ -124,6 +175,7 @@ REG16 IOINPCALL ideio_r16(UINT port); void ideio_reset(void); void ideio_bind(void); +void ideio_notify(REG8 sxsidrv, UINT action); #ifdef __cplusplus }