]> git.saurik.com Git - apple/xnu.git/blob - osfmk/sys/sdi.h
xnu-1228.tar.gz
[apple/xnu.git] / osfmk / sys / sdi.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28 /*
29 * @OSF_COPYRIGHT@
30 *
31 */
32 /*
33 * HISTORY
34 *
35 * Revision 1.1.1.1 1998/09/22 21:05:48 wsanchez
36 * Import of Mac OS X kernel (~semeria)
37 *
38 * Revision 1.1.1.1 1998/03/07 02:25:59 wsanchez
39 * Import of OSF Mach kernel (~mburg)
40 *
41 * Revision 1.1.7.1 1996/09/17 16:34:56 bruel
42 * removed size_t, already defined in types.h.
43 * [96/09/17 bruel]
44 *
45 * Revision 1.1.4.1 1996/04/17 17:48:54 davidp
46 * Created for use with SVR4 drivers.
47 * [1996/04/11 13:19:26 davidp]
48 *
49 * Revision 1.1.1.2 1996/03/04 17:53:46 calvert
50 * Created for use with SVR4 drivers.
51 *
52 * $EndLog$
53 */
54 /* In vi use ":set ts=4" to edit/view this file
55 */
56 #ifndef _SYS_SDI_H_
57 #define _SYS_SDI_H_ 1
58
59 #include "scsi/scsi_endian.h"
60
61 typedef u_long paddr_t;
62 typedef u_int rm_key_t;
63
64 typedef long hba_clock_t;
65
66 typedef u_long major_t;
67 typedef u_long minor_t;
68
69 typedef u_long hba_buf_t; /* just to satisfy declaration */
70 typedef u_long hba_uio_t; /* just to satisfy declaration */
71
72
73 struct ver_no {
74 uchar_t sv_release;
75 uchar_t sv_machine;
76 short sv_modes;
77 };
78
79 struct hba_idata_v4 {
80 int version_num;
81 char *name;
82 uchar_t ha_id;
83 ulong_t ioaddr1;
84 int dmachan1;
85 int iov;
86 int cntlr;
87 int active;
88 ulong_t idata_memaddr;
89 uchar_t idata_ctlorder;
90 uchar_t idata_nbus;
91 ushort_t idata_ntargets;
92 ushort_t idata_nluns;
93 rm_key_t idata_rmkey;
94 void *idata_intrcookie;
95 int idata_cpubind;
96 };
97
98 struct hba_idata {
99 int version_num;
100 char *name;
101 uchar_t ha_id;
102 ulong_t ioaddr1;
103 int dmachan1;
104 int iov;
105 int cntlr;
106 int active;
107 };
108
109 #define HBA_SVR4_2 1
110 #define HBA_SVR4_2_2 2
111 #define HBA_SVR4_2MP 3
112
113 #define HBA_VMASK 0xffff
114
115 #define HBA_IDATA_EXT 0x10000
116 #define HBA_EXT_INFO 0x20000
117 #define HBA_AUTOCONF 0x40000
118
119 #define VID_LEN 8
120 #define PID_LEN 16
121 #define REV_LEN 4
122
123 #define INQ_LEN VID_LEN+PID_LEN+1
124 #define INQ_EXLEN INQ_LEN+REV_LEN
125
126 struct ident {
127 BITFIELD_2( unsigned char,
128 id_type : 5,
129 id_pqual : 3);
130 BITFIELD_2(unsigned char,
131 id_qualif : 7,
132 id_rmb : 1);
133 uchar_t id_ver;
134 BITFIELD_2(unsigned char,
135 id_form : 4,
136 id_res1 : 4);
137 uchar_t id_len;
138 uchar_t id_vu [3];
139 char id_vendor [VID_LEN];
140 char id_prod [PID_LEN];
141 char id_revnum [REV_LEN];
142 };
143
144 #define SCSI_INQ_CON 0x0
145 #define SCSI_INQ_TC 0x1
146 #define SCSI_INQ_TNC 0x3
147
148 struct scsi_adr {
149 int scsi_ctl;
150 int scsi_target;
151 int scsi_lun;
152 int scsi_bus;
153 };
154
155 struct scsi_ad {
156 ulong_t sa_major;
157 ulong_t sa_minor;
158 uchar_t sa_lun;
159 BITFIELD_2(unsigned char,
160 sa_bus : 3,
161 sa_exta : 5);
162 short sa_ct;
163 };
164
165 /* sa_ct */
166 #define SDI_SA_CT(c,t) (((c) << 3) | ((t) & 0x07))
167 #define SDI_HAN(sa) (((sa)->sa_ct >> 3) & 0x07)
168 #define SDI_TCN(sa) ((sa)->sa_ct & 0x07)
169
170 #define SDI_ETCN(sa) ((sa)->sa_exta)
171 #define SDI_EHAN(sa) (((sa)->sa_ct >> 3) & 0x1f)
172
173 struct sdi_edt {
174 struct sdi_edt *hash_p;
175 short hba_no;
176 uchar_t scsi_id;
177 uchar_t lun;
178 struct owner *curdrv;
179 struct owner *owner_list;
180 ulong_t res1;
181 int pdtype;
182 uchar_t iotype;
183 char inquiry [INQ_EXLEN];
184 struct scsi_adr scsi_adr;
185 ulong_t memaddr;
186 uchar_t ctlorder;
187 struct ident edt_ident;
188 };
189
190 /* iotype */
191 #define F_DMA 0x001
192 #define F_DMA_24 F_DMA
193 #define F_PIO 0x002
194 #define F_SCGTH 0x004
195 #define F_RMB 0x008
196 #define F_DMA_32 0x010
197 #define F_HDWREA 0x020
198 #define F_RESID 0x040
199
200 struct mod_operations {
201 int (*modm_install)(void);
202 int (*modm_remove)(void);
203 int (*modm_info)(void);
204 int (*modm_bind)(void);
205 };
206
207 struct modlink {
208 struct mod_operations *ml_ops;
209 void *ml_type_data;
210 };
211
212 struct mod_type_data {
213 char *mtd_info;
214 void *mtd_pdata;
215 };
216
217 struct modwrapper {
218 int mw_rev;
219 int (*mw_load)(void);
220 int (*mw_unload)(void);
221 void (*mw_halt)(void);
222 void *mw_conf_data;
223 struct modlink *mw_modlink;
224 };
225
226 struct hbadata {
227 struct xsb *sb;
228 };
229
230 typedef struct physreq {
231 paddr_t phys_align;
232 paddr_t phys_boundary;
233 uchar_t phys_dmasize;
234 uchar_t phys_max_scgth;
235 uchar_t phys_flags;
236 void *phys_brkup_poolp;
237 } physreq_t;
238
239
240 typedef struct bcb {
241 uchar_t bcb_addrtypes;
242 uchar_t bcb_flags;
243 size_t bcb_max_xfer;
244 size_t bcb_granularity;
245 physreq_t *bcb_physreqp;
246 } bcb_t;
247
248 struct hbagetinfo {
249 char *name;
250 char iotype;
251 bcb_t *bcbp;
252 };
253
254 struct hba_info {
255 int *hba_flag;
256 ulong_t max_xfer;
257 long (*hba_freeblk)(struct hbadata *hdp, int cntlr);
258 struct hbadata *(*hba_getblk)(int flag, int cntlr);
259 long (*hba_icmd)(struct hbadata *hdp, int flag);
260 void (*hba_getinfo)(struct scsi_ad *sap,
261 struct hbagetinfo *hgip);
262 long (*hba_send)(struct hbadata *hdp, int flag);
263 int (*hba_xlat)(struct hbadata *hdp, int bflag, void *procp,
264 int flag);
265 int (*hba_open)(void);
266 int (*hba_close)(void);
267 int (*hba_ioctl)(void);
268 };
269
270 /* hba_flag */
271 #define HBA_MP 0x01
272 #define HBA_HOT 0x02
273 #define HBA_TIMEOUT 0x04
274
275 #define SC_EXHAN(minor) (((minor) >> 5) & 0x1f)
276 #define SC_EXTCN(minor) ((((minor) >> 2) & 0x07) | ((minor >> 7) & 0x18))
277 #define SC_EXLUN(minor) (((minor) & 0x03) | ((minor>>10) & 0x1C))
278 #define SC_BUS(minor) (((minor) >> 15) & 0x07)
279
280 #define SC_MKMINOR(h,t,l,b) ( \
281 (((h) & 0x1f) << 5) | \
282 (((t) & 0x07) << 2) | (((t) & 0x18) << 7) | \
283 ((l) & 0x03) | (((l) & 0x1c) << 10) | \
284 (((b) & 0x07) << 15) \
285 )
286
287 #define SDI_NAMESZ 49
288
289 #define SM_POOLSIZE 28
290 #define LG_POOLSIZE (sizeof (struct xsb))
291
292 #define SCB_TYPE 1
293 #define ISCB_TYPE 2
294 #define SFB_TYPE 3
295
296 #define SCB_WRITE 0x00
297 #define SCB_READ 0x01
298 #define SCB_LINK 0x02
299 #define SCB_HAAD 0x04
300 #define SCB_PARTBLK 0x08
301
302 #define SDI_NOALLOC 0x00000000
303 #define SDI_ASW 0x00000001
304 #define SDI_LINKF0 0x00000002
305 #define SDI_LINKF1 0x00000003
306 #define SDI_QFLUSH 0xE0000004
307 #define SDI_ABORT 0xF0000005
308 #define SDI_RESET 0xF0000006
309 #define SDI_CRESET 0xD0000007
310 #define SDI_V2PERR 0xA0000008
311 #define SDI_TIME 0xD0000009
312 #define SDI_NOTEQ 0x8000000A
313 #define SDI_HAERR 0xE000000B
314 #define SDI_MEMERR 0xA000000C
315 #define SDI_SBUSER 0xA000000D
316 #define SDI_CKSTAT 0xD000000E
317 #define SDI_SCBERR 0x8000000F
318 #define SDI_OOS 0xA0000010
319 #define SDI_NOSELE 0x90000011
320 #define SDI_MISMAT 0x90000012
321 #define SDI_PROGRES 0x00000013
322 #define SDI_UNUSED 0x00000014
323 #define SDI_ONEIC 0x80000017
324 #define SDI_SFBERR 0x80000019
325 #define SDI_TCERR 0x9000001A
326
327 #define SDI_ERROR 0x80000000
328 #define SDI_RETRY 0x40000000
329 #define SDI_MESS 0x20000000
330 #define SDI_SUSPEND 0x10000000
331
332 #define SFB_NOPF 0x00
333 #define SFB_RESETM 0x01
334 #define SFB_ABORTM 0x02
335 #define SFB_FLUSHR 0x03
336 #define SFB_RESUME 0x04
337 #define SFB_SUSPEND 0x05
338 #define SFB_ADD_DEV 0x06
339 #define SFB_RM_DEV 0x07
340 #define SFB_PAUSE 0x08
341 #define SFB_CONTINUE 0x09
342
343 #define SDI_386_AT 0x06
344 #define SDI_386_MCA 0x07
345 #define SDI_386_EISA 0x08
346
347 #define SDI_RET_OK 0
348 #define SDI_RET_ERR -1
349 #define SDI_RET_RETRY 1
350
351 #define SDI_SEND 0x0081
352 #define SDI_TRESET 0x0082
353 #define SDI_BRESET 0x0084
354 #define HA_VER 0x0083
355 #define SDI_RESERVE 0x0085
356 #define SDI_RELEASE 0x0086
357 #define SDI_RESTAT 0x0087
358 #define HA_GETPARMS 0x008a
359 #define IHA_GETPARMS 0x008b
360 #define HA_SETPARMS 0x008c
361 #define IHA_SETPARMS 0x008d
362 #define HA_GETPPARMS 0x008e
363
364 struct sense {
365 uchar_t sd_pad0;
366 BITFIELD_2(unsigned char,
367 sd_errc : 7,
368 sd_valid : 1);
369 uchar_t sd_res1;
370 BITFIELD_5(unsigned char,
371 sd_key : 4,
372 sd_res2 : 1,
373 sd_ili : 1,
374 sd_eom : 1,
375 sd_fm : 1);
376 uint_t sd_ba;
377 uchar_t sd_len;
378 uchar_t sd_res3 [4];
379 uchar_t sd_sencode;
380 uchar_t sd_qualifier;
381 uchar_t sd_fru;
382 BITFIELD_5(unsigned char,
383 sd_bitpt : 3,
384 sd_bpv : 1,
385 sd_res4 : 2,
386 sd_cd : 1,
387 sd_res5 : 1);
388 uchar_t sd_field [2];
389 uchar_t sd_res6;
390 uchar_t sd_buffer;
391 uchar_t sd_res7 [2];
392 };
393
394
395 struct sb_extra {
396 struct sense sb_sense;
397 };
398
399 #define sc_priv sc_extra
400
401 struct sb;
402
403 struct scb {
404 ulong_t sc_comp_code;
405 void *sc_extra;
406 void (*sc_int)(struct sb *sbp);
407 caddr_t sc_cmdpt;
408 caddr_t sc_datapt;
409 long sc_wd;
410 time_t sc_time;
411 struct scsi_ad sc_dev;
412 ushort_t sc_mode;
413 uchar_t sc_status;
414 char sc_fill;
415 struct sb *sc_link;
416 long sc_cmdsz;
417 long sc_datasz;
418 long sc_resid;
419 hba_clock_t sc_start;
420 };
421
422 struct sfb {
423 ulong_t sf_comp_code;
424 char *sf_priv;
425 void (*sf_int)(struct sb *sbp);
426 struct scsi_ad sf_dev;
427 ulong_t sf_func;
428 int sf_wd;
429 };
430
431 struct sb {
432 ulong_t sb_type;
433 union {
434 struct scb b_scb;
435 struct sfb b_sfb;
436 } sb_b;
437 };
438
439 #define SCB sb_b.b_scb
440 #define SFB sb_b.b_sfb
441
442 struct xsb {
443 struct sb sb;
444 struct hbadata *hbadata_p;
445 struct owner *owner_p;
446 struct sb_extra extra;
447 };
448
449 #define S_GOOD 0X00
450 #define S_CKCON 0X02
451 #define S_METGD 0X04
452 #define S_BUSY 0X08
453 #define S_INGD 0X10
454 #define S_INMET 0X12
455 #define S_RESER 0X18
456 #define S_CTERM 0x22
457 #define S_QFULL 0x28
458
459 #define SLEEP 0
460 #define NOSLEEP 1
461
462 #define KM_SLEEP SLEEP
463 #define KM_NOSLEEP NOSLEEP
464 #define KM_DMA 2
465 #define KM_REQ_DMA 4
466 #define KM_PHYSCONTIG 8
467
468 struct mod_drvintr {
469 ushort_t di_magic;
470 ushort_t di_version;
471 char *di_modname;
472 int *di_devflagp;
473 void (*di_handler)(int vect);
474 void *di_hook;
475 };
476
477 #define MOD_INTR_MAGIC 0xEB13
478 #define MOD_INTR_VER 1
479
480 struct o_mod_drvintr {
481 struct intr_info *drv_intrinfo;
482 void (*ihndler)(int vect);
483 };
484
485 #define MOD_INTRVER_MASK 0xff000000
486 #define MOD_INTRVER_42 0x01000000
487
488 #define INTRVER(infop) ((unsigned int)((infop)->ivect_no & MOD_INTRVER_MASK))
489 #define INTRNO(infop) ((infop)->ivect_no & ~MOD_INTRVER_MASK)
490
491 struct intr_info0 {
492 int ivect_no;
493 int int_pri;
494 int itype;
495 };
496
497 struct intr_info {
498 int ivect_no;
499 int int_pri;
500 int itype;
501 int int_cpu;
502 int int_mp;
503 };
504
505 #endif /* _SYS_SDI_H_ */