1 /*- 2 * Copyright (c) Peter Wemm <peter@netplex.com.au> 3 * 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 * $FreeBSD$ 27 */ 28 29 #ifndef _MACHINE_GLOBALDATA_H_ 30 #define _MACHINE_GLOBALDATA_H_ 31 32 #include <vm/vm.h> 33 #include <vm/pmap.h> 34 #include <machine/pmap.h> 35 #include <machine/segments.h> 36 #include <machine/tss.h> 37 38 /* XXX */ 39 #ifdef KTR_PERCPU 40 #include <sys/ktr.h> 41 #endif 42 43 /* 44 * This structure maps out the global data that needs to be kept on a 45 * per-cpu basis. genassym uses this to generate offsets for the assembler 46 * code, which also provides external symbols so that C can get at them as 47 * though they were really globals. 48 * 49 * The SMP parts are setup in pmap.c and locore.s for the BSP, and 50 * mp_machdep.c sets up the data for the AP's to "see" when they awake. 51 * The reason for doing it via a struct is so that an array of pointers 52 * to each CPU's data can be set up for things like "check curproc on all 53 * other processors" 54 */ 55 struct globaldata { 56 struct privatespace *gd_prvspace; /* self-reference */ 57 struct proc *gd_curproc; 58 struct proc *gd_npxproc; 59 struct pcb *gd_curpcb; 60 struct proc *gd_idleproc; 61 struct timeval gd_switchtime; 62 struct i386tss gd_common_tss; 63 int gd_switchticks; 64 int gd_intr_nesting_level; 65 struct segment_descriptor gd_common_tssd; 66 struct segment_descriptor *gd_tss_gdt; 67 int gd_currentldt; /* only used for USER_LDT */ 68 #ifdef SMP 69 u_int gd_cpuid; 70 u_int gd_cpu_lockid; 71 u_int gd_other_cpus; 72 int gd_inside_intr; 73 u_int gd_ss_eflags; 74 pt_entry_t *gd_prv_CMAP1; 75 pt_entry_t *gd_prv_CMAP2; 76 pt_entry_t *gd_prv_CMAP3; 77 pt_entry_t *gd_prv_PMAP1; 78 caddr_t gd_prv_CADDR1; 79 caddr_t gd_prv_CADDR2; 80 caddr_t gd_prv_CADDR3; 81 unsigned *gd_prv_PADDR1; 82 #endif 83 u_int gd_astpending; 84 SLIST_ENTRY(globaldata) gd_allcpu; 85 int gd_witness_spin_check; 86 #ifdef KTR_PERCPU 87 #ifdef KTR 88 volatile int gd_ktr_idx; 89 char *gd_ktr_buf; 90 char gd_ktr_buf_data[KTR_SIZE]; 91 #endif 92 #endif 93 }; 94 95 extern struct globaldata globaldata; 96 97 SLIST_HEAD(cpuhead, globaldata); 98 extern struct cpuhead cpuhead; 99 100 #ifdef SMP 101 /* 102 * This is the upper (0xff800000) address space layout that is per-cpu. 103 * It is setup in locore.s and pmap.c for the BSP and in mp_machdep.c for 104 * each AP. genassym helps export this to the assembler code. 105 */ 106 struct privatespace { 107 /* page 0 - data page */ 108 struct globaldata globaldata; 109 char __filler0[PAGE_SIZE - sizeof(struct globaldata)]; 110 111 /* page 1..4 - CPAGE1,CPAGE2,CPAGE3,PPAGE1 */ 112 char CPAGE1[PAGE_SIZE]; 113 char CPAGE2[PAGE_SIZE]; 114 char CPAGE3[PAGE_SIZE]; 115 char PPAGE1[PAGE_SIZE]; 116 117 /* page 5..4+UPAGES - idle stack (UPAGES pages) */ 118 char idlestack[UPAGES * PAGE_SIZE]; 119 }; 120 121 extern struct privatespace SMP_prvspace[]; 122 123 #endif 124 125 #endif /* ! _MACHINE_GLOBALDATA_H_ */ 126