Changeset 68
- Timestamp:
- Dec 27, 2010, 2:13:49 PM (15 years ago)
- Location:
- trunk/src/os2ahci
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/os2ahci/ahci.c
r66 r68 1246 1246 next = iorb->pNxtIORB; 1247 1247 iorb->Status = IORB_DONE; 1248 aws_free( iorb_workspace(iorb));1248 aws_free(add_workspace(iorb)); 1249 1249 if (iorb->RequestControl & IORB_ASYNC_POST) { 1250 1250 iorb->NotifyAddress(iorb); -
trunk/src/os2ahci/atapi.c
r67 r68 32 32 33 33 static void atapi_req_sense_pp (IORBH _far *iorb); 34 static int atapi_pad_cdb (u8 _far *cmd_in, u16 cmd_in_len, 35 u8 _far *cmd_out, u16 _far *cmd_out_len); 34 36 35 37 /* ------------------------ global/static variables ------------------------ */ … … 143 145 IORB_ADAPTER_PASSTHRU _far *pt = (IORB_ADAPTER_PASSTHRU _far *) iorb; 144 146 int rc; 145 u8 cdb[ATAPI_MAX_CDB_LEN] = {0};147 u8 cdb[ATAPI_MAX_CDB_LEN]; 146 148 u16 cdb_len; 147 149 148 150 if (pt->ControllerCmdLen > ATAPI_MAX_CDB_LEN) { 149 io erb_seterr(IOERR_CMD_SYNTAX);151 iorb_seterr(iorb, IOERR_CMD_SYNTAX); 150 152 return -1; 151 153 } 152 /* AHCI requires 12 or 16 byte commands; for now, we pad them 153 * since I have no idea what to do with commands that do not 154 * have a 12 or 16 byte equivalent */ 155 memcpy(cdb, pt->pControllerCmd, pt->ControllerCmdLen); 156 cdb_len = max(ATAPI_MIN_CDB_LEN, pt->ControllerCmdLen); 154 /* AHCI requires 12 or 16 byte commands */ 155 atapi_pad_cdb(pt->pControllerCmd, pt->ControllerCmdLen, 156 (u8 _far *) cdb, (u16 _far *) &cdb_len); 157 157 158 158 /* we do not perform the S/G limitation recovery loop here: … … 195 195 int rc; 196 196 u8 cdb[ATAPI_MIN_CDB_LEN]; 197 ATAPI_CDB_6 *pcdb; = (ATAPI_CDB_6*) cdb;197 ATAPI_CDB_6 _far *pcdb = (ATAPI_CDB_6 _far *) cdb; 198 198 199 199 /* allocate sense buffer in ADD workspace */ … … 289 289 } 290 290 291 /****************************************************************************** 292 * pad atapi commands; AHCI requires ATAPI commands to be either 12 or 293 * 16 bytes in length. This func converts commands that have a 12 byte 294 * equivalent, and pads the others to 12 bytes. 295 * cmd_out buffer is expected to be ATAPI_MAX_CDB_LEN in size. 296 * returns 0 on success, != 0 if the command can't be converted. 297 */ 298 int atapi_pad_cdb(u8 _far *cmd_in, u16 cmd_in_len, 299 u8 _far *cmd_out, u16 _far *cmd_out_len) 300 { 301 ATAPI_CDB_12 _far *p12; 302 303 if (cmd_in_len == ATAPI_MIN_CDB_LEN || cmd_in_len == ATAPI_MAX_CDB_LEN) { 304 /* command does not need to be converted */ 305 memcpy(cmd_out, cmd_in, cmd_in_len); 306 *cmd_out_len = cmd_in_len; 307 return 0; 308 } 309 310 memset(cmd_out, 0x00, ATAPI_MAX_CDB_LEN); 311 p12 = (ATAPI_CDB_12 _far *) cmd_out; 312 /* we always convert to 12 byte CDBs */ 313 *cmd_out_len = ATAPI_MIN_CDB_LEN; 314 315 /* check if command can be converted */ 316 switch (cmd_in[0]) { 317 318 case ATAPI_CMD_READ_6: 319 case ATAPI_CMD_WRITE_6: 320 /* convert from 6 to 12 byte equivalent */ 321 p12->cmd = 0xa0 | (cmd_in[0] & 0x0f); 322 p12->flags = cmd_in[1] & 0xc0; /* 6byte cmds have no flags (FUA etc.) */ 323 SET_CDB_32(p12->lba, (u32) cmd_in[3] | (u32) cmd_in[2] << 8 | 324 (u32) (cmd_in[1] & 0x1f) << 16); 325 SET_CDB_32(p12->trans_len, (u32) cmd_in[4]); 326 p12->control = cmd_in[5]; 327 break; 328 329 case ATAPI_CMD_READ_10: 330 case ATAPI_CMD_WRITE_10: 331 /* convert from 10 byte to 12 byte equivalent */ 332 p12->cmd = 0xa0 | (cmd_in[0] & 0x0f); 333 p12->flags = cmd_in[1]; 334 memcpy(p12->lba, cmd_in + 2, 4); 335 SET_CDB_32(p12->trans_len, (u32) GET_CDB_16(cmd_in + 7)); 336 p12->control = cmd_in[9]; 337 break; 338 339 default: 340 /* pad with zeroes to 12 bytes */ 341 memset(cmd_out, 0x00, ATAPI_MIN_CDB_LEN); 342 memcpy(cmd_out, cmd_in, cmd_in_len); 343 break; 344 } 345 346 return 0; 347 } 348 -
trunk/src/os2ahci/atapi.h
r65 r68 123 123 } ATAPI_SENSE_DATA; 124 124 125 /******************************************************************************Ã 126 * ATAPI_CDB_6 - describes 6 byte ATAPI command 127 */ 128 typedef struct _ATAPI_CDB_6 { 129 u8 cmd; /* command code */ 130 u8 lun; /* SCSI lun (ignored) */ 131 u8 resvd[2]; 132 u8 trans_len; /* transfer length */ 133 u8 control; 134 } ATAPI_CDB_6; 135 125 136 /****************************************************************************** 126 137 * ATAPI_CDB_10 - describes layout of generic 10 byte ATAPI command … … 146 157 } ATAPI_CDB_12; 147 158 148 /******************************************************************************Ã149 * ATAPI_CDB_6 - describes 6 byte ATAPI command150 */151 typedef struct _ATAPI_CDB_6 {152 u8 cmd; /* command code */153 u8 lun; /* SCSI lun (ignored) */154 u8 resvd[2];155 u8 trans_len; /* transfer length */156 u8 control;157 } ATAPI_CDB_6;158 159 159 160 160 /* ---------------------------- global variables --------------------------- */ -
trunk/src/os2ahci/ctxhook.c
r66 r68 336 336 * picked up by subsequent trigger_engine() calls. 337 337 */ 338 requeue_iorb(iorn);338 iorb_requeue(iorb); 339 339 340 340 } else { -
trunk/src/os2ahci/os2ahci.def
r64 r68 1 1 library os2ahci 2 Description '$@#thi.guten (www.thiguten.de):1.00.2010122 1#@OS/2 AHCI Adapter Device Driver'2 Description '$@#thi.guten (www.thiguten.de):1.00.20101227#@OS/2 AHCI Adapter Device Driver' 3 3 protmode 4 4 -
trunk/src/os2ahci/os2ahci.h
r35 r68 77 77 /* default command timeout (can be overwritten in the IORB) */ 78 78 #define DEFAULT_TIMEOUT 30000 79 80 /* max/min macros */ 81 #define max(a, b) a > b ? a : b 82 #define min(a, b) a < b ? a : b 79 83 80 84 /* debug output macros */
Note:
See TracChangeset
for help on using the changeset viewer.