pcpu.h revision 46129
135069Speter/*-
235069Speter * Copyright (c) Peter Wemm <peter@netplex.com.au>
335069Speter * All rights reserved.
435069Speter *
535069Speter * Redistribution and use in source and binary forms, with or without
635069Speter * modification, are permitted provided that the following conditions
735069Speter * are met:
835069Speter * 1. Redistributions of source code must retain the above copyright
935069Speter *    notice, this list of conditions and the following disclaimer.
1035069Speter * 2. Redistributions in binary form must reproduce the above copyright
1135069Speter *    notice, this list of conditions and the following disclaimer in the
1235069Speter *    documentation and/or other materials provided with the distribution.
1335069Speter *
1435069Speter * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1535069Speter * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1635069Speter * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1735069Speter * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1835069Speter * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1935069Speter * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2035069Speter * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2135069Speter * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2235069Speter * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2335069Speter * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2435069Speter * SUCH DAMAGE.
2535069Speter *
2646129Sluoqi * $Id: globaldata.h,v 1.7 1999/02/22 15:13:34 bde Exp $
2735069Speter */
2835069Speter
2935069Speter/*
3035069Speter * This structure maps out the global data that needs to be kept on a
3135069Speter * per-cpu basis.  genassym uses this to generate offsets for the assembler
3235069Speter * code, which also provides external symbols so that C can get at them as
3335069Speter * though they were really globals.
3435069Speter *
3535069Speter * The SMP parts are setup in pmap.c and locore.s for the BSP, and
3635069Speter * mp_machdep.c sets up the data for the AP's to "see" when they awake.
3735069Speter * The reason for doing it via a struct is so that an array of pointers
3835069Speter * to each CPU's data can be set up for things like "check curproc on all
3935069Speter * other processors"
4035069Speter */
4135069Speterstruct globaldata {
4246129Sluoqi	struct privatespace *gd_prvspace;	/* self-reference */
4346129Sluoqi	struct proc	*gd_curproc;
4446129Sluoqi	struct proc	*gd_npxproc;
4546129Sluoqi	struct pcb	*gd_curpcb;
4646129Sluoqi	struct timeval	gd_switchtime;
4746129Sluoqi	struct i386tss	gd_common_tss;
4846129Sluoqi	int		gd_switchticks;
4935069Speter#ifdef VM86
5046129Sluoqi	struct segment_descriptor gd_common_tssd;
5135069Speter#endif
5238422Smsmith#ifdef USER_LDT
5346129Sluoqi	int		gd_currentldt;
5438422Smsmith#endif
5535069Speter#ifdef SMP
5646129Sluoqi	u_int		gd_cpuid;
5746129Sluoqi	u_int		gd_cpu_lockid;
5846129Sluoqi	u_int		gd_other_cpus;
5946129Sluoqi	int		gd_inside_intr;
6046129Sluoqi	u_int		gd_ss_eflags;
6146129Sluoqi	pt_entry_t	*gd_prv_CMAP1;
6246129Sluoqi	pt_entry_t	*gd_prv_CMAP2;
6346129Sluoqi	pt_entry_t	*gd_prv_CMAP3;
6446129Sluoqi	pt_entry_t	*gd_prv_PMAP1;
6546129Sluoqi	caddr_t		gd_prv_CADDR1;
6646129Sluoqi	caddr_t		gd_prv_CADDR2;
6746129Sluoqi	caddr_t		gd_prv_CADDR3;
6846129Sluoqi	unsigned	*gd_prv_PADDR1;
6935069Speter#endif
7035069Speter};
7135069Speter
7235069Speter#ifdef SMP
7335069Speter/*
7435069Speter * This is the upper (0xff800000) address space layout that is per-cpu.
7535069Speter * It is setup in locore.s and pmap.c for the BSP and in mp_machdep.c for
7635069Speter * each AP.  genassym helps export this to the assembler code.
7735069Speter */
7835069Speterstruct privatespace {
7935069Speter	/* page 0 - data page */
8035069Speter	struct globaldata globaldata;
8135069Speter	char		__filler0[PAGE_SIZE - sizeof(struct globaldata)];
8235069Speter
8346129Sluoqi	/* page 1..4 - CPAGE1,CPAGE2,CPAGE3,PPAGE1 */
8435069Speter	char		CPAGE1[PAGE_SIZE];
8535069Speter	char		CPAGE2[PAGE_SIZE];
8635069Speter	char		CPAGE3[PAGE_SIZE];
8736125Stegge	char		PPAGE1[PAGE_SIZE];
8835069Speter
8946129Sluoqi	/* page 5..4+UPAGES - idle stack (UPAGES pages) */
9046129Sluoqi	char		idlestack[UPAGES * PAGE_SIZE];
9146129Sluoqi};
9235069Speter
9346129Sluoqiextern struct privatespace SMP_prvspace[];
9435069Speter
9535069Speter#endif
96