Home | History | Annotate | Line # | Download | only in include
locore.h revision 1.78.36.1.2.1
      1  1.78.36.1.2.1      matt /* $NetBSD: locore.h,v 1.78.36.1.2.1 2009/08/16 03:33:57 matt 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.68       wiz  * 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.70   tsutsui #define _MIPS_LOCORE_H
     26            1.2  jonathan 
     27           1.17    castor #ifndef _LKM
     28           1.32     soren #include "opt_cputype.h"
     29           1.17    castor #endif
     30           1.16    castor 
     31           1.59    simonb #include <mips/cpuregs.h>
     32           1.59    simonb 
     33           1.38       cgd struct tlb;
     34           1.38       cgd 
     35           1.59    simonb uint32_t mips_cp0_cause_read(void);
     36           1.59    simonb void	mips_cp0_cause_write(uint32_t);
     37           1.59    simonb uint32_t mips_cp0_status_read(void);
     38           1.59    simonb void	mips_cp0_status_write(uint32_t);
     39           1.29    simonb 
     40           1.77   tsutsui int _splraise(int);
     41           1.77   tsutsui int _spllower(int);
     42           1.77   tsutsui int _splset(int);
     43           1.77   tsutsui int _splget(void);
     44           1.77   tsutsui void _splnone(void);
     45           1.77   tsutsui void _setsoftintr(int);
     46           1.77   tsutsui void _clrsoftintr(int);
     47           1.77   tsutsui 
     48           1.59    simonb #ifdef MIPS1
     49           1.54    simonb void	mips1_SetPID(int);
     50           1.38       cgd void	mips1_TBIA(int);
     51           1.38       cgd void	mips1_TBIAP(int);
     52           1.38       cgd void	mips1_TBIS(vaddr_t);
     53           1.38       cgd int	mips1_TLBUpdate(u_int, u_int);
     54           1.38       cgd void	mips1_wbflush(void);
     55           1.76      yamt void	mips1_lwp_trampoline(void);
     56      1.78.36.1       snj void	mips1_setfunc_trampoline(void);
     57           1.38       cgd void	mips1_cpu_switch_resume(void);
     58           1.38       cgd 
     59           1.58   thorpej uint32_t tx3900_cp0_config_read(void);
     60           1.59    simonb #endif
     61           1.38       cgd 
     62           1.59    simonb #if defined(MIPS3) || defined(MIPS4)
     63           1.54    simonb void	mips3_SetPID(int);
     64           1.38       cgd void	mips3_TBIA(int);
     65           1.38       cgd void	mips3_TBIAP(int);
     66           1.38       cgd void	mips3_TBIS(vaddr_t);
     67           1.38       cgd int	mips3_TLBUpdate(u_int, u_int);
     68           1.38       cgd void	mips3_TLBRead(int, struct tlb *);
     69           1.71   tsutsui void	mips3_TLBWriteIndexedVPS(int, struct tlb *);
     70           1.38       cgd void	mips3_wbflush(void);
     71           1.76      yamt void	mips3_lwp_trampoline(void);
     72      1.78.36.1       snj void	mips3_setfunc_trampoline(void);
     73           1.38       cgd void	mips3_cpu_switch_resume(void);
     74           1.75  christos void	mips3_pagezero(void *dst);
     75           1.38       cgd 
     76           1.59    simonb #ifdef MIPS3_5900
     77           1.59    simonb void	mips5900_SetPID(int);
     78           1.59    simonb void	mips5900_TBIA(int);
     79           1.59    simonb void	mips5900_TBIAP(int);
     80           1.59    simonb void	mips5900_TBIS(vaddr_t);
     81           1.59    simonb int	mips5900_TLBUpdate(u_int, u_int);
     82           1.59    simonb void	mips5900_TLBRead(int, struct tlb *);
     83           1.71   tsutsui void	mips5900_TLBWriteIndexedVPS(int, struct tlb *);
     84           1.59    simonb void	mips5900_wbflush(void);
     85           1.76      yamt void	mips5900_lwp_trampoline(void);
     86      1.78.36.1       snj void	mips5900_setfunc_trampoline(void);
     87           1.59    simonb void	mips5900_cpu_switch_resume(void);
     88           1.75  christos void	mips5900_pagezero(void *dst);
     89           1.59    simonb #endif
     90           1.59    simonb #endif
     91           1.49       cgd 
     92           1.59    simonb #ifdef MIPS32
     93           1.59    simonb void	mips32_SetPID(int);
     94           1.59    simonb void	mips32_TBIA(int);
     95           1.59    simonb void	mips32_TBIAP(int);
     96           1.59    simonb void	mips32_TBIS(vaddr_t);
     97           1.59    simonb int	mips32_TLBUpdate(u_int, u_int);
     98           1.59    simonb void	mips32_TLBRead(int, struct tlb *);
     99           1.71   tsutsui void	mips32_TLBWriteIndexedVPS(int, struct tlb *);
    100           1.59    simonb void	mips32_wbflush(void);
    101           1.76      yamt void	mips32_lwp_trampoline(void);
    102      1.78.36.1       snj void	mips32_setfunc_trampoline(void);
    103           1.59    simonb void	mips32_cpu_switch_resume(void);
    104           1.59    simonb #endif
    105           1.59    simonb 
    106           1.59    simonb #ifdef MIPS64
    107           1.59    simonb void	mips64_SetPID(int);
    108           1.59    simonb void	mips64_TBIA(int);
    109           1.59    simonb void	mips64_TBIAP(int);
    110           1.59    simonb void	mips64_TBIS(vaddr_t);
    111           1.59    simonb int	mips64_TLBUpdate(u_int, u_int);
    112           1.59    simonb void	mips64_TLBRead(int, struct tlb *);
    113           1.71   tsutsui void	mips64_TLBWriteIndexedVPS(int, struct tlb *);
    114           1.59    simonb void	mips64_wbflush(void);
    115           1.76      yamt void	mips64_lwp_trampoline(void);
    116      1.78.36.1       snj void	mips64_setfunc_trampoline(void);
    117           1.59    simonb void	mips64_cpu_switch_resume(void);
    118           1.75  christos void	mips64_pagezero(void *dst);
    119           1.59    simonb #endif
    120           1.49       cgd 
    121           1.63    simonb #if defined(MIPS3) || defined(MIPS4) || defined(MIPS32) || defined(MIPS64)
    122           1.59    simonb uint32_t mips3_cp0_compare_read(void);
    123           1.59    simonb void	mips3_cp0_compare_write(uint32_t);
    124           1.49       cgd 
    125           1.59    simonb uint32_t mips3_cp0_config_read(void);
    126           1.59    simonb void	mips3_cp0_config_write(uint32_t);
    127           1.63    simonb #if defined(MIPS32) || defined(MIPS64)
    128           1.59    simonb uint32_t mipsNN_cp0_config1_read(void);
    129           1.59    simonb void	mipsNN_cp0_config1_write(uint32_t);
    130           1.63    simonb uint32_t mipsNN_cp0_config2_read(void);
    131           1.63    simonb uint32_t mipsNN_cp0_config3_read(void);
    132           1.63    simonb #endif
    133           1.59    simonb 
    134           1.59    simonb uint32_t mips3_cp0_count_read(void);
    135           1.59    simonb void	mips3_cp0_count_write(uint32_t);
    136           1.59    simonb 
    137           1.59    simonb uint32_t mips3_cp0_wired_read(void);
    138           1.59    simonb void	mips3_cp0_wired_write(uint32_t);
    139           1.69   tsutsui void	mips3_cp0_pg_mask_write(uint32_t);
    140           1.59    simonb 
    141  1.78.36.1.2.1      matt #if defined(__GNUC__) && !defined(__mips_o32)
    142  1.78.36.1.2.1      matt static inline uint64_t
    143  1.78.36.1.2.1      matt mips3_ld(const uint64_t *va)
    144  1.78.36.1.2.1      matt {
    145  1.78.36.1.2.1      matt 	uint64_t rv;
    146  1.78.36.1.2.1      matt #if defined(__mips_o32)
    147  1.78.36.1.2.1      matt 	uint32_t sr;
    148  1.78.36.1.2.1      matt 
    149  1.78.36.1.2.1      matt 	sr = mips_cp0_status_read();
    150  1.78.36.1.2.1      matt 	mips_cp0_status_write(sr & ~MIPS_SR_INT_IE);
    151  1.78.36.1.2.1      matt 
    152  1.78.36.1.2.1      matt 	__asm volatile(
    153  1.78.36.1.2.1      matt 		".set push		\n\t"
    154  1.78.36.1.2.1      matt 		".set mips3		\n\t"
    155  1.78.36.1.2.1      matt 		".set noreorder		\n\t"
    156  1.78.36.1.2.1      matt 		".set noat		\n\t"
    157  1.78.36.1.2.1      matt 		"ld	%M0,0(%1)	\n\t"
    158  1.78.36.1.2.1      matt 		"dsll32	%L0,%M0,0	\n\t"
    159  1.78.36.1.2.1      matt 		"dsra32	%M0,%M0,0	\n\t"		/* high word */
    160  1.78.36.1.2.1      matt 		"dsra32	%L0,%L0,0	\n\t"		/* low word */
    161  1.78.36.1.2.1      matt 		"ld	%0,0(%1)	\n\t"
    162  1.78.36.1.2.1      matt 		".set pop"
    163  1.78.36.1.2.1      matt 	    : "=d"(rv)
    164  1.78.36.1.2.1      matt 	    : "r"(va));
    165  1.78.36.1.2.1      matt 
    166  1.78.36.1.2.1      matt 	mips_cp0_status_write(sr);
    167  1.78.36.1.2.1      matt #elif defined(_LP64)
    168  1.78.36.1.2.1      matt 	rv = *va;
    169  1.78.36.1.2.1      matt #else
    170  1.78.36.1.2.1      matt 	__asm volatile("ld	%0,0(%1)" : "=d"(rv) : "r"(va));
    171  1.78.36.1.2.1      matt #endif
    172  1.78.36.1.2.1      matt 
    173  1.78.36.1.2.1      matt 	return rv;
    174  1.78.36.1.2.1      matt }
    175  1.78.36.1.2.1      matt static inline void
    176  1.78.36.1.2.1      matt mips3_sd(uint64_t *va, uint64_t v)
    177  1.78.36.1.2.1      matt {
    178  1.78.36.1.2.1      matt #if defined(__mips_o32)
    179  1.78.36.1.2.1      matt 	uint32_t sr;
    180  1.78.36.1.2.1      matt 
    181  1.78.36.1.2.1      matt 	sr = mips_cp0_status_read();
    182  1.78.36.1.2.1      matt 	mips_cp0_status_write(sr & ~MIPS_SR_INT_IE);
    183  1.78.36.1.2.1      matt 
    184  1.78.36.1.2.1      matt 	__asm volatile(
    185  1.78.36.1.2.1      matt 		".set push		\n\t"
    186  1.78.36.1.2.1      matt 		".set mips3		\n\t"
    187  1.78.36.1.2.1      matt 		".set noreorder		\n\t"
    188  1.78.36.1.2.1      matt 		".set noat		\n\t"
    189  1.78.36.1.2.1      matt 		"dsll32	%M0,%M0,0	\n\t"
    190  1.78.36.1.2.1      matt 		"dsll32	%L0,%L0,0	\n\t"
    191  1.78.36.1.2.1      matt 		"dsrl32	%L0,%L0,0	\n\t"
    192  1.78.36.1.2.1      matt 		"or	%0,%L0,%M0	\n\t"
    193  1.78.36.1.2.1      matt 		"sd	%0,0(%1)	\n\t"
    194  1.78.36.1.2.1      matt 		".set pop"
    195  1.78.36.1.2.1      matt 	    : "=d"(v) : "0"(v), "r"(va));
    196  1.78.36.1.2.1      matt 
    197  1.78.36.1.2.1      matt 	mips_cp0_status_write(sr);
    198  1.78.36.1.2.1      matt #elif defined(_LP64)
    199  1.78.36.1.2.1      matt 	*va = v;
    200  1.78.36.1.2.1      matt #else
    201  1.78.36.1.2.1      matt 	__asm volatile("sd	%0,0(%1)" :: "r"(v), "r"(va));
    202  1.78.36.1.2.1      matt #endif
    203  1.78.36.1.2.1      matt }
    204  1.78.36.1.2.1      matt #else
    205  1.78.36.1.2.1      matt uint64_t mips3_ld(uint64_t *va);
    206           1.59    simonb void	mips3_sd(uint64_t *, uint64_t);
    207  1.78.36.1.2.1      matt #endif	/* __GNUC__ */
    208           1.63    simonb #endif	/* MIPS3 || MIPS4 || MIPS32 || MIPS64 */
    209           1.59    simonb 
    210           1.63    simonb #if defined(MIPS3) || defined(MIPS4) || defined(MIPS64)
    211           1.74     perry static __inline uint32_t	mips3_lw_a64(uint64_t addr)
    212           1.59    simonb 		    __attribute__((__unused__));
    213           1.74     perry static __inline void	mips3_sw_a64(uint64_t addr, uint32_t val)
    214           1.59    simonb 		    __attribute__ ((__unused__));
    215           1.59    simonb 
    216           1.74     perry static __inline uint32_t
    217           1.59    simonb mips3_lw_a64(uint64_t addr)
    218           1.59    simonb {
    219           1.59    simonb 	uint32_t rv;
    220  1.78.36.1.2.1      matt #if defined(__mips_o32)
    221           1.59    simonb 	uint32_t sr;
    222           1.59    simonb 
    223           1.59    simonb 	sr = mips_cp0_status_read();
    224  1.78.36.1.2.1      matt 	mips_cp0_status_write((sr & ~MIPS_SR_INT_IE) | MIPS3_SR_KX);
    225           1.59    simonb 
    226  1.78.36.1.2.1      matt 	__asm volatile (
    227  1.78.36.1.2.1      matt 		".set push		\n\t"
    228  1.78.36.1.2.1      matt 		".set mips3		\n\t"
    229  1.78.36.1.2.1      matt 		".set noreorder		\n\t"
    230  1.78.36.1.2.1      matt 		".set noat		\n\t"
    231  1.78.36.1.2.1      matt 		"dsll32	%M1,%M1,0	\n\t"
    232  1.78.36.1.2.1      matt 		"dsll32	%L1,%L1,0	\n\t"
    233  1.78.36.1.2.1      matt 		"dsrl32	$L1,%L1,0	\n\t"
    234  1.78.36.1.2.1      matt 		"or	%1,%M1,%L1	\n\t"
    235  1.78.36.1.2.1      matt 		"lw	%0, 0(%1)	\n\t"
    236  1.78.36.1.2.1      matt 		".set pop"
    237  1.78.36.1.2.1      matt 	    : "=r"(rv), "=d"(addr)
    238  1.78.36.1.2.1      matt 	    : "1"(addr)
    239  1.78.36.1.2.1      matt 	    );
    240           1.59    simonb 
    241           1.59    simonb 	mips_cp0_status_write(sr);
    242  1.78.36.1.2.1      matt #elif defined(_LP64)
    243  1.78.36.1.2.1      matt 	rv = *(const uint32_t *)addr;
    244  1.78.36.1.2.1      matt #else
    245  1.78.36.1.2.1      matt 	__asm volatile("lw	%0, 0(%1)" : "=r"(rv) : "d"(addr));
    246  1.78.36.1.2.1      matt #endif
    247           1.59    simonb 	return (rv);
    248           1.59    simonb }
    249           1.59    simonb 
    250           1.74     perry static __inline void
    251           1.59    simonb mips3_sw_a64(uint64_t addr, uint32_t val)
    252           1.59    simonb {
    253  1.78.36.1.2.1      matt #if defined(__mips_o32)
    254           1.59    simonb 	uint32_t sr;
    255           1.59    simonb 
    256           1.59    simonb 	sr = mips_cp0_status_read();
    257  1.78.36.1.2.1      matt 	mips_cp0_status_write((sr & ~MIPS_SR_INT_IE) | MIPS3_SR_KX);
    258           1.59    simonb 
    259  1.78.36.1.2.1      matt 	__asm volatile (
    260  1.78.36.1.2.1      matt 		".set push		\n\t"
    261  1.78.36.1.2.1      matt 		".set mips3		\n\t"
    262  1.78.36.1.2.1      matt 		".set noreorder		\n\t"
    263  1.78.36.1.2.1      matt 		".set noat		\n\t"
    264  1.78.36.1.2.1      matt 		"dsll32	%M0,%M0,0	\n\t"
    265  1.78.36.1.2.1      matt 		"dsll32	%L0,%L0,0	\n\t"
    266  1.78.36.1.2.1      matt 		"dsrl32	$L0,%L0,0	\n\t"
    267  1.78.36.1.2.1      matt 		"or	%0,%M0,%L0	\n\t"
    268  1.78.36.1.2.1      matt 		"sw	%1, 0(%0)	\n\t"
    269  1.78.36.1.2.1      matt 		".set pop"
    270  1.78.36.1.2.1      matt 	    : "=d"(addr): "r"(val), "0"(addr)
    271  1.78.36.1.2.1      matt 	    );
    272           1.44       cgd 
    273           1.59    simonb 	mips_cp0_status_write(sr);
    274  1.78.36.1.2.1      matt #elif defined(_LP64)
    275  1.78.36.1.2.1      matt 	*(uint32_t *)addr = val;
    276  1.78.36.1.2.1      matt #else
    277  1.78.36.1.2.1      matt 	__asm volatile("sw	%1, 0(%0)" :: "d"(addr), "r"(val));
    278  1.78.36.1.2.1      matt #endif
    279           1.59    simonb }
    280           1.63    simonb #endif	/* MIPS3 || MIPS4 || MIPS64 */
    281            1.7  jonathan 
    282            1.1  jonathan /*
    283           1.58   thorpej  * A vector with an entry for each mips-ISA-level dependent
    284            1.1  jonathan  * locore function, and macros which jump through it.
    285           1.58   thorpej  *
    286            1.1  jonathan  * XXX the macro names are chosen to be compatible with the old
    287           1.58   thorpej  * XXX Sprite coding-convention names used in 4.4bsd/pmax.
    288            1.1  jonathan  */
    289            1.1  jonathan typedef struct  {
    290           1.38       cgd 	void (*setTLBpid)(int pid);
    291           1.38       cgd 	void (*TBIAP)(int);
    292           1.38       cgd 	void (*TBIS)(vaddr_t);
    293           1.38       cgd 	int  (*tlbUpdate)(u_int highreg, u_int lowreg);
    294           1.38       cgd 	void (*wbflush)(void);
    295            1.1  jonathan } mips_locore_jumpvec_t;
    296           1.13  jonathan 
    297           1.38       cgd void	mips_set_wbflush(void (*)(void));
    298           1.62    simonb void	mips_wait_idle(void);
    299            1.1  jonathan 
    300           1.38       cgd void	stacktrace(void);
    301           1.38       cgd void	logstacktrace(void);
    302            1.1  jonathan 
    303            1.1  jonathan /*
    304            1.1  jonathan  * The "active" locore-fuction vector, and
    305            1.1  jonathan  */
    306            1.1  jonathan extern mips_locore_jumpvec_t mips_locore_jumpvec;
    307           1.31  nisimura extern long *mips_locoresw[];
    308            1.1  jonathan 
    309           1.59    simonb #if    defined(MIPS1) && !defined(MIPS3) && !defined(MIPS32) && !defined(MIPS64)
    310           1.11  jonathan #define MachSetPID		mips1_SetPID
    311           1.30  nisimura #define MIPS_TBIAP()		mips1_TBIAP(mips_num_tlb_entries)
    312           1.30  nisimura #define MIPS_TBIS		mips1_TBIS
    313           1.11  jonathan #define MachTLBUpdate		mips1_TLBUpdate
    314           1.22  nisimura #define wbflush()		mips1_wbflush()
    315           1.76      yamt #define lwp_trampoline		mips1_lwp_trampoline
    316      1.78.36.1       snj #define setfunc_trampoline	mips1_setfunc_trampoline
    317           1.60       uch #elif !defined(MIPS1) &&  defined(MIPS3) && !defined(MIPS32) && !defined(MIPS64) && !defined(MIPS3_5900)
    318           1.59    simonb #define MachSetPID		mips3_SetPID
    319           1.59    simonb #define MIPS_TBIAP()		mips3_TBIAP(mips_num_tlb_entries)
    320           1.59    simonb #define MIPS_TBIS		mips3_TBIS
    321           1.59    simonb #define MachTLBUpdate		mips3_TLBUpdate
    322           1.71   tsutsui #define MachTLBWriteIndexedVPS	mips3_TLBWriteIndexedVPS
    323           1.76      yamt #define lwp_trampoline		mips3_lwp_trampoline
    324      1.78.36.1       snj #define setfunc_trampoline	mips3_setfunc_trampoline
    325           1.59    simonb #define wbflush()		mips3_wbflush()
    326           1.59    simonb #elif !defined(MIPS1) && !defined(MIPS3) &&  defined(MIPS32) && !defined(MIPS64)
    327           1.70   tsutsui #define MachSetPID		mips32_SetPID
    328           1.70   tsutsui #define MIPS_TBIAP()		mips32_TBIAP(mips_num_tlb_entries)
    329           1.70   tsutsui #define MIPS_TBIS		mips32_TBIS
    330           1.70   tsutsui #define MachTLBUpdate		mips32_TLBUpdate
    331           1.71   tsutsui #define MachTLBWriteIndexedVPS	mips32_TLBWriteIndexedVPS
    332           1.76      yamt #define lwp_trampoline		mips32_lwp_trampoline
    333      1.78.36.1       snj #define setfunc_trampoline	mips32_setfunc_trampoline
    334           1.59    simonb #define wbflush()		mips32_wbflush()
    335           1.59    simonb #elif !defined(MIPS1) && !defined(MIPS3) && !defined(MIPS32) &&  defined(MIPS64)
    336           1.59    simonb  /* all common with mips3 */
    337           1.59    simonb #define MachSetPID		mips64_SetPID
    338           1.59    simonb #define MIPS_TBIAP()		mips64_TBIAP(mips_num_tlb_entries)
    339           1.59    simonb #define MIPS_TBIS		mips64_TBIS
    340           1.59    simonb #define MachTLBUpdate		mips64_TLBUpdate
    341           1.71   tsutsui #define MachTLBWriteIndexedVPS	mips64_TLBWriteIndexedVPS
    342           1.76      yamt #define lwp_trampoline		mips64_lwp_trampoline
    343      1.78.36.1       snj #define setfunc_trampoline	mips64_setfunc_trampoline
    344           1.59    simonb #define wbflush()		mips64_wbflush()
    345           1.60       uch #elif !defined(MIPS1) &&  defined(MIPS3) && !defined(MIPS32) && !defined(MIPS64) && defined(MIPS3_5900)
    346           1.60       uch #define MachSetPID		mips5900_SetPID
    347           1.60       uch #define MIPS_TBIAP()		mips5900_TBIAP(mips_num_tlb_entries)
    348           1.60       uch #define MIPS_TBIS		mips5900_TBIS
    349           1.60       uch #define MachTLBUpdate		mips5900_TLBUpdate
    350           1.71   tsutsui #define MachTLBWriteIndexedVPS	mips5900_TLBWriteIndexedVPS
    351           1.76      yamt #define lwp_trampoline		mips5900_lwp_trampoline
    352      1.78.36.1       snj #define setfunc_trampoline	mips5900_setfunc_trampoline
    353           1.60       uch #define wbflush()		mips5900_wbflush()
    354           1.59    simonb #else
    355            1.1  jonathan #define MachSetPID		(*(mips_locore_jumpvec.setTLBpid))
    356           1.31  nisimura #define MIPS_TBIAP()		(*(mips_locore_jumpvec.TBIAP))(mips_num_tlb_entries)
    357           1.31  nisimura #define MIPS_TBIS		(*(mips_locore_jumpvec.TBIS))
    358            1.1  jonathan #define MachTLBUpdate		(*(mips_locore_jumpvec.tlbUpdate))
    359           1.22  nisimura #define wbflush()		(*(mips_locore_jumpvec.wbflush))()
    360           1.76      yamt #define lwp_trampoline		(mips_locoresw[1])
    361      1.78.36.1       snj #define setfunc_trampoline	(mips_locoresw[3])
    362           1.11  jonathan #endif
    363           1.31  nisimura 
    364           1.31  nisimura #define CPU_IDLE		(mips_locoresw[2])
    365           1.11  jonathan 
    366           1.16    castor /* cpu_switch_resume is called inside locore.S */
    367            1.7  jonathan 
    368            1.7  jonathan /*
    369            1.7  jonathan  * CPU identification, from PRID register.
    370            1.7  jonathan  */
    371           1.40       cgd typedef int mips_prid_t;
    372           1.40       cgd 
    373           1.70   tsutsui #define MIPS_PRID_REV(x)	(((x) >>  0) & 0x00ff)
    374           1.70   tsutsui #define MIPS_PRID_IMPL(x)	(((x) >>  8) & 0x00ff)
    375           1.45       cgd 
    376           1.59    simonb /* pre-MIPS32/64 */
    377           1.70   tsutsui #define MIPS_PRID_RSVD(x)	(((x) >> 16) & 0xffff)
    378           1.70   tsutsui #define MIPS_PRID_REV_MIN(x)	((MIPS_PRID_REV(x) >> 0) & 0x0f)
    379           1.70   tsutsui #define MIPS_PRID_REV_MAJ(x)	((MIPS_PRID_REV(x) >> 4) & 0x0f)
    380           1.45       cgd 
    381           1.59    simonb /* MIPS32/64 */
    382           1.70   tsutsui #define MIPS_PRID_CID(x)	(((x) >> 16) & 0x00ff)	/* Company ID */
    383           1.70   tsutsui #define     MIPS_PRID_CID_PREHISTORIC	0x00	/* Not MIPS32/64 */
    384           1.70   tsutsui #define     MIPS_PRID_CID_MTI		0x01	/* MIPS Technologies, Inc. */
    385           1.70   tsutsui #define     MIPS_PRID_CID_BROADCOM	0x02	/* Broadcom */
    386           1.70   tsutsui #define     MIPS_PRID_CID_ALCHEMY	0x03	/* Alchemy Semiconductor */
    387           1.70   tsutsui #define     MIPS_PRID_CID_SIBYTE	0x04	/* SiByte */
    388           1.70   tsutsui #define     MIPS_PRID_CID_SANDCRAFT	0x05	/* SandCraft */
    389           1.70   tsutsui #define     MIPS_PRID_CID_PHILIPS	0x06	/* Philips */
    390           1.70   tsutsui #define     MIPS_PRID_CID_TOSHIBA	0x07	/* Toshiba */
    391           1.70   tsutsui #define     MIPS_PRID_CID_LSI		0x08	/* LSI */
    392           1.67    simonb 				/*	0x09	unannounced */
    393           1.67    simonb 				/*	0x0a	unannounced */
    394           1.70   tsutsui #define     MIPS_PRID_CID_LEXRA		0x0b	/* Lexra */
    395           1.70   tsutsui #define MIPS_PRID_COPTS(x)	(((x) >> 24) & 0x00ff)	/* Company Options */
    396            1.6  jonathan 
    397            1.6  jonathan #ifdef _KERNEL
    398            1.6  jonathan /*
    399            1.6  jonathan  * Global variables used to communicate CPU type, and parameters
    400            1.6  jonathan  * such as cache size, from locore to higher-level code (e.g., pmap).
    401            1.6  jonathan  */
    402           1.40       cgd 
    403           1.40       cgd extern mips_prid_t cpu_id;
    404           1.40       cgd extern mips_prid_t fpu_id;
    405           1.14  jonathan extern int	mips_num_tlb_entries;
    406           1.52     jeffs 
    407           1.75  christos void mips_pagecopy(void *dst, void *src);
    408           1.75  christos void mips_pagezero(void *dst);
    409           1.19  jonathan 
    410           1.59    simonb #ifdef __HAVE_MIPS_MACHDEP_CACHE_CONFIG
    411           1.59    simonb void mips_machdep_cache_config(void);
    412           1.59    simonb #endif
    413           1.59    simonb 
    414           1.19  jonathan /*
    415           1.20    simonb  * trapframe argument passed to trap()
    416           1.19  jonathan  */
    417           1.64   thorpej 
    418           1.70   tsutsui #define TF_AST		0
    419           1.70   tsutsui #define TF_V0		1
    420           1.70   tsutsui #define TF_V1		2
    421           1.70   tsutsui #define TF_A0		3
    422           1.70   tsutsui #define TF_A1		4
    423           1.70   tsutsui #define TF_A2		5
    424           1.70   tsutsui #define TF_A3		6
    425           1.70   tsutsui #define TF_T0		7
    426           1.70   tsutsui #define TF_T1		8
    427           1.70   tsutsui #define TF_T2		9
    428           1.70   tsutsui #define TF_T3		10
    429           1.64   thorpej 
    430           1.64   thorpej #if defined(__mips_n32) || defined(__mips_n64)
    431           1.70   tsutsui #define TF_A4		11
    432           1.70   tsutsui #define TF_A5		12
    433           1.70   tsutsui #define TF_A6		13
    434           1.70   tsutsui #define TF_A7		14
    435           1.64   thorpej #else
    436           1.70   tsutsui #define TF_T4		11
    437           1.70   tsutsui #define TF_T5		12
    438           1.70   tsutsui #define TF_T6		13
    439           1.70   tsutsui #define TF_T7		14
    440           1.64   thorpej #endif /* __mips_n32 || __mips_n64 */
    441           1.64   thorpej 
    442           1.70   tsutsui #define TF_TA0		11
    443           1.70   tsutsui #define TF_TA1		12
    444           1.70   tsutsui #define TF_TA2		13
    445           1.70   tsutsui #define TF_TA3		14
    446           1.70   tsutsui 
    447           1.70   tsutsui #define TF_T8		15
    448           1.70   tsutsui #define TF_T9		16
    449           1.70   tsutsui 
    450           1.70   tsutsui #define TF_RA		17
    451           1.70   tsutsui #define TF_SR		18
    452           1.70   tsutsui #define TF_MULLO	19
    453           1.70   tsutsui #define TF_MULHI	20
    454           1.70   tsutsui #define TF_EPC		21		/* may be changed by trap() call */
    455           1.65   thorpej 
    456           1.70   tsutsui #define TF_NREGS	22
    457           1.64   thorpej 
    458           1.19  jonathan struct trapframe {
    459           1.64   thorpej 	mips_reg_t tf_regs[TF_NREGS];
    460           1.57       uch 	u_int32_t  tf_ppl;		/* previous priority level */
    461           1.57       uch 	int32_t    tf_pad;		/* for 8 byte aligned */
    462           1.19  jonathan };
    463           1.19  jonathan 
    464           1.19  jonathan /*
    465           1.19  jonathan  * Stack frame for kernel traps. four args passed in registers.
    466           1.19  jonathan  * A trapframe is pointed to by the 5th arg, and a dummy sixth argument
    467           1.19  jonathan  * is used to avoid alignment problems
    468           1.19  jonathan  */
    469           1.19  jonathan 
    470           1.19  jonathan struct kernframe {
    471  1.78.36.1.2.1      matt #if defined(__mips_o32) || defined(__mips_o64)
    472           1.19  jonathan 	register_t cf_args[4 + 1];
    473  1.78.36.1.2.1      matt #if defined(__mips_o32)
    474           1.19  jonathan 	register_t cf_pad;		/* (for 8 word alignment) */
    475  1.78.36.1.2.1      matt #endif
    476  1.78.36.1.2.1      matt #endif
    477  1.78.36.1.2.1      matt #if defined(__mips_n32) || defined(__mips_n64)
    478  1.78.36.1.2.1      matt 	register_t cf_args[8 + 1];
    479  1.78.36.1.2.1      matt #endif
    480           1.19  jonathan 	register_t cf_sp;
    481           1.19  jonathan 	register_t cf_ra;
    482           1.19  jonathan 	struct trapframe cf_frame;
    483           1.19  jonathan };
    484           1.61    simonb #endif	/* _KERNEL */
    485            1.1  jonathan #endif	/* _MIPS_LOCORE_H */
    486