| Commit | Line | Data |
|---|---|---|
| 984263bc MD |
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 | * | |
| 85100692 MD |
26 | * Only machine-dependant code should ever include this file. MI |
| 27 | * code and header files do NOT include this file. e.g. sys/globaldata.h | |
| 28 | * should not include this file. | |
| 29 | * | |
| 984263bc | 30 | * $FreeBSD: src/sys/i386/include/globaldata.h,v 1.11.2.1 2000/05/16 06:58:10 dillon Exp $ |
| f8334305 | 31 | * $DragonFly: src/sys/platform/pc32/include/globaldata.h,v 1.29 2006/10/23 21:50:31 dillon Exp $ |
| 984263bc MD |
32 | */ |
| 33 | ||
| 85100692 MD |
34 | #ifndef _MACHINE_GLOBALDATA_H_ |
| 35 | #define _MACHINE_GLOBALDATA_H_ | |
| 36 | ||
| ec12abe0 MD |
37 | #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES) |
| 38 | ||
| 85100692 MD |
39 | #ifndef _SYS_GLOBALDATA_H_ |
| 40 | #include <sys/globaldata.h> /* struct globaldata */ | |
| 41 | #endif | |
| 42 | #ifndef _SYS_THREAD_H_ | |
| 43 | #include <sys/thread.h> /* struct thread */ | |
| 44 | #endif | |
| 45 | #ifndef _MACHINE_SEGMENTS_H_ | |
| f8334305 | 46 | #include <machine/segments.h> /* struct segment_descriptor */ |
| 85100692 MD |
47 | #endif |
| 48 | #ifndef _MACHINE_TSS_H_ | |
| f8334305 | 49 | #include <machine/tss.h> /* struct i386tss */ |
| 85100692 | 50 | #endif |
| a02705a9 | 51 | #ifndef _MACHINE_NPX_H_ |
| f8334305 | 52 | #include <machine/npx.h> |
| a02705a9 | 53 | #endif |
| 5c5185ae SG |
54 | #ifndef _CPU_LWBUF_H_ |
| 55 | #include <cpu/lwbuf.h> | |
| 56 | #endif | |
| 85100692 | 57 | |
| ef0fdad1 MD |
58 | /* |
| 59 | * Note on interrupt control. Pending interrupts not yet dispatched are | |
| 729e15a8 SZ |
60 | * marked in gd_fpending or gd_spending. Once dispatched the interrupt's |
| 61 | * pending bit is cleared and the interrupt is masked. Upon completion | |
| 62 | * the interrupt is unmasked. | |
| 96728c05 MD |
63 | * |
| 64 | * For edge triggered interrupts interrupts may be enabled again at this | |
| 65 | * point and if they occur before the interrupt service routine is complete | |
| 66 | * the service routine will loop. | |
| 67 | * | |
| 68 | * The current thread's cpl is stored in the thread structure. | |
| 81c04d07 MD |
69 | * |
| 70 | * Note: the embedded globaldata and/or the mdglobaldata structure | |
| 71 | * may exceed the size of a page. | |
| ef0fdad1 | 72 | */ |
| 85100692 MD |
73 | struct mdglobaldata { |
| 74 | struct globaldata mi; | |
| 984263bc MD |
75 | struct segment_descriptor gd_common_tssd; |
| 76 | struct segment_descriptor *gd_tss_gdt; | |
| 85100692 MD |
77 | struct thread *gd_npxthread; |
| 78 | struct i386tss gd_common_tss; | |
| 5c5185ae | 79 | struct lwbuf_free_kvp_list gd_lwbuf_fpages; /* lwbuf: free kva */ |
| a02705a9 MD |
80 | union savefpu gd_savefpu; /* fast bcopy/zero temp fpu save area */ |
| 81 | int gd_fpu_lock; /* fast bcopy/zero cpu lock */ | |
| ef0fdad1 | 82 | int gd_fpending; /* fast interrupt pending */ |
| 729e15a8 | 83 | int unused002; |
| 5f456c40 MD |
84 | int gd_spending; /* software interrupt pending */ |
| 85 | int gd_sdelayed; /* delayed software ints */ | |
| ee66458c | 86 | int gd_currentldt; |
| a2a5ad0d | 87 | int gd_private_tss; |
| 0f7a3396 | 88 | u_int unused001; |
| 984263bc | 89 | u_int gd_other_cpus; |
| 984263bc | 90 | u_int gd_ss_eflags; |
| 85100692 MD |
91 | pt_entry_t *gd_CMAP1; |
| 92 | pt_entry_t *gd_CMAP2; | |
| 93 | pt_entry_t *gd_CMAP3; | |
| 94 | pt_entry_t *gd_PMAP1; | |
| c1692ddf | 95 | pt_entry_t *gd_GDMAP1; /* per-cpu whole page table map */ |
| 85100692 MD |
96 | caddr_t gd_CADDR1; |
| 97 | caddr_t gd_CADDR2; | |
| 98 | caddr_t gd_CADDR3; | |
| 99 | unsigned *gd_PADDR1; | |
| c1692ddf | 100 | unsigned *gd_GDADDR1; /* per-cpu whole page table map va */ |
| e126caf1 MD |
101 | u_int gd_acpi_id; |
| 102 | u_int gd_apic_id; | |
| 984263bc MD |
103 | }; |
| 104 | ||
| 81c04d07 MD |
105 | #define MDGLOBALDATA_BASEALLOC_SIZE \ |
| 106 | ((sizeof(struct mdglobaldata) + PAGE_MASK) & ~PAGE_MASK) | |
| 107 | #define MDGLOBALDATA_BASEALLOC_PAGES \ | |
| 108 | (MDGLOBALDATA_BASEALLOC_SIZE / PAGE_SIZE) | |
| 109 | #define MDGLOBALDATA_PAD \ | |
| 110 | (MDGLOBALDATA_BASEALLOC_SIZE - sizeof(struct mdglobaldata)) | |
| 111 | ||
| 984263bc MD |
112 | /* |
| 113 | * This is the upper (0xff800000) address space layout that is per-cpu. | |
| 114 | * It is setup in locore.s and pmap.c for the BSP and in mp_machdep.c for | |
| 115 | * each AP. genassym helps export this to the assembler code. | |
| b3f81036 | 116 | * |
| 81c04d07 MD |
117 | * WARNING! page-bounded fields and page table indexes are hardwired |
| 118 | * for SMPpt[] setup in i386/i386/mp_machdep.c and locore.s. | |
| f13b5eec MD |
119 | * |
| 120 | * WARNING! sizeof(privatespace[SMP_MAXCPU]) must fit in the KVA | |
| c1692ddf | 121 | * reserved for the SMPpt page table (typically one page table page = 4MB). |
| f13b5eec MD |
122 | * |
| 123 | * WARNING! This structure must be a multiple of PAGE_SIZE. | |
| 984263bc MD |
124 | */ |
| 125 | struct privatespace { | |
| 81c04d07 | 126 | /* main data page */ |
| 85100692 | 127 | struct mdglobaldata mdglobaldata; |
| 81c04d07 | 128 | char __filler0[MDGLOBALDATA_PAD]; |
| 984263bc | 129 | |
| 81c04d07 MD |
130 | /* mapping pages - CPAGE1,CPAGE2,CPAGE3,PPAGE1 */ |
| 131 | char CPAGE1[PAGE_SIZE]; /* SMPpt[n+0] */ | |
| 132 | char CPAGE2[PAGE_SIZE]; /* SMPpt[n+1] */ | |
| 133 | char CPAGE3[PAGE_SIZE]; /* SMPpt[n+2] */ | |
| 134 | char PPAGE1[PAGE_SIZE]; /* SMPpt[n+3] */ | |
| 984263bc | 135 | |
| 81c04d07 MD |
136 | /* idle stack (UPAGES pages) */ |
| 137 | char idlestack[UPAGES * PAGE_SIZE]; /* SMPpt[n+4] */ | |
| 984263bc | 138 | }; |
| ec12abe0 MD |
139 | #define mdcpu ((struct mdglobaldata *)_get_mycpu()) |
| 140 | ||
| 141 | #endif | |
| 142 | ||
| 143 | #ifdef _KERNEL | |
| 984263bc | 144 | |
| 8ad65e08 | 145 | extern struct privatespace CPU_prvspace[]; |
| 3020e3be | 146 | |
| ec12abe0 | 147 | #endif |
| 85100692 MD |
148 | |
| 149 | #endif |