pcpu.h revision 36125
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 *
2636125Stegge * $Id: globaldata.h,v 1.2 1998/04/06 18:59:15 peter 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 {
4235069Speter	struct proc	*curproc;
4335069Speter	struct proc	*npxproc;
4435069Speter	struct pcb	*curpcb;
4535069Speter	struct i386tss	common_tss;
4635069Speter#ifdef VM86
4735069Speter	struct segment_descriptor common_tssd;
4835069Speter	u_int		private_tss;
4935087Speter	u_int		my_tr;
5035069Speter#endif
5135069Speter#ifdef SMP
5235069Speter	u_int		cpuid;
5335069Speter	u_int		cpu_lockid;
5435069Speter	u_int		other_cpus;
5535069Speter	pd_entry_t	*my_idlePTD;
5635069Speter	u_int		ss_tpr;
5735069Speter	pt_entry_t	*prv_CMAP1;
5835069Speter	pt_entry_t	*prv_CMAP2;
5935069Speter	pt_entry_t	*prv_CMAP3;
6036125Stegge	pt_entry_t	*prv_PMAP1;
6135069Speter	int		inside_intr;
6235069Speter#endif
6335069Speter};
6435069Speter
6535069Speter#ifdef SMP
6635069Speter/*
6735069Speter * This is the upper (0xff800000) address space layout that is per-cpu.
6835069Speter * It is setup in locore.s and pmap.c for the BSP and in mp_machdep.c for
6935069Speter * each AP.  genassym helps export this to the assembler code.
7035069Speter */
7135069Speterstruct privatespace {
7235069Speter	/* page 0 - data page */
7335069Speter	struct globaldata globaldata;
7435069Speter	char		__filler0[PAGE_SIZE - sizeof(struct globaldata)];
7535069Speter
7635069Speter	/* page 1 - page table page */
7735069Speter	pt_entry_t	prvpt[NPTEPG];
7835069Speter
7935069Speter	/* page 2 - local apic mapping */
8035069Speter	lapic_t		lapic;
8135069Speter	char		__filler1[PAGE_SIZE - sizeof(lapic_t)];
8235069Speter
8336125Stegge	/* page 3..2+UPAGES - idle stack (UPAGES pages) */
8436125Stegge	char		idlestack[UPAGES * PAGE_SIZE];
8535069Speter
8636125Stegge	/* page 3+UPAGES..6+UPAGES - CPAGE1,CPAGE2,CPAGE3,PPAGE1 */
8735069Speter	char		CPAGE1[PAGE_SIZE];
8835069Speter	char		CPAGE2[PAGE_SIZE];
8935069Speter	char		CPAGE3[PAGE_SIZE];
9036125Stegge	char		PPAGE1[PAGE_SIZE];
9135069Speter
9236125Stegge	/* page 7+UPAGES..15 - spare, unmapped */
9336125Stegge	char		__filler2[(9-UPAGES) * PAGE_SIZE];
9435069Speter
9535069Speter	/* page 16-31 - space for IO apics */
9635069Speter	char		ioapics[16 * PAGE_SIZE];
9735069Speter
9835069Speter	/* page 32-47 - maybe other cpu's globaldata pages? */
9935069Speter};
10035069Speter#endif
101