| Commit | Line | Data |
|---|---|---|
| a7231bde 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 | * | |
| 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 | * | |
| 30 | * $FreeBSD: src/sys/i386/include/globaldata.h,v 1.11.2.1 2000/05/16 06:58:10 dillon Exp $ | |
| eec2b734 | 31 | * $DragonFly: src/sys/platform/vkernel/include/globaldata.h,v 1.8 2008/04/28 07:05:07 dillon Exp $ |
| a7231bde MD |
32 | */ |
| 33 | ||
| 34 | #ifndef _MACHINE_GLOBALDATA_H_ | |
| 35 | #define _MACHINE_GLOBALDATA_H_ | |
| 36 | ||
| 37 | #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES) | |
| 38 | ||
| 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 | |
| e4a473f1 MD |
45 | #ifndef _SYS_VKERNEL_H_ |
| 46 | #include <sys/vkernel.h> /* vpte_t */ | |
| 47 | #endif | |
| a7231bde MD |
48 | #ifndef _MACHINE_SEGMENTS_H_ |
| 49 | #include <machine/segments.h> /* struct segment_descriptor */ | |
| 50 | #endif | |
| 51 | #ifndef _MACHINE_TSS_H_ | |
| 52 | #include <machine/tss.h> /* struct i386tss */ | |
| 53 | #endif | |
| 54 | #ifndef _MACHINE_NPX_H_ | |
| 55 | #include <machine/npx.h> | |
| 56 | #endif | |
| 5c5185ae SG |
57 | #ifndef _CPU_LWBUF_H_ |
| 58 | #include <cpu/lwbuf.h> | |
| 59 | #endif | |
| a7231bde MD |
60 | |
| 61 | /* | |
| 62 | * Note on interrupt control. Pending interrupts not yet dispatched are | |
| 63 | * marked in gd_fpending, gd_ipending, or gd_spending. Once dispatched | |
| 64 | * the interrupt's pending bit is cleared and the interrupt is masked. | |
| 65 | * Upon completion the interrupt is unmasked. | |
| 66 | * | |
| 67 | * For edge triggered interrupts interrupts may be enabled again at this | |
| 68 | * point and if they occur before the interrupt service routine is complete | |
| 69 | * the service routine will loop. | |
| 70 | * | |
| 71 | * The current thread's cpl is stored in the thread structure. | |
| 72 | * | |
| 73 | * Note: the embedded globaldata and/or the mdglobaldata structure | |
| 74 | * may exceed the size of a page. | |
| 75 | */ | |
| 76 | struct mdglobaldata { | |
| 77 | struct globaldata mi; | |
| 78 | struct segment_descriptor gd_common_tssd; | |
| 79 | struct segment_descriptor *gd_tss_gdt; | |
| 80 | struct thread *gd_npxthread; | |
| 81 | struct i386tss gd_common_tss; | |
| 5c5185ae | 82 | struct lwbuf_free_kvp_list gd_lwbuf_fpages; /* lwbuf: free kva */ |
| a7231bde MD |
83 | union savefpu gd_savefpu; /* fast bcopy/zero temp fpu save area */ |
| 84 | int gd_fpu_lock; /* fast bcopy/zero cpu lock */ | |
| 85 | int gd_fpending; /* fast interrupt pending */ | |
| 86 | int gd_ipending; /* normal interrupt pending */ | |
| 87 | int gd_spending; /* software interrupt pending */ | |
| 88 | int gd_sdelayed; /* delayed software ints */ | |
| 89 | int gd_currentldt; | |
| 24eb47e0 MD |
90 | int unused003; |
| 91 | int unused002; | |
| a7231bde MD |
92 | u_int unused001; |
| 93 | u_int gd_other_cpus; | |
| 94 | u_int gd_ss_eflags; | |
| e4a473f1 MD |
95 | vpte_t *gd_CMAP1; /* pointer to pte for CADDR1 */ |
| 96 | vpte_t *gd_CMAP2; | |
| 97 | vpte_t *gd_CMAP3; | |
| 98 | vpte_t *gd_PMAP1; | |
| 99 | ||
| a7231bde MD |
100 | caddr_t gd_CADDR1; |
| 101 | caddr_t gd_CADDR2; | |
| 102 | caddr_t gd_CADDR3; | |
| e4a473f1 MD |
103 | vpte_t *gd_PADDR1; |
| 104 | ||
| 105 | /* | |
| 106 | * Page table mappings, see get_ptbase() | |
| 107 | */ | |
| 108 | vpte_t *gd_PT1map; /* points into privatedata */ | |
| 109 | vpte_t *gd_PT1pdir; /* KVA of page directory */ | |
| 110 | vpte_t *gd_PT1pde; /* pointer to pde */ | |
| 111 | vpte_t *gd_PT2map; | |
| 112 | vpte_t *gd_PT2pdir; | |
| 113 | vpte_t *gd_PT2pde; | |
| 114 | int gd_PTflip; | |
| 115 | ||
| eec2b734 MD |
116 | vpte_t *gd_PT3map; /* used from preemptive interrupt */ |
| 117 | vpte_t *gd_PT3pdir; | |
| 118 | vpte_t *gd_PT3pde; | |
| a7231bde MD |
119 | }; |
| 120 | ||
| 121 | #define MDGLOBALDATA_BASEALLOC_SIZE \ | |
| 122 | ((sizeof(struct mdglobaldata) + PAGE_MASK) & ~PAGE_MASK) | |
| 123 | #define MDGLOBALDATA_BASEALLOC_PAGES \ | |
| 124 | (MDGLOBALDATA_BASEALLOC_SIZE / PAGE_SIZE) | |
| 125 | #define MDGLOBALDATA_PAD \ | |
| 126 | (MDGLOBALDATA_BASEALLOC_SIZE - sizeof(struct mdglobaldata)) | |
| 127 | ||
| 128 | /* | |
| 129 | * This is the upper (0xff800000) address space layout that is per-cpu. | |
| 130 | * It is setup in locore.s and pmap.c for the BSP and in mp_machdep.c for | |
| 131 | * each AP. genassym helps export this to the assembler code. | |
| 132 | * | |
| e4a473f1 MD |
133 | * WARNING! This structure must be segment-aligned and portions within the |
| 134 | * structure must also be segment-aligned. The structure typically | |
| 135 | * takes 3 segments per cpu (12MB). | |
| a7231bde | 136 | */ |
| e4a473f1 MD |
137 | #define PRIVATESPACE_SEGPAD \ |
| 138 | (SEG_SIZE - \ | |
| 139 | ((sizeof(struct mdglobaldata) + MDGLOBALDATA_PAD + PAGE_SIZE * 4 + \ | |
| 140 | UPAGES * PAGE_SIZE) % SEG_SIZE)) \ | |
| 141 | ||
| a7231bde MD |
142 | struct privatespace { |
| 143 | /* main data page */ | |
| 144 | struct mdglobaldata mdglobaldata; | |
| 145 | char __filler0[MDGLOBALDATA_PAD]; | |
| 146 | ||
| 147 | /* mapping pages - CPAGE1,CPAGE2,CPAGE3,PPAGE1 */ | |
| e4a473f1 MD |
148 | char CPAGE1[PAGE_SIZE]; |
| 149 | char CPAGE2[PAGE_SIZE]; | |
| 150 | char CPAGE3[PAGE_SIZE]; | |
| 151 | vpte_t PPAGE1[PAGE_SIZE / sizeof(vpte_t)]; | |
| a7231bde MD |
152 | |
| 153 | /* idle stack (UPAGES pages) */ | |
| e4a473f1 MD |
154 | char idlestack[UPAGES * PAGE_SIZE]; |
| 155 | ||
| 156 | /* we must PAD to SEG_SIZE */ | |
| 157 | char __filler1[PRIVATESPACE_SEGPAD]; | |
| 158 | vpte_t PT1MAP[SEG_SIZE / sizeof(vpte_t)]; | |
| 159 | vpte_t PT2MAP[SEG_SIZE / sizeof(vpte_t)]; | |
| eec2b734 | 160 | vpte_t PT3MAP[SEG_SIZE / sizeof(vpte_t)]; |
| a7231bde MD |
161 | }; |
| 162 | #define mdcpu ((struct mdglobaldata *)_get_mycpu()) | |
| 163 | ||
| 164 | #endif | |
| 165 | ||
| 166 | #ifdef _KERNEL | |
| 167 | ||
| 8a9d8995 | 168 | extern struct privatespace *CPU_prvspace; |
| a7231bde MD |
169 | |
| 170 | #endif | |
| 171 | ||
| 172 | #endif |