| Commit | Line | Data |
|---|---|---|
| 8c10bfcf MD |
1 | /* |
| 2 | * Copyright (c) 2003,2004 The DragonFly Project. All rights reserved. | |
| 3 | * | |
| 4 | * This code is derived from software contributed to The DragonFly Project | |
| 5 | * by Matthew Dillon <dillon@backplane.com> | |
| 6 | * | |
| 7 | * Redistribution and use in source and binary forms, with or without | |
| 8 | * modification, are permitted provided that the following conditions | |
| 9 | * are met: | |
| 10 | * | |
| 11 | * 1. Redistributions of source code must retain the above copyright | |
| 12 | * notice, this list of conditions and the following disclaimer. | |
| 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
| 14 | * notice, this list of conditions and the following disclaimer in | |
| 15 | * the documentation and/or other materials provided with the | |
| 16 | * distribution. | |
| 17 | * 3. Neither the name of The DragonFly Project nor the names of its | |
| 18 | * contributors may be used to endorse or promote products derived | |
| 19 | * from this software without specific, prior written permission. | |
| 20 | * | |
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 22 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | |
| 24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | |
| 25 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | |
| 26 | * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, | |
| 27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
| 28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | |
| 29 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |
| 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |
| 31 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
| 32 | * SUCH DAMAGE. | |
| 33 | * | |
| 85100692 | 34 | * Copyright (c) Peter Wemm <peter@netplex.com.au> All rights reserved. |
| 85100692 MD |
35 | * |
| 36 | * Redistribution and use in source and binary forms, with or without | |
| 37 | * modification, are permitted provided that the following conditions | |
| 38 | * are met: | |
| 39 | * 1. Redistributions of source code must retain the above copyright | |
| 40 | * notice, this list of conditions and the following disclaimer. | |
| 41 | * 2. Redistributions in binary form must reproduce the above copyright | |
| 42 | * notice, this list of conditions and the following disclaimer in the | |
| 43 | * documentation and/or other materials provided with the distribution. | |
| 44 | * | |
| 45 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | |
| 46 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 47 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
| 48 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |
| 49 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
| 50 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
| 51 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
| 52 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
| 53 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
| 54 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
| 55 | * SUCH DAMAGE. | |
| 56 | * | |
| 57 | * $FreeBSD: src/sys/i386/include/globaldata.h,v 1.11.2.1 2000/05/16 06:58:10 dillon Exp $ | |
| c070746a | 58 | * $DragonFly: src/sys/sys/globaldata.h,v 1.49 2008/06/02 16:54:20 dillon Exp $ |
| 85100692 MD |
59 | */ |
| 60 | ||
| 61 | #ifndef _SYS_GLOBALDATA_H_ | |
| 62 | #define _SYS_GLOBALDATA_H_ | |
| 63 | ||
| a108bf71 MD |
64 | #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES) |
| 65 | ||
| 05220613 MD |
66 | #ifndef _SYS_STDINT_H_ |
| 67 | #include <sys/stdint.h> /* __int types */ | |
| 68 | #endif | |
| 96728c05 MD |
69 | #ifndef _SYS_TIME_H_ |
| 70 | #include <sys/time.h> /* struct timeval */ | |
| 71 | #endif | |
| 72 | #ifndef _SYS_VMMETER_H_ | |
| a2a5ad0d MD |
73 | #include <sys/vmmeter.h> /* struct vmmeter */ |
| 74 | #endif | |
| 75 | #ifndef _SYS_THREAD_H_ | |
| 76 | #include <sys/thread.h> /* struct thread */ | |
| 77 | #endif | |
| a108bf71 MD |
78 | #ifndef _SYS_SLABALLOC_H_ |
| 79 | #include <sys/slaballoc.h> /* SLGlobalData */ | |
| 80 | #endif | |
| 88c4d2f6 MD |
81 | #ifndef _SYS_SYSTIMER_H_ |
| 82 | #include <sys/systimer.h> /* fine-grained system timers */ | |
| 83 | #endif | |
| 24e51f36 HP |
84 | #ifndef _SYS_NCHSTATS_H_ |
| 85 | #include <sys/nchstats.h> | |
| 86 | #endif | |
| 10aa77c0 MD |
87 | #ifndef _SYS_SYSID_H_ |
| 88 | #include <sys/sysid.h> /* sysid_t */ | |
| 89 | #endif | |
| 96728c05 | 90 | |
| 85100692 MD |
91 | /* |
| 92 | * This structure maps out the global data that needs to be kept on a | |
| 93 | * per-cpu basis. genassym uses this to generate offsets for the assembler | |
| 94 | * code. The machine-dependant portions of this file can be found in | |
| 95 | * <machine/globaldata.h>, but only MD code should retrieve it. | |
| 96 | * | |
| 97 | * The SMP parts are setup in pmap.c and locore.s for the BSP, and | |
| 98 | * mp_machdep.c sets up the data for the AP's to "see" when they awake. | |
| 99 | * The reason for doing it via a struct is so that an array of pointers | |
| 100 | * to each CPU's data can be set up for things like "check curproc on all | |
| 101 | * other processors" | |
| 102 | * | |
| 103 | * NOTE! this structure needs to remain compatible between module accessors | |
| 104 | * and the kernel, so we can't throw in lots of #ifdef's. | |
| ef0fdad1 | 105 | * |
| 235957ed | 106 | * gd_reqflags serves serveral purposes, but it is primarily an interrupt |
| ef0fdad1 MD |
107 | * rollup flag used by the task switcher and spl mechanisms to decide that |
| 108 | * further checks are necessary. Interrupts are typically managed on a | |
| 109 | * per-processor basis at least until you leave a critical section, but | |
| 110 | * may then be scheduled to other cpus. | |
| a108bf71 MD |
111 | * |
| 112 | * gd_vme_avail and gd_vme_base cache free vm_map_entry structures for use | |
| 113 | * in various vm_map related operations. gd_vme_avail is *NOT* a count of | |
| 114 | * the number of structures in the cache but is instead a count of the number | |
| 115 | * of unreserved structures in the cache. See vm_map_entry_reserve(). | |
| 85100692 MD |
116 | */ |
| 117 | ||
| df2244e3 | 118 | struct sysmsg; |
| fc17ad60 | 119 | struct tslpentry; |
| 85100692 | 120 | struct privatespace; |
| a108bf71 | 121 | struct vm_map_entry; |
| bbb31c5d | 122 | struct spinlock; |
| fc7d5181 | 123 | struct pipe; |
| 85100692 MD |
124 | |
| 125 | struct globaldata { | |
| 126 | struct privatespace *gd_prvspace; /* self-reference */ | |
| 127 | struct thread *gd_curthread; | |
| c070746a | 128 | struct thread *gd_freetd; /* cache one free td */ |
| 05220613 | 129 | __uint32_t gd_reqflags; /* (see note above) */ |
| 438acbcc | 130 | long gd_flags; |
| 0d62f4af | 131 | lwkt_queue gd_tdallq; /* all threads */ |
| f9235b6d | 132 | lwkt_queue gd_tdrunq; /* runnable threads */ |
| 05220613 | 133 | __uint32_t gd_cpuid; |
| da23a592 | 134 | cpumask_t gd_cpumask; /* mask = CPUMASK(cpuid) */ |
| 3614fd91 | 135 | cpumask_t gd_other_cpus; /* mask of 'other' cpus */ |
| 85100692 | 136 | struct timeval gd_stattv; |
| 4a28fe22 | 137 | int gd_intr_nesting_level; /* hard code, intrs, ipis */ |
| 12e4aaff | 138 | struct vmmeter gd_cnt; |
| 3b6b7bd1 MD |
139 | struct lwkt_ipiq *gd_ipiq; /* array[ncpu] of ipiq's */ |
| 140 | struct lwkt_ipiq gd_cpusyncq; /* ipiq for cpu synchro */ | |
| f9235b6d | 141 | int gd_fairq_total_pri; |
| 52eedfb5 | 142 | struct thread gd_unused02B; |
| a2a5ad0d | 143 | struct thread gd_idlethread; |
| a108bf71 | 144 | SLGlobalData gd_slab; /* slab allocator */ |
| 27e88a6e | 145 | int gd_trap_nesting_level; /* track traps */ |
| a108bf71 MD |
146 | int gd_vme_avail; /* vm_map_entry reservation */ |
| 147 | struct vm_map_entry *gd_vme_base; /* vm_map_entry reservation */ | |
| 88c4d2f6 MD |
148 | struct systimerq gd_systimerq; /* per-cpu system timers */ |
| 149 | int gd_syst_nest; | |
| 88c4d2f6 MD |
150 | struct systimer gd_hardclock; /* scheduler periodic */ |
| 151 | struct systimer gd_statclock; /* statistics periodic */ | |
| 152 | struct systimer gd_schedclock; /* scheduler periodic */ | |
| 153 | volatile __uint32_t gd_time_seconds; /* uptime in seconds */ | |
| 154 | volatile sysclock_t gd_cpuclock_base; /* cpuclock relative base */ | |
| fc7d5181 MD |
155 | |
| 156 | struct pipe *gd_pipeq; /* cache pipe structures */ | |
| 24e51f36 | 157 | struct nchstats *gd_nchstats; /* namecache effectiveness */ |
| fc7d5181 | 158 | int gd_pipeqcount; /* number of structures */ |
| 10aa77c0 | 159 | sysid_t gd_sysid_alloc; /* allocate unique sysid */ |
| fc17ad60 MD |
160 | |
| 161 | struct tslpque *gd_tsleep_hash; /* tsleep/wakeup support */ | |
| 8f165b8c | 162 | void *gd_unused08; |
| d666840a | 163 | int gd_spinlocks_wr; /* Exclusive spinlocks held */ |
| bdfb4a94 | 164 | struct systimer *gd_systimer_inprog; /* in-progress systimer */ |
| b12a1521 | 165 | int gd_timer_running; |
| be71787b MD |
166 | u_int gd_idle_repeat; /* repeated switches to idle */ |
| 167 | int gd_ireserved[7]; | |
| 168 | void *gd_preserved[11]; /* future fields */ | |
| ca8c26b7 | 169 | /* extended by <machine/globaldata.h> */ |
| 85100692 MD |
170 | }; |
| 171 | ||
| 7966cb69 MD |
172 | typedef struct globaldata *globaldata_t; |
| 173 | ||
| 0a3f9b47 MD |
174 | #define RQB_IPIQ 0 |
| 175 | #define RQB_INTPEND 1 | |
| 176 | #define RQB_AST_OWEUPC 2 | |
| 177 | #define RQB_AST_SIGNAL 3 | |
| 178 | #define RQB_AST_USER_RESCHED 4 | |
| 179 | #define RQB_AST_LWKT_RESCHED 5 | |
| 180 | #define RQB_AST_UPCALL 6 | |
| 78ea5a2a | 181 | #define RQB_TIMER 7 |
| f9235b6d | 182 | #define RQB_RUNNING 8 |
| cbdd23b1 | 183 | #define RQB_WAKEUP 9 |
| 235957ed | 184 | |
| 0a3f9b47 MD |
185 | #define RQF_IPIQ (1 << RQB_IPIQ) |
| 186 | #define RQF_INTPEND (1 << RQB_INTPEND) | |
| 78ea5a2a | 187 | #define RQF_TIMER (1 << RQB_TIMER) |
| 0a3f9b47 MD |
188 | #define RQF_AST_OWEUPC (1 << RQB_AST_OWEUPC) |
| 189 | #define RQF_AST_SIGNAL (1 << RQB_AST_SIGNAL) | |
| 190 | #define RQF_AST_USER_RESCHED (1 << RQB_AST_USER_RESCHED) | |
| 191 | #define RQF_AST_LWKT_RESCHED (1 << RQB_AST_LWKT_RESCHED) | |
| 192 | #define RQF_AST_UPCALL (1 << RQB_AST_UPCALL) | |
| f9235b6d | 193 | #define RQF_RUNNING (1 << RQB_RUNNING) |
| cbdd23b1 | 194 | #define RQF_WAKEUP (1 << RQB_WAKEUP) |
| be71787b | 195 | |
| 0a3f9b47 MD |
196 | #define RQF_AST_MASK (RQF_AST_OWEUPC|RQF_AST_SIGNAL|\ |
| 197 | RQF_AST_USER_RESCHED|RQF_AST_LWKT_RESCHED|\ | |
| 198 | RQF_AST_UPCALL) | |
| 78ea5a2a | 199 | #define RQF_IDLECHECK_MASK (RQF_IPIQ|RQF_INTPEND|RQF_TIMER) |
| cbdd23b1 | 200 | #define RQF_IDLECHECK_WK_MASK (RQF_IDLECHECK_MASK|RQF_WAKEUP) |
| 235957ed | 201 | |
| 438acbcc MD |
202 | /* |
| 203 | * globaldata flags | |
| 204 | */ | |
| 205 | #define GDF_KPRINTF 0x0001 /* kprintf() reentrancy */ | |
| 206 | ||
| a108bf71 MD |
207 | #endif |
| 208 | ||
| 12e4aaff MD |
209 | #ifdef _KERNEL |
| 210 | struct globaldata *globaldata_find(int cpu); | |
| 0cd275af | 211 | int is_globaldata_space(vm_offset_t saddr, vm_offset_t eaddr); |
| 12e4aaff MD |
212 | #endif |
| 213 | ||
| 85100692 | 214 | #endif |