|
|
1.1 ! root 1: #ifndef IDE_H ! 2: #define IDE_H ! 3: ! 4: #include "hdreg.h" ! 5: ! 6: /* ! 7: * legacy ide ports ! 8: */ ! 9: #define IDEREG_DATA 0x00 ! 10: #define IDEREG_ERROR 0x01 ! 11: #define IDEREG_FEATURE IDEREG_ERROR ! 12: #define IDEREG_NSECTOR 0x02 ! 13: #define IDEREG_SECTOR 0x03 ! 14: #define IDEREG_LCYL 0x04 ! 15: #define IDEREG_HCYL 0x05 ! 16: #define IDEREG_CURRENT 0x06 ! 17: #define IDEREG_STATUS 0x07 ! 18: #define IDEREG_COMMAND IDEREG_STATUS ! 19: #define IDEREG_CONTROL 0x08 ! 20: #define IDEREG_ASTATUS IDEREG_CONTROL ! 21: ! 22: /* ! 23: * device control bits ! 24: */ ! 25: #define IDECON_NIEN 0x02 ! 26: #define IDECON_SRST 0x04 ! 27: ! 28: /* ! 29: * device head bits ! 30: */ ! 31: #define IDEHEAD_LBA 0x40 ! 32: #define IDEHEAD_DEV0 0x00 ! 33: #define IDEHEAD_DEV1 0x10 ! 34: ! 35: /* ! 36: * status bytes ! 37: */ ! 38: #define ERR_STAT 0x01 ! 39: #define DRQ_STAT 0x08 ! 40: #define SEEK_STAT 0x10 ! 41: #define WRERR_STAT 0x20 ! 42: #define READY_STAT 0x40 ! 43: #define BUSY_STAT 0x80 ! 44: ! 45: #define IREASON_CD 0x01 ! 46: #define IREASON_IO 0x02 ! 47: ! 48: /* ! 49: * ATA opcodes ! 50: */ ! 51: #define WIN_READ 0x20 ! 52: #define WIN_READ_EXT 0x24 ! 53: #define WIN_IDENTIFY 0xEC ! 54: #define WIN_PACKET 0xA0 ! 55: #define WIN_IDENTIFY_PACKET 0xA1 ! 56: ! 57: /* ! 58: * ATAPI opcodes ! 59: */ ! 60: #define ATAPI_TUR 0x00 ! 61: #define ATAPI_READ_10 0x28 ! 62: #define ATAPI_REQ_SENSE 0x03 ! 63: #define ATAPI_START_STOP_UNIT 0x1b ! 64: #define ATAPI_READ_CAPACITY 0x25 ! 65: ! 66: /* ! 67: * atapi sense keys ! 68: */ ! 69: #define ATAPI_SENSE_NOT_READY 0x02 ! 70: ! 71: /* ! 72: * supported device types ! 73: */ ! 74: enum { ! 75: ide_type_unknown, ! 76: ide_type_ata, ! 77: ide_type_atapi, ! 78: }; ! 79: ! 80: enum { ! 81: ide_media_floppy = 0x00, ! 82: ide_media_cdrom = 0x05, ! 83: ide_media_optical = 0x07, ! 84: ide_media_disk = 0x20, ! 85: }; ! 86: ! 87: /* ! 88: * drive addressing ! 89: */ ! 90: enum { ! 91: ide_chs = 1, ! 92: ide_lba28, ! 93: ide_lba48, ! 94: }; ! 95: ! 96: /* ! 97: * simple ata command that works for everything (except 48-bit lba commands) ! 98: */ ! 99: struct ata_command { ! 100: unsigned char *buffer; ! 101: unsigned int buflen; ! 102: ! 103: /* ! 104: * data register ! 105: */ ! 106: unsigned char data; ! 107: unsigned char feature; ! 108: unsigned char nsector; ! 109: unsigned char sector; ! 110: unsigned char lcyl; ! 111: unsigned char hcyl; ! 112: unsigned char device_head; ! 113: unsigned char command; ! 114: unsigned char control; ! 115: ! 116: /* ! 117: * or tasklet, just for lba48 for now (above could be scrapped) ! 118: */ ! 119: unsigned char task[10]; ! 120: ! 121: /* ! 122: * output ! 123: */ ! 124: unsigned char stat; ! 125: unsigned int bytes; ! 126: }; ! 127: ! 128: struct atapi_command { ! 129: unsigned char cdb[12]; ! 130: unsigned char *buffer; ! 131: unsigned int buflen; ! 132: unsigned char data_direction; ! 133: ! 134: unsigned char stat; ! 135: unsigned char sense_valid; ! 136: struct request_sense sense; ! 137: unsigned char old_cdb; ! 138: }; ! 139: ! 140: struct ide_channel; ! 141: ! 142: struct ide_drive { ! 143: char unit; /* 0: master, 1: slave */ ! 144: char present; /* there or not */ ! 145: char type; /* ata or atapi */ ! 146: char media; /* disk, cdrom, etc */ ! 147: char addressing; /* chs/lba28/lba48 */ ! 148: ! 149: char model[41]; /* name */ ! 150: int nr; ! 151: ! 152: unsigned long sectors; ! 153: ! 154: unsigned int max_sectors; ! 155: ! 156: /* ! 157: * for legacy chs crap ! 158: */ ! 159: unsigned int cyl; ! 160: unsigned int head; ! 161: unsigned int sect; ! 162: ! 163: unsigned int bs; /* block size */ ! 164: ! 165: struct ide_channel *channel; ! 166: }; ! 167: ! 168: struct ide_channel { ! 169: ! 170: char name[32]; ! 171: struct ide_channel *next; ! 172: ! 173: /* ! 174: * either mmio or io_regs is set to indicate mmio or not ! 175: */ ! 176: unsigned long mmio; ! 177: int io_regs[10]; ! 178: ! 179: /* ! 180: * can be set to a mmio hook, default it legacy outb/inb ! 181: */ ! 182: void (*obide_outb)(struct ide_channel *chan, ! 183: unsigned char addr, unsigned int port); ! 184: unsigned char (*obide_inb)(struct ide_channel *chan, ! 185: unsigned int port); ! 186: void (*obide_insw)(struct ide_channel *chan, ! 187: unsigned int port, unsigned char *addr, ! 188: unsigned int count); ! 189: void (*obide_outsw)(struct ide_channel *chan, ! 190: unsigned int port, unsigned char *addr, ! 191: unsigned int count); ! 192: ! 193: struct ide_drive drives[2]; ! 194: char selected; ! 195: char present; ! 196: ! 197: /* ! 198: * only one can be busy per channel ! 199: */ ! 200: struct ata_command ata_cmd; ! 201: struct atapi_command atapi_cmd; ! 202: ! 203: }; ! 204: ! 205: enum { ! 206: atapi_ddir_none, ! 207: atapi_ddir_read, ! 208: atapi_ddir_write, ! 209: }; ! 210: ! 211: static int ob_ide_atapi_request_sense(struct ide_drive *drive); ! 212: ! 213: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.