3 * Copyright (c) 2011 Hans Petter Selasky. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 #ifndef _BSD_KERNEL_H_
28 #define _BSD_KERNEL_H_
30 #if !defined(_STANDALONE)
31 #error "_STANDALONE is not defined!"
34 #undef __FreeBSD_version
35 #define __FreeBSD_version 1300000
37 #include <sys/cdefs.h>
38 #include <sys/queue.h>
39 #include <sys/errno.h>
41 #define howmany(x, y) (((x)+((y)-1))/(y))
42 #define nitems(x) (sizeof((x)) / sizeof((x)[0]))
43 #define isalpha(x) (((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z'))
44 #define isdigit(x) ((x) >= '0' && (x) <= '9')
45 #define panic(...) do { printf("USB PANIC: " __VA_ARGS__); while (1) ; } while (0)
49 #define USB_PROC_MAX 3
50 #define USB_BUS_GIANT_PROC(bus) (usb_process + 2)
51 #define USB_BUS_NON_GIANT_BULK_PROC(bus) (usb_process + 2)
52 #define USB_BUS_NON_GIANT_ISOC_PROC(bus) (usb_process + 2)
53 #define USB_BUS_EXPLORE_PROC(bus) (usb_process + 0)
54 #define USB_BUS_CONTROL_XFER_PROC(bus) (usb_process + 1)
55 #define SYSCTL_DECL(...)
56 struct sysctl_ctx_list {
61 #define SYSCTL_HANDLER_ARGS void *oidp, void *arg1, \
62 uint32_t arg2, struct sysctl_req *req
63 #define SYSCTL_NODE(name,...) struct { } name __used
64 #define SYSCTL_INT(...)
65 #define SYSCTL_UINT(...)
66 #define SYSCTL_PROC(...)
67 #define SYSCTL_ADD_NODE(...) NULL
68 #define SYSCTL_ADD_U16(...) NULL
69 #define SYSCTL_ADD_PROC(...) NULL
70 #define sysctl_handle_int(...) EOPNOTSUPP
71 #define sysctl_handle_string(...) EOPNOTSUPP
72 #define sysctl_ctx_init(ctx) do { (void)(ctx); } while (0)
73 #define sysctl_ctx_free(ctx) do { (void)(ctx); } while (0)
74 #define TUNABLE_INT(...)
75 #define MALLOC_DECLARE(...)
76 #define MALLOC_DEFINE(...)
77 #define EVENTHANDLER_DECLARE(...)
78 #define EVENTHANDLER_INVOKE(...)
80 #define SCHEDULER_STOPPED(x) (0)
81 #define PI_SWI(...) (0)
82 #define UNIQ_NAME(x) x
83 #define UNIQ_NAME_STR(x) #x
84 #define DEVCLASS_MAXUNIT 32
87 #define DEVMETHOD(what,func) { #what, (void *)&func }
88 #define DEVMETHOD_END {0,0}
89 #define EARLY_DRIVER_MODULE(a, b, c, d, e, f, g) DRIVER_MODULE(a, b, c, d, e, f)
90 #define DRIVER_MODULE(name, busname, driver, devclass, evh, arg) \
91 static struct module_data bsd_##name##_##busname##_driver_mod = { \
92 evh, arg, #busname, #name, #busname "/" #name, \
93 &driver, &devclass, { 0, 0 } }; \
94 SYSINIT(bsd_##name##_##busname##_driver_mod, SI_SUB_DRIVERS, \
95 SI_ORDER_MIDDLE, module_register, \
96 &bsd_##name##_##busname##_driver_mod)
97 #define SYSINIT(uniq, subs, order, _func, _data) \
98 const struct sysinit UNIQ_NAME(sysinit_##uniq) = { \
100 .data = __DECONST(void *, _data) \
102 SYSINIT_ENTRY(uniq##_entry, "sysinit", (subs), \
103 (order), "const struct sysinit", \
104 UNIQ_NAME_STR(sysinit_##uniq), "SYSINIT")
106 #define SYSUNINIT(uniq, subs, order, _func, _data) \
107 const struct sysinit UNIQ_NAME(sysuninit_##uniq) = { \
109 .data = __DECONST(void *, _data) \
111 SYSINIT_ENTRY(uniq##_entry, "sysuninit", (subs), \
112 (order), "const struct sysuninit", \
113 UNIQ_NAME_STR(sysuninit_##uniq), "SYSUNINIT")
114 #define MODULE_DEPEND(...)
115 #define MODULE_VERSION(...)
116 #define NULL ((void *)0)
117 #define BUS_SPACE_BARRIER_READ 0x01
118 #define BUS_SPACE_BARRIER_WRITE 0x02
121 #define PAGE_SIZE 4096
123 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
125 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
128 #define MTX_RECURSE 0
130 #define SX_NOWITNESS 0
131 #define WITNESS_WARN(...)
133 #define BUS_PROBE_GENERIC 0
134 #define BUS_PROBE_DEFAULT (-20)
135 #define CALLOUT_RETURNUNLOCKED 0x1
137 #define ffs(x) __builtin_ffs(x)
139 #define va_list __builtin_va_list
141 #define va_size(type) __builtin_va_size(type)
143 #define va_start(ap, last) __builtin_va_start(ap, last)
145 #define va_end(ap) __builtin_va_end(ap)
147 #define va_arg(ap, type) __builtin_va_arg((ap), type)
148 #define DEVICE_ATTACH(dev, ...) \
149 (((device_attach_t *)(device_get_method(dev, "device_attach")))(dev,## __VA_ARGS__))
150 #define DEVICE_DETACH(dev, ...) \
151 (((device_detach_t *)(device_get_method(dev, "device_detach")))(dev,## __VA_ARGS__))
152 #define DEVICE_PROBE(dev, ...) \
153 (((device_probe_t *)(device_get_method(dev, "device_probe")))(dev,## __VA_ARGS__))
154 #define DEVICE_RESUME(dev, ...) \
155 (((device_resume_t *)(device_get_method(dev, "device_resume")))(dev,## __VA_ARGS__))
156 #define DEVICE_SHUTDOWN(dev, ...) \
157 (((device_shutdown_t *)(device_get_method(dev, "device_shutdown")))(dev,## __VA_ARGS__))
158 #define DEVICE_SUSPEND(dev, ...) \
159 (((device_suspend_t *)(device_get_method(dev, "device_suspend")))(dev,## __VA_ARGS__))
160 #define USB_HANDLE_REQUEST(dev, ...) \
161 (((usb_handle_request_t *)(device_get_method(dev, "usb_handle_request")))(dev,## __VA_ARGS__))
162 #define USB_TAKE_CONTROLLER(dev, ...) \
163 (((usb_take_controller_t *)(device_get_method(dev, "usb_take_controller")))(dev,## __VA_ARGS__))
164 #define GPIO_PIN_SET(dev, ...) \
165 (((gpio_pin_set_t *)(device_get_method(dev, "gpio_pin_set")))(dev,## __VA_ARGS__))
166 #define GPIO_PIN_SETFLAGS(dev, ...) \
167 (((gpio_pin_setflags_t *)(device_get_method(dev, "gpio_pin_setflags")))(dev,## __VA_ARGS__))
170 SI_SUB_DUMMY = 0x0000000,
171 SI_SUB_LOCK = 0x1B00000,
172 SI_SUB_KLD = 0x2000000,
173 SI_SUB_DRIVERS = 0x3100000,
174 SI_SUB_PSEUDO = 0x7000000,
175 SI_SUB_KICK_SCHEDULER = 0xa000000,
176 SI_SUB_RUN_SCHEDULER = 0xfffffff
180 SI_ORDER_FIRST = 0x0000000,
181 SI_ORDER_SECOND = 0x0000001,
182 SI_ORDER_THIRD = 0x0000002,
183 SI_ORDER_FOURTH = 0x0000003,
184 SI_ORDER_MIDDLE = 0x1000000,
185 SI_ORDER_ANY = 0xfffffff /* last */
194 #define INT32_MAX 0x7fffffff
197 #ifndef HAVE_STANDARD_DEFS
198 #define _UINT8_T_DECLARED
199 typedef unsigned char uint8_t;
200 #define _INT8_T_DECLARED
201 typedef signed char int8_t;
202 #define _UINT16_T_DECLARED
203 typedef unsigned short uint16_t;
204 #define _INT16_T_DECLARED
205 typedef signed short int16_t;
206 #define _UINT32_T_DECLARED
207 typedef unsigned int uint32_t;
208 #define _INT32_T_DECLARED
209 typedef signed int int32_t;
210 #define _UINT64_T_DECLARED
212 typedef unsigned long long uint64_t;
214 typedef unsigned long uint64_t;
216 #define _INT16_T_DECLARED
218 typedef signed long long int64_t;
220 typedef signed long int64_t;
223 typedef uint16_t uid_t;
224 typedef uint16_t gid_t;
225 typedef uint16_t mode_t;
227 typedef uint8_t *caddr_t;
228 #define _UINTPTR_T_DECLARED
229 typedef unsigned long uintptr_t;
231 #define _SIZE_T_DECLARED
232 typedef unsigned long size_t;
233 typedef unsigned long u_long;
236 typedef unsigned long bus_addr_t;
237 typedef unsigned long bus_size_t;
239 typedef struct bus_dma_segment {
240 bus_addr_t ds_addr; /* DMA address */
241 bus_size_t ds_len; /* length of transfer */
249 typedef void *bus_dmamap_t;
250 typedef struct bus_dma_tag *bus_dma_tag_t;
254 BUS_DMA_UNLOCK = 0x02,
257 typedef void *bus_space_tag_t;
258 typedef uint8_t *bus_space_handle_t;
259 typedef int bus_dma_filter_t(void *, bus_addr_t);
260 typedef void bus_dma_lock_t(void *, bus_dma_lock_op_t);
262 typedef uint32_t bool;
269 void (*func) (void *arg);
280 #define mtx_assert(...) do { } while (0)
281 void mtx_init(struct mtx *, const char *, const char *, int);
282 void mtx_lock(struct mtx *);
283 void mtx_unlock(struct mtx *);
284 #define mtx_lock_spin(x) mtx_lock(x)
285 #define mtx_unlock_spin(x) mtx_unlock(x)
286 int mtx_owned(struct mtx *);
287 void mtx_destroy(struct mtx *);
289 extern struct mtx Giant;
297 #define sx_assert(...) do { } while (0)
298 #define sx_init(...) sx_init_flags(__VA_ARGS__, 0)
299 void sx_init_flags(struct sx *, const char *, int);
300 void sx_destroy(struct sx *);
301 void sx_xlock(struct sx *);
302 void sx_xunlock(struct sx *);
303 int sx_xlocked(struct sx *);
311 void cv_init(struct cv *, const char *desc);
312 void cv_destroy(struct cv *);
313 void cv_wait(struct cv *, struct mtx *);
314 int cv_timedwait(struct cv *, struct mtx *, int);
315 void cv_signal(struct cv *);
316 void cv_broadcast(struct cv *);
320 typedef void callout_fn_t (void *);
322 extern volatile int ticks;
325 LIST_ENTRY(callout) entry;
326 callout_fn_t *c_func;
333 void callout_init_mtx(struct callout *, struct mtx *, int);
334 void callout_reset(struct callout *, int, callout_fn_t *, void *);
335 void callout_stop(struct callout *);
336 void callout_drain(struct callout *);
337 int callout_pending(struct callout *);
338 void callout_process(int timeout);
348 typedef struct driver driver_t;
349 typedef struct devclass *devclass_t;
350 typedef struct device *device_t;
351 typedef void (driver_intr_t)(void *arg);
352 typedef int (driver_filter_t)(void *arg);
353 #define FILTER_STRAY 0x01
354 #define FILTER_HANDLED 0x02
355 #define FILTER_SCHEDULE_THREAD 0x04
357 typedef int device_attach_t (device_t dev);
358 typedef int device_detach_t (device_t dev);
359 typedef int device_resume_t (device_t dev);
360 typedef int device_shutdown_t (device_t dev);
361 typedef int device_probe_t (device_t dev);
362 typedef int device_suspend_t (device_t dev);
363 typedef int gpio_pin_set_t (device_t dev, uint32_t, unsigned int);
364 typedef int gpio_pin_setflags_t (device_t dev, uint32_t, uint32_t);
366 typedef int bus_child_location_str_t (device_t parent, device_t child, char *buf, size_t buflen);
367 typedef int bus_child_pnpinfo_str_t (device_t parent, device_t child, char *buf, size_t buflen);
368 typedef void bus_driver_added_t (device_t dev, driver_t *driver);
370 struct device_method {
375 typedef struct device_method device_method_t;
378 TAILQ_HEAD(device_list, device) dev_children;
379 TAILQ_ENTRY(device) dev_link;
381 struct device *dev_parent;
382 const struct module_data *dev_module;
385 driver_filter_t *dev_irq_filter;
386 driver_intr_t *dev_irq_fn;
391 char dev_nameunit[64];
394 uint8_t dev_res_alloc:1;
396 uint8_t dev_softc_set:1;
397 uint8_t dev_softc_alloc:1;
398 uint8_t dev_attached:1;
399 uint8_t dev_fixed_class:1;
400 uint8_t dev_unit_manual:1;
404 device_t dev_list[DEVCLASS_MAXUNIT];
409 const struct device_method *methods;
414 int (*callback) (struct module *, int, void *arg);
416 const char *bus_name;
417 const char *mod_name;
418 const char *long_name;
419 const struct driver *driver;
420 struct devclass **devclass_pp;
421 TAILQ_ENTRY(module_data) entry;
424 device_t device_get_parent(device_t dev);
425 void *device_get_method(device_t dev, const char *what);
426 const char *device_get_name(device_t dev);
427 const char *device_get_nameunit(device_t dev);
429 #define device_printf(dev, fmt,...) \
430 printf("%s: " fmt, device_get_nameunit(dev),## __VA_ARGS__)
431 device_t device_add_child(device_t dev, const char *name, int unit);
432 void device_quiet(device_t dev);
433 void device_set_interrupt(device_t dev, driver_filter_t *, driver_intr_t *, void *);
434 void device_run_interrupts(device_t parent);
435 void device_set_ivars(device_t dev, void *ivars);
436 void *device_get_ivars(device_t dev);
437 const char *device_get_desc(device_t dev);
438 int device_probe_and_attach(device_t dev);
439 int device_detach(device_t dev);
440 void *device_get_softc(device_t dev);
441 void device_set_softc(device_t dev, void *softc);
442 int device_delete_child(device_t dev, device_t child);
443 int device_delete_children(device_t dev);
444 int device_is_attached(device_t dev);
445 void device_set_desc(device_t dev, const char *desc);
446 void device_set_desc_copy(device_t dev, const char *desc);
447 int device_get_unit(device_t dev);
448 void *devclass_get_softc(devclass_t dc, int unit);
449 int devclass_get_maxunit(devclass_t dc);
450 device_t devclass_get_device(devclass_t dc, int unit);
451 devclass_t devclass_find(const char *classname);
453 #define bus_get_dma_tag(...) (NULL)
454 int bus_generic_detach(device_t dev);
455 int bus_generic_resume(device_t dev);
456 int bus_generic_shutdown(device_t dev);
457 int bus_generic_suspend(device_t dev);
458 int bus_generic_print_child(device_t dev, device_t child);
459 void bus_generic_driver_added(device_t dev, driver_t *driver);
460 int bus_space_subregion(bus_space_tag_t t, bus_space_handle_t bsh,
461 bus_size_t offset, bus_size_t size, bus_space_handle_t *nbshp);
465 void bus_space_write_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset, uint8_t data);
466 void bus_space_write_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset, uint16_t data);
467 void bus_space_write_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset, uint32_t data);
469 uint8_t bus_space_read_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset);
470 uint16_t bus_space_read_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset);
471 uint32_t bus_space_read_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset);
473 void 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);
474 void 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);
475 void 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);
477 void 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);
478 void 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);
479 void 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);
481 void 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);
482 void 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);
483 void 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);
484 void 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);
486 void bus_space_barrier(bus_space_tag_t space, bus_space_handle_t handle, bus_size_t offset, bus_size_t length, int flags);
488 void module_register(void *);
492 void *memset(void *, int, size_t len);
493 void *memcpy(void *, const void *, size_t len);
494 int printf(const char *,...) __printflike(1, 2);
495 int snprintf(char *restrict str, size_t size, const char *restrict format,...) __printflike(3, 4);
496 size_t strlen(const char *s);
501 #define malloc(s,x,f) usb_malloc(s)
502 void *usb_malloc(size_t);
505 #define free(p,x) usb_free(p)
506 void usb_free(void *);
508 #define strdup(p,x) usb_strdup(p)
509 char *usb_strdup(const char *str);
513 #ifndef HAVE_ENDIAN_DEFS
515 /* Assume little endian */
517 #define htole64(x) ((uint64_t)(x))
518 #define le64toh(x) ((uint64_t)(x))
520 #define htole32(x) ((uint32_t)(x))
521 #define le32toh(x) ((uint32_t)(x))
523 #define htole16(x) ((uint16_t)(x))
524 #define le16toh(x) ((uint16_t)(x))
526 #define be32toh(x) ((uint32_t)(x))
527 #define htobe32(x) ((uint32_t)(x))
530 #include <sys/endian.h>
535 typedef int usb_handle_request_t (device_t dev, const void *req, void **pptr, uint16_t *plen, uint16_t offset, uint8_t *pstate);
536 typedef int usb_take_controller_t (device_t dev);
540 void usb_uninit(void);
542 /* set some defaults */
544 #ifndef USB_POOL_SIZE
545 #define USB_POOL_SIZE (1024*1024) /* 1 MByte */
548 int pause(const char *, int);
549 void DELAY(unsigned int);
556 /* SYSTEM STARTUP API */
558 extern const void *sysinit_data[];
559 extern const void *sysuninit_data[];
571 INTR_EXCL = 256, /* exclusive interrupt */
572 INTR_MPSAFE = 512, /* this interrupt is SMP safe */
573 INTR_ENTROPY = 1024, /* this interrupt provides entropy */
574 INTR_MD1 = 4096, /* flag reserved for MD use */
575 INTR_MD2 = 8192, /* flag reserved for MD use */
576 INTR_MD3 = 16384, /* flag reserved for MD use */
577 INTR_MD4 = 32768 /* flag reserved for MD use */
581 u_long r_start; /* index of the first entry in this resource */
582 u_long r_end; /* index of the last entry (inclusive) */
586 struct resource_i *__r_i;
587 bus_space_tag_t r_bustag; /* bus_space tag */
588 bus_space_handle_t r_bushandle; /* bus_space handle */
591 struct resource_spec {
597 #define SYS_RES_IRQ 1 /* interrupt lines */
598 #define SYS_RES_DRQ 2 /* isa dma lines */
599 #define SYS_RES_MEMORY 3 /* i/o memory */
600 #define SYS_RES_IOPORT 4 /* i/o ports */
602 #define RF_ALLOCATED 0x0001 /* resource has been reserved */
603 #define RF_ACTIVE 0x0002 /* resource allocation has been activated */
604 #define RF_SHAREABLE 0x0004 /* resource permits contemporaneous sharing */
605 #define RF_SPARE1 0x0008
606 #define RF_SPARE2 0x0010
607 #define RF_FIRSTSHARE 0x0020 /* first in sharing list */
608 #define RF_PREFETCHABLE 0x0040 /* resource is prefetchable */
609 #define RF_OPTIONAL 0x0080 /* for bus_alloc_resources() */
611 int bus_alloc_resources(device_t, struct resource_spec *, struct resource **);
612 int bus_release_resource(device_t, int, int, struct resource *);
613 void bus_release_resources(device_t, const struct resource_spec *,
615 struct resource *bus_alloc_resource_any(device_t, int, int *, unsigned int);
616 int bus_generic_attach(device_t);
617 bus_space_tag_t rman_get_bustag(struct resource *);
618 bus_space_handle_t rman_get_bushandle(struct resource *);
619 u_long rman_get_size(struct resource *);
620 int bus_setup_intr(device_t, struct resource *, int, driver_filter_t,
621 driver_intr_t, void *, void **);
622 int bus_teardown_intr(device_t, struct resource *, void *);
623 int ofw_bus_status_okay(device_t);
624 int ofw_bus_is_compatible(device_t, char *);
626 extern int (*bus_alloc_resource_any_cb)(struct resource *res, device_t dev,
627 int type, int *rid, unsigned int flags);
628 extern int (*ofw_bus_status_ok_cb)(device_t dev);
629 extern int (*ofw_bus_is_compatible_cb)(device_t dev, char *name);
632 #define strlcpy(d,s,n) snprintf((d),(n),"%s",(s))
635 /* Should be defined in user application since it is machine-dependent */
636 extern int delay(unsigned int);
639 #define BUS_SPACE_MAXADDR_24BIT 0xFFFFFF
640 #define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFF
641 #define BUS_SPACE_MAXADDR 0xFFFFFFFF
642 #define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFF
643 #define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFF
644 #define BUS_SPACE_MAXSIZE 0xFFFFFFFF
646 #define BUS_DMA_WAITOK 0x00 /* safe to sleep (pseudo-flag) */
647 #define BUS_DMA_NOWAIT 0x01 /* not safe to sleep */
648 #define BUS_DMA_ALLOCNOW 0x02 /* perform resource allocation now */
649 #define BUS_DMA_COHERENT 0x04 /* hint: map memory in a coherent way */
650 #define BUS_DMA_ZERO 0x08 /* allocate zero'ed memory */
651 #define BUS_DMA_BUS1 0x10 /* placeholders for bus functions... */
652 #define BUS_DMA_BUS2 0x20
653 #define BUS_DMA_BUS3 0x40
654 #define BUS_DMA_BUS4 0x80
656 typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int);
659 bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
660 bus_size_t boundary, bus_addr_t lowaddr,
661 bus_addr_t highaddr, bus_dma_filter_t *filter,
662 void *filterarg, bus_size_t maxsize, int nsegments,
663 bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc,
664 void *lockfuncarg, bus_dma_tag_t *dmat);
666 int bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
668 void bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map);
669 int bus_dma_tag_destroy(bus_dma_tag_t dmat);
671 #endif /* _BSD_KERNEL_H_ */