2000-10-05 06:13:14 +04:00
|
|
|
/* $NetBSD: cpu.h,v 1.46 2000/10/05 02:13:14 cgd Exp $ */
|
1994-10-27 00:08:38 +03:00
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
/*-
|
1994-05-27 12:39:00 +04:00
|
|
|
* Copyright (c) 1992, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
1993-10-12 06:22:19 +03:00
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* Ralph Campbell and Rick Macklem.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1994-10-27 00:08:38 +03:00
|
|
|
* @(#)cpu.h 8.4 (Berkeley) 1/4/94
|
1993-10-12 06:22:19 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _CPU_H_
|
|
|
|
#define _CPU_H_
|
|
|
|
|
|
|
|
/*
|
1996-03-19 05:42:28 +03:00
|
|
|
* Exported definitions unique to NetBSD/mips cpu support.
|
1993-10-12 06:22:19 +03:00
|
|
|
*/
|
|
|
|
|
2000-03-25 02:06:03 +03:00
|
|
|
/*
|
|
|
|
* CTL_MACHDEP definitions.
|
|
|
|
*/
|
|
|
|
#define CPU_CONSDEV 1 /* dev_t: console terminal device */
|
|
|
|
#define CPU_BOOTED_KERNEL 2 /* string: booted kernel name */
|
|
|
|
#define CPU_ROOT_DEVICE 3 /* string: root device name */
|
2000-07-13 11:37:11 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Platform can override, but note this breaks userland compatability
|
|
|
|
* with other mips platforms.
|
|
|
|
*/
|
|
|
|
#ifndef CPU_MAXID
|
2000-03-25 02:06:03 +03:00
|
|
|
#define CPU_MAXID 4 /* number of valid machdep ids */
|
|
|
|
|
|
|
|
#define CTL_MACHDEP_NAMES { \
|
|
|
|
{ 0, 0 }, \
|
|
|
|
{ "console_device", CTLTYPE_STRUCT }, \
|
|
|
|
{ "booted_kernel", CTLTYPE_STRING }, \
|
|
|
|
{ "root_device", CTLTYPE_STRING }, \
|
|
|
|
}
|
2000-07-11 10:34:57 +04:00
|
|
|
#endif
|
2000-03-25 02:06:03 +03:00
|
|
|
|
2000-01-09 16:24:14 +03:00
|
|
|
#ifdef _KERNEL
|
|
|
|
#ifndef _LOCORE
|
|
|
|
|
1997-06-21 08:18:09 +04:00
|
|
|
/*
|
|
|
|
* Macros to find the CPU architecture we're on at run-time,
|
|
|
|
* or if possible, at compile-time.
|
|
|
|
*/
|
|
|
|
|
2000-10-05 06:13:14 +04:00
|
|
|
extern int cpu_arch;
|
|
|
|
|
|
|
|
#define CPU_ARCH_MIPS1 (1 << 0)
|
|
|
|
#define CPU_ARCH_MIPS2 (1 << 1)
|
|
|
|
#define CPU_ARCH_MIPS3 (1 << 2)
|
|
|
|
#define CPU_ARCH_MIPS4 (1 << 3)
|
|
|
|
#define CPU_ARCH_MIPS5 (1 << 4)
|
|
|
|
#define CPU_ARCH_MIPS32 (1 << 5)
|
|
|
|
#define CPU_ARCH_MIPS64 (1 << 6)
|
|
|
|
|
1997-06-21 08:18:09 +04:00
|
|
|
#if (MIPS1 + MIPS3) == 1
|
|
|
|
#ifdef MIPS1
|
|
|
|
# define CPUISMIPS3 0
|
|
|
|
#endif /* mips1 */
|
|
|
|
|
|
|
|
#ifdef MIPS3
|
|
|
|
# define CPUISMIPS3 1
|
|
|
|
#endif /* mips1 */
|
|
|
|
|
|
|
|
#else /* run-time test */
|
2000-10-05 04:52:59 +04:00
|
|
|
|
|
|
|
/* This test is ... rather bogus */
|
|
|
|
#define CPUISMIPS3 ((cpu_arch & (CPU_ARCH_MIPS3 | CPU_ARCH_MIPS4)) != 0)
|
1997-06-21 08:18:09 +04:00
|
|
|
#endif /* run-time test */
|
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
/*
|
|
|
|
* definitions of cpu-dependent requirements
|
|
|
|
* referenced in generic code
|
|
|
|
*/
|
1995-05-05 07:41:51 +04:00
|
|
|
#define cpu_wait(p) /* nothing */
|
|
|
|
#define cpu_swapout(p) panic("cpu_swapout: can't get here");
|
1993-10-12 06:22:19 +03:00
|
|
|
|
2000-07-11 10:34:57 +04:00
|
|
|
void cpu_intr __P((u_int32_t, u_int32_t, u_int32_t, u_int32_t));
|
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
/*
|
|
|
|
* Arguments to hardclock and gatherstats encapsulate the previous
|
|
|
|
* machine state in an opaque clockframe.
|
|
|
|
*/
|
1994-05-27 12:39:00 +04:00
|
|
|
struct clockframe {
|
1993-10-12 06:22:19 +03:00
|
|
|
int pc; /* program counter at time of interrupt */
|
|
|
|
int sr; /* status register at time of interrupt */
|
1994-05-27 12:39:00 +04:00
|
|
|
};
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1996-03-23 23:21:49 +03:00
|
|
|
/*
|
|
|
|
* A port must provde CLKF_USERMODE() and CLKF_BASEPRI() for use
|
|
|
|
* in machine-independent code. These differ on r4000 and r3000 systems;
|
|
|
|
* provide them in the port-dependent file that includes this one, using
|
|
|
|
* the macros below.
|
|
|
|
*/
|
|
|
|
|
1997-06-21 08:18:09 +04:00
|
|
|
/* mips1 versions */
|
1997-06-22 11:42:25 +04:00
|
|
|
#define MIPS1_CLKF_USERMODE(framep) ((framep)->sr & MIPS_SR_KU_PREV)
|
1997-06-21 08:18:09 +04:00
|
|
|
#define MIPS1_CLKF_BASEPRI(framep) \
|
1997-06-22 11:42:25 +04:00
|
|
|
((~(framep)->sr & (MIPS_INT_MASK | MIPS_SR_INT_ENA_PREV)) == 0)
|
1996-03-23 23:21:49 +03:00
|
|
|
|
1997-06-21 08:18:09 +04:00
|
|
|
/* mips3 versions */
|
1997-06-22 11:42:25 +04:00
|
|
|
#define MIPS3_CLKF_USERMODE(framep) ((framep)->sr & MIPS_SR_KSU_USER)
|
1997-06-21 08:18:09 +04:00
|
|
|
#define MIPS3_CLKF_BASEPRI(framep) \
|
2000-03-07 04:05:48 +03:00
|
|
|
((~(framep)->sr & (MIPS_INT_MASK | MIPS_SR_INT_IE)) == 0)
|
1996-03-23 23:21:49 +03:00
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
#define CLKF_PC(framep) ((framep)->pc)
|
|
|
|
#define CLKF_INTR(framep) (0)
|
|
|
|
|
1997-06-21 08:18:09 +04:00
|
|
|
#if defined(MIPS3) && !defined(MIPS1)
|
|
|
|
#define CLKF_USERMODE(framep) MIPS3_CLKF_USERMODE(framep)
|
|
|
|
#define CLKF_BASEPRI(framep) MIPS3_CLKF_BASEPRI(framep)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(MIPS3) && defined(MIPS1)
|
|
|
|
#define CLKF_USERMODE(framep) MIPS1_CLKF_USERMODE(framep)
|
|
|
|
#define CLKF_BASEPRI(framep) MIPS1_CLKF_BASEPRI(framep)
|
1997-06-16 10:17:25 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
1997-06-21 08:18:09 +04:00
|
|
|
#if defined(MIPS3) && defined(MIPS1)
|
|
|
|
#define CLKF_USERMODE(framep) \
|
|
|
|
((CPUISMIPS3) ? MIPS3_CLKF_USERMODE(framep): MIPS1_CLKF_USERMODE(framep))
|
|
|
|
#define CLKF_BASEPRI(framep) \
|
|
|
|
((CPUISMIPS3) ? MIPS3_CLKF_BASEPRI(framep): MIPS1_CLKF_BASEPRI(framep))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
/*
|
|
|
|
* Preempt the current process if in interrupt from user mode,
|
|
|
|
* or after the current trap/syscall if in system mode.
|
|
|
|
*/
|
2000-08-25 05:04:06 +04:00
|
|
|
#define need_resched(ci) { want_resched = 1; aston(); }
|
1993-10-12 06:22:19 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Give a profiling tick to the current process when the user profiling
|
1996-03-19 05:42:28 +03:00
|
|
|
* buffer pages are invalid. On the MIPS, request an ast to send us
|
1993-10-12 06:22:19 +03:00
|
|
|
* through trap, marking the proc as needing a profiling tick.
|
|
|
|
*/
|
1994-05-27 12:39:00 +04:00
|
|
|
#define need_proftick(p) { (p)->p_flag |= P_OWEUPC; aston(); }
|
1993-10-12 06:22:19 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Notify the current process (p) that it has a signal pending,
|
|
|
|
* process as soon as possible.
|
|
|
|
*/
|
|
|
|
#define signotify(p) aston()
|
|
|
|
|
|
|
|
#define aston() (astpending = 1)
|
|
|
|
|
1998-09-11 20:46:31 +04:00
|
|
|
extern int astpending; /* need to trap before returning to user mode */
|
|
|
|
extern int want_resched; /* resched() was called */
|
|
|
|
#ifdef MIPS3
|
|
|
|
extern u_int mips_L2CacheSize;
|
|
|
|
extern int mips_L2CacheIsSnooping; /* L2 cache snoops uncached writes ? */
|
|
|
|
extern int mips_L2CacheMixed;
|
2000-01-09 16:24:14 +03:00
|
|
|
#endif /* MIPS3 */
|
1999-01-14 21:45:45 +03:00
|
|
|
|
1998-02-20 02:07:14 +03:00
|
|
|
/*
|
2000-03-28 07:11:26 +04:00
|
|
|
* Misc prototypes and variable declarations.
|
1998-02-20 02:07:14 +03:00
|
|
|
*/
|
1998-10-28 07:26:52 +03:00
|
|
|
struct proc;
|
1999-01-14 21:45:45 +03:00
|
|
|
struct user;
|
|
|
|
|
2000-03-28 07:11:26 +04:00
|
|
|
extern struct proc *fpcurproc;
|
|
|
|
|
1999-01-14 21:45:45 +03:00
|
|
|
/* trap.c */
|
|
|
|
void child_return __P((void *));
|
2000-04-11 06:30:14 +04:00
|
|
|
void netintr __P((void));
|
1999-01-14 21:45:45 +03:00
|
|
|
int kdbpeek __P((vaddr_t));
|
1998-02-20 02:07:14 +03:00
|
|
|
|
1999-01-14 21:45:45 +03:00
|
|
|
/* mips_machdep.c */
|
1998-02-20 02:07:14 +03:00
|
|
|
void dumpsys __P((void));
|
|
|
|
int savectx __P((struct user *));
|
1998-02-26 02:25:16 +03:00
|
|
|
void mips_init_msgbuf __P((void));
|
2000-05-30 06:05:36 +04:00
|
|
|
void savefpregs __P((struct proc *));
|
|
|
|
void loadfpregs __P((struct proc *));
|
1996-03-19 05:42:28 +03:00
|
|
|
|
1998-09-11 20:46:31 +04:00
|
|
|
/* locore.S */
|
1999-01-14 21:45:45 +03:00
|
|
|
int badaddr __P((void *, size_t));
|
1998-09-11 20:46:31 +04:00
|
|
|
|
|
|
|
/* mips_machdep.c */
|
1999-01-14 21:45:45 +03:00
|
|
|
void cpu_identify __P((void));
|
|
|
|
void mips_vector_init __P((void));
|
1998-09-11 20:46:31 +04:00
|
|
|
|
2000-01-09 16:24:14 +03:00
|
|
|
#endif /* ! _LOCORE */
|
1999-01-14 21:45:45 +03:00
|
|
|
#endif /* _KERNEL */
|
1993-10-12 06:22:19 +03:00
|
|
|
|
|
|
|
#endif /* _CPU_H_ */
|