xref: /freebsd/sys/i386/include/pcpu.h (revision 6990ffd8a95caaba6858ad44ff1b3157d1efba8f)
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 #ifdef _KERNEL
33 
34 #include <machine/segments.h>
35 #include <machine/tss.h>
36 
37 /* XXX */
38 #ifdef KTR_PERCPU
39 #include <sys/ktr.h>
40 #endif
41 
42 /*
43  * This structure maps out the global data that needs to be kept on a
44  * per-cpu basis.  genassym uses this to generate offsets for the assembler
45  * code, which also provides external symbols so that C can get at them as
46  * though they were really globals.
47  *
48  * The SMP parts are setup in pmap.c and locore.s for the BSP, and
49  * mp_machdep.c sets up the data for the AP's to "see" when they awake.
50  * The reason for doing it via a struct is so that an array of pointers
51  * to each CPU's data can be set up for things like "check curproc on all
52  * other processors"
53  */
54 struct globaldata {
55 	struct globaldata *gd_prvspace;		/* self-reference */
56 	struct thread	*gd_curthread;
57 	struct thread	*gd_npxthread;
58 	struct pcb	*gd_curpcb;
59 	struct thread	*gd_idlethread;
60 	struct timeval	gd_switchtime;
61 	struct i386tss	gd_common_tss;
62 	int		gd_switchticks;
63 	struct segment_descriptor gd_common_tssd;
64 	struct segment_descriptor *gd_tss_gdt;
65 	int		gd_currentldt;
66 	u_int		gd_cpuid;
67 	u_int		gd_other_cpus;
68 	SLIST_ENTRY(globaldata) gd_allcpu;
69 	struct	lock_list_entry *gd_spinlocks;
70 #ifdef KTR_PERCPU
71 	volatile int	gd_ktr_idx;		/* Index into trace table */
72 	char	*gd_ktr_buf;
73 	char	gd_ktr_buf_data[KTR_SIZE];
74 #endif
75 };
76 
77 #endif	/* _KERNEL */
78 
79 #endif	/* ! _MACHINE_GLOBALDATA_H_ */
80