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