[BACK]Return to atascsi.h CVS log [TXT][DIR] Up to [local] / sys / dev / ata

Annotation of sys/dev/ata/atascsi.h, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: atascsi.h,v 1.25 2007/04/12 13:08:34 jsg Exp $ */
        !             2:
        !             3: /*
        !             4:  * Copyright (c) 2007 David Gwynne <dlg@openbsd.org>
        !             5:  *
        !             6:  * Permission to use, copy, modify, and distribute this software for any
        !             7:  * purpose with or without fee is hereby granted, provided that the above
        !             8:  * copyright notice and this permission notice appear in all copies.
        !             9:  *
        !            10:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
        !            11:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
        !            12:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
        !            13:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
        !            14:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
        !            15:  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
        !            16:  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
        !            17:  */
        !            18:
        !            19: struct atascsi;
        !            20:
        !            21: /*
        !            22:  * ATA commands
        !            23:  */
        !            24:
        !            25: #define ATA_C_READDMA_EXT      0x25
        !            26: #define ATA_C_READ_LOG_EXT     0x2f
        !            27: #define ATA_C_WRITEDMA_EXT     0x35
        !            28: #define ATA_C_READ_FPDMA       0x60
        !            29: #define ATA_C_WRITE_FPDMA      0x61
        !            30: #define ATA_C_PACKET           0xa0
        !            31: #define ATA_C_READDMA          0xc8
        !            32: #define ATA_C_WRITEDMA         0xca
        !            33: #define ATA_C_FLUSH_CACHE      0xe7
        !            34: #define ATA_C_FLUSH_CACHE_EXT  0xea /* lba48 */
        !            35: #define ATA_C_IDENTIFY         0xec
        !            36: #define ATA_C_SEC_FREEZE_LOCK  0xf5
        !            37:
        !            38: struct ata_identify {
        !            39:        u_int16_t       config;         /*   0 */
        !            40:        u_int16_t       ncyls;          /*   1 */
        !            41:        u_int16_t       reserved1;      /*   2 */
        !            42:        u_int16_t       nheads;         /*   3 */
        !            43:        u_int16_t       track_size;     /*   4 */
        !            44:        u_int16_t       sector_size;    /*   5 */
        !            45:        u_int16_t       nsectors;       /*   6 */
        !            46:        u_int16_t       reserved2[3];   /*   7 vendor unique */
        !            47:        u_int8_t        serial[20];     /*  10 */
        !            48:        u_int16_t       buffer_type;    /*  20 */
        !            49:        u_int16_t       buffer_size;    /*  21 */
        !            50:        u_int16_t       ecc;            /*  22 */
        !            51:        u_int8_t        firmware[8];    /*  23 */
        !            52:        u_int8_t        model[40];      /*  27 */
        !            53:        u_int16_t       multi;          /*  47 */
        !            54:        u_int16_t       dwcap;          /*  48 */
        !            55:        u_int16_t       cap;            /*  49 */
        !            56:        u_int16_t       reserved3;      /*  50 */
        !            57:        u_int16_t       piomode;        /*  51 */
        !            58:        u_int16_t       dmamode;        /*  52 */
        !            59:        u_int16_t       validinfo;      /*  53 */
        !            60:        u_int16_t       curcyls;        /*  54 */
        !            61:        u_int16_t       curheads;       /*  55 */
        !            62:        u_int16_t       cursectrk;      /*  56 */
        !            63:        u_int16_t       curseccp[2];    /*  57 */
        !            64:        u_int16_t       mult2;          /*  59 */
        !            65:        u_int16_t       addrsec[2];     /*  60 */
        !            66:        u_int16_t       worddma;        /*  62 */
        !            67:        u_int16_t       dworddma;       /*  63 */
        !            68:        u_int16_t       advpiomode;     /*  64 */
        !            69:        u_int16_t       minmwdma;       /*  65 */
        !            70:        u_int16_t       recmwdma;       /*  66 */
        !            71:        u_int16_t       minpio;         /*  67 */
        !            72:        u_int16_t       minpioflow;     /*  68 */
        !            73:        u_int16_t       reserved4[2];   /*  69 */
        !            74:        u_int16_t       typtime[2];     /*  71 */
        !            75:        u_int16_t       reserved5[2];   /*  73 */
        !            76:        u_int16_t       qdepth;         /*  75 */
        !            77:        u_int16_t       satacap;        /*  76 */
        !            78:        u_int16_t       reserved6;      /*  77 */
        !            79:        u_int16_t       satafsup;       /*  78 */
        !            80:        u_int16_t       satafen;        /*  79 */
        !            81:        u_int16_t       majver;         /*  80 */
        !            82:        u_int16_t       minver;         /*  81 */
        !            83:        u_int16_t       cmdset82;       /*  82 */
        !            84:        u_int16_t       cmdset83;       /*  83 */
        !            85:        u_int16_t       cmdset84;       /*  84 */
        !            86:        u_int16_t       features85;     /*  85 */
        !            87:        u_int16_t       features86;     /*  86 */
        !            88:        u_int16_t       features87;     /*  87 */
        !            89:        u_int16_t       ultradma;       /*  88 */
        !            90:        u_int16_t       erasetime;      /*  89 */
        !            91:        u_int16_t       erasetimex;     /*  90 */
        !            92:        u_int16_t       apm;            /*  91 */
        !            93:        u_int16_t       masterpw;       /*  92 */
        !            94:        u_int16_t       hwreset;        /*  93 */
        !            95:        u_int16_t       acoustic;       /*  94 */
        !            96:        u_int16_t       stream_min;     /*  95 */
        !            97:        u_int16_t       stream_xfer_d;  /*  96 */
        !            98:        u_int16_t       stream_lat;     /*  97 */
        !            99:        u_int16_t       streamperf[2];  /*  98 */
        !           100:        u_int16_t       addrsecxt[4];   /* 100 */
        !           101:        u_int16_t       stream_xfer_p;  /* 104 */
        !           102:        u_int16_t       padding1;       /* 105 */
        !           103:        u_int16_t       phys_sect_sz;   /* 106 */
        !           104:        u_int16_t       seek_delay;     /* 107 */
        !           105:        u_int16_t       naa_ieee_oui;   /* 108 */
        !           106:        u_int16_t       ieee_oui_uid;   /* 109 */
        !           107:        u_int16_t       uid_mid;        /* 110 */
        !           108:        u_int16_t       uid_low;        /* 111 */
        !           109:        u_int16_t       resv_wwn[4];    /* 112 */
        !           110:        u_int16_t       incits;         /* 116 */
        !           111:        u_int16_t       words_lsec[2];  /* 117 */
        !           112:        u_int16_t       cmdset119;      /* 119 */
        !           113:        u_int16_t       features120;    /* 120 */
        !           114:        u_int16_t       padding2[6];
        !           115:        u_int16_t       rmsn;           /* 127 */
        !           116:        u_int16_t       securestatus;   /* 128 */
        !           117:        u_int16_t       vendor[31];     /* 129 */
        !           118:        u_int16_t       padding3[16];   /* 160 */
        !           119:        u_int16_t       curmedser[30];  /* 176 */
        !           120:        u_int16_t       sctsupport;     /* 206 */
        !           121:        u_int16_t       padding4[48];   /* 207 */
        !           122:        u_int16_t       integrity;      /* 255 */
        !           123: } __packed;
        !           124:
        !           125: /*
        !           126:  * Frame Information Structures
        !           127:  */
        !           128:
        !           129: #define ATA_FIS_LENGTH         20
        !           130:
        !           131: struct ata_fis_h2d {
        !           132:        u_int8_t                type;
        !           133: #define ATA_FIS_TYPE_H2D               0x27
        !           134:        u_int8_t                flags;
        !           135: #define ATA_H2D_FLAGS_CMD              (1<<7)
        !           136:        u_int8_t                command;
        !           137:        u_int8_t                features;
        !           138: #define ATA_H2D_FEATURES_DMA           (1<<0)
        !           139: #define ATA_H2D_FEATURES_DIR           (1<<2)
        !           140: #define ATA_H2D_FEATURES_DIR_READ      (1<<2)
        !           141: #define ATA_H2D_FEATURES_DIR_WRITE     (0<<2)
        !           142:
        !           143:        u_int8_t                lba_low;
        !           144:        u_int8_t                lba_mid;
        !           145:        u_int8_t                lba_high;
        !           146:        u_int8_t                device;
        !           147: #define ATA_H2D_DEVICE_LBA             0x40
        !           148:
        !           149:        u_int8_t                lba_low_exp;
        !           150:        u_int8_t                lba_mid_exp;
        !           151:        u_int8_t                lba_high_exp;
        !           152:        u_int8_t                features_exp;
        !           153:
        !           154:        u_int8_t                sector_count;
        !           155:        u_int8_t                sector_count_exp;
        !           156:        u_int8_t                reserved0;
        !           157:        u_int8_t                control;
        !           158:
        !           159:        u_int8_t                reserved1;
        !           160:        u_int8_t                reserved2;
        !           161:        u_int8_t                reserved3;
        !           162:        u_int8_t                reserved4;
        !           163: } __packed;
        !           164:
        !           165: struct ata_fis_d2h {
        !           166:        u_int8_t                type;
        !           167: #define ATA_FIS_TYPE_D2H               0x34
        !           168:        u_int8_t                flags;
        !           169: #define ATA_D2H_FLAGS_INTR             (1<<6)
        !           170:        u_int8_t                status;
        !           171:        u_int8_t                error;
        !           172:
        !           173:        u_int8_t                lba_low;
        !           174:        u_int8_t                lba_mid;
        !           175:        u_int8_t                lba_high;
        !           176:        u_int8_t                device;
        !           177:
        !           178:        u_int8_t                lba_low_exp;
        !           179:        u_int8_t                lba_mid_exp;
        !           180:        u_int8_t                lba_high_exp;
        !           181:        u_int8_t                reserved0;
        !           182:
        !           183:        u_int8_t                sector_count;
        !           184:        u_int8_t                sector_count_exp;
        !           185:        u_int8_t                reserved1;
        !           186:        u_int8_t                reserved2;
        !           187:
        !           188:        u_int8_t                reserved3;
        !           189:        u_int8_t                reserved4;
        !           190:        u_int8_t                reserved5;
        !           191:        u_int8_t                reserved6;
        !           192: } __packed;
        !           193:
        !           194: /*
        !           195:  * SATA log page 10h -
        !           196:  * looks like a D2H FIS, with errored tag number in first byte.
        !           197:  */
        !           198: struct ata_log_page_10h {
        !           199:        struct ata_fis_d2h      err_regs;
        !           200: #define ATA_LOG_10H_TYPE_NOTQUEUED     0x80
        !           201: #define ATA_LOG_10H_TYPE_TAG_MASK      0x1f
        !           202:        u_int8_t                reserved[256 - sizeof(struct ata_fis_d2h)];
        !           203:        u_int8_t                vendor_specific[255];
        !           204:        u_int8_t                checksum;
        !           205: } __packed;
        !           206:
        !           207: /*
        !           208:  * SATA registers
        !           209:  */
        !           210:
        !           211: #define SATA_SStatus_DET               0x00f
        !           212: #define SATA_SStatus_DET_NODEV         0x000
        !           213: #define SATA_SStatus_DET_NOPHY         0x001
        !           214: #define SATA_SStatus_DET_DEV           0x003
        !           215: #define SATA_SStatus_DET_OFFLINE       0x008
        !           216:
        !           217: #define SATA_SStatus_SPD               0x0f0
        !           218: #define SATA_SStatus_SPD_NONE          0x000
        !           219: #define SATA_SStatus_SPD_1_5           0x010
        !           220: #define SATA_SStatus_SPD_3_0           0x020
        !           221:
        !           222: #define SATA_SStatus_IPM               0xf00
        !           223: #define SATA_SStatus_IPM_NODEV         0x000
        !           224: #define SATA_SStatus_IPM_ACTIVE                0x100
        !           225: #define SATA_SStatus_IPM_PARTIAL       0x200
        !           226: #define SATA_SStatus_IPM_SLUMBER       0x600
        !           227:
        !           228: #define SATA_SIGNATURE_PORT_MULTIPLIER 0x96690101
        !           229: #define SATA_SIGNATURE_ATAPI           0xeb140101
        !           230: #define SATA_SIGNATURE_DISK            0x00000101
        !           231:
        !           232: /*
        !           233:  * ATA interface
        !           234:  */
        !           235:
        !           236: struct ata_port {
        !           237:        struct atascsi          *ap_as;
        !           238:        int                     ap_port;
        !           239:        int                     ap_type;
        !           240: #define ATA_PORT_T_NONE                        0
        !           241: #define ATA_PORT_T_DISK                        1
        !           242: #define ATA_PORT_T_ATAPI               2
        !           243:        int                     ap_features;
        !           244: #define ATA_PORT_F_PROBED              (1 << 0)
        !           245:        int                     ap_ncqdepth;
        !           246: };
        !           247:
        !           248: struct ata_xfer {
        !           249:        struct ata_fis_h2d      *fis;
        !           250:        struct ata_fis_d2h      rfis;
        !           251:        u_int8_t                *packetcmd;
        !           252:        u_int8_t                tag;
        !           253:
        !           254:        u_int8_t                *data;
        !           255:        size_t                  datalen;
        !           256:        size_t                  resid;
        !           257:
        !           258:        void                    (*complete)(struct ata_xfer *);
        !           259:        struct timeout          stimeout;
        !           260:        u_int                   timeout;
        !           261:
        !           262:        int                     flags;
        !           263: #define ATA_F_READ                     (1<<0)
        !           264: #define ATA_F_WRITE                    (1<<1)
        !           265: #define ATA_F_NOWAIT                   (1<<2)
        !           266: #define ATA_F_POLL                     (1<<3)
        !           267: #define ATA_F_PIO                      (1<<4)
        !           268: #define ATA_F_PACKET                   (1<<5)
        !           269: #define ATA_F_NCQ                      (1<<6)
        !           270:        volatile int            state;
        !           271: #define ATA_S_SETUP                    0
        !           272: #define ATA_S_PENDING                  1
        !           273: #define ATA_S_COMPLETE                 2
        !           274: #define ATA_S_ERROR                    3
        !           275: #define ATA_S_TIMEOUT                  4
        !           276: #define ATA_S_ONCHIP                   5
        !           277: #define ATA_S_PUT                      6
        !           278:
        !           279:        void                    *atascsi_private;
        !           280:
        !           281:        void                    (*ata_put_xfer)(struct ata_xfer *);
        !           282: };
        !           283:
        !           284: #define ATA_QUEUED             0
        !           285: #define ATA_COMPLETE           1
        !           286: #define ATA_ERROR              2
        !           287:
        !           288: /*
        !           289:  * atascsi
        !           290:  */
        !           291:
        !           292: struct atascsi_methods {
        !           293:        int                     (*probe)(void *, int);
        !           294:        struct ata_xfer *       (*ata_get_xfer)(void *, int );
        !           295:        int                     (*ata_cmd)(struct ata_xfer *);
        !           296: };
        !           297:
        !           298: struct atascsi_attach_args {
        !           299:        void                    *aaa_cookie;
        !           300:
        !           301:        struct atascsi_methods  *aaa_methods;
        !           302:        void                    (*aaa_minphys)(struct buf *);
        !           303:        int                     aaa_nports;
        !           304:        int                     aaa_ncmds;
        !           305:        int                     aaa_capability;
        !           306: #define ASAA_CAP_NCQ           (1 << 0)
        !           307: #define ASAA_CAP_NEEDS_RESERVED        (1 << 1)
        !           308: };
        !           309:
        !           310: struct atascsi *atascsi_attach(struct device *, struct atascsi_attach_args *);
        !           311: int            atascsi_detach(struct atascsi *);
        !           312:
        !           313: int            atascsi_probe_dev(struct atascsi *, int);
        !           314: int            atascsi_detach_dev(struct atascsi *, int);

CVSweb