bsd_kernel.h revision 266396
1181335Sjhb/* $FreeBSD: head/sys/boot/usb/bsd_kernel.h 266396 2014-05-18 09:29:00Z hselasky $ */
2181335Sjhb/*-
3181335Sjhb * Copyright (c) 2011 Hans Petter Selasky. All rights reserved.
4181335Sjhb *
5181335Sjhb * Redistribution and use in source and binary forms, with or without
6181335Sjhb * modification, are permitted provided that the following conditions
7181335Sjhb * are met:
8181335Sjhb * 1. Redistributions of source code must retain the above copyright
9181335Sjhb *    notice, this list of conditions and the following disclaimer.
10181335Sjhb * 2. Redistributions in binary form must reproduce the above copyright
11181335Sjhb *    notice, this list of conditions and the following disclaimer in the
12181335Sjhb *    documentation and/or other materials provided with the distribution.
13181335Sjhb *
14181335Sjhb * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15181335Sjhb * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16181335Sjhb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17181335Sjhb * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18181335Sjhb * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19181335Sjhb * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20181335Sjhb * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21181335Sjhb * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22181335Sjhb * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23181335Sjhb * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24181335Sjhb * SUCH DAMAGE.
25181335Sjhb */
26181335Sjhb
27181335Sjhb#ifndef _BSD_KERNEL_H_
28181335Sjhb#define	_BSD_KERNEL_H_
29181335Sjhb
30181335Sjhb#define	_KERNEL
31181335Sjhb#define	__FreeBSD_version 1000000
32181335Sjhb
33181335Sjhb#include <sys/cdefs.h>
34181335Sjhb#include <sys/queue.h>
35181335Sjhb#include <sys/errno.h>
36181335Sjhb
37181335Sjhb#define	isalpha(x) (((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z'))
38181335Sjhb#define	isdigit(x) ((x) >= '0' && (x) <= '9')
39181335Sjhb#define	panic(...) do { printf("USB PANIC: " __VA_ARGS__); while (1) ; } while (0)
40181335Sjhb#define	M_USB 0
41181335Sjhb#define	M_USBDEV 0
42181335Sjhb#define	USB_PROC_MAX 3
43181335Sjhb#define	USB_BUS_GIANT_PROC(bus) (usb_process + 2)
44181335Sjhb#define	USB_BUS_NON_GIANT_PROC(bus) (usb_process + 2)
45181335Sjhb#define	USB_BUS_EXPLORE_PROC(bus) (usb_process + 0)
46181335Sjhb#define	USB_BUS_CONTROL_XFER_PROC(bus) (usb_process + 1)
47181335Sjhb#define	SYSCTL_DECL(...)
48232666Semaste#define	SYSCTL_NODE(name,...) struct { } name __used
49232666Semaste#define	SYSCTL_INT(...)
50232666Semaste#define	TUNABLE_INT(...)
51232666Semaste#define	MALLOC_DECLARE(...)
52181335Sjhb#define	MALLOC_DEFINE(...)
53181335Sjhb#define	EVENTHANDLER_DECLARE(...)
54181335Sjhb#define	EVENTHANDLER_INVOKE(...)
55181335Sjhb#define	KASSERT(...)
56181335Sjhb#define	SCHEDULER_STOPPED(x) (0)
57216077Scperciva#define	PI_SWI(...) (0)
58181335Sjhb#define	UNIQ_NAME(x) x
59181335Sjhb#define	UNIQ_NAME_STR(x) #x
60181335Sjhb#define	DEVCLASS_MAXUNIT 32
61181335Sjhb#define	MOD_LOAD 1
62181335Sjhb#define	MOD_UNLOAD 2
63181335Sjhb#define	DEVMETHOD(what,func) { #what, (void *)&func }
64181335Sjhb#define	DEVMETHOD_END {0,0}
65181335Sjhb#define	DRIVER_MODULE(name, busname, driver, devclass, evh, arg)	\
66181335Sjhb  static struct module_data bsd_##name##_##busname##_driver_mod = {	\
67181335Sjhb	evh, arg, #busname, #name, #busname "/" #name,			\
68181335Sjhb	&driver, &devclass, { 0, 0 } };					\
69181335SjhbSYSINIT(bsd_##name##_##busname##_driver_mod, SI_SUB_DRIVERS,		\
70181335Sjhb  SI_ORDER_MIDDLE, module_register,					\
71181335Sjhb  &bsd_##name##_##busname##_driver_mod)
72181335Sjhb#define	SYSINIT(uniq, subs, order, _func, _data)	\
73181335Sjhbconst struct sysinit UNIQ_NAME(sysinit_##uniq) = {	\
74181335Sjhb	.func = (_func),				\
75181335Sjhb	.data = __DECONST(void *, _data)		\
76181335Sjhb};							\
77181335SjhbSYSINIT_ENTRY(uniq##_entry, "sysinit", (subs),		\
78181335Sjhb    (order), "const struct sysinit",			\
79181335Sjhb    UNIQ_NAME_STR(sysinit_##uniq), "SYSINIT")
80181335Sjhb
81181335Sjhb#define	SYSUNINIT(uniq, subs, order, _func, _data)	\
82181335Sjhbconst struct sysinit UNIQ_NAME(sysuninit_##uniq) = {	\
83181335Sjhb	.func = (_func),				\
84181335Sjhb	.data = __DECONST(void *, _data)		\
85181335Sjhb};							\
86181335SjhbSYSINIT_ENTRY(uniq##_entry, "sysuninit", (subs),	\
87181335Sjhb    (order), "const struct sysuninit",			\
88181335Sjhb    UNIQ_NAME_STR(sysuninit_##uniq), "SYSUNINIT")
89181335Sjhb#define	MODULE_DEPEND(...)
90181335Sjhb#define	MODULE_VERSION(...)
91181335Sjhb#define	NULL ((void *)0)
92181335Sjhb#define	BUS_SPACE_BARRIER_READ 0x01
93181335Sjhb#define	BUS_SPACE_BARRIER_WRITE 0x02
94181335Sjhb#define	hz 1000
95181335Sjhb#define	PAGE_SIZE 4096
96181335Sjhb#define	MIN(a,b) (((a) < (b)) ? (a) : (b))
97181335Sjhb#define	MAX(a,b) (((a) > (b)) ? (a) : (b))
98181335Sjhb#define	MTX_DEF 0
99181335Sjhb#define	MTX_SPIN 0
100181335Sjhb#define	MTX_RECURSE 0
101181335Sjhb#define	SX_DUPOK 0
102181335Sjhb#define	SX_NOWITNESS 0
103181335Sjhb#define	WITNESS_WARN(...)
104181335Sjhb#define	cold 0
105181335Sjhb#define	BUS_PROBE_GENERIC 0
106181335Sjhb#define	CALLOUT_RETURNUNLOCKED 0x1
107181335Sjhb#define	va_list __builtin_va_list
108181335Sjhb#define	va_size(type) __builtin_va_size(type)
109181335Sjhb#define	va_start(ap, last) __builtin_va_start(ap, last)
110181335Sjhb#define	va_end(ap) __builtin_va_end(ap)
111181335Sjhb#define	va_arg(ap, type) __builtin_va_arg((ap), type)
112181335Sjhb#define	DEVICE_ATTACH(dev, ...) \
113181335Sjhb  (((device_attach_t *)(device_get_method(dev, "device_attach")))(dev,## __VA_ARGS__))
114181335Sjhb#define	DEVICE_DETACH(dev, ...) \
115181335Sjhb  (((device_detach_t *)(device_get_method(dev, "device_detach")))(dev,## __VA_ARGS__))
116181335Sjhb#define	DEVICE_PROBE(dev, ...) \
117181335Sjhb  (((device_probe_t *)(device_get_method(dev, "device_probe")))(dev,## __VA_ARGS__))
118181335Sjhb#define	DEVICE_RESUME(dev, ...) \
119181335Sjhb  (((device_resume_t *)(device_get_method(dev, "device_resume")))(dev,## __VA_ARGS__))
120181335Sjhb#define	DEVICE_SHUTDOWN(dev, ...) \
121181335Sjhb  (((device_shutdown_t *)(device_get_method(dev, "device_shutdown")))(dev,## __VA_ARGS__))
122181335Sjhb#define	DEVICE_SUSPEND(dev, ...) \
123181335Sjhb  (((device_suspend_t *)(device_get_method(dev, "device_suspend")))(dev,## __VA_ARGS__))
124181335Sjhb#define	USB_HANDLE_REQUEST(dev, ...) \
125181335Sjhb  (((usb_handle_request_t *)(device_get_method(dev, "usb_handle_request")))(dev,## __VA_ARGS__))
126181335Sjhb#define	USB_TAKE_CONTROLLER(dev, ...) \
127181335Sjhb  (((usb_take_controller_t *)(device_get_method(dev, "usb_take_controller")))(dev,## __VA_ARGS__))
128181335Sjhb
129181335Sjhbenum {
130181335Sjhb	SI_SUB_DUMMY = 0x0000000,
131181335Sjhb	SI_SUB_LOCK = 0x1B00000,
132181335Sjhb	SI_SUB_KLD = 0x2000000,
133181335Sjhb	SI_SUB_DRIVERS = 0x3100000,
134181335Sjhb	SI_SUB_PSEUDO = 0x7000000,
135181335Sjhb	SI_SUB_KICK_SCHEDULER = 0xa000000,
136181335Sjhb	SI_SUB_RUN_SCHEDULER = 0xfffffff
137181335Sjhb};
138181335Sjhb
139181335Sjhbenum {
140181335Sjhb	SI_ORDER_FIRST = 0x0000000,
141181335Sjhb	SI_ORDER_SECOND = 0x0000001,
142181335Sjhb	SI_ORDER_THIRD = 0x0000002,
143181335Sjhb	SI_ORDER_FOURTH = 0x0000003,
144181335Sjhb	SI_ORDER_MIDDLE = 0x1000000,
145181335Sjhb	SI_ORDER_ANY = 0xfffffff	/* last */
146181335Sjhb};
147181335Sjhb
148181335Sjhbstruct uio;
149181335Sjhbstruct thread;
150181335Sjhbstruct malloc_type;
151198846Sdelphijstruct usb_process;
152198846Sdelphij
153181335Sjhbtypedef unsigned char uint8_t;
154181335Sjhbtypedef signed char int8_t;
155181335Sjhb
156181335Sjhbtypedef unsigned short uint16_t;
157181335Sjhbtypedef signed short int16_t;
158181335Sjhb
159181335Sjhbtypedef unsigned int uint32_t;
160181335Sjhbtypedef signed int int32_t;
161181335Sjhb
162181335Sjhbtypedef unsigned long long uint64_t;
163181335Sjhbtypedef signed long long int64_t;
164181335Sjhb
165181335Sjhbtypedef unsigned long bus_addr_t;
166181335Sjhbtypedef unsigned long bus_size_t;
167181335Sjhb
168181335Sjhbtypedef unsigned long size_t;
169181335Sjhbtypedef unsigned long u_long;
170181335Sjhb
171181335Sjhbtypedef void *bus_dmamap_t;
172181335Sjhbtypedef void *bus_dma_tag_t;
173181335Sjhb
174181335Sjhbtypedef void *bus_space_tag_t;
175181335Sjhbtypedef uint8_t *bus_space_handle_t;
176181335Sjhb
177181335Sjhbtypedef uint16_t uid_t;
178181335Sjhbtypedef uint16_t gid_t;
179181335Sjhbtypedef uint16_t mode_t;
180181335Sjhb
181181335Sjhbtypedef uint8_t *caddr_t;
182181335Sjhbtypedef unsigned long __uintptr_t;
183181335Sjhbtypedef unsigned long uintptr_t;
184181335Sjhb
185181335Sjhb/* SYSINIT API */
186181335Sjhb
187181335Sjhb#include <sysinit.h>
188181335Sjhb
189181335Sjhbstruct sysinit {
190181335Sjhb	void    (*func) (void *arg);
191181335Sjhb	void   *data;
192181335Sjhb};
193181335Sjhb
194181335Sjhb/* MUTEX API */
195181335Sjhb
196181335Sjhbstruct mtx {
197181335Sjhb	int	owned;
198181335Sjhb	struct mtx *parent;
199181335Sjhb};
200181335Sjhb
201181335Sjhb#define	mtx_assert(...) do { } while (0)
202181335Sjhbvoid	mtx_init(struct mtx *, const char *, const char *, int);
203181335Sjhbvoid	mtx_lock(struct mtx *);
204181335Sjhbvoid	mtx_unlock(struct mtx *);
205181335Sjhb#define	mtx_lock_spin(x) mtx_lock(x)
206181335Sjhb#define	mtx_unlock_spin(x) mtx_unlock(x)
207181335Sjhbint	mtx_owned(struct mtx *);
208181335Sjhbvoid	mtx_destroy(struct mtx *);
209181335Sjhb
210181335Sjhbextern struct mtx Giant;
211181335Sjhb
212181335Sjhb/* SX API */
213181335Sjhb
214181335Sjhbstruct sx {
215181335Sjhb	int	owned;
216181335Sjhb};
217181335Sjhb
218181335Sjhb#define	sx_assert(...) do { } while (0)
219181335Sjhb#define	sx_init(...) sx_init_flags(__VA_ARGS__, 0)
220181335Sjhbvoid	sx_init_flags(struct sx *, const char *, int);
221181335Sjhbvoid	sx_destroy(struct sx *);
222181335Sjhbvoid	sx_xlock(struct sx *);
223181335Sjhbvoid	sx_xunlock(struct sx *);
224181335Sjhbint	sx_xlocked(struct sx *);
225181335Sjhb
226181335Sjhb/* CONDVAR API */
227181335Sjhb
228181335Sjhbstruct cv {
229181335Sjhb	int	sleeping;
230181335Sjhb};
231181335Sjhb
232181335Sjhbvoid	cv_init(struct cv *, const char *desc);
233181335Sjhbvoid	cv_destroy(struct cv *);
234181335Sjhbvoid	cv_wait(struct cv *, struct mtx *);
235181335Sjhbint	cv_timedwait(struct cv *, struct mtx *, int);
236181335Sjhbvoid	cv_signal(struct cv *);
237181335Sjhbvoid	cv_broadcast(struct cv *);
238181335Sjhb
239181335Sjhb/* CALLOUT API */
240181335Sjhb
241181335Sjhbtypedef void callout_fn_t (void *);
242181335Sjhb
243181335Sjhbextern volatile int ticks;
244181335Sjhb
245181335Sjhbstruct callout {
246181335Sjhb	LIST_ENTRY(callout) entry;
247181335Sjhb	callout_fn_t *func;
248181335Sjhb	void   *arg;
249181335Sjhb	struct mtx *mtx;
250181335Sjhb	int	flags;
251181335Sjhb	int	timeout;
252181335Sjhb};
253181335Sjhb
254181335Sjhbvoid	callout_init_mtx(struct callout *, struct mtx *, int);
255181335Sjhbvoid	callout_reset(struct callout *, int, callout_fn_t *, void *);
256181335Sjhbvoid	callout_stop(struct callout *);
257181335Sjhbvoid	callout_drain(struct callout *);
258181335Sjhbint	callout_pending(struct callout *);
259181335Sjhbvoid	callout_process(int timeout);
260181335Sjhb
261181335Sjhb/* DEVICE API */
262181335Sjhb
263181335Sjhbstruct driver;
264181335Sjhbstruct devclass;
265181335Sjhbstruct device;
266181335Sjhbstruct module;
267181335Sjhbstruct module_data;
268181335Sjhb
269181335Sjhbtypedef struct driver driver_t;
270181335Sjhbtypedef struct devclass *devclass_t;
271254959Sgavintypedef struct device *device_t;
272181335Sjhbtypedef void (driver_intr_t)(void *arg);
273254959Sgavintypedef int (driver_filter_t)(void *arg);
274181335Sjhb#define	FILTER_STRAY		0x01
275181335Sjhb#define	FILTER_HANDLED		0x02
276181335Sjhb#define	FILTER_SCHEDULE_THREAD	0x04
277181335Sjhb
278181335Sjhbtypedef int device_attach_t (device_t dev);
279181335Sjhbtypedef int device_detach_t (device_t dev);
280181335Sjhbtypedef int device_resume_t (device_t dev);
281181335Sjhbtypedef int device_shutdown_t (device_t dev);
282181335Sjhbtypedef int device_probe_t (device_t dev);
283181335Sjhbtypedef int device_suspend_t (device_t dev);
284181335Sjhb
285181335Sjhbtypedef int bus_child_location_str_t (device_t parent, device_t child, char *buf, size_t buflen);
286181335Sjhbtypedef int bus_child_pnpinfo_str_t (device_t parent, device_t child, char *buf, size_t buflen);
287181335Sjhbtypedef void bus_driver_added_t (device_t dev, driver_t *driver);
288181335Sjhb
289181335Sjhbstruct device_method {
290181335Sjhb	const char *desc;
291181335Sjhb	void   *const func;
292181335Sjhb};
293181335Sjhb
294181335Sjhbtypedef struct device_method device_method_t;
295181335Sjhb
296181335Sjhbstruct device {
297181335Sjhb	TAILQ_HEAD(device_list, device) dev_children;
298181335Sjhb	TAILQ_ENTRY(device) dev_link;
299181335Sjhb
300181335Sjhb	struct device *dev_parent;
301181335Sjhb	const struct module_data *dev_module;
302181335Sjhb	void   *dev_sc;
303181335Sjhb	void   *dev_aux;
304181335Sjhb	driver_filter_t *dev_irq_filter;
305181335Sjhb	driver_intr_t *dev_irq_fn;
306181335Sjhb	void   *dev_irq_arg;
307181335Sjhb
308181335Sjhb	uint16_t dev_unit;
309181335Sjhb
310198586Sjhb	char	dev_nameunit[64];
311198586Sjhb	char	dev_desc[64];
312198586Sjhb
313198586Sjhb	uint8_t	dev_res_alloc:1;
314198586Sjhb	uint8_t	dev_quiet:1;
315198586Sjhb	uint8_t	dev_softc_set:1;
316198586Sjhb	uint8_t	dev_softc_alloc:1;
317	uint8_t	dev_attached:1;
318	uint8_t	dev_fixed_class:1;
319	uint8_t	dev_unit_manual:1;
320};
321
322struct devclass {
323	device_t dev_list[DEVCLASS_MAXUNIT];
324};
325
326struct driver {
327	const char *name;
328	const struct device_method *methods;
329	uint32_t size;
330};
331
332struct module_data {
333	int     (*callback) (struct module *, int, void *arg);
334	void   *arg;
335	const char *bus_name;
336	const char *mod_name;
337	const char *long_name;
338	const struct driver *driver;
339	struct devclass **devclass_pp;
340	TAILQ_ENTRY(module_data) entry;
341};
342
343device_t device_get_parent(device_t dev);
344void   *device_get_method(device_t dev, const char *what);
345const char *device_get_name(device_t dev);
346const char *device_get_nameunit(device_t dev);
347
348#define	device_printf(dev, fmt,...) \
349	printf("%s: " fmt, device_get_nameunit(dev),## __VA_ARGS__)
350device_t device_add_child(device_t dev, const char *name, int unit);
351void	device_quiet(device_t dev);
352void	device_set_interrupt(device_t dev, driver_filter_t *, driver_intr_t *, void *);
353void	device_run_interrupts(device_t parent);
354void	device_set_ivars(device_t dev, void *ivars);
355void   *device_get_ivars(device_t dev);
356const char *device_get_desc(device_t dev);
357int	device_probe_and_attach(device_t dev);
358int	device_detach(device_t dev);
359void   *device_get_softc(device_t dev);
360void	device_set_softc(device_t dev, void *softc);
361int	device_delete_child(device_t dev, device_t child);
362int	device_delete_children(device_t dev);
363int	device_is_attached(device_t dev);
364void	device_set_desc(device_t dev, const char *desc);
365void	device_set_desc_copy(device_t dev, const char *desc);
366int	device_get_unit(device_t dev);
367void   *devclass_get_softc(devclass_t dc, int unit);
368int	devclass_get_maxunit(devclass_t dc);
369device_t devclass_get_device(devclass_t dc, int unit);
370devclass_t devclass_find(const char *classname);
371
372#define	bus_get_dma_tag(...) (NULL)
373int	bus_generic_detach(device_t dev);
374int	bus_generic_resume(device_t dev);
375int	bus_generic_shutdown(device_t dev);
376int	bus_generic_suspend(device_t dev);
377int	bus_generic_print_child(device_t dev, device_t child);
378void	bus_generic_driver_added(device_t dev, driver_t *driver);
379
380/* BUS SPACE API */
381
382void	bus_space_write_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset, uint8_t data);
383void	bus_space_write_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset, uint16_t data);
384void	bus_space_write_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset, uint32_t data);
385
386uint8_t	bus_space_read_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset);
387uint16_t bus_space_read_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset);
388uint32_t bus_space_read_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset);
389
390void	bus_space_read_multi_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset, uint8_t *datap, bus_size_t count);
391void	bus_space_read_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset, uint16_t *datap, bus_size_t count);
392void	bus_space_read_multi_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset, uint32_t *datap, bus_size_t count);
393
394void	bus_space_write_multi_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset, uint8_t *datap, bus_size_t count);
395void	bus_space_write_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset, uint16_t *datap, bus_size_t count);
396void	bus_space_write_multi_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset, uint32_t *datap, bus_size_t count);
397
398void	bus_space_read_region_1(bus_space_tag_t space, bus_space_handle_t handle, bus_size_t offset, uint8_t *datap, bus_size_t count);
399void	bus_space_write_region_1(bus_space_tag_t space, bus_space_handle_t handle, bus_size_t offset, uint8_t *datap, bus_size_t count);
400void	bus_space_read_region_4(bus_space_tag_t space, bus_space_handle_t handle, bus_size_t offset, uint32_t *datap, bus_size_t count);
401void	bus_space_write_region_4(bus_space_tag_t space, bus_space_handle_t handle, bus_size_t offset, uint32_t *datap, bus_size_t count);
402
403void	bus_space_barrier(bus_space_tag_t space, bus_space_handle_t handle, bus_size_t offset, bus_size_t length, int flags);
404
405void	module_register(void *);
406
407/* LIB-C */
408
409void   *memset(void *, int, size_t len);
410void   *memcpy(void *, const void *, size_t len);
411int	printf(const char *,...) __printflike(1, 2);
412int	snprintf(char *restrict str, size_t size, const char *restrict format,...) __printflike(3, 4);
413size_t	strlen(const char *s);
414
415/* MALLOC API */
416
417#define	malloc(s,x,f) usb_malloc(s)
418void   *usb_malloc(size_t);
419
420#define	free(p,x) usb_free(p)
421void	usb_free(void *);
422
423#define	strdup(p,x) usb_strdup(p)
424char   *usb_strdup(const char *str);
425
426/* ENDIANNESS */
427
428/* Assume little endian */
429
430#define	htole64(x) ((uint64_t)(x))
431#define	le64toh(x) ((uint64_t)(x))
432
433#define	htole32(x) ((uint32_t)(x))
434#define	le32toh(x) ((uint32_t)(x))
435
436#define	htole16(x) ((uint16_t)(x))
437#define	le16toh(x) ((uint16_t)(x))
438
439#define	be32toh(x) ((uint32_t)(x))
440#define	htobe32(x) ((uint32_t)(x))
441
442/* USB */
443
444typedef int usb_handle_request_t (device_t dev, const void *req, void **pptr, uint16_t *plen, uint16_t offset, uint8_t *pstate);
445typedef int usb_take_controller_t (device_t dev);
446
447void	usb_idle(void);
448void	usb_init(void);
449void	usb_uninit(void);
450
451/* set some defaults */
452
453#ifndef USB_POOL_SIZE
454#define	USB_POOL_SIZE (1024*1024)	/* 1 MByte */
455#endif
456
457int	pause(const char *, int);
458void	DELAY(unsigned int);
459
460/* OTHER */
461
462struct selinfo {
463};
464
465/* SYSTEM STARTUP API */
466
467extern const void *sysinit_data[];
468extern const void *sysuninit_data[];
469
470#endif					/* _BSD_KERNEL_H_ */
471