pcpu.h revision 83642
1/*-
2 * Copyright (c) 1999 Luoqi Chen <luoqi@freebsd.org>
3 * Copyright (c) Peter Wemm <peter@netplex.com.au>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 *    notice, this list of conditions and the following disclaimer in the
13 *    documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 * $FreeBSD: head/sys/powerpc/include/pcpu.h 83642 2001-09-18 21:37:09Z jhb $
28 */
29
30#ifndef	_MACHINE_GLOBALDATA_H_
31#define	_MACHINE_GLOBALDATA_H_
32
33#ifdef _KERNEL
34
35#include <sys/queue.h>
36
37/*
38 * This structure maps out the global data that needs to be kept on a
39 * per-cpu basis.  genassym uses this to generate offsets for the assembler
40 * code, which also provides external symbols so that C can get at them as
41 * though they were really globals. This structure is pointed to by
42 * the per-cpu system value (see alpha_pal_rdval() and alpha_pal_wrval()).
43 * Inside the kernel, the globally reserved register t7 is used to
44 * point at the globaldata structure.
45 */
46struct globaldata {
47	struct thread	*gd_curthread;		/* current thread */
48	struct thread	*gd_idlethread;		/* idle thread */
49	struct thread	*gd_fpcurthread;	/* fp state owner */
50	struct pcb	*gd_curpcb;		/* current pcb */
51	struct timeval	gd_switchtime;
52	int		gd_switchticks;
53	u_int		gd_cpuid;		/* this cpu number */
54	u_int		gd_other_cpus;		/* all other cpus */
55	int		gd_inside_intr;
56	u_int32_t	gd_next_asn;		/* next ASN to allocate */
57	u_int32_t	gd_current_asngen;	/* ASN rollover check */
58	u_int32_t	gd_intr_nesting_level;  /* interrupt recursion */
59
60	SLIST_ENTRY(globaldata) gd_allcpu;
61	struct	lock_list_entry *gd_spinlocks;
62#ifdef KTR_PERCPU
63	volatile int	gd_ktr_idx;		/* Index into trace table */
64	char	*gd_ktr_buf;
65	char	gd_ktr_buf_data[KTR_SIZE];
66#endif
67};
68
69void globaldata_init(struct globaldata *pcpu, int cpuid, size_t sz);
70
71#endif	/* _KERNEL */
72
73#endif	/* !_MACHINE_GLOBALDATA_H_ */
74