GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / cfe / cfe / include / dev_ide_common.h
blob71a1d9817eb337460ed64573d9793497d13c5596
1 /* *********************************************************************
2 * Broadcom Common Firmware Environment (CFE)
3 *
4 * Generic IDE disk driver File: dev_ide_common.c
5 *
6 * This file contains common constants and structures for IDE
7 * disks and CFE drivers for them.
8 *
9 * Author: Mitch Lichtenberg (mpl@broadcom.com)
11 *********************************************************************
13 * Copyright 2000,2001,2002,2003
14 * Broadcom Corporation. All rights reserved.
16 * This software is furnished under license and may be used and
17 * copied only in accordance with the following terms and
18 * conditions. Subject to these conditions, you may download,
19 * copy, install, use, modify and distribute modified or unmodified
20 * copies of this software in source and/or binary form. No title
21 * or ownership is transferred hereby.
23 * 1) Any source code used, modified or distributed must reproduce
24 * and retain this copyright notice and list of conditions
25 * as they appear in the source file.
27 * 2) No right is granted to use any trade name, trademark, or
28 * logo of Broadcom Corporation. The "Broadcom Corporation"
29 * name may not be used to endorse or promote products derived
30 * from this software without the prior written permission of
31 * Broadcom Corporation.
33 * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
34 * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
35 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
36 * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
37 * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
38 * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
39 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
40 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
41 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
42 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
43 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
44 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
45 * THE POSSIBILITY OF SUCH DAMAGE.
46 ********************************************************************* */
49 /* *********************************************************************
50 * Constants
51 ********************************************************************* */
53 #define IDE_REG_DATA 0x0
54 #define IDE_REG_ERROR 0x1
55 #define IDE_REG_PRECOMP 0x1
56 #define IDE_REG_SECCNT 0x2
57 #define IDE_REG_IR 0x2 /* ATAPI */
58 #define IDE_REG_SECNUM 0x3
59 #define IDE_REG_BCLSB 0x4 /* ATAPI */
60 #define IDE_REG_BCMSB 0x5 /* ATAPI */
61 #define IDE_REG_CYLLSB 0x4
62 #define IDE_REG_CYLMSB 0x5
63 #define IDE_REG_DRVHD 0x6
64 #define IDE_REG_STATUS 0x7
65 #define IDE_REG_COMMAND 0x7
66 #define IDE_REG_ALTSTAT 0x6 /* Note: ALTSTAT is really 0x3F6, what do we do? */
67 #define IDE_REG_DIGOUT 0x6
69 #define IDE_IR_CD 0x01 /* 1 = command, 0 = data */
70 #define IDE_IR_IO 0x02 /* 1 = from device, 0 = to device */
71 #define IDE_IR_REL 0x04
73 #define IDE_ERR_BBK 0x80 /* sector marked bad by host */
74 #define IDE_ERR_UNC 0x40 /* uncorrectable error */
75 #define IDE_ERR_MC 0x20 /* medium changed */
76 #define IDE_ERR_NID 0x10 /* no ID mark found */
77 #define IDE_ERR_MCR 0x08 /* medium change required */
78 #define IDE_ERR_ABT 0x04 /* command aborted */
79 #define IDE_ERR_NT0 0x02 /* track 0 not found */
80 #define IDE_ERR_NDM 0x01 /* address mark not found */
82 #define IDE_DRV_SLAVE 0x10
83 #define IDE_DRV_LBA 0x40
84 #define IDE_DRV_MBO 0xA0
85 #define IDE_DRV_HDMASK 0x0F
87 #define IDE_STS_BSY 0x80 /* drive is busy */
88 #define IDE_STS_RDY 0x40 /* drive is ready */
89 #define IDE_STS_WFT 0x20 /* write fault */
90 #define IDE_STS_SKC 0x10 /* seek complete */
91 #define IDE_STS_DRQ 0x08 /* data can be transferred */
92 #define IDE_STS_CORR 0x04 /* correctable data error */
93 #define IDE_STS_IDX 0x02 /* index mark just passed */
94 #define IDE_STS_ERR 0x01 /* Error register contains info */
96 #define IDE_CMD_RECAL 0x10
97 #define IDE_CMD_READ 0x20
98 #define IDE_CMD_READRETRY 0x21
99 #define IDE_CMD_WRITE 0x30
100 #define IDE_CMD_READVERIFY 0x40
101 #define IDE_CMD_DIAGNOSTIC 0x90
102 #define IDE_CMD_INITPARAMS 0x91
103 #define IDE_CMD_SETMULTIPLE 0xC6
104 #define IDE_CMD_POWER_MODE 0xE5
105 #define IDE_CMD_DRIVE_INFO 0xEC
107 #define IDE_CMD_ATAPI_SOFTRESET 0x08
108 #define IDE_CMD_ATAPI_PACKET 0xA0
109 #define IDE_CMD_ATAPI_IDENTIFY 0xA1
110 #define IDE_CMD_ATAPI_SERVICE 0xA2
112 #define IDE_DOR_SRST 0x04
113 #define IDE_DOR_IEN 0x02
115 #define DISK_SECTORSIZE 512
116 #define CDROM_SECTORSIZE 2048
117 #define MAX_SECTORSIZE 2048
119 #define ATAPI_SENSE_MASK 0xF0
120 #define ATAPI_SENSE_NONE 0x00
121 #define ATAPI_SENSE_RECOVERED 0x10
122 #define ATAPI_SENSE_NOTREADY 0x20
123 #define ATAPI_SENSE_MEDIUMERROR 0x30
124 #define ATAPI_SENSE_HWERROR 0x40
125 #define ATAPI_SENSE_ILLREQUEST 0x50
126 #define ATAPI_SENSE_ATTENTION 0x60
127 #define ATAPI_SENSE_PROTECT 0x70
128 #define ATAPI_SENSE_BLANKCHECK 0x80
129 #define ATAPI_SENSE_VSPECIFIC 0x90
130 #define ATAPI_SENSE_COPYABORT 0xA0
131 #define ATAPI_SENSE_CMDABORT 0xB0
132 #define ATAPI_SENSE_EQUAL 0xC0
133 #define ATAPI_SENSE_VOLOVERFLOW 0xD0
134 #define ATAPI_SENSE_MISCOMPARE 0xE0
135 #define ATAPI_SENSE_RESERVED 0xF0
137 #define ATAPI_SIG_LSB 0x14
138 #define ATAPI_SIG_MSB 0xEB
140 #define CDB_CMD_READ 0x28
141 #define CDB_CMD_WRITE 0x2A
142 #define CDB_CMD_REQSENSE 0x03
145 /* *********************************************************************
146 * Structures
147 ********************************************************************* */
149 typedef struct idecommon_dispatch_s idecommon_dispatch_t;
151 struct idecommon_dispatch_s {
152 void *ref;
153 uint32_t baseaddr;
154 uint8_t (*inb)(idecommon_dispatch_t *disp,uint32_t reg);
155 uint16_t (*inw)(idecommon_dispatch_t *disp,uint32_t reg);
156 void (*ins)(idecommon_dispatch_t *disp,uint32_t reg,uint8_t *buf,int len);
158 void (*outb)(idecommon_dispatch_t *disp,uint32_t reg,uint8_t val);
159 void (*outw)(idecommon_dispatch_t *disp,uint32_t reg,uint16_t val);
160 void (*outs)(idecommon_dispatch_t *disp,uint32_t reg,uint8_t *buf,int len);
163 #define IDEDISP_WRITEREG8(ide,reg,val) (*((ide)->outb))(ide,reg,val)
164 #define IDEDISP_WRITEREG16(ide,reg,val) (*((ide)->outw))(ide,reg,val)
165 #define IDEDISP_WRITEBUF(ide,reg,buf,len) (*((ide)->outs))(ide,reg,buf,len)
166 #define IDEDISP_READREG8(ide,reg) (*((ide)->inb))(ide,reg)
167 #define IDEDISP_READREG16(ide,reg) (*((ide)->inw))(ide,reg)
168 #define IDEDISP_READBUF(ide,reg,buf,len) (*((ide)->ins))(ide,reg,buf,len)
170 typedef struct idecommon_s idecommon_t;
172 struct idecommon_s {
173 idecommon_dispatch_t *idecommon_dispatch;
174 unsigned long idecommon_addr; /* physical address */
175 int idecommon_unit; /* 0 or 1 master/slave */
176 int idecommon_sectorsize; /* size of each sector */
177 long long idecommon_ttlsect; /* total sectors */
178 int idecommon_atapi; /* 1 if ATAPI device */
179 int idecommon_devtype; /* device type */
180 uint64_t idecommon_deferprobe; /* Defer probe to open */
181 uint32_t idecommon_flags; /* flags for underlying driver */
182 int (*idecommon_readfunc)(idecommon_t *ide,uint64_t lba,int numsec,uint8_t *buffer);
183 int (*idecommon_writefunc)(idecommon_t *ide,uint64_t lba,int numsec,uint8_t *buffer);
185 uint32_t timer;
190 /* *********************************************************************
191 * Prototypes
192 ********************************************************************* */
194 extern void idecommon_init(idecommon_t *ide,int devtype);
195 extern int idecommon_open(cfe_devctx_t *ctx);
196 extern int idecommon_read(cfe_devctx_t *ctx,iocb_buffer_t *buffer);
197 extern int idecommon_inpstat(cfe_devctx_t *ctx,iocb_inpstat_t *inpstat);
198 extern int idecommon_write(cfe_devctx_t *ctx,iocb_buffer_t *buffer);
199 extern int idecommon_ioctl(cfe_devctx_t *ctx,iocb_buffer_t *buffer);
200 extern int idecommon_identify(idecommon_t *ide,unsigned char *buffer);
201 extern int idecommon_close(cfe_devctx_t *ctx);
202 extern int idecommon_devprobe(idecommon_t *ide,int noisy);
203 void idecommon_attach(cfe_devdisp_t *disp);