1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 #ifndef _USB_PORT_H
43 #define _USB_PORT_H
44
45
46
47
48
49
50 #ifdef __HAVE_GENERIC_SOFT_INTERRUPTS
51 #define USB_USE_SOFTINTR
52 #else
53 #undef USB_USE_SOFTINTR
54 #endif
55
56 #define Static
57
58 #define UMASS_ATAPISTR "atapiscsi"
59
60
61 #define PQUIRK_NOSENSE ADEV_NOSENSE
62 #define PQUIRK_ONLYBIG SDEV_ONLYBIG
63
64 #define sel_klist si_note
65
66 typedef struct proc *usb_proc_ptr;
67
68 #define UCOMBUSCF_PORTNO 0
69 #define UCOMBUSCF_PORTNO_DEFAULT -1
70 #define UHIDBUSCF_REPORTID 0
71 #define UHIDBUSCF_REPORTID_DEFAULT -1
72
73 #define mstohz(ms) ((ms) * hz / 1000)
74
75 #define sel_klist si_note
76
77 typedef int usb_malloc_type;
78
79 #define if_deactivate(x)
80 #define IF_INPUT(ifp, m) ether_input_mbuf((ifp), (m))
81
82 #define swap_bytes_change_sign16_le swap_bytes_change_sign16
83 #define change_sign16_swap_bytes_le change_sign16_swap_bytes
84 #define change_sign16_le change_sign16
85
86 #define ulinear8_to_slinear16_le ulinear8_to_linear16_le
87 #define ulinear8_to_slinear16_be ulinear8_to_linear16_be
88 #define slinear16_to_ulinear8_le linear16_to_ulinear8_le
89 #define slinear16_to_ulinear8_be linear16_to_ulinear8_be
90
91 typedef struct device *device_ptr_t;
92 #define USBBASEDEVICE struct device
93 #define USBDEV(bdev) (&(bdev))
94 #define USBDEVNAME(bdev) ((bdev).dv_xname)
95 #define USBDEVUNIT(bdev) ((bdev).dv_unit)
96 #define USBDEVPTRNAME(bdevptr) ((bdevptr)->dv_xname)
97 #define USBGETSOFTC(d) ((void *)(d))
98
99 #define DECLARE_USB_DMA_T \
100 struct usb_dma_block; \
101 typedef struct { \
102 struct usb_dma_block *block; \
103 u_int offs; \
104 } usb_dma_t
105
106 typedef struct timeout usb_callout_t;
107 #define usb_callout_init(h) timeout_set(&(h), NULL, NULL)
108 #define usb_callout(h, t, f, d) \
109 do { \
110 timeout_del(&(h)); \
111 timeout_set(&(h), (f), (d)); \
112 timeout_add(&(h), (t)); \
113 } while (0)
114 #define usb_callout_pending(h) timeout_pending(&(h))
115 #define usb_uncallout(h, f, d) timeout_del(&(h))
116
117 #define USB_DECLARE_DRIVER_CLASS(dname, devclass) \
118 int __CONCAT(dname,_match)(struct device *, void *, void *); \
119 void __CONCAT(dname,_attach)(struct device *, struct device *, void *); \
120 int __CONCAT(dname,_detach)(struct device *, int); \
121 int __CONCAT(dname,_activate)(struct device *, enum devact); \
122 \
123 struct cfdriver __CONCAT(dname,_cd) = { \
124 NULL, #dname, devclass \
125 }; \
126 \
127 const struct cfattach __CONCAT(dname,_ca) = { \
128 sizeof(struct __CONCAT(dname,_softc)), \
129 __CONCAT(dname,_match), \
130 __CONCAT(dname,_attach), \
131 __CONCAT(dname,_detach), \
132 __CONCAT(dname,_activate), \
133 }
134
135 #define USB_DECLARE_DRIVER(dname) USB_DECLARE_DRIVER_CLASS(dname, DV_DULL)
136
137 #define USB_MATCH(dname) \
138 int \
139 __CONCAT(dname,_match)(parent, match, aux) \
140 struct device *parent; \
141 void *match; \
142 void *aux;
143
144 #define USB_MATCH_START(dname, uaa) \
145 struct usb_attach_arg *uaa = aux
146
147 #define USB_ATTACH(dname) \
148 void \
149 __CONCAT(dname,_attach)(parent, self, aux) \
150 struct device *parent; \
151 struct device *self; \
152 void *aux;
153
154 #define USB_ATTACH_START(dname, sc, uaa) \
155 struct __CONCAT(dname,_softc) *sc = \
156 (struct __CONCAT(dname,_softc) *)self; \
157 struct usb_attach_arg *uaa = aux
158
159
160 #define USB_ATTACH_ERROR_RETURN return
161 #define USB_ATTACH_SUCCESS_RETURN return
162
163 #define USB_ATTACH_SETUP printf("\n")
164
165 #define USB_DETACH(dname) \
166 int \
167 __CONCAT(dname,_detach)(self, flags) \
168 struct device *self; \
169 int flags;
170
171 #define USB_DETACH_START(dname, sc) \
172 struct __CONCAT(dname,_softc) *sc = \
173 (struct __CONCAT(dname,_softc) *)self
174
175 #define USB_GET_SC_OPEN(dname, unit, sc) \
176 if (unit >= __CONCAT(dname,_cd).cd_ndevs) \
177 return (ENXIO); \
178 sc = __CONCAT(dname,_cd).cd_devs[unit]; \
179 if (sc == NULL) \
180 return (ENXIO)
181
182 #define USB_GET_SC(dname, unit, sc) \
183 sc = __CONCAT(dname,_cd).cd_devs[unit]
184
185 #define USB_DO_ATTACH(dev, bdev, parent, args, print, sub) \
186 (config_found_sm(parent, args, print, sub))
187
188 #endif