Home | History | Annotate | Line # | Download | only in include
locore.h revision 1.53.2.2
      1  1.53.2.2   thorpej /* $NetBSD: locore.h,v 1.53.2.2 2002/01/10 19:46:01 thorpej 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  *
     21      1.33     soren  * We currently provide support for MIPS I and MIPS III.
     22       1.1  jonathan  */
     23       1.1  jonathan 
     24       1.1  jonathan #ifndef _MIPS_LOCORE_H
     25       1.1  jonathan #define  _MIPS_LOCORE_H
     26       1.2  jonathan 
     27      1.17    castor #ifndef _LKM
     28      1.32     soren #include "opt_cputype.h"
     29      1.16    castor #include "opt_mips_cache.h"
     30      1.17    castor #endif
     31      1.16    castor 
     32      1.38       cgd struct tlb;
     33      1.38       cgd 
     34       1.2  jonathan /*
     35      1.16    castor  * locore service routine for exception vectors. Used outside locore
     36       1.2  jonathan  * only to print them by name in stack tracebacks
     37       1.2  jonathan  */
     38       1.2  jonathan 
     39      1.46       cgd u_int32_t mips_cp0_cause_read(void);
     40      1.46       cgd void	mips_cp0_cause_write(u_int32_t);
     41      1.46       cgd u_int32_t mips_cp0_status_read(void);
     42      1.46       cgd void	mips_cp0_status_write(u_int32_t);
     43      1.29    simonb 
     44  1.53.2.1   thorpej void	mips1_SetPID(int);
     45      1.38       cgd void	mips1_TBIA(int);
     46      1.38       cgd void	mips1_TBIAP(int);
     47      1.38       cgd void	mips1_TBIS(vaddr_t);
     48      1.38       cgd int	mips1_TLBUpdate(u_int, u_int);
     49      1.38       cgd void	mips1_wbflush(void);
     50      1.38       cgd void	mips1_proc_trampoline(void);
     51      1.38       cgd void	mips1_cpu_switch_resume(void);
     52      1.38       cgd 
     53  1.53.2.2   thorpej uint32_t tx3900_cp0_config_read(void);
     54      1.38       cgd 
     55  1.53.2.1   thorpej void	mips3_SetPID(int);
     56      1.38       cgd void	mips3_TBIA(int);
     57      1.38       cgd void	mips3_TBIAP(int);
     58      1.38       cgd void	mips3_TBIS(vaddr_t);
     59      1.38       cgd int	mips3_TLBUpdate(u_int, u_int);
     60      1.38       cgd void	mips3_TLBRead(int, struct tlb *);
     61      1.38       cgd void	mips3_wbflush(void);
     62      1.38       cgd void	mips3_proc_trampoline(void);
     63      1.38       cgd void	mips3_cpu_switch_resume(void);
     64      1.38       cgd 
     65      1.49       cgd u_int32_t mips3_cp0_compare_read(void);
     66      1.49       cgd void	mips3_cp0_compare_write(u_int32_t);
     67      1.49       cgd 
     68      1.49       cgd u_int32_t mips3_cp0_config_read(void);
     69  1.53.2.1   thorpej void	mips3_cp0_config_write(u_int32_t);
     70      1.49       cgd 
     71      1.49       cgd u_int32_t mips3_cp0_count_read(void);
     72  1.53.2.1   thorpej void	mips3_cp0_count_write(u_int32_t);
     73      1.49       cgd 
     74      1.49       cgd u_int32_t mips3_cp0_wired_read(void);
     75      1.49       cgd void	mips3_cp0_wired_write(u_int32_t);
     76      1.44       cgd 
     77      1.44       cgd u_int64_t mips3_ld(u_int64_t *);
     78      1.44       cgd void	mips3_sd(u_int64_t *, u_int64_t);
     79       1.7  jonathan 
     80       1.1  jonathan /*
     81  1.53.2.2   thorpej  * A vector with an entry for each mips-ISA-level dependent
     82       1.1  jonathan  * locore function, and macros which jump through it.
     83  1.53.2.2   thorpej  *
     84       1.1  jonathan  * XXX the macro names are chosen to be compatible with the old
     85  1.53.2.2   thorpej  * XXX Sprite coding-convention names used in 4.4bsd/pmax.
     86       1.1  jonathan  */
     87       1.1  jonathan typedef struct  {
     88      1.38       cgd 	void (*setTLBpid)(int pid);
     89      1.38       cgd 	void (*TBIAP)(int);
     90      1.38       cgd 	void (*TBIS)(vaddr_t);
     91      1.38       cgd 	int  (*tlbUpdate)(u_int highreg, u_int lowreg);
     92      1.38       cgd 	void (*wbflush)(void);
     93       1.1  jonathan } mips_locore_jumpvec_t;
     94      1.13  jonathan 
     95      1.13  jonathan /* Override writebuffer-drain method. */
     96      1.38       cgd void	mips_set_wbflush(void (*)(void));
     97       1.1  jonathan 
     98      1.23    simonb /* stacktrace() -- print a stack backtrace to the console */
     99      1.38       cgd void	stacktrace(void);
    100      1.23    simonb /* logstacktrace() -- log a stack traceback to msgbuf */
    101      1.38       cgd void	logstacktrace(void);
    102       1.1  jonathan 
    103       1.1  jonathan /*
    104       1.1  jonathan  * The "active" locore-fuction vector, and
    105       1.1  jonathan  */
    106       1.1  jonathan extern mips_locore_jumpvec_t mips_locore_jumpvec;
    107       1.1  jonathan extern mips_locore_jumpvec_t r2000_locore_vec;
    108       1.1  jonathan extern mips_locore_jumpvec_t r4000_locore_vec;
    109      1.31  nisimura extern long *mips_locoresw[];
    110       1.1  jonathan 
    111      1.53   thorpej #if defined(MIPS3) && !defined(MIPS1)
    112      1.11  jonathan #define MachSetPID		mips3_SetPID
    113      1.30  nisimura #define MIPS_TBIAP()		mips3_TBIAP(mips_num_tlb_entries)
    114      1.30  nisimura #define MIPS_TBIS		mips3_TBIS
    115      1.11  jonathan #define MachTLBUpdate		mips3_TLBUpdate
    116      1.22  nisimura #define wbflush()		mips3_wbflush()
    117      1.11  jonathan #define proc_trampoline		mips3_proc_trampoline
    118      1.11  jonathan #endif
    119      1.11  jonathan 
    120      1.53   thorpej #if !defined(MIPS3) && defined(MIPS1)
    121      1.11  jonathan #define MachSetPID		mips1_SetPID
    122      1.30  nisimura #define MIPS_TBIAP()		mips1_TBIAP(mips_num_tlb_entries)
    123      1.30  nisimura #define MIPS_TBIS		mips1_TBIS
    124      1.11  jonathan #define MachTLBUpdate		mips1_TLBUpdate
    125      1.22  nisimura #define wbflush()		mips1_wbflush()
    126      1.11  jonathan #define proc_trampoline		mips1_proc_trampoline
    127      1.11  jonathan #endif
    128      1.11  jonathan 
    129      1.53   thorpej #if defined(MIPS3) && defined(MIPS1)
    130       1.1  jonathan #define MachSetPID		(*(mips_locore_jumpvec.setTLBpid))
    131      1.31  nisimura #define MIPS_TBIAP()		(*(mips_locore_jumpvec.TBIAP))(mips_num_tlb_entries)
    132      1.31  nisimura #define MIPS_TBIS		(*(mips_locore_jumpvec.TBIS))
    133       1.1  jonathan #define MachTLBUpdate		(*(mips_locore_jumpvec.tlbUpdate))
    134      1.22  nisimura #define wbflush()		(*(mips_locore_jumpvec.wbflush))()
    135      1.31  nisimura #define proc_trampoline		(mips_locoresw[1])
    136      1.11  jonathan #endif
    137      1.31  nisimura 
    138      1.31  nisimura #define CPU_IDLE		(mips_locoresw[2])
    139      1.11  jonathan 
    140      1.16    castor /* cpu_switch_resume is called inside locore.S */
    141       1.7  jonathan 
    142       1.7  jonathan /*
    143       1.7  jonathan  * CPU identification, from PRID register.
    144       1.7  jonathan  */
    145      1.40       cgd typedef int mips_prid_t;
    146      1.40       cgd 
    147      1.40       cgd #define	MIPS_PRID_REV(x)	(((x) >>  0) & 0x00ff)
    148      1.40       cgd #define	MIPS_PRID_IMPL(x)	(((x) >>  8) & 0x00ff)
    149      1.45       cgd 
    150      1.45       cgd /* pre-MIPS32 */
    151      1.40       cgd #define	MIPS_PRID_RSVD(x)	(((x) >> 16) & 0xffff)
    152      1.40       cgd #define	MIPS_PRID_REV_MIN(x)	((MIPS_PRID_REV(x) >> 0) & 0x0f)
    153      1.40       cgd #define	MIPS_PRID_REV_MAJ(x)	((MIPS_PRID_REV(x) >> 4) & 0x0f)
    154      1.45       cgd 
    155      1.45       cgd /* MIPS32 */
    156      1.45       cgd #define	MIPS_PRID_CID(x)	(((x) >> 16) & 0x00ff)	/* Company ID */
    157      1.45       cgd #define	    MIPS_PRID_CID_PREHISTORIC	0x00	/* Not MIPS32 */
    158      1.45       cgd #define	    MIPS_PRID_CID_MTI		0x01	/* MIPS Technologies, Inc. */
    159  1.53.2.1   thorpej #define	    MIPS_PRID_CID_ALCHEMY	0x03	/* Alchemy Semiconductor */
    160  1.53.2.1   thorpej #define	    MIPS_PRID_CID_SIBYTE	0x04	/* SiByte */
    161       1.6  jonathan 
    162       1.6  jonathan #ifdef _KERNEL
    163       1.6  jonathan 
    164       1.6  jonathan /*
    165       1.6  jonathan  * Global variables used to communicate CPU type, and parameters
    166       1.6  jonathan  * such as cache size, from locore to higher-level code (e.g., pmap).
    167       1.6  jonathan  */
    168      1.40       cgd 
    169      1.40       cgd extern mips_prid_t cpu_id;
    170      1.40       cgd extern mips_prid_t fpu_id;
    171      1.14  jonathan extern int	mips_num_tlb_entries;
    172      1.52     jeffs 
    173      1.52     jeffs void mips_pagecopy(caddr_t dst, caddr_t src);
    174      1.52     jeffs void mips_pagezero(caddr_t dst);
    175      1.19  jonathan 
    176      1.19  jonathan /*
    177      1.20    simonb  * trapframe argument passed to trap()
    178      1.19  jonathan  */
    179      1.19  jonathan struct trapframe {
    180      1.19  jonathan 	mips_reg_t tf_regs[17];
    181      1.19  jonathan 	mips_reg_t tf_ra;
    182      1.19  jonathan 	mips_reg_t tf_sr;
    183      1.19  jonathan 	mips_reg_t tf_mullo;
    184      1.19  jonathan 	mips_reg_t tf_mulhi;
    185      1.19  jonathan 	mips_reg_t tf_epc;		/* may be changed by trap() call */
    186  1.53.2.2   thorpej 	u_int32_t  tf_ppl;		/* previous priority level */
    187  1.53.2.2   thorpej 	int32_t    tf_pad;		/* for 8 byte aligned */
    188      1.19  jonathan };
    189      1.19  jonathan 
    190      1.19  jonathan /*
    191      1.19  jonathan  * Stack frame for kernel traps. four args passed in registers.
    192      1.19  jonathan  * A trapframe is pointed to by the 5th arg, and a dummy sixth argument
    193      1.19  jonathan  * is used to avoid alignment problems
    194      1.19  jonathan  */
    195      1.19  jonathan 
    196      1.19  jonathan struct kernframe {
    197      1.19  jonathan 	register_t cf_args[4 + 1];
    198      1.19  jonathan 	register_t cf_pad;		/* (for 8 word alignment) */
    199      1.19  jonathan 	register_t cf_sp;
    200      1.19  jonathan 	register_t cf_ra;
    201      1.19  jonathan 	struct trapframe cf_frame;
    202      1.19  jonathan };
    203      1.14  jonathan 
    204       1.6  jonathan #endif
    205       1.1  jonathan 
    206       1.1  jonathan #endif	/* _MIPS_LOCORE_H */
    207