1 /* 2 * Copyright 2007-2018, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _FBSD_COMPAT_SYS_KERNEL_H_ 6 #define _FBSD_COMPAT_SYS_KERNEL_H_ 7 8 9 #include <stddef.h> 10 11 #include <sys/haiku-module.h> 12 13 #include <sys/linker_set.h> 14 #include <sys/queue.h> 15 16 17 /* The rate at which FreeBSD can generate callouts (kind of timeout mechanism). 18 * For FreeBSD 8 this is typically 1000 times per second (100 for ARM). 19 * This value is defined in a file called subr_param.c 20 * 21 * While Haiku can have a much higher granularity, it is not a good idea to have 22 * this since FreeBSD tries to do certain tasks based on ticks, for instance 23 * autonegotiation and wlan scanning. 24 * Suffixing LL prevents integer overflows during calculations. 25 * as it defines a long long constant. */ 26 #define hz 1000LL 27 28 int32_t _get_ticks(); 29 #define ticks (_get_ticks()) 30 31 32 /* sysinit */ 33 enum sysinit_elem_order { 34 SI_ORDER_FIRST = 0x0000000, 35 SI_ORDER_SECOND = 0x0000001, 36 SI_ORDER_THIRD = 0x0000002, 37 SI_ORDER_FOURTH = 0x0000003, 38 SI_ORDER_MIDDLE = 0x1000000, 39 SI_ORDER_ANY = 0xfffffff /* last */ 40 }; 41 42 typedef void (*system_init_func_t)(void *); 43 44 struct sysinit { 45 const char* name; 46 enum sysinit_elem_order order; 47 system_init_func_t func; 48 const void* arg; 49 }; 50 51 #define SYSINIT(uniquifier, subsystem, _order, _func, ident) \ 52 static struct sysinit sysinit_##uniquifier = { \ 53 .name = #uniquifier, \ 54 .order = _order, \ 55 .func = _func, \ 56 .arg = ident, \ 57 }; \ 58 DATA_SET(__freebsd_sysinit, sysinit_##uniquifier) 59 60 #define SYSUNINIT(uniquifier, subsystem, _order, _func, ident) \ 61 static struct sysinit sysuninit_##uniquifier = { \ 62 .name = #uniquifier, \ 63 .order = _order, \ 64 .func = _func, \ 65 .arg = ident, \ 66 }; \ 67 DATA_SET(__freebsd_sysuninit, sysuninit_##uniquifier) 68 69 70 /* confighooks */ 71 typedef void (*ich_func_t)(void *_arg); 72 73 struct intr_config_hook { 74 TAILQ_ENTRY(intr_config_hook) ich_links; 75 ich_func_t ich_func; 76 void *ich_arg; 77 }; 78 79 int config_intrhook_establish(struct intr_config_hook *hook); 80 void config_intrhook_disestablish(struct intr_config_hook *hook); 81 82 83 /* misc. */ 84 #define TUNABLE_INT(path, var) 85 #define TUNABLE_INT_FETCH(path, var) 86 87 88 #endif // _FBSD_COMPAT_SYS_KERNEL_H_ 89