Home | History | Annotate | Line # | Download | only in include
locore.h revision 1.31
      1  1.31  nisimura /*	$NetBSD: locore.h,v 1.31 2000/05/10 01:34:13 nisimura Exp $	*/
      2   1.1  jonathan 
      3   1.1  jonathan /*
      4   1.1  jonathan  * Copyright 1996 The Board of Trustees of The Leland Stanford
      5   1.1  jonathan  * Junior University. All Rights Reserved.
      6   1.1  jonathan  *
      7   1.1  jonathan  * Permission to use, copy, modify, and distribute this
      8   1.1  jonathan  * software and its documentation for any purpose and without
      9   1.1  jonathan  * fee is hereby granted, provided that the above copyright
     10   1.1  jonathan  * notice appear in all copies.  Stanford University
     11   1.1  jonathan  * makes no representations about the suitability of this
     12   1.1  jonathan  * software for any purpose.  It is provided "as is" without
     13   1.1  jonathan  * express or implied warranty.
     14   1.1  jonathan  */
     15   1.1  jonathan 
     16   1.1  jonathan /*
     17   1.1  jonathan  * Jump table for MIPS cpu locore functions that are implemented
     18   1.1  jonathan  * differently on different generations, or instruction-level
     19   1.1  jonathan  * archtecture (ISA) level, the Mips family.
     20   1.1  jonathan  * The following functions must be provided for each mips ISA level:
     21   1.1  jonathan  *
     22  1.20    simonb  *
     23   1.1  jonathan  *	MachFlushCache
     24   1.1  jonathan  *	MachFlushDCache
     25   1.1  jonathan  *	MachFlushICache
     26   1.1  jonathan  *	MachForceCacheUpdate
     27   1.5    mhitch  *	wbflush
     28   1.5    mhitch  *	proc_trampoline()
     29   1.9    mhitch  *	cpu_switch_resume()
     30   1.1  jonathan  *
     31   1.1  jonathan  * We currently provide support for:
     32   1.1  jonathan  *
     33   1.1  jonathan  *	r2000 and r3000 (mips ISA-I)
     34   1.1  jonathan  *	r4000 and r4400 in 32-bit mode (mips ISA-III?)
     35   1.1  jonathan  */
     36   1.1  jonathan 
     37   1.1  jonathan #ifndef _MIPS_LOCORE_H
     38   1.1  jonathan #define  _MIPS_LOCORE_H
     39   1.2  jonathan 
     40  1.17    castor #ifndef _LKM
     41  1.16    castor #include "opt_mips_cache.h"
     42  1.17    castor #endif
     43  1.16    castor 
     44   1.2  jonathan /*
     45  1.16    castor  * locore service routine for exception vectors. Used outside locore
     46   1.2  jonathan  * only to print them by name in stack tracebacks
     47   1.2  jonathan  */
     48   1.2  jonathan 
     49  1.29    simonb u_int32_t mips_read_causereg __P((void));
     50  1.29    simonb u_int32_t mips_read_statusreg __P((void));
     51  1.29    simonb 
     52  1.29    simonb void mips1_ConfigCache  __P((void));
     53  1.29    simonb void mips1_FlushCache  __P((void));
     54  1.29    simonb void mips1_FlushDCache  __P((vaddr_t addr, vsize_t len));
     55  1.29    simonb void mips1_FlushICache  __P((vaddr_t addr, vsize_t len));
     56  1.29    simonb void mips1_ForceCacheUpdate __P((void));
     57  1.30  nisimura 
     58  1.29    simonb void mips1_SetPID   __P((int pid));
     59  1.29    simonb void mips1_TBIA __P((int));
     60  1.29    simonb void mips1_TBIAP __P((int));
     61  1.29    simonb void mips1_TBIS __P((vaddr_t));
     62  1.31  nisimura void mips1_TBRPL __P((vaddr_t, vaddr_t, paddr_t));
     63  1.30  nisimura int mips1_TLBUpdate __P((u_int, /*pt_entry_t*/ u_int));
     64  1.29    simonb 
     65  1.29    simonb void mips1_wbflush __P((void));
     66  1.29    simonb void mips1_proc_trampoline __P((void));
     67  1.29    simonb void mips1_cpu_switch_resume __P((void));
     68  1.29    simonb 
     69  1.29    simonb void mips3_ConfigCache __P((void));
     70  1.29    simonb void mips3_FlushCache  __P((void));
     71  1.29    simonb void mips3_FlushDCache __P((vaddr_t addr, vaddr_t len));
     72  1.29    simonb void mips3_FlushICache __P((vaddr_t addr, vaddr_t len));
     73  1.29    simonb void mips3_ForceCacheUpdate __P((void));
     74  1.29    simonb void mips3_HitFlushDCache __P((vaddr_t, int));
     75  1.30  nisimura 
     76  1.29    simonb void mips3_SetPID  __P((int pid));
     77  1.30  nisimura void mips3_TBIA __P((int));
     78  1.30  nisimura void mips3_TBIAP __P((int));
     79  1.30  nisimura void mips3_TBIS __P((vaddr_t));
     80  1.31  nisimura void mips3_TBRPL __P((vaddr_t, vaddr_t, paddr_t));
     81  1.29    simonb int mips3_TLBUpdate __P((u_int, /*pt_entry_t*/ u_int));
     82  1.14  jonathan struct tlb;
     83  1.29    simonb void mips3_TLBRead __P((int, struct tlb *));
     84  1.16    castor #if 0
     85  1.29    simonb void mips3_TLBWriteIndexedVPS __P((u_int index, struct tlb *tlb));
     86  1.29    simonb void mips3_TLBWriteIndexed __P((u_int index, u_int high,
     87  1.29    simonb 				u_int lo0, u_int lo1));
     88  1.16    castor #endif
     89  1.30  nisimura void mips3_SetWIRED __P((int));
     90  1.29    simonb void mips3_wbflush __P((void));
     91  1.29    simonb void mips3_proc_trampoline __P((void));
     92  1.29    simonb void mips3_cpu_switch_resume __P((void));
     93  1.29    simonb 
     94  1.29    simonb void mips5200_FlushCache  __P((void));
     95  1.29    simonb void mips5200_FlushDCache __P((vaddr_t addr, vaddr_t len));
     96  1.29    simonb void mips5200_HitFlushDCache __P((vaddr_t, int));
     97  1.29    simonb void mips5200_FlushICache __P((vaddr_t addr, vaddr_t len));
     98  1.29    simonb 
     99  1.29    simonb u_int32_t mips3_cycle_count __P((void));
    100  1.29    simonb u_int32_t mips3_write_count __P((u_int32_t));
    101  1.29    simonb u_int32_t mips3_read_compare __P((void));
    102  1.29    simonb u_int32_t mips3_read_config __P((void));
    103  1.29    simonb void mips3_write_compare __P((u_int32_t));
    104  1.29    simonb void mips3_write_xcontext_upper __P((u_int32_t));
    105  1.29    simonb void mips3_clearBEV __P((void));
    106   1.7  jonathan 
    107   1.1  jonathan /*
    108   1.1  jonathan  *  A vector with an entry for each mips-ISA-level dependent
    109   1.1  jonathan  * locore function, and macros which jump through it.
    110   1.1  jonathan  * XXX the macro names are chosen to be compatible with the old
    111   1.1  jonathan  * Sprite  coding-convention names used in 4.4bsd/pmax.
    112   1.1  jonathan  */
    113   1.1  jonathan typedef struct  {
    114   1.1  jonathan 	void (*flushCache)  __P((void));
    115  1.16    castor 	void (*flushDCache) __P((vaddr_t addr, vsize_t len));
    116  1.16    castor 	void (*flushICache) __P((vaddr_t addr, vsize_t len));
    117   1.1  jonathan 	void (*forceCacheUpdate)  __P((void));
    118   1.1  jonathan 	void (*setTLBpid)  __P((int pid));
    119  1.31  nisimura 	void (*TBIAP)	__P((int));
    120  1.31  nisimura 	void (*TBIS)	__P((vaddr_t));
    121  1.31  nisimura 	void (*TBRPL)	__P((vaddr_t, vaddr_t, paddr_t));
    122  1.31  nisimura 	int  (*tlbUpdate)  __P((u_int highreg, u_int lowreg));
    123   1.5    mhitch 	void (*wbflush) __P((void));
    124   1.1  jonathan } mips_locore_jumpvec_t;
    125  1.13  jonathan 
    126  1.13  jonathan /* Override writebuffer-drain method. */
    127  1.13  jonathan void mips_set_wbflush __P((void (*) __P((void)) ));
    128   1.1  jonathan 
    129  1.23    simonb 
    130  1.23    simonb /* stacktrace() -- print a stack backtrace to the console */
    131  1.23    simonb void stacktrace __P((void));
    132  1.23    simonb /* logstacktrace() -- log a stack traceback to msgbuf */
    133  1.23    simonb void logstacktrace __P((void));
    134   1.1  jonathan 
    135   1.1  jonathan /*
    136   1.1  jonathan  * The "active" locore-fuction vector, and
    137   1.1  jonathan 
    138   1.1  jonathan  */
    139   1.1  jonathan extern mips_locore_jumpvec_t mips_locore_jumpvec;
    140   1.1  jonathan extern mips_locore_jumpvec_t r2000_locore_vec;
    141   1.1  jonathan extern mips_locore_jumpvec_t r4000_locore_vec;
    142  1.31  nisimura extern long *mips_locoresw[];
    143   1.1  jonathan 
    144  1.11  jonathan #if defined(MIPS3) && !defined (MIPS1)
    145  1.25     soren #if	defined(MIPS3_L2CACHE_ABSENT) && defined(MIPS3_5200)
    146  1.25     soren #define MachFlushCache		mips5200_FlushCache
    147  1.25     soren #define MachFlushDCache		mips5200_FlushDCache
    148  1.25     soren #define MachHitFlushDCache	mips5200_HitFlushDCache
    149  1.25     soren #define MachFlushICache		mips5200_FlushICache
    150  1.25     soren #else
    151  1.11  jonathan #define MachFlushCache		mips3_FlushCache
    152  1.21      shin #if	defined(MIPS3_L2CACHE_ABSENT) && defined(MIPS3_4100)
    153  1.21      shin #define MachFlushDCache         mips3_FlushDCache		/* VR4100 */
    154  1.16    castor #elif	!defined(MIPS3_L2CACHE_ABSENT) && defined(MIPS3_L2CACHE_PRESENT)
    155  1.11  jonathan #define MachFlushDCache		mips3_FlushDCache
    156  1.16    castor #else
    157  1.16    castor #define MachFlushDCache		(*(mips_locore_jumpvec.flushDCache))
    158  1.16    castor #endif
    159  1.25     soren #define MachHitFlushDCache	mips3_HitFlushDCache
    160  1.11  jonathan #define MachFlushICache		mips3_FlushICache
    161  1.25     soren #endif
    162  1.11  jonathan #define MachForceCacheUpdate	mips3_ForceCacheUpdate
    163  1.11  jonathan #define MachSetPID		mips3_SetPID
    164  1.30  nisimura #define MIPS_TBIAP()		mips3_TBIAP(mips_num_tlb_entries)
    165  1.30  nisimura #define MIPS_TBIS		mips3_TBIS
    166  1.31  nisimura #define MIPS_TBRPL		mips3_TBRPL
    167  1.11  jonathan #define MachTLBUpdate		mips3_TLBUpdate
    168  1.22  nisimura #define wbflush()		mips3_wbflush()
    169  1.11  jonathan #define proc_trampoline		mips3_proc_trampoline
    170  1.11  jonathan #endif
    171  1.11  jonathan 
    172  1.11  jonathan #if !defined(MIPS3) && defined (MIPS1)
    173  1.11  jonathan #define MachFlushCache		mips1_FlushCache
    174  1.11  jonathan #define MachFlushDCache		mips1_FlushDCache
    175  1.11  jonathan #define MachFlushICache		mips1_FlushICache
    176  1.11  jonathan #define MachForceCacheUpdate	mips1_ForceCacheUpdate
    177  1.11  jonathan #define MachSetPID		mips1_SetPID
    178  1.30  nisimura #define MIPS_TBIAP()		mips1_TBIAP(mips_num_tlb_entries)
    179  1.30  nisimura #define MIPS_TBIS		mips1_TBIS
    180  1.31  nisimura #define MIPS_TBRPL		mips1_TBRPL
    181  1.11  jonathan #define MachTLBUpdate		mips1_TLBUpdate
    182  1.22  nisimura #define wbflush()		mips1_wbflush()
    183  1.11  jonathan #define proc_trampoline		mips1_proc_trampoline
    184  1.11  jonathan #endif
    185  1.11  jonathan 
    186  1.11  jonathan 
    187  1.11  jonathan 
    188  1.11  jonathan #if defined(MIPS3) && defined (MIPS1)
    189   1.1  jonathan #define MachFlushCache		(*(mips_locore_jumpvec.flushCache))
    190   1.1  jonathan #define MachFlushDCache		(*(mips_locore_jumpvec.flushDCache))
    191   1.1  jonathan #define MachFlushICache		(*(mips_locore_jumpvec.flushICache))
    192   1.1  jonathan #define MachForceCacheUpdate	(*(mips_locore_jumpvec.forceCacheUpdate))
    193   1.1  jonathan #define MachSetPID		(*(mips_locore_jumpvec.setTLBpid))
    194  1.31  nisimura #define MIPS_TBIAP()		(*(mips_locore_jumpvec.TBIAP))(mips_num_tlb_entries)
    195  1.31  nisimura #define MIPS_TBIS		(*(mips_locore_jumpvec.TBIS))
    196  1.31  nisimura #define MIPS_TBRPL		(*(mips_locore_jumpvec.TBRPL))
    197   1.1  jonathan #define MachTLBUpdate		(*(mips_locore_jumpvec.tlbUpdate))
    198  1.31  nisimura #define MachHitFlushDCache	mips3_HitFlushDCache
    199  1.22  nisimura #define wbflush()		(*(mips_locore_jumpvec.wbflush))()
    200  1.31  nisimura #define proc_trampoline		(mips_locoresw[1])
    201  1.11  jonathan #endif
    202  1.31  nisimura 
    203  1.31  nisimura #define CPU_IDLE		(mips_locoresw[2])
    204  1.11  jonathan 
    205  1.16    castor /* cpu_switch_resume is called inside locore.S */
    206   1.7  jonathan 
    207   1.7  jonathan /*
    208   1.7  jonathan  * CPU identification, from PRID register.
    209   1.7  jonathan  */
    210   1.7  jonathan union cpuprid {
    211   1.7  jonathan 	int	cpuprid;
    212   1.7  jonathan 	struct {
    213   1.7  jonathan #if BYTE_ORDER == BIG_ENDIAN
    214   1.7  jonathan 		u_int	pad1:16;	/* reserved */
    215   1.7  jonathan 		u_int	cp_imp:8;	/* implementation identifier */
    216   1.7  jonathan 		u_int	cp_majrev:4;	/* major revision identifier */
    217   1.7  jonathan 		u_int	cp_minrev:4;	/* minor revision identifier */
    218   1.7  jonathan #else
    219   1.7  jonathan 		u_int	cp_minrev:4;	/* minor revision identifier */
    220   1.7  jonathan 		u_int	cp_majrev:4;	/* major revision identifier */
    221   1.7  jonathan 		u_int	cp_imp:8;	/* implementation identifier */
    222   1.7  jonathan 		u_int	pad1:16;	/* reserved */
    223   1.7  jonathan #endif
    224   1.7  jonathan 	} cpu;
    225   1.7  jonathan };
    226   1.7  jonathan 
    227   1.6  jonathan 
    228   1.6  jonathan #ifdef _KERNEL
    229   1.6  jonathan 
    230   1.6  jonathan /*
    231   1.6  jonathan  * Global variables used to communicate CPU type, and parameters
    232   1.6  jonathan  * such as cache size, from locore to higher-level code (e.g., pmap).
    233   1.6  jonathan  */
    234   1.8  jonathan extern union	cpuprid cpu_id;
    235   1.8  jonathan extern union	cpuprid fpu_id;
    236   1.8  jonathan extern int	cpu_arch;
    237  1.14  jonathan extern int	mips_num_tlb_entries;
    238  1.14  jonathan extern u_int	mips_L1DCacheSize;
    239  1.14  jonathan extern u_int	mips_L1ICacheSize;
    240  1.14  jonathan extern u_int	mips_L1DCacheLSize;
    241  1.14  jonathan extern u_int	mips_L1ICacheLSize;
    242  1.14  jonathan extern int	mips_L2CachePresent;
    243   1.9    mhitch extern u_int	mips_L2CacheLSize;
    244   1.9    mhitch extern u_int	mips_CacheAliasMask;
    245  1.14  jonathan 
    246  1.14  jonathan #ifdef MIPS3
    247  1.14  jonathan extern int	mips3_L1TwoWayCache;
    248  1.14  jonathan extern int	mips3_cacheflush_bug;
    249  1.14  jonathan #endif /* MIPS3 */
    250  1.19  jonathan 
    251  1.19  jonathan /*
    252  1.20    simonb  * trapframe argument passed to trap()
    253  1.19  jonathan  */
    254  1.19  jonathan struct trapframe {
    255  1.19  jonathan 	mips_reg_t tf_regs[17];
    256  1.19  jonathan 	mips_reg_t tf_ra;
    257  1.19  jonathan 	mips_reg_t tf_sr;
    258  1.19  jonathan 	mips_reg_t tf_mullo;
    259  1.19  jonathan 	mips_reg_t tf_mulhi;
    260  1.19  jonathan 	mips_reg_t tf_epc;		/* may be changed by trap() call */
    261  1.19  jonathan };
    262  1.19  jonathan 
    263  1.19  jonathan /*
    264  1.19  jonathan  * Stack frame for kernel traps. four args passed in registers.
    265  1.19  jonathan  * A trapframe is pointed to by the 5th arg, and a dummy sixth argument
    266  1.19  jonathan  * is used to avoid alignment problems
    267  1.19  jonathan  */
    268  1.19  jonathan 
    269  1.19  jonathan struct kernframe {
    270  1.19  jonathan 	register_t cf_args[4 + 1];
    271  1.19  jonathan 	register_t cf_pad;		/* (for 8 word alignment) */
    272  1.19  jonathan 	register_t cf_sp;
    273  1.19  jonathan 	register_t cf_ra;
    274  1.19  jonathan 	struct trapframe cf_frame;
    275  1.19  jonathan };
    276  1.14  jonathan 
    277   1.6  jonathan #endif
    278   1.1  jonathan 
    279   1.1  jonathan #endif	/* _MIPS_LOCORE_H */
    280