df87986fa9ab97580e9c33154cba21ad2c2aba84
[dragonfly.git] / sys / dev / disk / nata / atapi-fd.h
1 /*-
2  * Copyright (c) 1998 - 2006 Søren Schmidt <sos@FreeBSD.org>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer,
10  *    without modification, immediately at the beginning of the file.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  *
26  * $FreeBSD: src/sys/dev/ata/atapi-fd.h,v 1.26 2006/03/05 20:30:54 sos Exp $
27  * $DragonFly: src/sys/dev/disk/nata/atapi-fd.h,v 1.1 2006/12/04 14:40:37 tgen Exp $
28  */
29
30 #include <sys/param.h>
31 #include <sys/devicestat.h>
32 #include <sys/disk.h>
33
34 /* ATAPI Rewriteable drive Capabilities and Mechanical Status Page */
35 struct afd_capabilities {
36     u_int16_t   data_length;
37     u_int8_t    medium_type;
38 #define MFD_2DD_UN              0x10
39 #define MFD_2DD                 0x11
40 #define MFD_HD_UN               0x20
41 #define MFD_HD_12_98            0x22
42 #define MFD_HD_12               0x23
43 #define MFD_HD_144              0x24
44 #define MFD_UHD                 0x31
45
46 #define MFD_UNKNOWN             0x00
47 #define MFD_NO_DISC             0x70
48 #define MFD_DOOR_OPEN           0x71
49 #define MFD_FMT_ERROR           0x72
50
51     u_int8_t    reserved0       :7;
52     u_int8_t    wp              :1;             /* write protect */
53     u_int8_t    unused[4];
54
55     /* capabilities page */
56     u_int8_t    page_code       :6;
57 #define ATAPI_REWRITEABLE_CAP_PAGE        0x05
58
59     u_int8_t    reserved1_6     :1;
60     u_int8_t    ps              :1;             /* page save supported */
61     u_int8_t    page_length;                    /* page length */
62     u_int16_t   transfer_rate;                  /* in kilobits per second */
63     u_int8_t    heads;                          /* number of heads */
64     u_int8_t    sectors;                        /* number of sectors pr track */
65     u_int16_t   sector_size;                    /* number of bytes per sector */
66     u_int16_t   cylinders;                      /* number of cylinders */
67     u_int8_t    reserved10[10];
68     u_int8_t    motor_delay;                    /* motor off delay */
69     u_int8_t    reserved21[7];
70     u_int16_t   rpm;                            /* rotations per minute */
71     u_int8_t    reserved30[2];
72 };
73
74 struct afd_capacity {
75     u_int32_t   capacity;
76     u_int32_t   blocksize;
77 };
78
79 struct afd_capacity_big {
80     u_int64_t   capacity;
81     u_int32_t   blocksize;
82 };
83
84 struct afd_softc {
85     u_int64_t           mediasize;
86     u_int32_t           heads;
87     u_int32_t           sectors;
88     u_int32_t           sectorsize;
89     struct devstat      stats;
90     struct disk         disk;                   /* virtual drives */
91     cdev_t              cdev;                   /* device placeholder */
92 };