Home | History | Annotate | Line # | Download | only in include
locore.h revision 1.16
      1  1.16    castor /*	$NetBSD: locore.h,v 1.16 1999/01/14 18:45:46 castor 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.1  jonathan  *
     23   1.1  jonathan  *	MachFlushCache
     24   1.1  jonathan  *	MachFlushDCache
     25   1.1  jonathan  *	MachFlushICache
     26   1.1  jonathan  *	MachForceCacheUpdate
     27   1.1  jonathan  *	MachSetPID
     28   1.1  jonathan  *	MachTLBFlush
     29  1.16    castor  *	MachTLBFlushAddr
     30  1.16    castor  *	MachTLBUpdate
     31   1.5    mhitch  *	wbflush
     32   1.5    mhitch  *	proc_trampoline()
     33   1.9    mhitch  *	cpu_switch_resume()
     34   1.1  jonathan  *
     35   1.1  jonathan  * We currently provide support for:
     36   1.1  jonathan  *
     37   1.1  jonathan  *	r2000 and r3000 (mips ISA-I)
     38   1.1  jonathan  *	r4000 and r4400 in 32-bit mode (mips ISA-III?)
     39   1.1  jonathan  */
     40   1.1  jonathan 
     41   1.1  jonathan #ifndef _MIPS_LOCORE_H
     42   1.1  jonathan #define  _MIPS_LOCORE_H
     43   1.2  jonathan 
     44  1.16    castor #include "opt_mips_cache.h"
     45  1.16    castor 
     46   1.2  jonathan /*
     47  1.16    castor  * locore service routine for exception vectors. Used outside locore
     48   1.2  jonathan  * only to print them by name in stack tracebacks
     49   1.2  jonathan  */
     50   1.2  jonathan 
     51  1.14  jonathan extern u_int32_t mips_read_causereg __P((void));
     52  1.14  jonathan extern u_int32_t mips_read_statusreg __P((void));
     53  1.14  jonathan 
     54   1.3  jonathan extern void mips1_ConfigCache  __P((void));
     55   1.3  jonathan extern void mips1_FlushCache  __P((void));
     56  1.16    castor extern void mips1_FlushDCache  __P((vaddr_t addr, vsize_t len));
     57  1.16    castor extern void mips1_FlushICache  __P((vaddr_t addr, vsize_t len));
     58   1.3  jonathan extern void mips1_ForceCacheUpdate __P((void));
     59   1.3  jonathan extern void mips1_SetPID   __P((int pid));
     60  1.14  jonathan extern void mips1_TLBFlush __P((int numtlb));
     61   1.3  jonathan extern void mips1_TLBFlushAddr   __P( /* XXX Really pte highpart ? */
     62  1.15  nisimura 					  (vaddr_t addr));
     63   1.5    mhitch extern int mips1_TLBUpdate __P((u_int, /*pt_entry_t*/ u_int));
     64   1.3  jonathan extern void mips1_TLBWriteIndexed  __P((u_int index, u_int high,
     65   1.1  jonathan 					    u_int low));
     66   1.5    mhitch extern void mips1_wbflush __P((void));
     67   1.5    mhitch extern void mips1_proc_trampoline __P((void));
     68   1.9    mhitch extern void mips1_cpu_switch_resume __P((void));
     69   1.1  jonathan 
     70   1.3  jonathan extern void mips3_ConfigCache __P((void));
     71   1.3  jonathan extern void mips3_FlushCache  __P((void));
     72  1.15  nisimura extern void mips3_FlushDCache __P((vaddr_t addr, vaddr_t len));
     73  1.16    castor #ifdef	MIPS3_L2CACHE_ABSENT
     74  1.16    castor extern void mips52xx_FlushDCache __P((vaddr_t addr, vaddr_t len));
     75  1.16    castor #endif
     76  1.15  nisimura extern void mips3_FlushICache __P((vaddr_t addr, vaddr_t len));
     77   1.3  jonathan extern void mips3_ForceCacheUpdate __P((void));
     78  1.15  nisimura extern void mips3_HitFlushDCache __P((vaddr_t, int));
     79   1.3  jonathan extern void mips3_SetPID  __P((int pid));
     80  1.14  jonathan extern void mips3_TLBFlush __P((int numtlb));
     81   1.3  jonathan extern void mips3_TLBFlushAddr __P( /* XXX Really pte highpart ? */
     82  1.15  nisimura 					  (vaddr_t addr));
     83   1.5    mhitch extern int mips3_TLBUpdate __P((u_int, /*pt_entry_t*/ u_int));
     84  1.14  jonathan struct tlb;
     85  1.14  jonathan extern void mips3_TLBRead __P((int, struct tlb *));
     86  1.16    castor #if 0
     87  1.14  jonathan extern void mips3_TLBWriteIndexedVPS __P((u_int index, struct tlb *tlb));
     88   1.3  jonathan extern void mips3_TLBWriteIndexed __P((u_int index, u_int high,
     89   1.5    mhitch 					   u_int lo0, u_int lo1));
     90  1.16    castor #endif
     91   1.5    mhitch extern void mips3_wbflush __P((void));
     92   1.5    mhitch extern void mips3_proc_trampoline __P((void));
     93   1.9    mhitch extern void mips3_cpu_switch_resume __P((void));
     94   1.1  jonathan 
     95   1.7  jonathan extern void mips3_SetWIRED __P((int));
     96   1.7  jonathan 
     97  1.14  jonathan extern u_int32_t mips3_cycle_count __P((void));
     98  1.16    castor extern u_int32_t mips3_write_count __P((u_int32_t));
     99  1.14  jonathan extern u_int32_t mips3_read_compare __P((void));
    100  1.14  jonathan extern u_int32_t mips3_read_config __P((void));
    101  1.14  jonathan extern void mips3_write_compare __P((u_int32_t));
    102  1.16    castor extern void mips3_write_xcontext_upper __P((u_int32_t));
    103   1.7  jonathan 
    104   1.1  jonathan /*
    105   1.1  jonathan  *  A vector with an entry for each mips-ISA-level dependent
    106   1.1  jonathan  * locore function, and macros which jump through it.
    107   1.1  jonathan  * XXX the macro names are chosen to be compatible with the old
    108   1.1  jonathan  * Sprite  coding-convention names used in 4.4bsd/pmax.
    109   1.1  jonathan  */
    110   1.1  jonathan typedef struct  {
    111   1.1  jonathan 	void (*flushCache)  __P((void));
    112  1.16    castor 	void (*flushDCache) __P((vaddr_t addr, vsize_t len));
    113  1.16    castor 	void (*flushICache) __P((vaddr_t addr, vsize_t len));
    114   1.1  jonathan 	void (*forceCacheUpdate)  __P((void));
    115   1.1  jonathan 	void (*setTLBpid)  __P((int pid));
    116  1.14  jonathan 	void (*tlbFlush)  __P((int numtlb));
    117  1.15  nisimura 	void (*tlbFlushAddr)  __P((vaddr_t)); /* XXX Really pte highpart ? */
    118   1.5    mhitch 	int (*tlbUpdate)  __P((u_int highreg, u_int lowreg));
    119   1.5    mhitch 	void (*wbflush) __P((void));
    120   1.5    mhitch 	void (*proc_trampoline) __P((void));
    121   1.9    mhitch 	void (*cpu_switch_resume) __P((void));
    122   1.1  jonathan } mips_locore_jumpvec_t;
    123  1.13  jonathan 
    124  1.13  jonathan /* Override writebuffer-drain method. */
    125  1.13  jonathan void mips_set_wbflush __P((void (*) __P((void)) ));
    126   1.1  jonathan 
    127   1.1  jonathan 
    128   1.1  jonathan /*
    129   1.1  jonathan  * The "active" locore-fuction vector, and
    130   1.1  jonathan 
    131   1.1  jonathan  */
    132   1.1  jonathan extern mips_locore_jumpvec_t mips_locore_jumpvec;
    133   1.1  jonathan extern mips_locore_jumpvec_t r2000_locore_vec;
    134   1.1  jonathan extern mips_locore_jumpvec_t r4000_locore_vec;
    135   1.1  jonathan 
    136  1.11  jonathan #if defined(MIPS3) && !defined (MIPS1)
    137  1.11  jonathan #define MachFlushCache		mips3_FlushCache
    138  1.16    castor #if	defined(MIPS3_L2CACHE_ABSENT) && !defined(MIPS3_L2CACHE_PRESENT)
    139  1.16    castor #define MachFlushDCache		mips52xx_FlushDCache
    140  1.16    castor #elif	!defined(MIPS3_L2CACHE_ABSENT) && defined(MIPS3_L2CACHE_PRESENT)
    141  1.11  jonathan #define MachFlushDCache		mips3_FlushDCache
    142  1.16    castor #else
    143  1.16    castor #define MachFlushDCache		(*(mips_locore_jumpvec.flushDCache))
    144  1.16    castor #endif
    145  1.11  jonathan #define MachFlushICache		mips3_FlushICache
    146  1.11  jonathan #define MachForceCacheUpdate	mips3_ForceCacheUpdate
    147  1.11  jonathan #define MachSetPID		mips3_SetPID
    148  1.14  jonathan #define MachTLBFlush()		mips3_TLBFlush(mips_num_tlb_entries)
    149  1.11  jonathan #define MachTLBFlushAddr	mips3_TLBFlushAddr
    150  1.11  jonathan #define MachTLBUpdate		mips3_TLBUpdate
    151  1.11  jonathan #define wbflush			mips3_wbflush
    152  1.11  jonathan #define proc_trampoline		mips3_proc_trampoline
    153  1.11  jonathan #endif
    154  1.11  jonathan 
    155  1.11  jonathan #if !defined(MIPS3) && defined (MIPS1)
    156  1.11  jonathan #define MachFlushCache		mips1_FlushCache
    157  1.11  jonathan #define MachFlushDCache		mips1_FlushDCache
    158  1.11  jonathan #define MachFlushICache		mips1_FlushICache
    159  1.11  jonathan #define MachForceCacheUpdate	mips1_ForceCacheUpdate
    160  1.11  jonathan #define MachSetPID		mips1_SetPID
    161  1.14  jonathan #define MachTLBFlush()		mips1_TLBFlush(MIPS1_TLB_NUM_TLB_ENTRIES)
    162  1.11  jonathan #define MachTLBFlushAddr	mips1_TLBFlushAddr
    163  1.11  jonathan #define MachTLBUpdate		mips1_TLBUpdate
    164  1.11  jonathan #define wbflush			mips1_wbflush
    165  1.11  jonathan #define proc_trampoline		mips1_proc_trampoline
    166  1.11  jonathan #endif
    167  1.11  jonathan 
    168  1.11  jonathan 
    169  1.11  jonathan 
    170  1.11  jonathan #if defined(MIPS3) && defined (MIPS1)
    171   1.1  jonathan #define MachFlushCache		(*(mips_locore_jumpvec.flushCache))
    172   1.1  jonathan #define MachFlushDCache		(*(mips_locore_jumpvec.flushDCache))
    173   1.1  jonathan #define MachFlushICache		(*(mips_locore_jumpvec.flushICache))
    174   1.1  jonathan #define MachForceCacheUpdate	(*(mips_locore_jumpvec.forceCacheUpdate))
    175   1.1  jonathan #define MachSetPID		(*(mips_locore_jumpvec.setTLBpid))
    176  1.14  jonathan #define MachTLBFlush()		(*(mips_locore_jumpvec.tlbFlush))(mips_num_tlb_entries)
    177   1.1  jonathan #define MachTLBFlushAddr	(*(mips_locore_jumpvec.tlbFlushAddr))
    178   1.1  jonathan #define MachTLBUpdate		(*(mips_locore_jumpvec.tlbUpdate))
    179   1.5    mhitch #define wbflush			(*(mips_locore_jumpvec.wbflush))
    180   1.5    mhitch #define proc_trampoline		(mips_locore_jumpvec.proc_trampoline)
    181  1.11  jonathan #endif
    182  1.11  jonathan 
    183  1.16    castor /* cpu_switch_resume is called inside locore.S */
    184   1.7  jonathan 
    185   1.7  jonathan /*
    186   1.7  jonathan  * CPU identification, from PRID register.
    187   1.7  jonathan  */
    188   1.7  jonathan union cpuprid {
    189   1.7  jonathan 	int	cpuprid;
    190   1.7  jonathan 	struct {
    191   1.7  jonathan #if BYTE_ORDER == BIG_ENDIAN
    192   1.7  jonathan 		u_int	pad1:16;	/* reserved */
    193   1.7  jonathan 		u_int	cp_imp:8;	/* implementation identifier */
    194   1.7  jonathan 		u_int	cp_majrev:4;	/* major revision identifier */
    195   1.7  jonathan 		u_int	cp_minrev:4;	/* minor revision identifier */
    196   1.7  jonathan #else
    197   1.7  jonathan 		u_int	cp_minrev:4;	/* minor revision identifier */
    198   1.7  jonathan 		u_int	cp_majrev:4;	/* major revision identifier */
    199   1.7  jonathan 		u_int	cp_imp:8;	/* implementation identifier */
    200   1.7  jonathan 		u_int	pad1:16;	/* reserved */
    201   1.7  jonathan #endif
    202   1.7  jonathan 	} cpu;
    203   1.7  jonathan };
    204   1.7  jonathan 
    205   1.6  jonathan 
    206   1.6  jonathan #ifdef _KERNEL
    207   1.6  jonathan 
    208   1.6  jonathan /*
    209   1.6  jonathan  * Global variables used to communicate CPU type, and parameters
    210   1.6  jonathan  * such as cache size, from locore to higher-level code (e.g., pmap).
    211   1.6  jonathan  */
    212   1.8  jonathan extern union	cpuprid cpu_id;
    213   1.8  jonathan extern union	cpuprid fpu_id;
    214   1.8  jonathan extern int	cpu_arch;
    215  1.14  jonathan extern int	mips_num_tlb_entries;
    216  1.14  jonathan extern u_int	mips_L1DCacheSize;
    217  1.14  jonathan extern u_int	mips_L1ICacheSize;
    218  1.14  jonathan extern u_int	mips_L1DCacheLSize;
    219  1.14  jonathan extern u_int	mips_L1ICacheLSize;
    220  1.14  jonathan extern int	mips_L2CachePresent;
    221   1.9    mhitch extern u_int	mips_L2CacheLSize;
    222   1.9    mhitch extern u_int	mips_CacheAliasMask;
    223  1.14  jonathan 
    224  1.14  jonathan #ifdef MIPS3
    225  1.14  jonathan extern int	mips3_L1TwoWayCache;
    226  1.14  jonathan extern int	mips3_cacheflush_bug;
    227  1.14  jonathan #endif /* MIPS3 */
    228  1.14  jonathan 
    229   1.6  jonathan #endif
    230   1.1  jonathan 
    231   1.1  jonathan #endif	/* _MIPS_LOCORE_H */
    232