]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/boot/kshim/bsd_kernel.h
Update mandoc to 20160116
[FreeBSD/FreeBSD.git] / sys / boot / kshim / bsd_kernel.h
1 /* $FreeBSD$ */
2 /*-
3  * Copyright (c) 2011 Hans Petter Selasky. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
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.
13  *
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
24  * SUCH DAMAGE.
25  */
26
27 #ifndef _BSD_KERNEL_H_
28 #define _BSD_KERNEL_H_
29
30 #define _KERNEL
31 #undef __FreeBSD_version
32 #define __FreeBSD_version 1100000
33
34 #include <sys/cdefs.h>
35 #include <sys/queue.h>
36 #include <sys/errno.h>
37
38 #define isalpha(x) (((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z'))
39 #define isdigit(x) ((x) >= '0' && (x) <= '9')
40 #define panic(...) do { printf("USB PANIC: " __VA_ARGS__); while (1) ; } while (0)
41 #define rebooting 0
42 #define M_USB 0
43 #define M_USBDEV 0
44 #define USB_PROC_MAX 3
45 #define USB_BUS_GIANT_PROC(bus) (usb_process + 2)
46 #define USB_BUS_NON_GIANT_BULK_PROC(bus) (usb_process + 2)
47 #define USB_BUS_NON_GIANT_ISOC_PROC(bus) (usb_process + 2)
48 #define USB_BUS_EXPLORE_PROC(bus) (usb_process + 0)
49 #define USB_BUS_CONTROL_XFER_PROC(bus) (usb_process + 1)
50 #define SYSCTL_DECL(...)
51 #define SYSCTL_NODE(name,...) struct { } name __used
52 #define SYSCTL_INT(...)
53 #define TUNABLE_INT(...)
54 #define MALLOC_DECLARE(...)
55 #define MALLOC_DEFINE(...)
56 #define EVENTHANDLER_DECLARE(...)
57 #define EVENTHANDLER_INVOKE(...)
58 #define KASSERT(...)
59 #define SCHEDULER_STOPPED(x) (0)
60 #define PI_SWI(...) (0)
61 #define UNIQ_NAME(x) x
62 #define UNIQ_NAME_STR(x) #x
63 #define DEVCLASS_MAXUNIT 32
64 #define MOD_LOAD 1
65 #define MOD_UNLOAD 2
66 #define DEVMETHOD(what,func) { #what, (void *)&func }
67 #define DEVMETHOD_END {0,0}
68 #define DRIVER_MODULE(name, busname, driver, devclass, evh, arg)        \
69   static struct module_data bsd_##name##_##busname##_driver_mod = {     \
70         evh, arg, #busname, #name, #busname "/" #name,                  \
71         &driver, &devclass, { 0, 0 } };                                 \
72 SYSINIT(bsd_##name##_##busname##_driver_mod, SI_SUB_DRIVERS,            \
73   SI_ORDER_MIDDLE, module_register,                                     \
74   &bsd_##name##_##busname##_driver_mod)
75 #define SYSINIT(uniq, subs, order, _func, _data)        \
76 const struct sysinit UNIQ_NAME(sysinit_##uniq) = {      \
77         .func = (_func),                                \
78         .data = __DECONST(void *, _data)                \
79 };                                                      \
80 SYSINIT_ENTRY(uniq##_entry, "sysinit", (subs),          \
81     (order), "const struct sysinit",                    \
82     UNIQ_NAME_STR(sysinit_##uniq), "SYSINIT")
83
84 #define SYSUNINIT(uniq, subs, order, _func, _data)      \
85 const struct sysinit UNIQ_NAME(sysuninit_##uniq) = {    \
86         .func = (_func),                                \
87         .data = __DECONST(void *, _data)                \
88 };                                                      \
89 SYSINIT_ENTRY(uniq##_entry, "sysuninit", (subs),        \
90     (order), "const struct sysuninit",                  \
91     UNIQ_NAME_STR(sysuninit_##uniq), "SYSUNINIT")
92 #define MODULE_DEPEND(...)
93 #define MODULE_VERSION(...)
94 #define NULL ((void *)0)
95 #define BUS_SPACE_BARRIER_READ 0x01
96 #define BUS_SPACE_BARRIER_WRITE 0x02
97 #define hz 1000
98 #undef PAGE_SIZE
99 #define PAGE_SIZE 4096
100 #undef MIN
101 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
102 #undef MAX
103 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
104 #define MTX_DEF 0
105 #define MTX_SPIN 0
106 #define MTX_RECURSE 0
107 #define SX_DUPOK 0
108 #define SX_NOWITNESS 0
109 #define WITNESS_WARN(...)
110 #define cold 0
111 #define BUS_PROBE_GENERIC 0
112 #define BUS_PROBE_DEFAULT (-20)
113 #define CALLOUT_RETURNUNLOCKED 0x1
114 #undef ffs
115 #define ffs(x) __builtin_ffs(x)
116 #undef va_list
117 #define va_list __builtin_va_list
118 #undef va_size
119 #define va_size(type) __builtin_va_size(type)
120 #undef va_start
121 #define va_start(ap, last) __builtin_va_start(ap, last)
122 #undef va_end
123 #define va_end(ap) __builtin_va_end(ap)
124 #undef va_arg
125 #define va_arg(ap, type) __builtin_va_arg((ap), type)
126 #define DEVICE_ATTACH(dev, ...) \
127   (((device_attach_t *)(device_get_method(dev, "device_attach")))(dev,## __VA_ARGS__))
128 #define DEVICE_DETACH(dev, ...) \
129   (((device_detach_t *)(device_get_method(dev, "device_detach")))(dev,## __VA_ARGS__))
130 #define DEVICE_PROBE(dev, ...) \
131   (((device_probe_t *)(device_get_method(dev, "device_probe")))(dev,## __VA_ARGS__))
132 #define DEVICE_RESUME(dev, ...) \
133   (((device_resume_t *)(device_get_method(dev, "device_resume")))(dev,## __VA_ARGS__))
134 #define DEVICE_SHUTDOWN(dev, ...) \
135   (((device_shutdown_t *)(device_get_method(dev, "device_shutdown")))(dev,## __VA_ARGS__))
136 #define DEVICE_SUSPEND(dev, ...) \
137   (((device_suspend_t *)(device_get_method(dev, "device_suspend")))(dev,## __VA_ARGS__))
138 #define USB_HANDLE_REQUEST(dev, ...) \
139   (((usb_handle_request_t *)(device_get_method(dev, "usb_handle_request")))(dev,## __VA_ARGS__))
140 #define USB_TAKE_CONTROLLER(dev, ...) \
141   (((usb_take_controller_t *)(device_get_method(dev, "usb_take_controller")))(dev,## __VA_ARGS__))
142 #define GPIO_PIN_SET(dev, ...) \
143   (((gpio_pin_set_t *)(device_get_method(dev, "gpio_pin_set")))(dev,## __VA_ARGS__))
144 #define GPIO_PIN_SETFLAGS(dev, ...) \
145   (((gpio_pin_setflags_t *)(device_get_method(dev, "gpio_pin_setflags")))(dev,## __VA_ARGS__))
146
147 enum {
148         SI_SUB_DUMMY = 0x0000000,
149         SI_SUB_LOCK = 0x1B00000,
150         SI_SUB_KLD = 0x2000000,
151         SI_SUB_DRIVERS = 0x3100000,
152         SI_SUB_PSEUDO = 0x7000000,
153         SI_SUB_KICK_SCHEDULER = 0xa000000,
154         SI_SUB_RUN_SCHEDULER = 0xfffffff
155 };
156
157 enum {
158         SI_ORDER_FIRST = 0x0000000,
159         SI_ORDER_SECOND = 0x0000001,
160         SI_ORDER_THIRD = 0x0000002,
161         SI_ORDER_FOURTH = 0x0000003,
162         SI_ORDER_MIDDLE = 0x1000000,
163         SI_ORDER_ANY = 0xfffffff        /* last */
164 };
165
166 struct uio;
167 struct thread;
168 struct malloc_type;
169 struct usb_process;
170
171 #ifndef HAVE_STANDARD_DEFS
172 #define _UINT8_T_DECLARED
173 typedef unsigned char uint8_t;
174 #define _INT8_T_DECLARED
175 typedef signed char int8_t;
176 #define _UINT16_T_DECLARED
177 typedef unsigned short uint16_t;
178 #define _INT16_T_DECLARED
179 typedef signed short int16_t;
180 #define _UINT32_T_DECLARED
181 typedef unsigned int uint32_t;
182 #define _INT32_T_DECLARED
183 typedef signed int int32_t;
184 #define _UINT64_T_DECLARED
185 typedef unsigned long long uint64_t;
186 #define _INT16_T_DECLARED
187 typedef signed long long int64_t;
188
189 typedef uint16_t uid_t;
190 typedef uint16_t gid_t;
191 typedef uint16_t mode_t;
192
193 typedef uint8_t *caddr_t;
194 #define _UINTPTR_T_DECLARED
195 typedef unsigned long uintptr_t;
196
197 #define _SIZE_T_DECLARED
198 typedef unsigned long size_t;
199 typedef unsigned long u_long;
200 #endif
201
202 typedef unsigned long bus_addr_t;
203 typedef unsigned long bus_size_t;
204
205 typedef void *bus_dmamap_t;
206 typedef void *bus_dma_tag_t;
207
208 typedef void *bus_space_tag_t;
209 typedef uint8_t *bus_space_handle_t;
210
211 /* SYSINIT API */
212
213 #include <sysinit.h>
214
215 struct sysinit {
216         void    (*func) (void *arg);
217         void   *data;
218 };
219
220 /* MUTEX API */
221
222 struct mtx {
223         int     owned;
224         struct mtx *parent;
225 };
226
227 #define mtx_assert(...) do { } while (0)
228 void    mtx_init(struct mtx *, const char *, const char *, int);
229 void    mtx_lock(struct mtx *);
230 void    mtx_unlock(struct mtx *);
231 #define mtx_lock_spin(x) mtx_lock(x)
232 #define mtx_unlock_spin(x) mtx_unlock(x)
233 int     mtx_owned(struct mtx *);
234 void    mtx_destroy(struct mtx *);
235
236 extern struct mtx Giant;
237
238 /* SX API */
239
240 struct sx {
241         int     owned;
242 };
243
244 #define sx_assert(...) do { } while (0)
245 #define sx_init(...) sx_init_flags(__VA_ARGS__, 0)
246 void    sx_init_flags(struct sx *, const char *, int);
247 void    sx_destroy(struct sx *);
248 void    sx_xlock(struct sx *);
249 void    sx_xunlock(struct sx *);
250 int     sx_xlocked(struct sx *);
251
252 /* CONDVAR API */
253
254 struct cv {
255         int     sleeping;
256 };
257
258 void    cv_init(struct cv *, const char *desc);
259 void    cv_destroy(struct cv *);
260 void    cv_wait(struct cv *, struct mtx *);
261 int     cv_timedwait(struct cv *, struct mtx *, int);
262 void    cv_signal(struct cv *);
263 void    cv_broadcast(struct cv *);
264
265 /* CALLOUT API */
266
267 typedef void callout_fn_t (void *);
268
269 extern volatile int ticks;
270
271 struct callout {
272         LIST_ENTRY(callout) entry;
273         callout_fn_t *func;
274         void   *arg;
275         struct mtx *mtx;
276         int     flags;
277         int     timeout;
278 };
279
280 void    callout_init_mtx(struct callout *, struct mtx *, int);
281 void    callout_reset(struct callout *, int, callout_fn_t *, void *);
282 void    callout_stop(struct callout *);
283 void    callout_drain(struct callout *);
284 int     callout_pending(struct callout *);
285 void    callout_process(int timeout);
286
287 /* DEVICE API */
288
289 struct driver;
290 struct devclass;
291 struct device;
292 struct module;
293 struct module_data;
294
295 typedef struct driver driver_t;
296 typedef struct devclass *devclass_t;
297 typedef struct device *device_t;
298 typedef void (driver_intr_t)(void *arg);
299 typedef int (driver_filter_t)(void *arg);
300 #define FILTER_STRAY            0x01
301 #define FILTER_HANDLED          0x02
302 #define FILTER_SCHEDULE_THREAD  0x04
303
304 typedef int device_attach_t (device_t dev);
305 typedef int device_detach_t (device_t dev);
306 typedef int device_resume_t (device_t dev);
307 typedef int device_shutdown_t (device_t dev);
308 typedef int device_probe_t (device_t dev);
309 typedef int device_suspend_t (device_t dev);
310 typedef int gpio_pin_set_t (device_t dev, uint32_t, unsigned int);
311 typedef int gpio_pin_setflags_t (device_t dev, uint32_t, uint32_t);
312
313 typedef int bus_child_location_str_t (device_t parent, device_t child, char *buf, size_t buflen);
314 typedef int bus_child_pnpinfo_str_t (device_t parent, device_t child, char *buf, size_t buflen);
315 typedef void bus_driver_added_t (device_t dev, driver_t *driver);
316
317 struct device_method {
318         const char *desc;
319         void   *const func;
320 };
321
322 typedef struct device_method device_method_t;
323
324 struct device {
325         TAILQ_HEAD(device_list, device) dev_children;
326         TAILQ_ENTRY(device) dev_link;
327
328         struct device *dev_parent;
329         const struct module_data *dev_module;
330         void   *dev_sc;
331         void   *dev_aux;
332         driver_filter_t *dev_irq_filter;
333         driver_intr_t *dev_irq_fn;
334         void   *dev_irq_arg;
335
336         uint16_t dev_unit;
337
338         char    dev_nameunit[64];
339         char    dev_desc[64];
340
341         uint8_t dev_res_alloc:1;
342         uint8_t dev_quiet:1;
343         uint8_t dev_softc_set:1;
344         uint8_t dev_softc_alloc:1;
345         uint8_t dev_attached:1;
346         uint8_t dev_fixed_class:1;
347         uint8_t dev_unit_manual:1;
348 };
349
350 struct devclass {
351         device_t dev_list[DEVCLASS_MAXUNIT];
352 };
353
354 struct driver {
355         const char *name;
356         const struct device_method *methods;
357         uint32_t size;
358 };
359
360 struct module_data {
361         int     (*callback) (struct module *, int, void *arg);
362         void   *arg;
363         const char *bus_name;
364         const char *mod_name;
365         const char *long_name;
366         const struct driver *driver;
367         struct devclass **devclass_pp;
368         TAILQ_ENTRY(module_data) entry;
369 };
370
371 device_t device_get_parent(device_t dev);
372 void   *device_get_method(device_t dev, const char *what);
373 const char *device_get_name(device_t dev);
374 const char *device_get_nameunit(device_t dev);
375
376 #define device_printf(dev, fmt,...) \
377         printf("%s: " fmt, device_get_nameunit(dev),## __VA_ARGS__)
378 device_t device_add_child(device_t dev, const char *name, int unit);
379 void    device_quiet(device_t dev);
380 void    device_set_interrupt(device_t dev, driver_filter_t *, driver_intr_t *, void *);
381 void    device_run_interrupts(device_t parent);
382 void    device_set_ivars(device_t dev, void *ivars);
383 void   *device_get_ivars(device_t dev);
384 const char *device_get_desc(device_t dev);
385 int     device_probe_and_attach(device_t dev);
386 int     device_detach(device_t dev);
387 void   *device_get_softc(device_t dev);
388 void    device_set_softc(device_t dev, void *softc);
389 int     device_delete_child(device_t dev, device_t child);
390 int     device_delete_children(device_t dev);
391 int     device_is_attached(device_t dev);
392 void    device_set_desc(device_t dev, const char *desc);
393 void    device_set_desc_copy(device_t dev, const char *desc);
394 int     device_get_unit(device_t dev);
395 void   *devclass_get_softc(devclass_t dc, int unit);
396 int     devclass_get_maxunit(devclass_t dc);
397 device_t devclass_get_device(devclass_t dc, int unit);
398 devclass_t devclass_find(const char *classname);
399
400 #define bus_get_dma_tag(...) (NULL)
401 int     bus_generic_detach(device_t dev);
402 int     bus_generic_resume(device_t dev);
403 int     bus_generic_shutdown(device_t dev);
404 int     bus_generic_suspend(device_t dev);
405 int     bus_generic_print_child(device_t dev, device_t child);
406 void    bus_generic_driver_added(device_t dev, driver_t *driver);
407 int     bus_space_subregion(bus_space_tag_t t, bus_space_handle_t bsh,
408     bus_size_t offset, bus_size_t size, bus_space_handle_t *nbshp);
409
410 /* BUS SPACE API */
411
412 void    bus_space_write_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset, uint8_t data);
413 void    bus_space_write_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset, uint16_t data);
414 void    bus_space_write_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset, uint32_t data);
415
416 uint8_t bus_space_read_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset);
417 uint16_t bus_space_read_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset);
418 uint32_t bus_space_read_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset);
419
420 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);
421 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);
422 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);
423
424 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);
425 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);
426 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);
427
428 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);
429 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);
430 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);
431 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);
432
433 void    bus_space_barrier(bus_space_tag_t space, bus_space_handle_t handle, bus_size_t offset, bus_size_t length, int flags);
434
435 void    module_register(void *);
436
437 /* LIB-C */
438
439 void   *memset(void *, int, size_t len);
440 void   *memcpy(void *, const void *, size_t len);
441 int     printf(const char *,...) __printflike(1, 2);
442 int     snprintf(char *restrict str, size_t size, const char *restrict format,...) __printflike(3, 4);
443 size_t  strlen(const char *s);
444
445 /* MALLOC API */
446
447 #undef malloc
448 #define malloc(s,x,f) usb_malloc(s)
449 void   *usb_malloc(size_t);
450
451 #undef free
452 #define free(p,x) usb_free(p)
453 void    usb_free(void *);
454
455 #define strdup(p,x) usb_strdup(p)
456 char   *usb_strdup(const char *str);
457
458 /* ENDIANNESS */
459
460 #ifndef HAVE_ENDIAN_DEFS
461
462 /* Assume little endian */
463
464 #define htole64(x) ((uint64_t)(x))
465 #define le64toh(x) ((uint64_t)(x))
466
467 #define htole32(x) ((uint32_t)(x))
468 #define le32toh(x) ((uint32_t)(x))
469
470 #define htole16(x) ((uint16_t)(x))
471 #define le16toh(x) ((uint16_t)(x))
472
473 #define be32toh(x) ((uint32_t)(x))
474 #define htobe32(x) ((uint32_t)(x))
475
476 #else
477 #include <sys/endian.h>
478 #endif
479
480 /* USB */
481
482 typedef int usb_handle_request_t (device_t dev, const void *req, void **pptr, uint16_t *plen, uint16_t offset, uint8_t *pstate);
483 typedef int usb_take_controller_t (device_t dev);
484
485 void    usb_idle(void);
486 void    usb_init(void);
487 void    usb_uninit(void);
488
489 /* set some defaults */
490
491 #ifndef USB_POOL_SIZE
492 #define USB_POOL_SIZE (1024*1024)       /* 1 MByte */
493 #endif
494
495 int     pause(const char *, int);
496 void    DELAY(unsigned int);
497
498 /* OTHER */
499
500 struct selinfo {
501 };
502
503 /* SYSTEM STARTUP API */
504
505 extern const void *sysinit_data[];
506 extern const void *sysuninit_data[];
507
508 /* Resources */
509
510 enum intr_type {
511         INTR_TYPE_TTY = 1,
512         INTR_TYPE_BIO = 2,
513         INTR_TYPE_NET = 4,
514         INTR_TYPE_CAM = 8,
515         INTR_TYPE_MISC = 16,
516         INTR_TYPE_CLK = 32,
517         INTR_TYPE_AV = 64,
518         INTR_EXCL = 256,                /* exclusive interrupt */
519         INTR_MPSAFE = 512,              /* this interrupt is SMP safe */
520         INTR_ENTROPY = 1024,            /* this interrupt provides entropy */
521         INTR_MD1 = 4096,                /* flag reserved for MD use */
522         INTR_MD2 = 8192,                /* flag reserved for MD use */
523         INTR_MD3 = 16384,               /* flag reserved for MD use */
524         INTR_MD4 = 32768                /* flag reserved for MD use */
525 };
526
527 struct resource_i {
528         u_long          r_start;        /* index of the first entry in this resource */
529         u_long          r_end;          /* index of the last entry (inclusive) */
530 };
531
532 struct resource {
533         struct resource_i       *__r_i;
534         bus_space_tag_t         r_bustag; /* bus_space tag */
535         bus_space_handle_t      r_bushandle;    /* bus_space handle */
536 };
537
538 struct resource_spec {
539         int     type;
540         int     rid;
541         int     flags;
542 };
543
544 #define SYS_RES_IRQ     1       /* interrupt lines */
545 #define SYS_RES_DRQ     2       /* isa dma lines */
546 #define SYS_RES_MEMORY  3       /* i/o memory */
547 #define SYS_RES_IOPORT  4       /* i/o ports */
548
549 #define RF_ALLOCATED    0x0001  /* resource has been reserved */
550 #define RF_ACTIVE       0x0002  /* resource allocation has been activated */
551 #define RF_SHAREABLE    0x0004  /* resource permits contemporaneous sharing */
552 #define RF_SPARE1       0x0008
553 #define RF_SPARE2       0x0010
554 #define RF_FIRSTSHARE   0x0020  /* first in sharing list */
555 #define RF_PREFETCHABLE 0x0040  /* resource is prefetchable */
556 #define RF_OPTIONAL     0x0080  /* for bus_alloc_resources() */
557
558 int bus_alloc_resources(device_t, struct resource_spec *, struct resource **);
559 int bus_release_resource(device_t, int, int, struct resource *);
560 void bus_release_resources(device_t, const struct resource_spec *,
561     struct resource **);
562 struct resource *bus_alloc_resource_any(device_t, int, int *, unsigned int);
563 int bus_generic_attach(device_t);
564 bus_space_tag_t rman_get_bustag(struct resource *);
565 bus_space_handle_t rman_get_bushandle(struct resource *);
566 u_long rman_get_size(struct resource *);
567 int bus_setup_intr(device_t, struct resource *, int, driver_filter_t,
568     driver_intr_t, void *, void **);
569 int bus_teardown_intr(device_t, struct resource *, void *);
570 int ofw_bus_status_okay(device_t);
571 int ofw_bus_is_compatible(device_t, char *);
572
573 extern int (*bus_alloc_resource_any_cb)(struct resource *res, device_t dev,
574     int type, int *rid, unsigned int flags);
575 extern int (*ofw_bus_status_ok_cb)(device_t dev);
576 extern int (*ofw_bus_is_compatible_cb)(device_t dev, char *name);
577
578 #ifndef strlcpy
579 #define strlcpy(d,s,n) snprintf((d),(n),"%s",(s))
580 #endif
581
582 #endif                                  /* _BSD_KERNEL_H_ */