Home | History | Annotate | Line # | Download | only in include
cpu.h revision 1.36
      1 /*	$NetBSD: cpu.h,v 1.36 2000/03/24 23:06:04 soren Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1992, 1993
      5  *	The Regents of the University of California.  All rights reserved.
      6  *
      7  * This code is derived from software contributed to Berkeley by
      8  * Ralph Campbell and Rick Macklem.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *	This product includes software developed by the University of
     21  *	California, Berkeley and its contributors.
     22  * 4. Neither the name of the University nor the names of its contributors
     23  *    may be used to endorse or promote products derived from this software
     24  *    without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     36  * SUCH DAMAGE.
     37  *
     38  *	@(#)cpu.h	8.4 (Berkeley) 1/4/94
     39  */
     40 
     41 #ifndef _CPU_H_
     42 #define _CPU_H_
     43 
     44 /*
     45  * Exported definitions unique to NetBSD/mips cpu support.
     46  */
     47 
     48 /*
     49  * CTL_MACHDEP definitions.
     50  */
     51 #define CPU_CONSDEV		1	/* dev_t: console terminal device */
     52 #define CPU_BOOTED_KERNEL	2	/* string: booted kernel name */
     53 #define CPU_ROOT_DEVICE		3	/* string: root device name */
     54 #define CPU_MAXID		4	/* number of valid machdep ids */
     55 
     56 #define CTL_MACHDEP_NAMES { \
     57 	{ 0, 0 }, \
     58 	{ "console_device", CTLTYPE_STRUCT }, \
     59 	{ "booted_kernel", CTLTYPE_STRING }, \
     60 	{ "root_device", CTLTYPE_STRING }, \
     61 }
     62 
     63 
     64 #ifdef _KERNEL
     65 #ifndef _LOCORE
     66 
     67 /*
     68  * Macros to find the CPU architecture we're on at run-time,
     69  * or if possible, at compile-time.
     70  */
     71 
     72 #if (MIPS1 + MIPS3) == 1
     73 #ifdef MIPS1
     74 # define CPUISMIPS3	0
     75 #endif /* mips1 */
     76 
     77 #ifdef MIPS3
     78 #  define CPUISMIPS3	 1
     79 #endif /* mips1 */
     80 
     81 #else /* run-time test */
     82 extern int cpu_arch;
     83 #define CPUISMIPS3	(cpu_arch == 3)
     84 #endif /* run-time test */
     85 
     86 /*
     87  * definitions of cpu-dependent requirements
     88  * referenced in generic code
     89  */
     90 #define	cpu_wait(p)			/* nothing */
     91 #define	cpu_swapout(p)			panic("cpu_swapout: can't get here");
     92 #define	cpu_number()			0
     93 
     94 /*
     95  * Arguments to hardclock and gatherstats encapsulate the previous
     96  * machine state in an opaque clockframe.
     97  */
     98 struct clockframe {
     99 	int	pc;	/* program counter at time of interrupt */
    100 	int	sr;	/* status register at time of interrupt */
    101 };
    102 
    103 /*
    104  * A port must provde CLKF_USERMODE() and CLKF_BASEPRI() for use
    105  * in machine-independent code. These differ on r4000 and r3000 systems;
    106  * provide them in the port-dependent file that includes this one, using
    107  * the macros below.
    108  */
    109 
    110 /* mips1 versions */
    111 #define	MIPS1_CLKF_USERMODE(framep)	((framep)->sr & MIPS_SR_KU_PREV)
    112 #define	MIPS1_CLKF_BASEPRI(framep)	\
    113 	((~(framep)->sr & (MIPS_INT_MASK | MIPS_SR_INT_ENA_PREV)) == 0)
    114 
    115 /* mips3 versions */
    116 #define	MIPS3_CLKF_USERMODE(framep)	((framep)->sr & MIPS_SR_KSU_USER)
    117 #define	MIPS3_CLKF_BASEPRI(framep)	\
    118 	((~(framep)->sr & (MIPS_INT_MASK | MIPS_SR_INT_IE)) == 0)
    119 
    120 #define	CLKF_PC(framep)		((framep)->pc)
    121 #define	CLKF_INTR(framep)	(0)
    122 
    123 #if defined(MIPS3) && !defined(MIPS1)
    124 #define	CLKF_USERMODE(framep)	MIPS3_CLKF_USERMODE(framep)
    125 #define	CLKF_BASEPRI(framep)	MIPS3_CLKF_BASEPRI(framep)
    126 #endif
    127 
    128 #if !defined(MIPS3) && defined(MIPS1)
    129 #define	CLKF_USERMODE(framep)	MIPS1_CLKF_USERMODE(framep)
    130 #define	CLKF_BASEPRI(framep)	MIPS1_CLKF_BASEPRI(framep)
    131 #endif
    132 
    133 
    134 #if defined(MIPS3) && defined(MIPS1)
    135 #define CLKF_USERMODE(framep) \
    136     ((CPUISMIPS3) ? MIPS3_CLKF_USERMODE(framep):  MIPS1_CLKF_USERMODE(framep))
    137 #define CLKF_BASEPRI(framep) \
    138     ((CPUISMIPS3) ? MIPS3_CLKF_BASEPRI(framep):  MIPS1_CLKF_BASEPRI(framep))
    139 #endif
    140 
    141 
    142 /*
    143  * Preempt the current process if in interrupt from user mode,
    144  * or after the current trap/syscall if in system mode.
    145  */
    146 #define	need_resched()	{ want_resched = 1; aston(); }
    147 
    148 /*
    149  * Give a profiling tick to the current process when the user profiling
    150  * buffer pages are invalid.  On the MIPS, request an ast to send us
    151  * through trap, marking the proc as needing a profiling tick.
    152  */
    153 #define	need_proftick(p)	{ (p)->p_flag |= P_OWEUPC; aston(); }
    154 
    155 /*
    156  * Notify the current process (p) that it has a signal pending,
    157  * process as soon as possible.
    158  */
    159 #define	signotify(p)	aston()
    160 
    161 #define aston()		(astpending = 1)
    162 
    163 extern int astpending;	/* need to trap before returning to user mode */
    164 extern int want_resched;	/* resched() was called */
    165 #ifdef MIPS3
    166 extern u_int	mips_L2CacheSize;
    167 extern int	mips_L2CacheIsSnooping; /* L2 cache snoops uncached writes ? */
    168 extern int	mips_L2CacheMixed;
    169 
    170 #ifdef MIPS3_INTERNAL_TIMER_INTERRUPT
    171 extern u_int32_t mips3_intr_cycle_count;
    172 extern u_int32_t mips3_timer_delta;
    173 #endif
    174 #endif /* MIPS3 */
    175 
    176 /*
    177  * Misc prototypes.
    178  */
    179 struct proc;
    180 struct user;
    181 
    182 /* trap.c */
    183 void	child_return __P((void *));
    184 int	kdbpeek __P((vaddr_t));
    185 
    186 /* mips_machdep.c */
    187 void	dumpsys __P((void));
    188 int	savectx __P((struct user *));
    189 void	mips_init_msgbuf __P((void));
    190 
    191 /* locore.S */
    192 void	savefpregs __P((struct proc *));
    193 void	switchfpregs __P((struct proc *, struct proc *));
    194 int	badaddr __P((void *, size_t));
    195 
    196 /* mips_machdep.c */
    197 void	cpu_identify __P((void));
    198 void	mips_vector_init __P((void));
    199 
    200 #endif /* ! _LOCORE */
    201 #endif /* _KERNEL */
    202 
    203 #endif /* _CPU_H_ */
    204