--- np2/cbus/ideio.h 2004/03/26 03:12:37 1.2 +++ np2/cbus/ideio.h 2005/03/05 16:35:49 1.8 @@ -1,6 +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; @@ -17,10 +32,27 @@ typedef struct { UINT8 surfaces; UINT8 sectors; UINT8 bufdir; + UINT8 buftc; + + // for ATA multiple mode + UINT8 mulcnt; + UINT8 multhr; + UINT8 mulmode; + + // 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]; } _IDEDRV, *IDEDRV; typedef struct { @@ -44,11 +76,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 @@ -64,13 +99,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 @@ -87,16 +129,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 { @@ -105,7 +156,6 @@ enum { }; - #ifdef __cplusplus extern "C" { #endif @@ -113,10 +163,11 @@ extern "C" { extern IDEIO ideio; void IOOUTCALL ideio_w16(UINT port, REG16 value); -REG16 IOOUTCALL ideio_r16(UINT port); +REG16 IOINPCALL ideio_r16(UINT port); void ideio_reset(void); void ideio_bind(void); +void ideio_notify(REG8 sxsidrv, UINT action); #ifdef __cplusplus }