pcpu.h revision 181875
1129198Scognet/*-
2129198Scognet * Copyright (c) 1999 Luoqi Chen <luoqi@freebsd.org>
3129198Scognet * All rights reserved.
4129198Scognet *
5129198Scognet * Redistribution and use in source and binary forms, with or without
6129198Scognet * modification, are permitted provided that the following conditions
7129198Scognet * are met:
8129198Scognet * 1. Redistributions of source code must retain the above copyright
9129198Scognet *    notice, this list of conditions and the following disclaimer.
10129198Scognet * 2. Redistributions in binary form must reproduce the above copyright
11129198Scognet *    notice, this list of conditions and the following disclaimer in the
12129198Scognet *    documentation and/or other materials provided with the distribution.
13129198Scognet *
14129198Scognet * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15129198Scognet * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16129198Scognet * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17129198Scognet * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18129198Scognet * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19129198Scognet * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20129198Scognet * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21129198Scognet * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22129198Scognet * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23129198Scognet * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24129198Scognet * SUCH DAMAGE.
25129198Scognet *
26129198Scognet *	from: FreeBSD: src/sys/i386/include/globaldata.h,v 1.27 2001/04/27
27129198Scognet * $FreeBSD: head/sys/arm/include/pcpu.h 181875 2008-08-19 19:53:52Z jhb $
28129198Scognet */
29129198Scognet
30129198Scognet#ifndef	_MACHINE_PCPU_H_
31129198Scognet#define	_MACHINE_PCPU_H_
32129198Scognet
33129198Scognet#ifdef _KERNEL
34129198Scognet
35129198Scognet#include <machine/frame.h>
36129198Scognet
37129198Scognet#define	ALT_STACK_SIZE	128
38129198Scognet
39129198Scognetstruct vmspace;
40129198Scognet
41181875Sjhb#endif	/* _KERNEL */
42181875Sjhb
43129198Scognet/*
44129198Scognet * Inside the kernel, the globally reserved register g7 is used to
45129198Scognet * point at the globaldata structure.
46129198Scognet */
47129198Scognet#define	PCPU_MD_FIELDS							\
48129198Scognet	struct pcup *pc_prvspace;
49129198Scognet
50181875Sjhb#ifdef _KERNEL
51181875Sjhb
52129198Scognetstruct pcb;
53129198Scognetstruct pcpu;
54129198Scognet
55129198Scognetextern struct pcpu *pcpup;
56137228Scognetextern struct pcpu __pcpu;
57129198Scognet
58137228Scognet#define	PCPU_GET(member)	(__pcpu.pc_ ## member)
59167429Salc
60167429Salc/*
61167429Salc * XXX The implementation of this operation should be made atomic
62167429Salc * with respect to preemption.
63167429Salc */
64170291Sattilio#define	PCPU_ADD(member, value)	(__pcpu.pc_ ## member += (value))
65170388Sjeff#define	PCPU_INC(member)	PCPU_ADD(member, 1)
66137228Scognet#define	PCPU_PTR(member)	(&__pcpu.pc_ ## member)
67137228Scognet#define	PCPU_SET(member,value)	(__pcpu.pc_ ## member = (value))
68129198Scognet
69129198Scognet#endif	/* _KERNEL */
70129198Scognet
71129198Scognet#endif	/* !_MACHINE_PCPU_H_ */
72