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