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