1 /*- 2 * SPDX-License-Identifier: BSD-4-Clause 3 * 4 * Copyright (c) 1995 Terrence R. Lambert 5 * All rights reserved. 6 * 7 * Copyright (c) 1990, 1993 8 * The Regents of the University of California. All rights reserved. 9 * (c) UNIX System Laboratories, Inc. 10 * All or some portions of this file are derived from material licensed 11 * to the University of California by American Telephone and Telegraph 12 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 13 * the permission of UNIX System Laboratories, Inc. 14 * 15 * Redistribution and use in source and binary forms, with or without 16 * modification, are permitted provided that the following conditions 17 * are met: 18 * 1. Redistributions of source code must retain the above copyright 19 * notice, this list of conditions and the following disclaimer. 20 * 2. Redistributions in binary form must reproduce the above copyright 21 * notice, this list of conditions and the following disclaimer in the 22 * documentation and/or other materials provided with the distribution. 23 * 3. All advertising materials mentioning features or use of this software 24 * must display the following acknowledgement: 25 * This product includes software developed by the University of 26 * California, Berkeley and its contributors. 27 * 4. Neither the name of the University nor the names of its contributors 28 * may be used to endorse or promote products derived from this software 29 * without specific prior written permission. 30 * 31 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 32 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 33 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 34 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 35 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 39 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 40 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 41 * SUCH DAMAGE. 42 * 43 * @(#)kernel.h 8.3 (Berkeley) 1/21/94 44 * $FreeBSD$ 45 */ 46 47 #ifndef _SYS_KERNEL_H_ 48 #define _SYS_KERNEL_H_ 49 50 #define __GNUCLIKE___SECTION 1 51 #include <sys/linker_set.h> 52 53 /* 54 * Enumerated types for known system startup interfaces. 55 * 56 * Startup occurs in ascending numeric order; the list entries are 57 * sorted prior to attempting startup to guarantee order. Items 58 * of the same level are arbitrated for order based on the 'order' 59 * element. 60 * 61 * These numbers are arbitrary and are chosen ONLY for ordering; the 62 * enumeration values are explicit rather than implicit to provide 63 * for binary compatibility with inserted elements. 64 * 65 * The SI_SUB_LAST value must have the highest lexical value. 66 */ 67 enum sysinit_sub_id { 68 SI_SUB_KMEM = 0x1800000, /* kernel memory*/ 69 SI_SUB_DRIVERS = 0x3100000, /* Let Drivers initialize */ 70 SI_SUB_CONFIGURE = 0x3800000, /* Configure devices */ 71 SI_SUB_ROOT_CONF = 0xb000000, /* Find root devices */ 72 SI_SUB_LAST = 0xfffffff /* final initialization */ 73 }; 74 75 /* 76 * Some enumerated orders; "ANY" sorts last. 77 */ 78 enum sysinit_elem_order { 79 SI_ORDER_FIRST = 0x0000000, /* first*/ 80 SI_ORDER_SECOND = 0x0000001, /* second*/ 81 SI_ORDER_THIRD = 0x0000002, /* third*/ 82 SI_ORDER_FOURTH = 0x0000003, /* fourth*/ 83 SI_ORDER_FIFTH = 0x0000004, /* fifth*/ 84 SI_ORDER_SIXTH = 0x0000005, /* sixth*/ 85 SI_ORDER_SEVENTH = 0x0000006, /* seventh*/ 86 SI_ORDER_EIGHTH = 0x0000007, /* eighth*/ 87 SI_ORDER_MIDDLE = 0x1000000, /* somewhere in the middle */ 88 SI_ORDER_ANY = 0xfffffff /* last*/ 89 }; 90 91 /* 92 * A system initialization call instance 93 * 94 * At the moment there is one instance of sysinit. We probably do not 95 * want two which is why this code is if'd out, but we definitely want 96 * to discern SYSINIT's which take non-constant data pointers and 97 * SYSINIT's which take constant data pointers, 98 * 99 * The C_* macros take functions expecting const void * arguments 100 * while the non-C_* macros take functions expecting just void * arguments. 101 * 102 * With -Wcast-qual on, the compiler issues warnings: 103 * - if we pass non-const data or functions taking non-const data 104 * to a C_* macro. 105 * 106 * - if we pass const data to the normal macros 107 * 108 * However, no warning is issued if we pass a function taking const data 109 * through a normal non-const macro. This is ok because the function is 110 * saying it won't modify the data so we don't care whether the data is 111 * modifiable or not. 112 */ 113 114 typedef void (*sysinit_nfunc_t)(void *); 115 typedef void (*sysinit_cfunc_t)(const void *); 116 117 struct sysinit { 118 enum sysinit_sub_id subsystem; /* subsystem identifier*/ 119 enum sysinit_elem_order order; /* init order within subsystem*/ 120 sysinit_cfunc_t func; /* function */ 121 const void *udata; /* multiplexer/argument */ 122 }; 123 124 /* 125 * Default: no special processing 126 * 127 * The C_ version of SYSINIT is for data pointers to const 128 * data ( and functions taking data pointers to const data ). 129 * At the moment it is no different from SYSINIT and thus 130 * still results in warnings. 131 * 132 * The casts are necessary to have the compiler produce the 133 * correct warnings when -Wcast-qual is used. 134 * 135 */ 136 #define C_SYSINIT(uniquifier, subsystem, order, func, ident) \ 137 static struct sysinit uniquifier ## _sys_init = { \ 138 subsystem, \ 139 order, \ 140 func, \ 141 (ident) \ 142 }; \ 143 DATA_SET(sysinit_set,uniquifier ## _sys_init) 144 145 #define SYSINIT(uniquifier, subsystem, order, func, ident) \ 146 C_SYSINIT(uniquifier, subsystem, order, \ 147 (sysinit_cfunc_t)(sysinit_nfunc_t)func, (void *)(ident)) 148 149 /* 150 * Called on module unload: no special processing 151 */ 152 #define C_SYSUNINIT(uniquifier, subsystem, order, func, ident) \ 153 static struct sysinit uniquifier ## _sys_uninit = { \ 154 subsystem, \ 155 order, \ 156 func, \ 157 (ident) \ 158 }; \ 159 DATA_SET(sysuninit_set,uniquifier ## _sys_uninit) 160 161 #define SYSUNINIT(uniquifier, subsystem, order, func, ident) \ 162 C_SYSUNINIT(uniquifier, subsystem, order, \ 163 (sysinit_cfunc_t)(sysinit_nfunc_t)func, (void *)(ident)) 164 #endif /* !_SYS_KERNEL_H_*/ 165