2 * This file is part of the UCB release of Plan 9. It is subject to the license
3 * terms in the LICENSE file found in the top-level directory of this
4 * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
5 * part of the UCB release of Plan 9, including this file, may be copied,
6 * modified, propagated, or distributed except according to the terms contained
13 typedef struct SDev SDev;
14 typedef struct SDifc SDifc;
15 typedef struct SDio SDio;
16 typedef struct SDpart SDpart;
17 typedef struct SDperm SDperm;
18 typedef struct SDreq SDreq;
19 typedef struct SDunit SDunit;
38 unsigned char inquiry[255]; /* format follows SCSI spec */
39 unsigned char sense[18]; /* format follows SCSI spec */
45 SDpart *part; /* nil or array of size npart */
50 QLock raw; /* raw read or write in progress */
51 uint32_t rawinuse; /* really just a test-and-set */
58 * Each controller is represented by a SDev.
61 Ref r; /* Number of callers using device */
62 SDifc *ifc; /* pnp/legacy */
68 QLock ql; /* enable/disable */
70 int nunit; /* Number of units */
71 QLock unitlock; /* `Loading' of units */
72 int *unitflg; /* Unit flags */
80 SDev *(*legacy)(int, int);
81 int (*enable)(SDev *);
82 int (*disable)(SDev *);
84 int (*verify)(SDunit *);
85 int (*online)(SDunit *);
87 int (*rctl)(SDunit *, char *, int);
88 int (*wctl)(SDunit *, Cmdbuf *);
90 int32_t (*bio)(SDunit *, int, int, void *, int32_t, uint64_t);
91 SDev *(*probe)(DevConf *);
92 void (*clear)(SDev *);
93 char *(*rtopctl)(SDev *, char *, char *);
94 int (*wtopctl)(SDev *, Cmdbuf *);
101 unsigned char cmd[16];
110 unsigned char sense[256];
114 SDnosense = 0x00000001,
115 SDvalidsense = 0x00010000,
117 SDinq0periphqual = 0xe0,
118 SDinq0periphtype = 0x1f,
119 SDinq1removable = 0x80,
121 /* periphtype values */
122 SDperdisk = 0, /* Direct access (disk) */
123 SDpertape = 1, /* Sequential eg, tape */
124 SDperpr = 2, /* Printer */
125 SDperworm = 4, /* Worm */
126 SDpercd = 5, /* CD-ROM */
127 SDpermo = 7, /* rewriteable MO */
128 SDperjuke = 8, /* medium-changer */
132 SDretry = -5, /* internal to controllers */
140 SDcheck = 0x02, /* check condition */
141 SDbusy = 0x08, /* busy */
143 SDmaxio = 2048 * 1024,
148 * Allow the default #defines for sdmalloc & sdfree to be overridden by
149 * system-specific versions. This can be used to avoid extra copying
150 * by making sure sd buffers are cache-aligned (some ARM systems) or
151 * page-aligned (xen) for DMA.
154 #define sdmalloc(n) malloc(n)
155 #define sdfree(p) free(p)
159 * mmc/sd/sdio host controller interface
165 void (*enable)(void);
166 int (*inquiry)(char *, int);
167 int (*cmd)(uint32_t, uint32_t, uint32_t *);
168 void (*iosetup)(int, void *, int, int);
169 void (*io)(int, unsigned char *, int);
175 extern void sdadddevs(SDev *);
176 extern void sdaddconf(SDunit *);
177 extern void sdaddallconfs(void (*f)(SDunit *));
178 extern void sdaddpart(SDunit *, char *, uint64_t, uint64_t);
179 extern int sdsetsense(SDreq *, int, int, int, int);
180 extern int sdmodesense(SDreq *, unsigned char *, void *, int);
181 extern int sdfakescsi(SDreq *, void *, int);
184 extern int scsiverify(SDunit *);
185 extern int scsionline(SDunit *);
186 extern int32_t scsibio(SDunit *, int, int, void *, int32_t, uint64_t);
187 extern SDev *scsiid(SDev *, SDifc *);
190 * hardware info about a device
192 typedef struct devport {
198 uint32_t intnum; /* interrupt number */
199 char *type; /* card type, malloced */
200 int nports; /* Number of ports */
201 Devport *ports; /* The ports themselves */