Changeset 68


Ignore:
Timestamp:
Dec 27, 2010, 2:13:49 PM (15 years ago)
Author:
markus
Message:

made it compile, added atapi command mapping/padding (->12 bytes)

Location:
trunk/src/os2ahci
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/os2ahci/ahci.c

    r66 r68  
    12461246    next = iorb->pNxtIORB;
    12471247    iorb->Status = IORB_DONE;
    1248     aws_free(iorb_workspace(iorb));
     1248    aws_free(add_workspace(iorb));
    12491249    if (iorb->RequestControl & IORB_ASYNC_POST) {
    12501250      iorb->NotifyAddress(iorb);
  • trunk/src/os2ahci/atapi.c

    r67 r68  
    3232
    3333static void atapi_req_sense_pp      (IORBH _far *iorb);
     34static int atapi_pad_cdb            (u8 _far *cmd_in, u16 cmd_in_len,
     35                                     u8 _far *cmd_out, u16 _far *cmd_out_len);
    3436
    3537/* ------------------------ global/static variables ------------------------ */
     
    143145  IORB_ADAPTER_PASSTHRU _far *pt = (IORB_ADAPTER_PASSTHRU _far *) iorb;
    144146  int rc;
    145   u8 cdb[ATAPI_MAX_CDB_LEN] = {0};
     147  u8 cdb[ATAPI_MAX_CDB_LEN];
    146148  u16 cdb_len;
    147149
    148150  if (pt->ControllerCmdLen > ATAPI_MAX_CDB_LEN) {
    149     ioerb_seterr(IOERR_CMD_SYNTAX);
     151    iorb_seterr(iorb, IOERR_CMD_SYNTAX);
    150152    return -1;
    151153  }
    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);
    157157
    158158  /* we do not perform the S/G limitation recovery loop here:
     
    195195  int rc;
    196196  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;
    198198 
    199199  /* allocate sense buffer in ADD workspace */
     
    289289}
    290290
     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 */
     298int 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  
    123123} ATAPI_SENSE_DATA;
    124124
     125/******************************************************************************Ü
     126 * ATAPI_CDB_6 - describes 6 byte ATAPI command
     127 */
     128typedef 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
    125136/******************************************************************************
    126137 * ATAPI_CDB_10 - describes layout of generic 10 byte ATAPI command
     
    146157} ATAPI_CDB_12;
    147158
    148 /******************************************************************************Ü
    149  * ATAPI_CDB_6 - describes 6 byte ATAPI command
    150  */
    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 
    159159
    160160/* ---------------------------- global variables --------------------------- */
  • trunk/src/os2ahci/ctxhook.c

    r66 r68  
    336336               * picked up by subsequent trigger_engine() calls.
    337337               */
    338               requeue_iorb(iorn);
     338              iorb_requeue(iorb);
    339339
    340340            } else {
  • trunk/src/os2ahci/os2ahci.def

    r64 r68  
    11library os2ahci
    2 Description '$@#thi.guten (www.thiguten.de):1.00.20101221#@OS/2 AHCI Adapter Device Driver'
     2Description '$@#thi.guten (www.thiguten.de):1.00.20101227#@OS/2 AHCI Adapter Device Driver'
    33protmode
    44
  • trunk/src/os2ahci/os2ahci.h

    r35 r68  
    7777/* default command timeout (can be overwritten in the IORB) */
    7878#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
    7983
    8084/* debug output macros */
Note: See TracChangeset for help on using the changeset viewer.