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
39 unsigned char inquiry[255]; /* format follows SCSI spec */
40 unsigned char sense[18]; /* format follows SCSI spec */
46 struct sdpart *part; /* nil or array of size npart */
49 struct sdperm ctlperm;
51 qlock_t raw; /* raw read or write in progress */
52 uint32_t rawinuse; /* really just a test-and-set */
55 struct sdperm rawperm;
59 * Each controller is represented by a struct sdev.
62 struct kref r; /* Number of callers using device */
63 struct sdifc *ifc; /* pnp/legacy */
69 qlock_t ql; /* enable/disable */
71 int nunit; /* Number of units */
72 qlock_t unitlock; /* `Loading' of units */
73 int *unitflg; /* Unit flags */
80 struct sdev *(*pnp)(void);
81 struct sdev *(*legacy)(int, int);
82 int (*enable)(struct sdev *);
83 int (*disable)(struct sdev *);
85 int (*verify)(struct sdunit *);
86 int (*online)(struct sdunit *);
87 int (*rio)(struct sdreq *);
88 int (*rctl)(struct sdunit *, char *, int);
89 int (*wctl)(struct sdunit *, struct cmdbuf *);
91 int32_t (*bio)(struct sdunit *, int, int, void *, int32_t, uint64_t);
92 struct sdev *(*probe)(struct devconf *);
93 void (*clear)(struct sdev *);
94 char *(*rtopctl)(struct sdev *, char *, char *);
95 int (*wtopctl)(struct sdev *, struct cmdbuf *);
102 unsigned char cmd[16];
111 unsigned char sense[256];
115 SDnosense = 0x00000001,
116 SDvalidsense = 0x00010000,
118 SDinq0periphqual = 0xe0,
119 SDinq0periphtype = 0x1f,
120 SDinq1removable = 0x80,
122 /* periphtype values */
123 SDperdisk = 0, /* Direct access (disk) */
124 SDpertape = 1, /* Sequential eg, tape */
125 SDperpr = 2, /* Printer */
126 SDperworm = 4, /* Worm */
127 SDpercd = 5, /* CD-ROM */
128 SDpermo = 7, /* rewriteable MO */
129 SDperjuke = 8, /* medium-changer */
133 SDretry = -5, /* internal to controllers */
141 SDcheck = 0x02, /* check condition */
142 SDbusy = 0x08, /* busy */
144 SDmaxio = 2048 * 1024,
149 * mmc/sd/sdio host controller interface
155 void (*enable)(void);
156 int (*inquiry)(char *, int);
157 int (*cmd)(uint32_t, uint32_t, uint32_t *);
158 void (*iosetup)(int, void *, int, int);
159 void (*io)(int, unsigned char *, int);
162 extern struct sdio sdio;
165 extern void sdadddevs(struct sdev *);
166 extern void sdaddconf(struct sdunit *);
167 extern void sdaddallconfs(void (*f)(struct sdunit *));
168 extern void sdaddpart(struct sdunit *, char *, uint64_t, uint64_t);
169 extern int sdsetsense(struct sdreq *, int, int, int, int);
170 extern int sdmodesense(struct sdreq *, unsigned char *, void *, int);
171 extern int sdfakescsi(struct sdreq *, void *, int);
174 extern int scsiverify(struct sdunit *);
175 extern int scsionline(struct sdunit *);
176 extern int32_t scsibio(struct sdunit *, int, int, void *, int32_t, uint64_t);
177 extern struct sdev *scsiid(struct sdev *, struct sdifc *);
180 * hardware info about a device
188 uint32_t intnum; /* interrupt number */
189 char *type; /* card type, malloced */
190 int nports; /* Number of ports */
191 struct devport *ports; /* The ports themselves */