rename amd64 architecture to x86_64
[dragonfly.git] / sys / platform / pc64 / include / globaldata.h
CommitLineData
39923942
SS
1/*-
2 * Copyright (c) Peter Wemm <peter@netplex.com.au>
c8fe38ae 3 * Copyright (c) 2008 The DragonFly Project.
39923942
SS
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 * Only machine-dependant code should ever include this file. MI
28 * code and header files do NOT include this file. e.g. sys/globaldata.h
29 * should not include this file.
30 *
31 * $FreeBSD: src/sys/i386/include/globaldata.h,v 1.11.2.1 2000/05/16 06:58:10 dillon Exp $
c8fe38ae 32 * $DragonFly: src/sys/platform/pc64/include/globaldata.h,v 1.2 2008/08/29 17:07:17 dillon Exp $
39923942
SS
33 */
34
35#ifndef _MACHINE_GLOBALDATA_H_
36#define _MACHINE_GLOBALDATA_H_
37
38#if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
39
40#ifndef _SYS_GLOBALDATA_H_
41#include <sys/globaldata.h> /* struct globaldata */
42#endif
43#ifndef _SYS_THREAD_H_
44#include <sys/thread.h> /* struct thread */
45#endif
46#ifndef _MACHINE_SEGMENTS_H_
c8fe38ae 47#include <machine/segments.h> /* struct user_segment_descriptor */
39923942
SS
48#endif
49#ifndef _MACHINE_TSS_H_
c1543a89 50#include <machine/tss.h> /* struct x86_64tss */
c8fe38ae
MD
51#endif
52#ifndef _MACHINE_NPX_H_
53#include <machine/npx.h>
39923942
SS
54#endif
55
56/*
57 * Note on interrupt control. Pending interrupts not yet dispatched are
729e15a8
SZ
58 * marked in gd_fpending or gd_spending. Once dispatched the interrupt's
59 * pending bit is cleared and the interrupt is masked. Upon completion
60 * the interrupt is unmasked.
39923942
SS
61 *
62 * For edge triggered interrupts interrupts may be enabled again at this
63 * point and if they occur before the interrupt service routine is complete
64 * the service routine will loop.
65 *
66 * The current thread's cpl is stored in the thread structure.
46d4e165
JG
67 *
68 * Note: the embedded globaldata and/or the mdglobaldata structure
69 * may exceed the size of a page.
39923942
SS
70 */
71struct mdglobaldata {
72 struct globaldata mi;
c8fe38ae
MD
73 struct user_segment_descriptor gd_common_tssd;
74 struct user_segment_descriptor *gd_tss_gdt;
39923942 75 struct thread *gd_npxthread;
c1543a89 76 struct x86_64tss gd_common_tss;
c8fe38ae
MD
77 union savefpu gd_savefpu; /* fast bcopy/zero temp fpu save area */
78 int gd_fpu_lock; /* fast bcopy/zero cpu lock */
39923942 79 int gd_fpending; /* fast interrupt pending */
729e15a8 80 int unused002;
39923942
SS
81 int gd_spending; /* software interrupt pending */
82 int gd_sdelayed; /* delayed software ints */
83 int gd_currentldt;
84 int gd_private_tss;
46d4e165 85 u_int unused001;
39923942
SS
86 u_int gd_other_cpus;
87 u_int gd_ss_eflags;
88 pt_entry_t *gd_CMAP1;
89 pt_entry_t *gd_CMAP2;
90 pt_entry_t *gd_CMAP3;
91 pt_entry_t *gd_PMAP1;
92 caddr_t gd_CADDR1;
93 caddr_t gd_CADDR2;
94 caddr_t gd_CADDR3;
c8fe38ae 95 pt_entry_t *gd_PADDR1;
46d4e165
JG
96 u_int gd_acpi_id;
97 u_int gd_apic_id;
c8fe38ae
MD
98 register_t gd_scratch_rsp;
99 register_t gd_rsp0;
100 register_t gd_user_fs; /* current user fs in MSR */
101 register_t gd_user_gs; /* current user gs in MSR */
39923942
SS
102};
103
c8fe38ae
MD
104#define MDGLOBALDATA_BASEALLOC_SIZE \
105 ((sizeof(struct mdglobaldata) + PAGE_MASK) & ~PAGE_MASK)
106#define MDGLOBALDATA_BASEALLOC_PAGES \
107 (MDGLOBALDATA_BASEALLOC_SIZE / PAGE_SIZE)
108#define MDGLOBALDATA_PAD \
109 (MDGLOBALDATA_BASEALLOC_SIZE - sizeof(struct mdglobaldata))
110
39923942
SS
111/*
112 * This is the upper (0xff800000) address space layout that is per-cpu.
113 * It is setup in locore.s and pmap.c for the BSP and in mp_machdep.c for
114 * each AP. genassym helps export this to the assembler code.
115 *
c8fe38ae 116 * JG WARNING! page-bounded fields are hardwired for SMPpt[] setup in
39923942
SS
117 * i386/i386/mp_machdep.c and locore.s.
118 */
119struct privatespace {
0855a2af 120 /* JG TODO: fix comments describing layout */
39923942
SS
121 /* page 0 - data page */
122 struct mdglobaldata mdglobaldata;
0855a2af 123 char __filler0[MDGLOBALDATA_PAD];
39923942
SS
124
125 /* page 1..4 - CPAGE1,CPAGE2,CPAGE3,PPAGE1 */
126 char CPAGE1[PAGE_SIZE]; /* SMPpt[1] */
127 char CPAGE2[PAGE_SIZE]; /* SMPpt[2] */
128 char CPAGE3[PAGE_SIZE]; /* SMPpt[3] */
129 char PPAGE1[PAGE_SIZE]; /* SMPpt[4] */
130
131 /* page 5..4+UPAGES - idle stack (UPAGES pages) */
132 char idlestack[UPAGES * PAGE_SIZE]; /* SMPpt[5..] */
133};
134#define mdcpu ((struct mdglobaldata *)_get_mycpu())
135
136#endif
137
138#ifdef _KERNEL
139
140extern struct privatespace CPU_prvspace[];
141
142#endif
143
144#endif