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