Home | History | Annotate | Line # | Download | only in include
locore.h revision 1.52.2.1
      1  1.52.2.1   nathanw /* $NetBSD: locore.h,v 1.52.2.1 2001/06/21 19:28:00 nathanw 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.38       cgd struct tlb;
     42      1.38       cgd 
     43       1.2  jonathan /*
     44      1.16    castor  * locore service routine for exception vectors. Used outside locore
     45       1.2  jonathan  * only to print them by name in stack tracebacks
     46       1.2  jonathan  */
     47       1.2  jonathan 
     48      1.46       cgd u_int32_t mips_cp0_cause_read(void);
     49      1.46       cgd void	mips_cp0_cause_write(u_int32_t);
     50      1.46       cgd u_int32_t mips_cp0_status_read(void);
     51      1.46       cgd void	mips_cp0_status_write(u_int32_t);
     52      1.29    simonb 
     53      1.43  nisimura int	mips1_icsize(void);
     54      1.43  nisimura int	mips1_dcsize(void);
     55      1.38       cgd void	mips1_FlushCache(void);
     56      1.38       cgd void	mips1_FlushDCache(vaddr_t addr, vsize_t len);
     57      1.38       cgd void	mips1_FlushICache(vaddr_t addr, vsize_t len);
     58      1.38       cgd 
     59      1.38       cgd void	mips1_SetPID(int pid);
     60      1.38       cgd void	mips1_TBIA(int);
     61      1.38       cgd void	mips1_TBIAP(int);
     62      1.38       cgd void	mips1_TBIS(vaddr_t);
     63      1.38       cgd int	mips1_TLBUpdate(u_int, u_int);
     64      1.38       cgd void	mips1_wbflush(void);
     65      1.38       cgd void	mips1_proc_trampoline(void);
     66      1.38       cgd void	mips1_cpu_switch_resume(void);
     67      1.38       cgd 
     68      1.42     chuck void	mips3_ConfigCache(int);
     69      1.38       cgd void	mips3_FlushCache(void);
     70  1.52.2.1   nathanw void	mips3_FlushDCache(vaddr_t addr, vsize_t len);
     71  1.52.2.1   nathanw void	mips3_FlushICache(vaddr_t addr, vsize_t len);
     72  1.52.2.1   nathanw void	mips3_HitFlushDCache(vaddr_t, vsize_t);
     73      1.38       cgd 
     74      1.38       cgd void	mips3_SetPID(int pid);
     75      1.38       cgd void	mips3_TBIA(int);
     76      1.38       cgd void	mips3_TBIAP(int);
     77      1.38       cgd void	mips3_TBIS(vaddr_t);
     78      1.38       cgd int	mips3_TLBUpdate(u_int, u_int);
     79      1.38       cgd void	mips3_TLBRead(int, struct tlb *);
     80      1.38       cgd void	mips3_wbflush(void);
     81      1.38       cgd void	mips3_proc_trampoline(void);
     82      1.38       cgd void	mips3_cpu_switch_resume(void);
     83      1.38       cgd 
     84      1.38       cgd void	mips3_FlushCache_2way(void);
     85      1.38       cgd void	mips3_FlushDCache_2way(vaddr_t addr, vaddr_t len);
     86      1.38       cgd void	mips3_FlushICache_2way(vaddr_t addr, vaddr_t len);
     87  1.52.2.1   nathanw void	mips3_HitFlushDCache_2way(vaddr_t, vsize_t);
     88      1.38       cgd 
     89      1.49       cgd u_int32_t mips3_cp0_compare_read(void);
     90      1.49       cgd void	mips3_cp0_compare_write(u_int32_t);
     91      1.49       cgd 
     92      1.49       cgd u_int32_t mips3_cp0_config_read(void);
     93      1.49       cgd void	mips3_cp0_count_write(u_int32_t);
     94      1.49       cgd 
     95      1.49       cgd u_int32_t mips3_cp0_count_read(void);
     96      1.49       cgd void	mips3_cp0_config_write(u_int32_t);
     97      1.49       cgd 
     98      1.49       cgd u_int32_t mips3_cp0_wired_read(void);
     99      1.49       cgd void	mips3_cp0_wired_write(u_int32_t);
    100      1.44       cgd 
    101      1.44       cgd u_int64_t mips3_ld(u_int64_t *);
    102      1.44       cgd void	mips3_sd(u_int64_t *, u_int64_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.38       cgd 	void (*flushCache)(void);
    112      1.38       cgd 	void (*flushDCache)(vaddr_t addr, vsize_t len);
    113      1.38       cgd 	void (*flushICache)(vaddr_t addr, vsize_t len);
    114  1.52.2.1   nathanw 	void (*hitflushDCache)(vaddr_t, vsize_t);
    115      1.38       cgd 	void (*setTLBpid)(int pid);
    116      1.38       cgd 	void (*TBIAP)(int);
    117      1.38       cgd 	void (*TBIS)(vaddr_t);
    118      1.38       cgd 	int  (*tlbUpdate)(u_int highreg, u_int lowreg);
    119      1.38       cgd 	void (*wbflush)(void);
    120       1.1  jonathan } mips_locore_jumpvec_t;
    121      1.13  jonathan 
    122      1.13  jonathan /* Override writebuffer-drain method. */
    123      1.38       cgd void	mips_set_wbflush(void (*)(void));
    124       1.1  jonathan 
    125      1.23    simonb 
    126      1.23    simonb /* stacktrace() -- print a stack backtrace to the console */
    127      1.38       cgd void	stacktrace(void);
    128      1.23    simonb /* logstacktrace() -- log a stack traceback to msgbuf */
    129      1.38       cgd void	logstacktrace(void);
    130       1.1  jonathan 
    131       1.1  jonathan /*
    132       1.1  jonathan  * The "active" locore-fuction vector, and
    133       1.1  jonathan  */
    134       1.1  jonathan extern mips_locore_jumpvec_t mips_locore_jumpvec;
    135       1.1  jonathan extern mips_locore_jumpvec_t r2000_locore_vec;
    136       1.1  jonathan extern mips_locore_jumpvec_t r4000_locore_vec;
    137      1.31  nisimura extern long *mips_locoresw[];
    138       1.1  jonathan 
    139  1.52.2.1   nathanw /*
    140  1.52.2.1   nathanw  * Always indirect to get the cache ops.  There are just too many
    141  1.52.2.1   nathanw  * combinations to try and worry about.
    142  1.52.2.1   nathanw  */
    143  1.52.2.1   nathanw #define MachFlushCache		(*(mips_locore_jumpvec.flushCache))
    144      1.16    castor #define MachFlushDCache		(*(mips_locore_jumpvec.flushDCache))
    145  1.52.2.1   nathanw #define MachFlushICache		(*(mips_locore_jumpvec.flushICache))
    146  1.52.2.1   nathanw #define	MachHitFlushDCache	(*(mips_locore_jumpvec.hitflushDCache))
    147  1.52.2.1   nathanw 
    148  1.52.2.1   nathanw #if defined(MIPS3) && !defined(MIPS1)
    149      1.11  jonathan #define MachSetPID		mips3_SetPID
    150      1.30  nisimura #define MIPS_TBIAP()		mips3_TBIAP(mips_num_tlb_entries)
    151      1.30  nisimura #define MIPS_TBIS		mips3_TBIS
    152      1.11  jonathan #define MachTLBUpdate		mips3_TLBUpdate
    153      1.22  nisimura #define wbflush()		mips3_wbflush()
    154      1.11  jonathan #define proc_trampoline		mips3_proc_trampoline
    155      1.11  jonathan #endif
    156      1.11  jonathan 
    157  1.52.2.1   nathanw #if !defined(MIPS3) && defined(MIPS1)
    158      1.11  jonathan #define MachSetPID		mips1_SetPID
    159      1.30  nisimura #define MIPS_TBIAP()		mips1_TBIAP(mips_num_tlb_entries)
    160      1.30  nisimura #define MIPS_TBIS		mips1_TBIS
    161      1.11  jonathan #define MachTLBUpdate		mips1_TLBUpdate
    162      1.22  nisimura #define wbflush()		mips1_wbflush()
    163      1.11  jonathan #define proc_trampoline		mips1_proc_trampoline
    164      1.11  jonathan #endif
    165      1.11  jonathan 
    166  1.52.2.1   nathanw #if defined(MIPS3) && defined(MIPS1)
    167       1.1  jonathan #define MachSetPID		(*(mips_locore_jumpvec.setTLBpid))
    168      1.31  nisimura #define MIPS_TBIAP()		(*(mips_locore_jumpvec.TBIAP))(mips_num_tlb_entries)
    169      1.31  nisimura #define MIPS_TBIS		(*(mips_locore_jumpvec.TBIS))
    170       1.1  jonathan #define MachTLBUpdate		(*(mips_locore_jumpvec.tlbUpdate))
    171      1.22  nisimura #define wbflush()		(*(mips_locore_jumpvec.wbflush))()
    172      1.31  nisimura #define proc_trampoline		(mips_locoresw[1])
    173      1.11  jonathan #endif
    174      1.31  nisimura 
    175      1.31  nisimura #define CPU_IDLE		(mips_locoresw[2])
    176      1.11  jonathan 
    177      1.16    castor /* cpu_switch_resume is called inside locore.S */
    178       1.7  jonathan 
    179       1.7  jonathan /*
    180       1.7  jonathan  * CPU identification, from PRID register.
    181       1.7  jonathan  */
    182      1.40       cgd typedef int mips_prid_t;
    183      1.40       cgd 
    184      1.40       cgd #define	MIPS_PRID_REV(x)	(((x) >>  0) & 0x00ff)
    185      1.40       cgd #define	MIPS_PRID_IMPL(x)	(((x) >>  8) & 0x00ff)
    186      1.45       cgd 
    187      1.45       cgd /* pre-MIPS32 */
    188      1.40       cgd #define	MIPS_PRID_RSVD(x)	(((x) >> 16) & 0xffff)
    189      1.40       cgd #define	MIPS_PRID_REV_MIN(x)	((MIPS_PRID_REV(x) >> 0) & 0x0f)
    190      1.40       cgd #define	MIPS_PRID_REV_MAJ(x)	((MIPS_PRID_REV(x) >> 4) & 0x0f)
    191      1.45       cgd 
    192      1.45       cgd /* MIPS32 */
    193      1.45       cgd #define	MIPS_PRID_CID(x)	(((x) >> 16) & 0x00ff)	/* Company ID */
    194      1.45       cgd #define	    MIPS_PRID_CID_PREHISTORIC	0x00	/* Not MIPS32 */
    195      1.45       cgd #define	    MIPS_PRID_CID_MTI		0x01	/* MIPS Technologies, Inc. */
    196       1.6  jonathan 
    197       1.6  jonathan #ifdef _KERNEL
    198       1.6  jonathan 
    199       1.6  jonathan /*
    200       1.6  jonathan  * Global variables used to communicate CPU type, and parameters
    201       1.6  jonathan  * such as cache size, from locore to higher-level code (e.g., pmap).
    202       1.6  jonathan  */
    203      1.40       cgd 
    204      1.40       cgd extern mips_prid_t cpu_id;
    205      1.40       cgd extern mips_prid_t fpu_id;
    206      1.14  jonathan extern int	mips_num_tlb_entries;
    207      1.14  jonathan extern u_int	mips_L1DCacheSize;
    208      1.14  jonathan extern u_int	mips_L1ICacheSize;
    209      1.14  jonathan extern u_int	mips_L1DCacheLSize;
    210      1.14  jonathan extern u_int	mips_L1ICacheLSize;
    211      1.14  jonathan extern int	mips_L2CachePresent;
    212       1.9    mhitch extern u_int	mips_L2CacheLSize;
    213       1.9    mhitch extern u_int	mips_CacheAliasMask;
    214      1.39     jeffs extern u_int	mips_CachePreferMask;
    215      1.51     jeffs 
    216      1.51     jeffs #define mips_indexof(addr)	(((int)(addr)) & mips_CacheAliasMask)
    217      1.14  jonathan 
    218      1.14  jonathan #ifdef MIPS3
    219      1.14  jonathan extern int	mips3_L1TwoWayCache;
    220      1.14  jonathan extern int	mips3_cacheflush_bug;
    221      1.14  jonathan #endif /* MIPS3 */
    222      1.52     jeffs 
    223      1.52     jeffs void mips_pagecopy(caddr_t dst, caddr_t src);
    224      1.52     jeffs void mips_pagezero(caddr_t dst);
    225      1.19  jonathan 
    226      1.19  jonathan /*
    227      1.20    simonb  * trapframe argument passed to trap()
    228      1.19  jonathan  */
    229      1.19  jonathan struct trapframe {
    230      1.19  jonathan 	mips_reg_t tf_regs[17];
    231      1.19  jonathan 	mips_reg_t tf_ra;
    232      1.19  jonathan 	mips_reg_t tf_sr;
    233      1.19  jonathan 	mips_reg_t tf_mullo;
    234      1.19  jonathan 	mips_reg_t tf_mulhi;
    235      1.19  jonathan 	mips_reg_t tf_epc;		/* may be changed by trap() call */
    236      1.19  jonathan };
    237      1.19  jonathan 
    238      1.19  jonathan /*
    239      1.19  jonathan  * Stack frame for kernel traps. four args passed in registers.
    240      1.19  jonathan  * A trapframe is pointed to by the 5th arg, and a dummy sixth argument
    241      1.19  jonathan  * is used to avoid alignment problems
    242      1.19  jonathan  */
    243      1.19  jonathan 
    244      1.19  jonathan struct kernframe {
    245      1.19  jonathan 	register_t cf_args[4 + 1];
    246      1.19  jonathan 	register_t cf_pad;		/* (for 8 word alignment) */
    247      1.19  jonathan 	register_t cf_sp;
    248      1.19  jonathan 	register_t cf_ra;
    249      1.19  jonathan 	struct trapframe cf_frame;
    250      1.19  jonathan };
    251      1.14  jonathan 
    252       1.6  jonathan #endif
    253       1.1  jonathan 
    254       1.1  jonathan #endif	/* _MIPS_LOCORE_H */
    255