pcpu.h revision 81763
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 * 2650477Speter * $FreeBSD: head/sys/i386/include/pcpu.h 81763 2001-08-16 09:29:35Z obrien $ 2735069Speter */ 2835069Speter 2965557Sjasone#ifndef _MACHINE_GLOBALDATA_H_ 3065557Sjasone#define _MACHINE_GLOBALDATA_H_ 3165557Sjasone 3281763Sobrien#ifdef _KERNEL 3381763Sobrien 3465557Sjasone#include <machine/segments.h> 3565557Sjasone#include <machine/tss.h> 3665557Sjasone 3765557Sjasone/* XXX */ 3865557Sjasone#ifdef KTR_PERCPU 3965557Sjasone#include <sys/ktr.h> 4065557Sjasone#endif 4165557Sjasone 4235069Speter/* 4335069Speter * This structure maps out the global data that needs to be kept on a 4435069Speter * per-cpu basis. genassym uses this to generate offsets for the assembler 4535069Speter * code, which also provides external symbols so that C can get at them as 4635069Speter * though they were really globals. 4735069Speter * 4835069Speter * The SMP parts are setup in pmap.c and locore.s for the BSP, and 4935069Speter * mp_machdep.c sets up the data for the AP's to "see" when they awake. 5035069Speter * The reason for doing it via a struct is so that an array of pointers 5135069Speter * to each CPU's data can be set up for things like "check curproc on all 5235069Speter * other processors" 5335069Speter */ 5435069Speterstruct globaldata { 5581763Sobrien struct globaldata *gd_prvspace; /* self-reference */ 5681763Sobrien struct proc *gd_curproc; /* current process */ 5781763Sobrien struct proc *gd_idleproc; /* idle process */ 5881763Sobrien struct proc *gd_npxproc; 5981763Sobrien struct pcb *gd_curpcb; /* current pcb */ 6081763Sobrien struct timeval gd_switchtime; 6181763Sobrien struct i386tss gd_common_tss; 6281763Sobrien int gd_switchticks; 6381763Sobrien struct segment_descriptor gd_common_tssd; 6481763Sobrien struct segment_descriptor *gd_tss_gdt; 6581763Sobrien int gd_currentldt; 6681763Sobrien u_int gd_cpuid; /* this cpu number */ 6781763Sobrien u_int gd_other_cpus; /* all other cpus */ 6865557Sjasone SLIST_ENTRY(globaldata) gd_allcpu; 6981763Sobrien struct lock_list_entry *gd_spinlocks; 7065557Sjasone#ifdef KTR_PERCPU 7181763Sobrien volatile int gd_ktr_idx; /* Index into trace table */ 7281763Sobrien char *gd_ktr_buf; 7381763Sobrien char gd_ktr_buf_data[KTR_SIZE]; 7465557Sjasone#endif 7535069Speter}; 7635069Speter 7735069Speter#ifdef SMP 7835069Speter/* 7935069Speter * This is the upper (0xff800000) address space layout that is per-cpu. 8035069Speter * It is setup in locore.s and pmap.c for the BSP and in mp_machdep.c for 8135069Speter * each AP. genassym helps export this to the assembler code. 8235069Speter */ 8335069Speterstruct privatespace { 8435069Speter /* page 0 - data page */ 8581763Sobrien struct globaldata globaldata; 8681763Sobrien char __filler0[PAGE_SIZE - sizeof(struct globaldata)]; 8735069Speter 8871818Speter /* page 1 - idle stack (UPAGES pages) */ 8981763Sobrien char idlestack[UPAGES * PAGE_SIZE]; 9071818Speter /* page 1+UPAGES... */ 9146129Sluoqi}; 9235069Speter 9346129Sluoqiextern struct privatespace SMP_prvspace[]; 9435069Speter 9535069Speter#endif 9665557Sjasone 9781763Sobrien#endif /* _KERNEL */ 9881763Sobrien 9965557Sjasone#endif /* ! _MACHINE_GLOBALDATA_H_ */ 100