Home | History | Annotate | Line # | Download | only in include
cpu.h revision 1.35.8.1
      1 /* $NetBSD: cpu.h,v 1.35.8.1 1999/12/27 18:31:25 wrstuden Exp $ */
      2 
      3 /*-
      4  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
      9  * NASA Ames Research Center.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions and the following disclaimer.
     16  * 2. Redistributions in binary form must reproduce the above copyright
     17  *    notice, this list of conditions and the following disclaimer in the
     18  *    documentation and/or other materials provided with the distribution.
     19  * 3. All advertising materials mentioning features or use of this software
     20  *    must display the following acknowledgement:
     21  *	This product includes software developed by the NetBSD
     22  *	Foundation, Inc. and its contributors.
     23  * 4. Neither the name of The NetBSD Foundation nor the names of its
     24  *    contributors may be used to endorse or promote products derived
     25  *    from this software without specific prior written permission.
     26  *
     27  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     28  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     29  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     30  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     31  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     37  * POSSIBILITY OF SUCH DAMAGE.
     38  */
     39 
     40 /*
     41  * Copyright (c) 1988 University of Utah.
     42  * Copyright (c) 1982, 1990, 1993
     43  *	The Regents of the University of California.  All rights reserved.
     44  *
     45  * This code is derived from software contributed to Berkeley by
     46  * the Systems Programming Group of the University of Utah Computer
     47  * Science Department.
     48  *
     49  * Redistribution and use in source and binary forms, with or without
     50  * modification, are permitted provided that the following conditions
     51  * are met:
     52  * 1. Redistributions of source code must retain the above copyright
     53  *    notice, this list of conditions and the following disclaimer.
     54  * 2. Redistributions in binary form must reproduce the above copyright
     55  *    notice, this list of conditions and the following disclaimer in the
     56  *    documentation and/or other materials provided with the distribution.
     57  * 3. All advertising materials mentioning features or use of this software
     58  *    must display the following acknowledgement:
     59  *	This product includes software developed by the University of
     60  *	California, Berkeley and its contributors.
     61  * 4. Neither the name of the University nor the names of its contributors
     62  *    may be used to endorse or promote products derived from this software
     63  *    without specific prior written permission.
     64  *
     65  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     66  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     67  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     68  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     69  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     70  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     71  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     72  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     73  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     74  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     75  * SUCH DAMAGE.
     76  *
     77  * from: Utah $Hdr: cpu.h 1.16 91/03/25$
     78  *
     79  *	@(#)cpu.h	8.4 (Berkeley) 1/5/94
     80  */
     81 
     82 #ifndef _ALPHA_CPU_H_
     83 #define _ALPHA_CPU_H_
     84 
     85 #if defined(_KERNEL) && !defined(_LKM)
     86 #include "opt_multiprocessor.h"
     87 #endif
     88 
     89 /*
     90  * Exported definitions unique to Alpha cpu support.
     91  */
     92 
     93 #include <machine/alpha_cpu.h>
     94 
     95 #ifdef _KERNEL
     96 #include <machine/frame.h>
     97 
     98 #if defined(MULTIPROCESSOR)
     99 
    100 #include <sys/lock.h>			/* will also get LOCKDEBUG */
    101 
    102 struct cpu_info {
    103 	/*
    104 	 * Public members.
    105 	 */
    106 	struct proc *ci_curproc;	/* current owner of the processor */
    107 	struct simplelock ci_slock;	/* lock on this data structure */
    108 	cpuid_t ci_cpuid;		/* our CPU ID */
    109 #if defined(DIAGNOSTIC) || defined(LOCKDEBUG)
    110 	u_long ci_spin_locks;		/* # of spin locks held */
    111 	u_long ci_simple_locks;		/* # of simple locks held */
    112 #endif
    113 
    114 	/*
    115 	 * Private members.
    116 	 */
    117 	struct proc *ci_fpcurproc;	/* current owner of the FPU */
    118 	paddr_t ci_curpcb;		/* PA of current HW PCB */
    119 	struct pcb *ci_idle_pcb;	/* our idle PCB */
    120 	paddr_t ci_idle_pcb_paddr;	/* PA of idle PCB */
    121 	u_long ci_flags;		/* flags; see below */
    122 	u_long ci_ipis;			/* interprocessor interrupts pending */
    123 	struct device *ci_dev;		/* pointer to our device */
    124 };
    125 
    126 #define	CPUF_PRIMARY	0x01		/* CPU is primary CPU */
    127 #define	CPUF_PRESENT	0x02		/* CPU is present */
    128 #define	CPUF_RUNNING	0x04		/* CPU is running */
    129 
    130 extern	u_long cpus_running;
    131 extern	struct cpu_info cpu_info[];
    132 
    133 #define	curcpu()	((struct cpu_info *)alpha_pal_rdval())
    134 
    135 #define	fpcurproc	curcpu()->ci_fpcurproc
    136 #define	curpcb		curcpu()->ci_curpcb
    137 
    138 void	cpu_boot_secondary_processors __P((void));
    139 #else
    140 extern	struct proc *fpcurproc;		/* current owner of FPU */
    141 extern	paddr_t curpcb;			/* PA of current HW context */
    142 #endif /* MULTIPROCESSOR */
    143 
    144 /*
    145  * definitions of cpu-dependent requirements
    146  * referenced in generic code
    147  */
    148 #define	cpu_wait(p)		/* nothing */
    149 #define	cpu_number()		alpha_pal_whami()
    150 
    151 /*
    152  * Arguments to hardclock and gatherstats encapsulate the previous
    153  * machine state in an opaque clockframe.  One the Alpha, we use
    154  * what we push on an interrupt (a trapframe).
    155  */
    156 struct clockframe {
    157 	struct trapframe	cf_tf;
    158 };
    159 #define	CLKF_USERMODE(framep)						\
    160 	(((framep)->cf_tf.tf_regs[FRAME_PS] & ALPHA_PSL_USERMODE) != 0)
    161 #define	CLKF_BASEPRI(framep)						\
    162 	(((framep)->cf_tf.tf_regs[FRAME_PS] & ALPHA_PSL_IPL_MASK) == 0)
    163 #define	CLKF_PC(framep)		((framep)->cf_tf.tf_regs[FRAME_PC])
    164 /*
    165  * XXX No way to accurately tell if we were in interrupt mode before taking
    166  * clock interrupt.
    167  */
    168 #define	CLKF_INTR(framep)	(0)
    169 
    170 /*
    171  * Preempt the current process if in interrupt from user mode,
    172  * or after the current trap/syscall if in system mode.
    173  */
    174 #define	need_resched()	{ want_resched = 1; aston(); }
    175 
    176 /*
    177  * Give a profiling tick to the current process when the user profiling
    178  * buffer pages are invalid.  On the hp300, request an ast to send us
    179  * through trap, marking the proc as needing a profiling tick.
    180  */
    181 #define	need_proftick(p)	{ (p)->p_flag |= P_OWEUPC; aston(); }
    182 
    183 /*
    184  * Notify the current process (p) that it has a signal pending,
    185  * process as soon as possible.
    186  */
    187 #define	signotify(p)	aston()
    188 
    189 #define	aston()		(astpending = 1)
    190 
    191 u_int64_t astpending;		/* need to trap before returning to user mode */
    192 u_int64_t want_resched;		/* resched() was called */
    193 #endif /* _KERNEL */
    194 
    195 /*
    196  * CTL_MACHDEP definitions.
    197  */
    198 #define	CPU_CONSDEV		1	/* dev_t: console terminal device */
    199 #define	CPU_ROOT_DEVICE		2	/* string: root device name */
    200 #define	CPU_UNALIGNED_PRINT	3	/* int: print unaligned accesses */
    201 #define	CPU_UNALIGNED_FIX	4	/* int: fix unaligned accesses */
    202 #define	CPU_UNALIGNED_SIGBUS	5	/* int: SIGBUS unaligned accesses */
    203 #define	CPU_BOOTED_KERNEL	6	/* string: booted kernel name */
    204 #define	CPU_MAXID		7	/* 6 valid machdep IDs */
    205 
    206 #define	CTL_MACHDEP_NAMES { \
    207 	{ 0, 0 }, \
    208 	{ "console_device", CTLTYPE_STRUCT }, \
    209 	{ "root_device", CTLTYPE_STRING }, \
    210 	{ "unaligned_print", CTLTYPE_INT }, \
    211 	{ "unaligned_fix", CTLTYPE_INT }, \
    212 	{ "unaligned_sigbus", CTLTYPE_INT }, \
    213 	{ "booted_kernel", CTLTYPE_STRING }, \
    214 }
    215 
    216 #ifdef _KERNEL
    217 
    218 struct pcb;
    219 struct proc;
    220 struct reg;
    221 struct rpb;
    222 struct trapframe;
    223 
    224 int	badaddr	__P((void *, size_t));
    225 
    226 #endif /* _KERNEL */
    227 #endif /* _ALPHA_CPU_H_ */
    228