2000-01-28 18:08:36 +03:00
|
|
|
/* $NetBSD: locore.h,v 1.24 2000/01/28 15:08:36 takemura Exp $ */
|
1996-05-19 05:32:56 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 1996 The Board of Trustees of The Leland Stanford
|
|
|
|
* Junior University. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this
|
|
|
|
* software and its documentation for any purpose and without
|
|
|
|
* fee is hereby granted, provided that the above copyright
|
|
|
|
* notice appear in all copies. Stanford University
|
|
|
|
* makes no representations about the suitability of this
|
|
|
|
* software for any purpose. It is provided "as is" without
|
|
|
|
* express or implied warranty.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Jump table for MIPS cpu locore functions that are implemented
|
|
|
|
* differently on different generations, or instruction-level
|
|
|
|
* archtecture (ISA) level, the Mips family.
|
|
|
|
* The following functions must be provided for each mips ISA level:
|
|
|
|
*
|
1999-04-24 12:01:01 +04:00
|
|
|
*
|
1996-05-19 05:32:56 +04:00
|
|
|
* MachFlushCache
|
|
|
|
* MachFlushDCache
|
|
|
|
* MachFlushICache
|
|
|
|
* MachForceCacheUpdate
|
|
|
|
* MachSetPID
|
|
|
|
* MachTLBFlush
|
1999-01-14 21:45:45 +03:00
|
|
|
* MachTLBFlushAddr
|
|
|
|
* MachTLBUpdate
|
1997-06-15 21:33:53 +04:00
|
|
|
* wbflush
|
|
|
|
* proc_trampoline()
|
1997-06-19 10:31:14 +04:00
|
|
|
* cpu_switch_resume()
|
1996-05-19 05:32:56 +04:00
|
|
|
*
|
|
|
|
* We currently provide support for:
|
|
|
|
*
|
|
|
|
* r2000 and r3000 (mips ISA-I)
|
|
|
|
* r4000 and r4400 in 32-bit mode (mips ISA-III?)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _MIPS_LOCORE_H
|
|
|
|
#define _MIPS_LOCORE_H
|
|
|
|
|
1999-01-15 13:07:12 +03:00
|
|
|
#ifndef _LKM
|
1999-01-14 21:45:45 +03:00
|
|
|
#include "opt_mips_cache.h"
|
1999-01-15 13:07:12 +03:00
|
|
|
#endif
|
1999-01-14 21:45:45 +03:00
|
|
|
|
1996-05-21 03:38:26 +04:00
|
|
|
/*
|
1999-01-14 21:45:45 +03:00
|
|
|
* locore service routine for exception vectors. Used outside locore
|
1996-05-21 03:38:26 +04:00
|
|
|
* only to print them by name in stack tracebacks
|
|
|
|
*/
|
|
|
|
|
1998-09-11 20:46:31 +04:00
|
|
|
extern u_int32_t mips_read_causereg __P((void));
|
|
|
|
extern u_int32_t mips_read_statusreg __P((void));
|
2000-01-28 18:08:36 +03:00
|
|
|
extern void mips_idle __P((void));
|
1998-09-11 20:46:31 +04:00
|
|
|
|
1996-10-14 01:37:35 +04:00
|
|
|
extern void mips1_ConfigCache __P((void));
|
|
|
|
extern void mips1_FlushCache __P((void));
|
1999-01-14 21:45:45 +03:00
|
|
|
extern void mips1_FlushDCache __P((vaddr_t addr, vsize_t len));
|
|
|
|
extern void mips1_FlushICache __P((vaddr_t addr, vsize_t len));
|
1996-10-14 01:37:35 +04:00
|
|
|
extern void mips1_ForceCacheUpdate __P((void));
|
|
|
|
extern void mips1_SetPID __P((int pid));
|
1999-01-16 01:26:42 +03:00
|
|
|
extern void mips1_clean_tlb __P((void));
|
1998-09-11 20:46:31 +04:00
|
|
|
extern void mips1_TLBFlush __P((int numtlb));
|
1996-10-14 01:37:35 +04:00
|
|
|
extern void mips1_TLBFlushAddr __P( /* XXX Really pte highpart ? */
|
1999-01-06 07:11:25 +03:00
|
|
|
(vaddr_t addr));
|
1997-06-15 21:33:53 +04:00
|
|
|
extern int mips1_TLBUpdate __P((u_int, /*pt_entry_t*/ u_int));
|
1996-10-14 01:37:35 +04:00
|
|
|
extern void mips1_TLBWriteIndexed __P((u_int index, u_int high,
|
1996-05-19 05:32:56 +04:00
|
|
|
u_int low));
|
1997-06-15 21:33:53 +04:00
|
|
|
extern void mips1_wbflush __P((void));
|
|
|
|
extern void mips1_proc_trampoline __P((void));
|
1997-06-19 10:31:14 +04:00
|
|
|
extern void mips1_cpu_switch_resume __P((void));
|
1996-05-19 05:32:56 +04:00
|
|
|
|
1996-10-14 01:37:35 +04:00
|
|
|
extern void mips3_ConfigCache __P((void));
|
|
|
|
extern void mips3_FlushCache __P((void));
|
1999-01-06 07:11:25 +03:00
|
|
|
extern void mips3_FlushDCache __P((vaddr_t addr, vaddr_t len));
|
1999-01-14 21:45:45 +03:00
|
|
|
#ifdef MIPS3_L2CACHE_ABSENT
|
|
|
|
extern void mips52xx_FlushDCache __P((vaddr_t addr, vaddr_t len));
|
|
|
|
#endif
|
1999-01-06 07:11:25 +03:00
|
|
|
extern void mips3_FlushICache __P((vaddr_t addr, vaddr_t len));
|
1996-10-14 01:37:35 +04:00
|
|
|
extern void mips3_ForceCacheUpdate __P((void));
|
1999-01-06 07:11:25 +03:00
|
|
|
extern void mips3_HitFlushDCache __P((vaddr_t, int));
|
1996-10-14 01:37:35 +04:00
|
|
|
extern void mips3_SetPID __P((int pid));
|
1998-09-11 20:46:31 +04:00
|
|
|
extern void mips3_TLBFlush __P((int numtlb));
|
1996-10-14 01:37:35 +04:00
|
|
|
extern void mips3_TLBFlushAddr __P( /* XXX Really pte highpart ? */
|
1999-01-06 07:11:25 +03:00
|
|
|
(vaddr_t addr));
|
1997-06-15 21:33:53 +04:00
|
|
|
extern int mips3_TLBUpdate __P((u_int, /*pt_entry_t*/ u_int));
|
1998-09-11 20:46:31 +04:00
|
|
|
struct tlb;
|
|
|
|
extern void mips3_TLBRead __P((int, struct tlb *));
|
1999-01-14 21:45:45 +03:00
|
|
|
#if 0
|
1998-09-11 20:46:31 +04:00
|
|
|
extern void mips3_TLBWriteIndexedVPS __P((u_int index, struct tlb *tlb));
|
1996-10-14 01:37:35 +04:00
|
|
|
extern void mips3_TLBWriteIndexed __P((u_int index, u_int high,
|
1997-06-15 21:33:53 +04:00
|
|
|
u_int lo0, u_int lo1));
|
1999-01-14 21:45:45 +03:00
|
|
|
#endif
|
1997-06-15 21:33:53 +04:00
|
|
|
extern void mips3_wbflush __P((void));
|
|
|
|
extern void mips3_proc_trampoline __P((void));
|
1997-06-19 10:31:14 +04:00
|
|
|
extern void mips3_cpu_switch_resume __P((void));
|
1996-05-19 05:32:56 +04:00
|
|
|
|
1997-06-16 13:50:26 +04:00
|
|
|
extern void mips3_SetWIRED __P((int));
|
|
|
|
|
1998-09-11 20:46:31 +04:00
|
|
|
extern u_int32_t mips3_cycle_count __P((void));
|
1999-01-14 21:45:45 +03:00
|
|
|
extern u_int32_t mips3_write_count __P((u_int32_t));
|
1998-09-11 20:46:31 +04:00
|
|
|
extern u_int32_t mips3_read_compare __P((void));
|
|
|
|
extern u_int32_t mips3_read_config __P((void));
|
|
|
|
extern void mips3_write_compare __P((u_int32_t));
|
1999-01-14 21:45:45 +03:00
|
|
|
extern void mips3_write_xcontext_upper __P((u_int32_t));
|
1997-06-16 13:50:26 +04:00
|
|
|
|
1996-05-19 05:32:56 +04:00
|
|
|
/*
|
|
|
|
* A vector with an entry for each mips-ISA-level dependent
|
|
|
|
* locore function, and macros which jump through it.
|
|
|
|
* XXX the macro names are chosen to be compatible with the old
|
|
|
|
* Sprite coding-convention names used in 4.4bsd/pmax.
|
|
|
|
*/
|
|
|
|
typedef struct {
|
|
|
|
void (*flushCache) __P((void));
|
1999-01-14 21:45:45 +03:00
|
|
|
void (*flushDCache) __P((vaddr_t addr, vsize_t len));
|
|
|
|
void (*flushICache) __P((vaddr_t addr, vsize_t len));
|
1996-05-19 05:32:56 +04:00
|
|
|
void (*forceCacheUpdate) __P((void));
|
|
|
|
void (*setTLBpid) __P((int pid));
|
1998-09-11 20:46:31 +04:00
|
|
|
void (*tlbFlush) __P((int numtlb));
|
1999-01-06 07:11:25 +03:00
|
|
|
void (*tlbFlushAddr) __P((vaddr_t)); /* XXX Really pte highpart ? */
|
1997-06-15 21:33:53 +04:00
|
|
|
int (*tlbUpdate) __P((u_int highreg, u_int lowreg));
|
|
|
|
void (*wbflush) __P((void));
|
|
|
|
void (*proc_trampoline) __P((void));
|
1997-06-19 10:31:14 +04:00
|
|
|
void (*cpu_switch_resume) __P((void));
|
2000-01-28 18:08:36 +03:00
|
|
|
void (*cpu_idle) __P((void));
|
1996-05-19 05:32:56 +04:00
|
|
|
} mips_locore_jumpvec_t;
|
|
|
|
|
1998-04-23 14:31:02 +04:00
|
|
|
/* Override writebuffer-drain method. */
|
|
|
|
void mips_set_wbflush __P((void (*) __P((void)) ));
|
|
|
|
|
1996-05-19 05:32:56 +04:00
|
|
|
|
2000-01-09 13:05:55 +03:00
|
|
|
/* stacktrace() -- print a stack backtrace to the console */
|
|
|
|
void stacktrace __P((void));
|
|
|
|
/* logstacktrace() -- log a stack traceback to msgbuf */
|
|
|
|
void logstacktrace __P((void));
|
|
|
|
|
1996-05-19 05:32:56 +04:00
|
|
|
/*
|
|
|
|
* The "active" locore-fuction vector, and
|
|
|
|
|
|
|
|
*/
|
|
|
|
extern mips_locore_jumpvec_t mips_locore_jumpvec;
|
|
|
|
extern mips_locore_jumpvec_t r2000_locore_vec;
|
|
|
|
extern mips_locore_jumpvec_t r4000_locore_vec;
|
|
|
|
|
1997-06-22 07:17:37 +04:00
|
|
|
#if defined(MIPS3) && !defined (MIPS1)
|
|
|
|
#define MachFlushCache mips3_FlushCache
|
1999-09-25 04:00:37 +04:00
|
|
|
#if defined(MIPS3_L2CACHE_ABSENT) && defined(MIPS3_4100)
|
|
|
|
#define MachFlushDCache mips3_FlushDCache /* VR4100 */
|
|
|
|
#elif defined(MIPS3_L2CACHE_ABSENT) && !defined(MIPS3_L2CACHE_PRESENT)
|
|
|
|
#define MachFlushDCache mips52xx_FlushDCache /* RM5200 */
|
1999-01-14 21:45:45 +03:00
|
|
|
#elif !defined(MIPS3_L2CACHE_ABSENT) && defined(MIPS3_L2CACHE_PRESENT)
|
1997-06-22 07:17:37 +04:00
|
|
|
#define MachFlushDCache mips3_FlushDCache
|
1999-01-14 21:45:45 +03:00
|
|
|
#else
|
|
|
|
#define MachFlushDCache (*(mips_locore_jumpvec.flushDCache))
|
|
|
|
#endif
|
1997-06-22 07:17:37 +04:00
|
|
|
#define MachFlushICache mips3_FlushICache
|
|
|
|
#define MachForceCacheUpdate mips3_ForceCacheUpdate
|
|
|
|
#define MachSetPID mips3_SetPID
|
1998-09-11 20:46:31 +04:00
|
|
|
#define MachTLBFlush() mips3_TLBFlush(mips_num_tlb_entries)
|
1997-06-22 07:17:37 +04:00
|
|
|
#define MachTLBFlushAddr mips3_TLBFlushAddr
|
|
|
|
#define MachTLBUpdate mips3_TLBUpdate
|
1999-11-12 09:17:13 +03:00
|
|
|
#define wbflush() mips3_wbflush()
|
1997-06-22 07:17:37 +04:00
|
|
|
#define proc_trampoline mips3_proc_trampoline
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(MIPS3) && defined (MIPS1)
|
|
|
|
#define MachFlushCache mips1_FlushCache
|
|
|
|
#define MachFlushDCache mips1_FlushDCache
|
|
|
|
#define MachFlushICache mips1_FlushICache
|
|
|
|
#define MachForceCacheUpdate mips1_ForceCacheUpdate
|
|
|
|
#define MachSetPID mips1_SetPID
|
1998-09-11 20:46:31 +04:00
|
|
|
#define MachTLBFlush() mips1_TLBFlush(MIPS1_TLB_NUM_TLB_ENTRIES)
|
1997-06-22 07:17:37 +04:00
|
|
|
#define MachTLBFlushAddr mips1_TLBFlushAddr
|
|
|
|
#define MachTLBUpdate mips1_TLBUpdate
|
1999-11-12 09:17:13 +03:00
|
|
|
#define wbflush() mips1_wbflush()
|
1997-06-22 07:17:37 +04:00
|
|
|
#define proc_trampoline mips1_proc_trampoline
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(MIPS3) && defined (MIPS1)
|
1996-05-19 05:32:56 +04:00
|
|
|
#define MachFlushCache (*(mips_locore_jumpvec.flushCache))
|
|
|
|
#define MachFlushDCache (*(mips_locore_jumpvec.flushDCache))
|
|
|
|
#define MachFlushICache (*(mips_locore_jumpvec.flushICache))
|
|
|
|
#define MachForceCacheUpdate (*(mips_locore_jumpvec.forceCacheUpdate))
|
|
|
|
#define MachSetPID (*(mips_locore_jumpvec.setTLBpid))
|
1998-09-11 20:46:31 +04:00
|
|
|
#define MachTLBFlush() (*(mips_locore_jumpvec.tlbFlush))(mips_num_tlb_entries)
|
1996-05-19 05:32:56 +04:00
|
|
|
#define MachTLBFlushAddr (*(mips_locore_jumpvec.tlbFlushAddr))
|
|
|
|
#define MachTLBUpdate (*(mips_locore_jumpvec.tlbUpdate))
|
1999-11-12 09:17:13 +03:00
|
|
|
#define wbflush() (*(mips_locore_jumpvec.wbflush))()
|
1997-06-15 21:33:53 +04:00
|
|
|
#define proc_trampoline (mips_locore_jumpvec.proc_trampoline)
|
1997-06-22 07:17:37 +04:00
|
|
|
#endif
|
|
|
|
|
1999-01-14 21:45:45 +03:00
|
|
|
/* cpu_switch_resume is called inside locore.S */
|
1997-06-16 13:50:26 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* CPU identification, from PRID register.
|
|
|
|
*/
|
|
|
|
union cpuprid {
|
|
|
|
int cpuprid;
|
|
|
|
struct {
|
|
|
|
#if BYTE_ORDER == BIG_ENDIAN
|
|
|
|
u_int pad1:16; /* reserved */
|
|
|
|
u_int cp_imp:8; /* implementation identifier */
|
|
|
|
u_int cp_majrev:4; /* major revision identifier */
|
|
|
|
u_int cp_minrev:4; /* minor revision identifier */
|
|
|
|
#else
|
|
|
|
u_int cp_minrev:4; /* minor revision identifier */
|
|
|
|
u_int cp_majrev:4; /* major revision identifier */
|
|
|
|
u_int cp_imp:8; /* implementation identifier */
|
|
|
|
u_int pad1:16; /* reserved */
|
|
|
|
#endif
|
|
|
|
} cpu;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
1997-06-16 10:17:25 +04:00
|
|
|
#ifdef _KERNEL
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Global variables used to communicate CPU type, and parameters
|
|
|
|
* such as cache size, from locore to higher-level code (e.g., pmap).
|
|
|
|
*/
|
Changes for configuring both MIPS1 and MIPS3, from a merge of
similar design and code by Jason Thorpe and Jonathan Stone.
NOTE: the kernel-stack-switching code and cacheflush() calls in
locore.S still use #ifdef MIPS3 and need more work.
mips/include/cpu.h:
Add CPUISMIPS3 for run-time tests of what CPU architecture level
we're running on.
mips/include/locore.h:
Add declarations of locore cache-size variables for ref/def toolchain.
mips/include/mips1_pte.h:
mips1 TLB bit definitions.
mips/include/mips3_pte.h:
mips3 TLB bit definitions.
mips/include/pte.h:
define accesor macros for TLB bits (e.g., mips_pg_m_bit(),
that expand to CPU constants if only one CPU arch is configured,
or to inline functions if both MIPS1 and MIPS3 are configured.
mips/mips/locore_r2000.S:
Use MIPS1_PG_xxx constants inside mips1-specific code.
mips/mips/locore_r4000.S:
Use MIPS3_PG_xxx constants inside mips3-specific code.
mips/mips/locore.S:
Use MIPS1_PG_xxx constants inside mips3-specific code.
Use MIPS1_PG_xxx constants inside mips1-specific code.
(Needs more work!)
mips/mips/{pmap.c,vm_machdep.c,trap.c}, pmax/pmax/machdep.c:
Use MIPS3_PG_xxx constants inside mips3-specific functions,
and MIPS1_PG_XXX inside mips1-specific code.
Otherwise, use mips_pg_XXX_bit() macros where they apply,
and use "if (CPUISMIPS3) { ... } else {... }" where they don't.
mips/mips/mips_machdep.c:
Import Michael Hitch's fixes from the pmax locore-init code
into mips_vector_init().
pmax/pmax/machdep.c:
Use generic mips_vector_init() locore vector-init function.
1997-06-17 03:41:40 +04:00
|
|
|
extern union cpuprid cpu_id;
|
|
|
|
extern union cpuprid fpu_id;
|
|
|
|
extern int cpu_arch;
|
1998-09-11 20:46:31 +04:00
|
|
|
extern int mips_num_tlb_entries;
|
|
|
|
extern u_int mips_L1DCacheSize;
|
|
|
|
extern u_int mips_L1ICacheSize;
|
|
|
|
extern u_int mips_L1DCacheLSize;
|
|
|
|
extern u_int mips_L1ICacheLSize;
|
|
|
|
extern int mips_L2CachePresent;
|
1997-06-19 10:31:14 +04:00
|
|
|
extern u_int mips_L2CacheLSize;
|
|
|
|
extern u_int mips_CacheAliasMask;
|
1998-09-11 20:46:31 +04:00
|
|
|
|
|
|
|
#ifdef MIPS3
|
|
|
|
extern int mips3_L1TwoWayCache;
|
|
|
|
extern int mips3_cacheflush_bug;
|
|
|
|
#endif /* MIPS3 */
|
|
|
|
|
1999-02-27 05:54:05 +03:00
|
|
|
/*
|
1999-04-24 12:01:01 +04:00
|
|
|
* trapframe argument passed to trap()
|
1999-02-27 05:54:05 +03:00
|
|
|
*/
|
|
|
|
struct trapframe {
|
|
|
|
mips_reg_t tf_regs[17];
|
|
|
|
mips_reg_t tf_ra;
|
|
|
|
mips_reg_t tf_sr;
|
|
|
|
mips_reg_t tf_mullo;
|
|
|
|
mips_reg_t tf_mulhi;
|
|
|
|
mips_reg_t tf_epc; /* may be changed by trap() call */
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Stack frame for kernel traps. four args passed in registers.
|
|
|
|
* A trapframe is pointed to by the 5th arg, and a dummy sixth argument
|
|
|
|
* is used to avoid alignment problems
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct kernframe {
|
|
|
|
register_t cf_args[4 + 1];
|
|
|
|
register_t cf_pad; /* (for 8 word alignment) */
|
|
|
|
register_t cf_sp;
|
|
|
|
register_t cf_ra;
|
|
|
|
struct trapframe cf_frame;
|
|
|
|
};
|
|
|
|
|
1997-06-16 10:17:25 +04:00
|
|
|
#endif
|
|
|
|
|
1996-05-19 05:32:56 +04:00
|
|
|
#endif /* _MIPS_LOCORE_H */
|