Home | History | Annotate | Line # | Download | only in include
cpu.h revision 1.57.2.12
      1  1.57.2.12  thorpej /*	$NetBSD: cpu.h,v 1.57.2.12 2002/12/11 06:11:01 thorpej Exp $	*/
      2   1.57.2.2      wdk 
      3   1.57.2.2      wdk /*-
      4   1.57.2.2      wdk  * Copyright (c) 1992, 1993
      5   1.57.2.2      wdk  *	The Regents of the University of California.  All rights reserved.
      6   1.57.2.2      wdk  *
      7   1.57.2.2      wdk  * This code is derived from software contributed to Berkeley by
      8   1.57.2.2      wdk  * Ralph Campbell and Rick Macklem.
      9   1.57.2.2      wdk  *
     10   1.57.2.2      wdk  * Redistribution and use in source and binary forms, with or without
     11   1.57.2.2      wdk  * modification, are permitted provided that the following conditions
     12   1.57.2.2      wdk  * are met:
     13   1.57.2.2      wdk  * 1. Redistributions of source code must retain the above copyright
     14   1.57.2.2      wdk  *    notice, this list of conditions and the following disclaimer.
     15   1.57.2.2      wdk  * 2. Redistributions in binary form must reproduce the above copyright
     16   1.57.2.2      wdk  *    notice, this list of conditions and the following disclaimer in the
     17   1.57.2.2      wdk  *    documentation and/or other materials provided with the distribution.
     18   1.57.2.2      wdk  * 3. All advertising materials mentioning features or use of this software
     19   1.57.2.2      wdk  *    must display the following acknowledgement:
     20   1.57.2.2      wdk  *	This product includes software developed by the University of
     21   1.57.2.2      wdk  *	California, Berkeley and its contributors.
     22   1.57.2.2      wdk  * 4. Neither the name of the University nor the names of its contributors
     23   1.57.2.2      wdk  *    may be used to endorse or promote products derived from this software
     24   1.57.2.2      wdk  *    without specific prior written permission.
     25   1.57.2.2      wdk  *
     26   1.57.2.2      wdk  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     27   1.57.2.2      wdk  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     28   1.57.2.2      wdk  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     29   1.57.2.2      wdk  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     30   1.57.2.2      wdk  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     31   1.57.2.2      wdk  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     32   1.57.2.2      wdk  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     33   1.57.2.2      wdk  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     34   1.57.2.2      wdk  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     35   1.57.2.2      wdk  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     36   1.57.2.2      wdk  * SUCH DAMAGE.
     37   1.57.2.2      wdk  *
     38   1.57.2.2      wdk  *	@(#)cpu.h	8.4 (Berkeley) 1/4/94
     39   1.57.2.2      wdk  */
     40   1.57.2.2      wdk 
     41   1.57.2.2      wdk #ifndef _CPU_H_
     42   1.57.2.2      wdk #define _CPU_H_
     43   1.57.2.2      wdk 
     44   1.57.2.2      wdk #include <mips/cpuregs.h>
     45   1.57.2.2      wdk 
     46   1.57.2.2      wdk /*
     47   1.57.2.2      wdk  * Exported definitions unique to NetBSD/mips cpu support.
     48   1.57.2.2      wdk  */
     49   1.57.2.2      wdk 
     50  1.57.2.12  thorpej #ifdef _KERNEL
     51   1.57.2.2      wdk #ifndef _LOCORE
     52   1.57.2.2      wdk #include <sys/sched.h>
     53   1.57.2.2      wdk 
     54   1.57.2.2      wdk #if defined(_KERNEL_OPT)
     55   1.57.2.2      wdk #include "opt_lockdebug.h"
     56   1.57.2.2      wdk #endif
     57   1.57.2.2      wdk 
     58   1.57.2.2      wdk struct cpu_info {
     59   1.57.2.2      wdk 	struct schedstate_percpu ci_schedstate; /* scheduler state */
     60   1.57.2.5  nathanw 	u_long ci_cpu_freq;		/* CPU frequency */
     61   1.57.2.5  nathanw 	u_long ci_cycles_per_hz;	/* CPU freq / hz */
     62   1.57.2.5  nathanw 	u_long ci_divisor_delay;	/* for delay/DELAY */
     63   1.57.2.7  nathanw 	u_long ci_divisor_recip;	/* scaled reciprocal of previous;
     64   1.57.2.7  nathanw 					   see below */
     65   1.57.2.2      wdk #if defined(DIAGNOSTIC) || defined(LOCKDEBUG)
     66   1.57.2.2      wdk 	u_long ci_spin_locks;		/* # of spin locks held */
     67   1.57.2.2      wdk 	u_long ci_simple_locks;		/* # of simple locks held */
     68   1.57.2.2      wdk #endif
     69   1.57.2.2      wdk };
     70  1.57.2.12  thorpej 
     71   1.57.2.7  nathanw /*
     72   1.57.2.7  nathanw  * To implement a more accurate microtime using the CP0 COUNT register
     73   1.57.2.7  nathanw  * we need to divide that register by the number of cycles per MHz.
     74   1.57.2.7  nathanw  * But...
     75   1.57.2.7  nathanw  *
     76   1.57.2.7  nathanw  * DIV and DIVU are expensive on MIPS (eg 75 clocks on the R4000).  MULT
     77   1.57.2.7  nathanw  * and MULTU are only 12 clocks on the same CPU.
     78   1.57.2.7  nathanw  *
     79   1.57.2.7  nathanw  * The strategy we use is to calculate the reciprical of cycles per MHz,
     80   1.57.2.7  nathanw  * scaled by 1<<32.  Then we can simply issue a MULTU and pluck of the
     81   1.57.2.7  nathanw  * HI register and have the results of the division.
     82   1.57.2.7  nathanw  */
     83   1.57.2.7  nathanw #define	MIPS_SET_CI_RECIPRICAL(cpu)					\
     84   1.57.2.7  nathanw do {									\
     85   1.57.2.7  nathanw 	KASSERT((cpu)->ci_divisor_delay != 0);				\
     86   1.57.2.7  nathanw 	(cpu)->ci_divisor_recip = 0x100000000ULL / (cpu)->ci_divisor_delay; \
     87   1.57.2.7  nathanw } while (0)
     88   1.57.2.7  nathanw 
     89   1.57.2.7  nathanw #define	MIPS_COUNT_TO_MHZ(cpu, count, res)				\
     90   1.57.2.7  nathanw 	asm volatile("multu %1,%2 ; mfhi %0"				\
     91   1.57.2.7  nathanw 	    : "=r"((res)) : "r"((count)), "r"((cpu)->ci_divisor_recip))
     92  1.57.2.12  thorpej 
     93  1.57.2.12  thorpej #endif /* !_LOCORE */
     94  1.57.2.12  thorpej #endif /* _KERNEL */
     95   1.57.2.2      wdk 
     96   1.57.2.2      wdk /*
     97   1.57.2.2      wdk  * CTL_MACHDEP definitions.
     98   1.57.2.2      wdk  */
     99   1.57.2.2      wdk #define CPU_CONSDEV		1	/* dev_t: console terminal device */
    100   1.57.2.2      wdk #define CPU_BOOTED_KERNEL	2	/* string: booted kernel name */
    101   1.57.2.2      wdk #define CPU_ROOT_DEVICE		3	/* string: root device name */
    102  1.57.2.11  nathanw #define CPU_LLSC		4	/* OS/CPU supports LL/SC instruction */
    103   1.57.2.2      wdk 
    104   1.57.2.2      wdk /*
    105   1.57.2.2      wdk  * Platform can override, but note this breaks userland compatibility
    106   1.57.2.2      wdk  * with other mips platforms.
    107   1.57.2.2      wdk  */
    108   1.57.2.2      wdk #ifndef CPU_MAXID
    109  1.57.2.11  nathanw #define CPU_MAXID		5	/* number of valid machdep ids */
    110   1.57.2.2      wdk 
    111   1.57.2.2      wdk #define CTL_MACHDEP_NAMES { \
    112   1.57.2.2      wdk 	{ 0, 0 }, \
    113   1.57.2.2      wdk 	{ "console_device", CTLTYPE_STRUCT }, \
    114   1.57.2.2      wdk 	{ "booted_kernel", CTLTYPE_STRING }, \
    115   1.57.2.2      wdk 	{ "root_device", CTLTYPE_STRING }, \
    116  1.57.2.11  nathanw 	{ "llsc", CTLTYPE_INT }, \
    117   1.57.2.2      wdk }
    118   1.57.2.2      wdk #endif
    119   1.57.2.2      wdk 
    120   1.57.2.2      wdk #ifdef _KERNEL
    121   1.57.2.2      wdk #ifndef _LOCORE
    122   1.57.2.2      wdk extern struct cpu_info cpu_info_store;
    123   1.57.2.2      wdk 
    124   1.57.2.2      wdk #define	curcpu()	(&cpu_info_store)
    125   1.57.2.2      wdk #define	cpu_number()	(0)
    126   1.57.2.3  thorpej #define	cpu_proc_fork(p1, p2)
    127   1.57.2.5  nathanw #endif /* !_LOCORE */
    128   1.57.2.2      wdk 
    129   1.57.2.2      wdk /*
    130   1.57.2.2      wdk  * Macros to find the CPU architecture we're on at run-time,
    131   1.57.2.2      wdk  * or if possible, at compile-time.
    132   1.57.2.2      wdk  */
    133   1.57.2.2      wdk 
    134   1.57.2.5  nathanw #define	CPU_ARCH_MIPSx	0		/* XXX unknown */
    135   1.57.2.2      wdk #define	CPU_ARCH_MIPS1	(1 << 0)
    136   1.57.2.2      wdk #define	CPU_ARCH_MIPS2	(1 << 1)
    137   1.57.2.2      wdk #define	CPU_ARCH_MIPS3	(1 << 2)
    138   1.57.2.2      wdk #define	CPU_ARCH_MIPS4	(1 << 3)
    139   1.57.2.2      wdk #define	CPU_ARCH_MIPS5	(1 << 4)
    140   1.57.2.2      wdk #define	CPU_ARCH_MIPS32	(1 << 5)
    141   1.57.2.2      wdk #define	CPU_ARCH_MIPS64	(1 << 6)
    142   1.57.2.2      wdk 
    143   1.57.2.5  nathanw #ifndef _LOCORE
    144   1.57.2.5  nathanw /* XXX simonb
    145   1.57.2.5  nathanw  * Should the following be in a cpu_info type structure?
    146   1.57.2.5  nathanw  * And how many of these are per-cpu vs. per-system?  (Ie,
    147   1.57.2.5  nathanw  * we can assume that all cpus have the same mmu-type, but
    148   1.57.2.5  nathanw  * maybe not that all cpus run at the same clock speed.
    149   1.57.2.5  nathanw  * Some SGI's apparently support R12k and R14k in the same
    150   1.57.2.5  nathanw  * box.)
    151   1.57.2.5  nathanw  */
    152   1.57.2.5  nathanw extern int cpu_arch;
    153   1.57.2.5  nathanw extern int mips_cpu_flags;
    154   1.57.2.5  nathanw extern int mips_has_r4k_mmu;
    155   1.57.2.5  nathanw extern int mips_has_llsc;
    156   1.57.2.5  nathanw extern int mips3_pg_cached;
    157   1.57.2.5  nathanw 
    158   1.57.2.5  nathanw #define	CPU_MIPS_R4K_MMU		0x0001
    159   1.57.2.5  nathanw #define	CPU_MIPS_NO_LLSC		0x0002
    160   1.57.2.5  nathanw #define	CPU_MIPS_CAUSE_IV		0x0004
    161   1.57.2.5  nathanw #define	CPU_MIPS_HAVE_SPECIAL_CCA	0x0008	/* Defaults to '3' if not set. */
    162   1.57.2.5  nathanw #define	CPU_MIPS_CACHED_CCA_MASK	0x0070
    163   1.57.2.5  nathanw #define	CPU_MIPS_CACHED_CCA_SHIFT	 4
    164   1.57.2.6  nathanw #define	CPU_MIPS_DOUBLE_COUNT		0x0080	/* 1 cp0 count == 2 clock cycles */
    165   1.57.2.7  nathanw #define	CPU_MIPS_USE_WAIT		0x0100	/* Use "wait"-based cpu_idle() */
    166   1.57.2.7  nathanw #define	CPU_MIPS_NO_WAIT		0x0200	/* Inverse of previous, for mips32/64 */
    167   1.57.2.5  nathanw #define	MIPS_NOT_SUPP			0x8000
    168   1.57.2.5  nathanw 
    169   1.57.2.5  nathanw #ifdef _LKM
    170   1.57.2.5  nathanw /* Assume all CPU architectures are valid for LKM's */
    171   1.57.2.5  nathanw #define	MIPS1	1
    172   1.57.2.5  nathanw #define	MIPS3	1
    173   1.57.2.5  nathanw #define	MIPS4	1
    174   1.57.2.5  nathanw #define	MIPS32	1
    175   1.57.2.5  nathanw #define	MIPS64	1
    176   1.57.2.5  nathanw #endif
    177   1.57.2.2      wdk 
    178   1.57.2.5  nathanw #if (MIPS1 + MIPS3 + MIPS4 + MIPS32 + MIPS64) == 0
    179   1.57.2.5  nathanw #error at least one of MIPS1, MIPS3, MIPS4, MIPS32 or MIPS64 must be specified
    180   1.57.2.5  nathanw #endif
    181   1.57.2.5  nathanw 
    182   1.57.2.5  nathanw #if (MIPS1 + MIPS3 + MIPS4 + MIPS32 + MIPS64) == 1
    183   1.57.2.5  nathanw #ifdef MIPS1
    184   1.57.2.5  nathanw # define CPUISMIPS3		0
    185   1.57.2.5  nathanw # define CPUIS64BITS		0
    186   1.57.2.5  nathanw # define CPUISMIPS32		0
    187   1.57.2.5  nathanw # define CPUISMIPS64		0
    188   1.57.2.5  nathanw # define CPUISMIPSNN		0
    189   1.57.2.5  nathanw # define MIPS_HAS_R4K_MMU	0
    190   1.57.2.5  nathanw # define MIPS_HAS_CLOCK		0
    191   1.57.2.5  nathanw # define MIPS_HAS_LLSC		0
    192   1.57.2.5  nathanw #endif /* MIPS1 */
    193   1.57.2.5  nathanw 
    194   1.57.2.5  nathanw #if defined(MIPS3) || defined(MIPS4)
    195   1.57.2.5  nathanw # define CPUISMIPS3		1
    196   1.57.2.5  nathanw # define CPUIS64BITS		1
    197   1.57.2.5  nathanw # define CPUISMIPS32		0
    198   1.57.2.5  nathanw # define CPUISMIPS64		0
    199   1.57.2.5  nathanw # define CPUISMIPSNN		0
    200   1.57.2.5  nathanw # define MIPS_HAS_R4K_MMU	1
    201   1.57.2.5  nathanw # define MIPS_HAS_CLOCK		1
    202   1.57.2.5  nathanw # define MIPS_HAS_LLSC		(mips_has_llsc)
    203   1.57.2.5  nathanw #endif /* MIPS3 || MIPS4 */
    204   1.57.2.5  nathanw 
    205   1.57.2.5  nathanw #ifdef MIPS32
    206   1.57.2.5  nathanw # define CPUISMIPS3		1
    207   1.57.2.5  nathanw # define CPUIS64BITS		0
    208   1.57.2.5  nathanw # define CPUISMIPS32		1
    209   1.57.2.5  nathanw # define CPUISMIPS64		0
    210   1.57.2.5  nathanw # define CPUISMIPSNN		1
    211   1.57.2.5  nathanw # define MIPS_HAS_R4K_MMU	1
    212   1.57.2.5  nathanw # define MIPS_HAS_CLOCK		1
    213   1.57.2.5  nathanw # define MIPS_HAS_LLSC		1
    214   1.57.2.5  nathanw #endif /* MIPS32 */
    215   1.57.2.5  nathanw 
    216   1.57.2.5  nathanw #ifdef MIPS64
    217   1.57.2.5  nathanw # define CPUISMIPS3		1
    218   1.57.2.5  nathanw # define CPUIS64BITS		1
    219   1.57.2.5  nathanw # define CPUISMIPS32		0
    220   1.57.2.5  nathanw # define CPUISMIPS64		1
    221   1.57.2.5  nathanw # define CPUISMIPSNN		1
    222   1.57.2.5  nathanw # define MIPS_HAS_R4K_MMU	1
    223   1.57.2.5  nathanw # define MIPS_HAS_CLOCK		1
    224   1.57.2.5  nathanw # define MIPS_HAS_LLSC		1
    225  1.57.2.10  nathanw #endif /* MIPS64 */
    226   1.57.2.2      wdk 
    227   1.57.2.2      wdk #else /* run-time test */
    228   1.57.2.2      wdk 
    229   1.57.2.5  nathanw #define	MIPS_HAS_R4K_MMU	(mips_has_r4k_mmu)
    230   1.57.2.5  nathanw #define	MIPS_HAS_LLSC		(mips_has_llsc)
    231   1.57.2.5  nathanw 
    232   1.57.2.2      wdk /* This test is ... rather bogus */
    233   1.57.2.5  nathanw #define	CPUISMIPS3	((cpu_arch & \
    234   1.57.2.5  nathanw 	(CPU_ARCH_MIPS3 | CPU_ARCH_MIPS4 | CPU_ARCH_MIPS32 | CPU_ARCH_MIPS64)) != 0)
    235   1.57.2.5  nathanw 
    236   1.57.2.5  nathanw /* And these aren't much better while the previous test exists as is... */
    237   1.57.2.5  nathanw #define	CPUISMIPS32	((cpu_arch & CPU_ARCH_MIPS32) != 0)
    238   1.57.2.5  nathanw #define	CPUISMIPS64	((cpu_arch & CPU_ARCH_MIPS64) != 0)
    239   1.57.2.5  nathanw #define	CPUISMIPSNN	((cpu_arch & (CPU_ARCH_MIPS32 | CPU_ARCH_MIPS64)) != 0)
    240   1.57.2.5  nathanw #define	CPUIS64BITS	((cpu_arch & \
    241   1.57.2.5  nathanw 	(CPU_ARCH_MIPS3 | CPU_ARCH_MIPS4 | CPU_ARCH_MIPS64)) != 0)
    242   1.57.2.5  nathanw 
    243   1.57.2.5  nathanw #define	MIPS_HAS_CLOCK	(cpu_arch >= CPU_ARCH_MIPS3)
    244   1.57.2.2      wdk #endif /* run-time test */
    245   1.57.2.2      wdk 
    246   1.57.2.5  nathanw /* Shortcut for MIPS3 or above defined */
    247   1.57.2.5  nathanw #if defined(MIPS3) || defined(MIPS4) || defined(MIPS32) || defined(MIPS64)
    248   1.57.2.5  nathanw #define	MIPS3_PLUS	1
    249   1.57.2.5  nathanw #else
    250   1.57.2.5  nathanw #undef MIPS3_PLUS
    251   1.57.2.5  nathanw #endif
    252   1.57.2.5  nathanw 
    253   1.57.2.5  nathanw 
    254   1.57.2.2      wdk /*
    255   1.57.2.2      wdk  * definitions of cpu-dependent requirements
    256   1.57.2.2      wdk  * referenced in generic code
    257   1.57.2.2      wdk  */
    258   1.57.2.2      wdk #define	cpu_wait(p)			/* nothing */
    259   1.57.2.2      wdk #define	cpu_swapout(p)			panic("cpu_swapout: can't get here");
    260   1.57.2.2      wdk 
    261   1.57.2.5  nathanw void cpu_intr(u_int32_t, u_int32_t, u_int32_t, u_int32_t);
    262   1.57.2.2      wdk 
    263   1.57.2.2      wdk /*
    264   1.57.2.2      wdk  * Arguments to hardclock and gatherstats encapsulate the previous
    265   1.57.2.2      wdk  * machine state in an opaque clockframe.
    266   1.57.2.2      wdk  */
    267   1.57.2.2      wdk struct clockframe {
    268   1.57.2.2      wdk 	int	pc;	/* program counter at time of interrupt */
    269   1.57.2.2      wdk 	int	sr;	/* status register at time of interrupt */
    270   1.57.2.2      wdk 	int	ppl;	/* previous priority level at time of interrupt */
    271   1.57.2.2      wdk };
    272   1.57.2.2      wdk 
    273   1.57.2.2      wdk /*
    274   1.57.2.2      wdk  * A port must provde CLKF_USERMODE() and CLKF_BASEPRI() for use
    275   1.57.2.2      wdk  * in machine-independent code. These differ on r4000 and r3000 systems;
    276   1.57.2.2      wdk  * provide them in the port-dependent file that includes this one, using
    277   1.57.2.2      wdk  * the macros below.
    278   1.57.2.2      wdk  */
    279   1.57.2.2      wdk 
    280   1.57.2.2      wdk /* mips1 versions */
    281   1.57.2.2      wdk #define	MIPS1_CLKF_USERMODE(framep)	((framep)->sr & MIPS_SR_KU_PREV)
    282   1.57.2.2      wdk #define	MIPS1_CLKF_BASEPRI(framep)	\
    283   1.57.2.2      wdk 	((~(framep)->sr & (MIPS_INT_MASK | MIPS_SR_INT_ENA_PREV)) == 0)
    284   1.57.2.2      wdk 
    285   1.57.2.2      wdk /* mips3 versions */
    286   1.57.2.2      wdk #define	MIPS3_CLKF_USERMODE(framep)	((framep)->sr & MIPS_SR_KSU_USER)
    287   1.57.2.2      wdk #define	MIPS3_CLKF_BASEPRI(framep)	\
    288   1.57.2.2      wdk 	((~(framep)->sr & (MIPS_INT_MASK | MIPS_SR_INT_IE)) == 0)
    289   1.57.2.2      wdk 
    290   1.57.2.2      wdk #ifdef IPL_ICU_MASK
    291   1.57.2.2      wdk #define ICU_CLKF_BASEPRI(framep)	((framep)->ppl == 0)
    292   1.57.2.2      wdk #endif
    293   1.57.2.2      wdk 
    294   1.57.2.2      wdk #define	CLKF_PC(framep)		((framep)->pc)
    295   1.57.2.2      wdk #define	CLKF_INTR(framep)	(0)
    296   1.57.2.2      wdk 
    297   1.57.2.5  nathanw #if defined(MIPS3_PLUS) && !defined(MIPS1)		/* XXX bogus! */
    298   1.57.2.2      wdk #define	CLKF_USERMODE(framep)	MIPS3_CLKF_USERMODE(framep)
    299   1.57.2.2      wdk #define	CLKF_BASEPRI(framep)	MIPS3_CLKF_BASEPRI(framep)
    300   1.57.2.2      wdk #endif
    301   1.57.2.2      wdk 
    302   1.57.2.5  nathanw #if !defined(MIPS3_PLUS) && defined(MIPS1)		/* XXX bogus! */
    303   1.57.2.2      wdk #define	CLKF_USERMODE(framep)	MIPS1_CLKF_USERMODE(framep)
    304   1.57.2.2      wdk #define	CLKF_BASEPRI(framep)	MIPS1_CLKF_BASEPRI(framep)
    305   1.57.2.2      wdk #endif
    306   1.57.2.2      wdk 
    307   1.57.2.2      wdk #ifdef IPL_ICU_MASK
    308   1.57.2.2      wdk #undef CLKF_BASEPRI
    309   1.57.2.2      wdk #define CLKF_BASEPRI(framep)	ICU_CLKF_BASEPRI(framep)
    310   1.57.2.2      wdk #endif
    311   1.57.2.2      wdk 
    312   1.57.2.5  nathanw #if defined(MIPS3_PLUS) && defined(MIPS1)		/* XXX bogus! */
    313   1.57.2.2      wdk #define CLKF_USERMODE(framep) \
    314   1.57.2.2      wdk     ((CPUISMIPS3) ? MIPS3_CLKF_USERMODE(framep):  MIPS1_CLKF_USERMODE(framep))
    315   1.57.2.2      wdk #define CLKF_BASEPRI(framep) \
    316   1.57.2.2      wdk     ((CPUISMIPS3) ? MIPS3_CLKF_BASEPRI(framep):  MIPS1_CLKF_BASEPRI(framep))
    317   1.57.2.2      wdk #endif
    318   1.57.2.2      wdk 
    319   1.57.2.2      wdk /*
    320   1.57.2.2      wdk  * This is used during profiling to integrate system time.  It can safely
    321   1.57.2.2      wdk  * assume that the process is resident.
    322   1.57.2.2      wdk  */
    323   1.57.2.2      wdk #define	PROC_PC(p)							\
    324   1.57.2.2      wdk 	(((struct frame *)(p)->p_md.md_regs)->f_regs[37])	/* XXX PC */
    325   1.57.2.2      wdk 
    326   1.57.2.2      wdk /*
    327   1.57.2.2      wdk  * Preempt the current process if in interrupt from user mode,
    328   1.57.2.2      wdk  * or after the current trap/syscall if in system mode.
    329   1.57.2.2      wdk  */
    330   1.57.2.2      wdk #define	need_resched(ci)						\
    331   1.57.2.2      wdk do {									\
    332   1.57.2.2      wdk 	want_resched = 1;						\
    333   1.57.2.2      wdk 	if (curproc != NULL)						\
    334   1.57.2.9  nathanw 		aston(curproc);						\
    335   1.57.2.2      wdk } while (/*CONSTCOND*/0)
    336   1.57.2.2      wdk 
    337   1.57.2.2      wdk /*
    338   1.57.2.2      wdk  * Give a profiling tick to the current process when the user profiling
    339   1.57.2.2      wdk  * buffer pages are invalid.  On the MIPS, request an ast to send us
    340   1.57.2.2      wdk  * through trap, marking the proc as needing a profiling tick.
    341   1.57.2.2      wdk  */
    342   1.57.2.2      wdk #define	need_proftick(p)						\
    343   1.57.2.2      wdk do {									\
    344   1.57.2.2      wdk 	(p)->p_flag |= P_OWEUPC;					\
    345   1.57.2.2      wdk 	aston(p);							\
    346   1.57.2.2      wdk } while (/*CONSTCOND*/0)
    347   1.57.2.2      wdk 
    348   1.57.2.2      wdk /*
    349   1.57.2.2      wdk  * Notify the current process (p) that it has a signal pending,
    350   1.57.2.2      wdk  * process as soon as possible.
    351   1.57.2.2      wdk  */
    352   1.57.2.2      wdk #define	signotify(p)	aston(p)
    353   1.57.2.2      wdk 
    354   1.57.2.2      wdk #define aston(p)	((p)->p_md.md_astpending = 1)
    355   1.57.2.2      wdk 
    356   1.57.2.2      wdk extern int want_resched;		/* resched() was called */
    357   1.57.2.2      wdk 
    358   1.57.2.2      wdk /*
    359   1.57.2.2      wdk  * Misc prototypes and variable declarations.
    360   1.57.2.2      wdk  */
    361  1.57.2.12  thorpej struct lwp;
    362   1.57.2.2      wdk struct user;
    363   1.57.2.2      wdk 
    364  1.57.2.12  thorpej extern struct lwp *fpcurlwp;	/* the current FPU owner */
    365  1.57.2.12  thorpej extern struct pcb *curpcb;	/* the current running pcb */
    366  1.57.2.12  thorpej extern struct segtab *segbase;	/* current segtab base */
    367   1.57.2.2      wdk 
    368   1.57.2.2      wdk /* trap.c */
    369   1.57.2.5  nathanw void	netintr(void);
    370   1.57.2.5  nathanw int	kdbpeek(vaddr_t);
    371   1.57.2.2      wdk 
    372   1.57.2.2      wdk /* mips_machdep.c */
    373   1.57.2.5  nathanw void	dumpsys(void);
    374   1.57.2.5  nathanw int	savectx(struct user *);
    375   1.57.2.5  nathanw void	mips_init_msgbuf(void);
    376   1.57.2.5  nathanw void	savefpregs(struct lwp *);
    377   1.57.2.5  nathanw void	loadfpregs(struct lwp *);
    378   1.57.2.2      wdk 
    379   1.57.2.6  nathanw /* locore*.S */
    380   1.57.2.5  nathanw int	badaddr(void *, size_t);
    381   1.57.2.6  nathanw int	badaddr64(uint64_t, size_t);
    382   1.57.2.2      wdk 
    383   1.57.2.2      wdk /* mips_machdep.c */
    384   1.57.2.5  nathanw void	cpu_identify(void);
    385   1.57.2.5  nathanw void	mips_vector_init(void);
    386   1.57.2.2      wdk 
    387   1.57.2.2      wdk #endif /* ! _LOCORE */
    388   1.57.2.2      wdk #endif /* _KERNEL */
    389   1.57.2.2      wdk #endif /* _CPU_H_ */
    390