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