MP Implmentation 3/4: MAJOR progress on SMP, full userland MP is now working!
[dragonfly.git] / sys / platform / pc32 / include / globaldata.h
CommitLineData
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 $
a2a5ad0d 31 * $DragonFly: src/sys/platform/pc32/include/globaldata.h,v 1.17 2003/07/10 04:47:53 dillon Exp $
984263bc
MD
32 */
33
85100692
MD
34#ifndef _MACHINE_GLOBALDATA_H_
35#define _MACHINE_GLOBALDATA_H_
36
37#ifndef _SYS_GLOBALDATA_H_
38#include <sys/globaldata.h> /* struct globaldata */
39#endif
40#ifndef _SYS_THREAD_H_
41#include <sys/thread.h> /* struct thread */
42#endif
43#ifndef _MACHINE_SEGMENTS_H_
44#include <machine/segments.h> /* struct segment_descriptor */
45#endif
46#ifndef _MACHINE_TSS_H_
47#include <machine/tss.h> /* struct i386tss */
48#endif
49
ef0fdad1
MD
50/*
51 * Note on interrupt control. Pending interrupts not yet dispatched are
96728c05
MD
52 * marked in gd_fpending or gd_ipending. Once dispatched the interrupt's
53 * pending bit is cleared and the interrupt is masked. Upon completion
54 * the interrupt is unmasked.
55 *
56 * For edge triggered interrupts interrupts may be enabled again at this
57 * point and if they occur before the interrupt service routine is complete
58 * the service routine will loop.
59 *
60 * The current thread's cpl is stored in the thread structure.
ef0fdad1 61 */
85100692
MD
62struct mdglobaldata {
63 struct globaldata mi;
984263bc
MD
64 struct segment_descriptor gd_common_tssd;
65 struct segment_descriptor *gd_tss_gdt;
85100692
MD
66 struct thread *gd_npxthread;
67 struct i386tss gd_common_tss;
ef0fdad1
MD
68 int gd_fpending; /* fast interrupt pending */
69 int gd_ipending; /* normal interrupt pending */
85100692 70 int gd_currentldt; /* USER_LDT */
a2a5ad0d 71 int gd_private_tss;
984263bc
MD
72 u_int gd_cpu_lockid;
73 u_int gd_other_cpus;
984263bc 74 u_int gd_ss_eflags;
85100692
MD
75 pt_entry_t *gd_CMAP1;
76 pt_entry_t *gd_CMAP2;
77 pt_entry_t *gd_CMAP3;
78 pt_entry_t *gd_PMAP1;
79 caddr_t gd_CADDR1;
80 caddr_t gd_CADDR2;
81 caddr_t gd_CADDR3;
82 unsigned *gd_PADDR1;
984263bc
MD
83};
84
984263bc
MD
85/*
86 * This is the upper (0xff800000) address space layout that is per-cpu.
87 * It is setup in locore.s and pmap.c for the BSP and in mp_machdep.c for
88 * each AP. genassym helps export this to the assembler code.
b3f81036
MD
89 *
90 * WARNING! page-bounded fields are hardwired for SMPpt[] setup in
91 * i386/i386/mp_machdep.c and locore.s.
984263bc
MD
92 */
93struct privatespace {
94 /* page 0 - data page */
85100692
MD
95 struct mdglobaldata mdglobaldata;
96 char __filler0[PAGE_SIZE - sizeof(struct mdglobaldata)];
984263bc
MD
97
98 /* page 1..4 - CPAGE1,CPAGE2,CPAGE3,PPAGE1 */
b3f81036
MD
99 char CPAGE1[PAGE_SIZE]; /* SMPpt[1] */
100 char CPAGE2[PAGE_SIZE]; /* SMPpt[2] */
101 char CPAGE3[PAGE_SIZE]; /* SMPpt[3] */
102 char PPAGE1[PAGE_SIZE]; /* SMPpt[4] */
984263bc
MD
103
104 /* page 5..4+UPAGES - idle stack (UPAGES pages) */
b3f81036 105 char idlestack[UPAGES * PAGE_SIZE]; /* SMPpt[5..] */
984263bc
MD
106};
107
8ad65e08 108extern struct privatespace CPU_prvspace[];
3020e3be 109
85100692 110#define mdcpu ((struct mdglobaldata *)_get_mycpu())
85100692
MD
111
112#endif