Ignore:
Timestamp:
Dec 16, 2010, 3:54:53 PM (15 years ago)
Author:
markus
Message:

added atapi_ calls; untested

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/os2ahci/atapi.h

    r13 r60  
    22 * atapi.h - ATAPI structures and macros for os2ahci driver
    33 *
    4  * Copyright (c) 2010 Christian Mueller. Parts copied from/inspired by the
    5  * Linux AHCI driver; those parts are (c) Linux AHCI/ATA maintainers
     4 * Copyright (c) 2010 Christian Mueller, Markus Thielen.
     5 * Parts copied from/inspired by the  Linux AHCI driver;
     6 * those parts are (c) Linux AHCI/ATA maintainers
    67 *
    78 *  This program is free software; you can redistribute it and/or modify
     
    2223/* -------------------------- macros and constants ------------------------- */
    2324
     25/******************************************************************************
     26 * macros to fill in ATAPI CDB values
     27 */
     28#define SET_CDB_16(_t, _v)  (_t)[0] = (u8) ((_v) >> 8);       \
     29                            (_t)[1] = (u8)  (_v)
     30#define SET_CDB_24(_t, _v)  (_t)[0] = (u8) ((_v) >> 16);      \
     31                            (_t)[1] = (u8) ((_v) >> 8);       \
     32                            (_t)[2] = (u8)  (_v)
     33#define SET_CDB_32(_t, _v)  (_t)[0] = (u8) ((_v) >> 24);      \
     34                            (_t)[1] = (u8) ((_v) >> 16);      \
     35                            (_t)[2] = (u8) ((_v) >> 8);       \
     36                            (_t)[3] = (u8)  (_v)
     37
     38#define GET_CDB_16(_f)      ((u16) (_f)[0] << 8  |            \
     39                             (u16) (_f)[1])
     40#define GET_CDB_24(_f)      ((u32) (_f)[0] << 16 |            \
     41                             (u32) (_f)[1] << 8   |           \
     42                             (u32) (_f)[2])
     43#define GET_CDB_32(_f)      ((u32) (_f)[0] << 24  |           \
     44                             (u32) (_f)[1] << 16  |           \
     45                             (u32) (_f)[2] << 24  |           \
     46                             (u32) (_f)[3])
     47
     48
     49/******************************************************************************
     50 * ATAPI/MMC command codes (as far as relevant for us)
     51 */
     52#define ATAPI_CMD_READ_6           0x08
     53#define ATAPI_CMD_READ_10          0x28
     54#define ATAPI_CMD_READ_12          0xa8
     55#define ATAPI_CMD_READ_16          0x88
     56#define ATAPI_CMD_WRITE_6          0x0a
     57#define ATAPI_CMD_WRITE_10         0x2a
     58#define ATAPI_CMD_WRITE_12         0xaa
     59#define ATAPI_CMD_WRITE_16         0x8a
     60#define ATAPI_CMD_REQUEST_SENSE    0x03
     61
     62/******************************************************************************
     63 * ATAPI command flag bits
     64 */
     65#define ATAPI_FLAG_FUA             0x80
     66#define ATAPI_FLAG_DPO             0x10
     67
     68/******************************************************************************
     69 * ATAPI sense data
     70 */
     71#define ATAPI_SENSE_LEN            64
     72
     73#define ASENSE_NO_SENSE            0x00  /* no sense -> success */
     74#define ASENSE_RECOVERED_ERROR     0x01  /* recovered error -> success */
     75#define ASENSE_NOT_READY           0x02  /* device not ready */
     76#define ASENSE_MEDIUM_ERROR        0x03  /* medium/CRC error */
     77#define ASENSE_HARDWARE_ERROR      0x04  /* device error */
     78#define ASENSE_ILLEGAL_REQUEST     0x05  /* invalid command/parameters issued */
     79#define ASENSE_UNIT_ATTENTION      0x06  /* new medium */
     80#define ASENSE_DATA_PROTECT        0x07  /* protected LBA */
     81#define ASENSE_BLANK_CHECK         0x08  /* unformatted or write protected */
     82#define ASENSE_VENDOR_SPECIFIC     0x09  /* vendor specific sense data */
     83#define ASENSE_COPY_ABORTED        0x0a  /* copy, ...command aborted */
     84#define ASENSE_ABORTED_COMMAND     0x0b  /* command has been aborted */
     85#define ASENSE_EQUAL               0x0c
     86#define ASENSE_VOLUME_OVERFLOW     0x0d  /* out of space */
     87#define ASENSE_MISCOMPARE          0x0e  /* verification failed */
     88#define ASENSE_RESERVED            0x0f
     89
     90/******************************************************************************
     91 * macro to get sense key from ATAPI_SENSE_DATA pointer
     92 */
     93#define ATAPI_GET_SENSE(p_) (u8)(p_->sense.sense_key & 0x0f)
     94
    2495/* ------------------------ typedefs and structures ------------------------ */
     96
     97/******************************************************************************
     98 * ATAPI_SENSE_DATA - define layout of ATAPI sense data
     99 */
     100typedef union _ATAPI_SENSE_DATA {
     101  struct {
     102    u8 valid_respc;      /* valid bit (bit 7), response code (bits 6:0) */
     103    u8 segment;          /* segment number (obsolete) */
     104    u8 sense_key;        /* some flags (bits 7:4), sense key (bits 3:0) */
     105    u8 info[4];          /* information (?) */
     106    u8 adl_len;          /* additional sense info length */
     107    u8 cmd_specific[4];  /* command specific stuff (ignored) */
     108    u8 asc;              /* additional sense code */
     109    u8 ascq;             /* additional sense code qualifier */
     110    u8 fruc;             /* field replaceable unit code */
     111    u8 flags;            /* vendor-specific flags */
     112    u8 field_off[2];     /* offset to invalid field in parm list */
     113  } sense;
     114
     115  u8 padding[ATAPI_SENSE_LEN]; /* pad to 64 bytes */
     116
     117} ATAPI_SENSE_DATA;
     118
     119/******************************************************************************
     120 * ATAPI_CDB_10 - describes layout of generic 10 byte ATAPI command
     121 */
     122typedef struct _ATAPI_CMD_10 {
     123  u8   cmd;            /* SCSI/ATAPI command code */
     124  u8   flags;          /* flags (DPO, FUA) */
     125  u8   lba[4];         /* logical block address */
     126  u8   trans_len[2];   /* number of blocks to transfer */
     127  u8   control;        /* (nothing much) */
     128} ATAPI_CDB_10;
     129
     130/******************************************************************************
     131 * ATAPI_CDB_12 - describes layout of generic 12 byte ATAPI command
     132 */
     133typedef struct _ATAPI_CMD_12 {
     134  u8   cmd;            /* SCSI/ATAPI command code */
     135  u8   flags;          /* flags (DPO, FUA) */
     136  u8   lba[4];         /* logical block address */
     137  u8   trans_len[4];   /* number of blocks to transfer */
     138  u8   reserved;
     139  u8   control;        /* (nothing much) */
     140} ATAPI_CDB_12;
     141
     142/******************************************************************************Ü
     143 * ATAPI_CDB_REQ_SENSE - describes request sense command
     144 */
     145typedef struct _ATAPI_CMD_REQ_SENSE {
     146  u8   cmd;            /* command code (0x03) */
     147  u8   lun:3;          /* SCSI lun (ignored) */
     148  u8   resvd:5;
     149  u8   buffer_len;     /* sense buffer length */
     150  u8   control;
     151} ATAPI_CDB_REQ_SENSE;
     152
    25153
    26154/* ---------------------------- global variables --------------------------- */
Note: See TracChangeset for help on using the changeset viewer.