MP Implmentation 3/4: MAJOR progress on SMP, full userland MP is now working!
[dragonfly.git] / sys / sys / globaldata.h
CommitLineData
85100692
MD
1/*-
2 * Copyright (c) Peter Wemm <peter@netplex.com.au> All rights reserved.
3 * Copyright (c) 2003 Matthew Dillon <dillon@backplane.net> 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 *
26 * $FreeBSD: src/sys/i386/include/globaldata.h,v 1.11.2.1 2000/05/16 06:58:10 dillon Exp $
a2a5ad0d 27 * $DragonFly: src/sys/sys/globaldata.h,v 1.9 2003/07/10 04:47:55 dillon Exp $
85100692
MD
28 */
29
30#ifndef _SYS_GLOBALDATA_H_
31#define _SYS_GLOBALDATA_H_
32
96728c05
MD
33#ifndef _SYS_TIME_H_
34#include <sys/time.h> /* struct timeval */
35#endif
36#ifndef _SYS_VMMETER_H_
a2a5ad0d
MD
37#include <sys/vmmeter.h> /* struct vmmeter */
38#endif
39#ifndef _SYS_THREAD_H_
40#include <sys/thread.h> /* struct thread */
41#endif
96728c05 42
85100692
MD
43/*
44 * This structure maps out the global data that needs to be kept on a
45 * per-cpu basis. genassym uses this to generate offsets for the assembler
46 * code. The machine-dependant portions of this file can be found in
47 * <machine/globaldata.h>, but only MD code should retrieve it.
48 *
49 * The SMP parts are setup in pmap.c and locore.s for the BSP, and
50 * mp_machdep.c sets up the data for the AP's to "see" when they awake.
51 * The reason for doing it via a struct is so that an array of pointers
52 * to each CPU's data can be set up for things like "check curproc on all
53 * other processors"
54 *
55 * NOTE! this structure needs to remain compatible between module accessors
56 * and the kernel, so we can't throw in lots of #ifdef's.
ef0fdad1
MD
57 *
58 * gd_reqpri serves serveral purposes, bu it is primarily an interrupt
59 * rollup flag used by the task switcher and spl mechanisms to decide that
60 * further checks are necessary. Interrupts are typically managed on a
61 * per-processor basis at least until you leave a critical section, but
62 * may then be scheduled to other cpus.
85100692
MD
63 */
64
85100692
MD
65struct privatespace;
66
67struct globaldata {
68 struct privatespace *gd_prvspace; /* self-reference */
69 struct thread *gd_curthread;
85100692 70 int gd_tdfreecount; /* new thread cache */
ef0fdad1 71 int gd_reqpri; /* (see note above) */
73e4f7b9 72 TAILQ_HEAD(,thread) gd_tdallq; /* all threads */
85100692 73 TAILQ_HEAD(,thread) gd_tdfreeq; /* new thread cache */
4b5f931b
MD
74 TAILQ_HEAD(,thread) gd_tdrunq[32]; /* runnable threads */
75 u_int32_t gd_runqmask; /* which queues? */
85100692 76 u_int gd_cpuid;
4e92c39d 77 u_int gd_other_cpus; /* mask of 'other' cpus */
85100692 78 struct timeval gd_stattv;
ef0fdad1 79 int gd_intr_nesting_level; /* (for fast interrupts) */
85100692 80 int gd_astpending; /* sorta MD but easier here */
12e4aaff 81 struct vmmeter gd_cnt;
96728c05 82 struct lwkt_ipiq *gd_ipiq;
a2a5ad0d
MD
83 struct thread gd_schedthread;
84 struct thread gd_idlethread;
85100692
MD
85 /* extended by <machine/pcpu.h> */
86};
87
12e4aaff
MD
88#ifdef _KERNEL
89struct globaldata *globaldata_find(int cpu);
90#endif
91
85100692 92#endif