Home | History | Annotate | Line # | Download | only in include
locore.h revision 1.78.36.1.2.10
      1  1.78.36.1.2.10     cyber /* $NetBSD: locore.h,v 1.78.36.1.2.10 2010/01/20 20:40:45 cyber 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.78.36.1.2.8      matt struct tlbmask;
     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.78.36.1.2.8      matt void	mips1_tlb_set_asid(uint32_t);
     50   1.78.36.1.2.8      matt void	mips1_tlb_invalidate_all(size_t);
     51   1.78.36.1.2.9      matt void	mips1_tlb_invalidate_asids(size_t, uint32_t, uint32_t);
     52   1.78.36.1.2.8      matt void	mips1_tlb_invalidate_addr(vaddr_t);
     53   1.78.36.1.2.8      matt int	mips1_tlb_update(vaddr_t, uint32_t);
     54   1.78.36.1.2.8      matt void	mips1_tlb_read_indexed(size_t, struct tlbmask *);
     55            1.38       cgd void	mips1_wbflush(void);
     56            1.76      yamt void	mips1_lwp_trampoline(void);
     57       1.78.36.1       snj void	mips1_setfunc_trampoline(void);
     58            1.38       cgd void	mips1_cpu_switch_resume(void);
     59            1.38       cgd 
     60            1.58   thorpej uint32_t tx3900_cp0_config_read(void);
     61            1.59    simonb #endif
     62            1.38       cgd 
     63            1.59    simonb #if defined(MIPS3) || defined(MIPS4)
     64   1.78.36.1.2.8      matt void	mips3_tlb_set_asid(uint32_t);
     65   1.78.36.1.2.8      matt void	mips3_tlb_invalidate_all(size_t);
     66   1.78.36.1.2.9      matt void	mips3_tlb_invalidate_asids(size_t, uint32_t, uint32_t);
     67   1.78.36.1.2.8      matt void	mips3_tlb_invalidate_addr(vaddr_t);
     68   1.78.36.1.2.8      matt int	mips3_tlb_update(vaddr_t, uint32_t);
     69   1.78.36.1.2.8      matt void	mips3_tlb_read_indexed(size_t, struct tlbmask *);
     70   1.78.36.1.2.8      matt void	mips3_tlb_write_indexed_VPS(size_t, struct tlbmask *);
     71            1.38       cgd void	mips3_wbflush(void);
     72            1.76      yamt void	mips3_lwp_trampoline(void);
     73       1.78.36.1       snj void	mips3_setfunc_trampoline(void);
     74            1.38       cgd void	mips3_cpu_switch_resume(void);
     75            1.75  christos void	mips3_pagezero(void *dst);
     76            1.38       cgd 
     77            1.59    simonb #ifdef MIPS3_5900
     78   1.78.36.1.2.8      matt void	mips5900_tlb_set_asid(uint32_t);
     79   1.78.36.1.2.8      matt void	mips5900_tlb_invalidate_all(size_t);
     80   1.78.36.1.2.9      matt void	mips5900_tlb_invalidate_asids(size_t, uint32_t, uint32_t);
     81   1.78.36.1.2.8      matt void	mips5900_tlb_invalidate_addr(vaddr_t);
     82   1.78.36.1.2.8      matt int	mips5900_tlb_update(vaddr_t, uint32_t);
     83   1.78.36.1.2.8      matt void	mips5900_tlb_read_indexed(size_t, struct tlbmask *);
     84   1.78.36.1.2.8      matt void	mips5900_tlb_write_indexed_VPS(size_t, struct tlbmask *);
     85            1.59    simonb void	mips5900_wbflush(void);
     86            1.76      yamt void	mips5900_lwp_trampoline(void);
     87       1.78.36.1       snj void	mips5900_setfunc_trampoline(void);
     88            1.59    simonb void	mips5900_cpu_switch_resume(void);
     89            1.75  christos void	mips5900_pagezero(void *dst);
     90            1.59    simonb #endif
     91            1.59    simonb #endif
     92            1.49       cgd 
     93            1.59    simonb #ifdef MIPS32
     94   1.78.36.1.2.8      matt void	mips32_tlb_set_asid(uint32_t);
     95   1.78.36.1.2.8      matt void	mips32_tlb_invalidate_all(size_t);
     96   1.78.36.1.2.9      matt void	mips32_tlb_invalidate_asids(size_t, uint32_t, uint32_t);
     97   1.78.36.1.2.8      matt void	mips32_tlb_invalidate_addr(vaddr_t);
     98   1.78.36.1.2.8      matt int	mips32_tlb_update(vaddr_t, uint32_t);
     99   1.78.36.1.2.8      matt void	mips32_tlb_read_indexed(size_t, struct tlbmask *);
    100   1.78.36.1.2.8      matt void	mips32_tlb_write_indexed_VPS(size_t, struct tlbmask *);
    101            1.59    simonb void	mips32_wbflush(void);
    102            1.76      yamt void	mips32_lwp_trampoline(void);
    103       1.78.36.1       snj void	mips32_setfunc_trampoline(void);
    104            1.59    simonb void	mips32_cpu_switch_resume(void);
    105            1.59    simonb #endif
    106            1.59    simonb 
    107            1.59    simonb #ifdef MIPS64
    108   1.78.36.1.2.8      matt void	mips64_tlb_set_asid(uint32_t);
    109   1.78.36.1.2.8      matt void	mips64_tlb_invalidate_all(size_t);
    110   1.78.36.1.2.9      matt void	mips64_tlb_invalidate_asids(size_t, uint32_t, uint32_t);
    111   1.78.36.1.2.8      matt void	mips64_tlb_invalidate_addr(vaddr_t);
    112   1.78.36.1.2.8      matt int	mips64_tlb_update(vaddr_t, uint32_t);
    113   1.78.36.1.2.8      matt void	mips64_tlb_read_indexed(size_t, struct tlbmask *);
    114   1.78.36.1.2.8      matt void	mips64_tlb_write_indexed_VPS(size_t, struct tlbmask *);
    115            1.59    simonb void	mips64_wbflush(void);
    116            1.76      yamt void	mips64_lwp_trampoline(void);
    117       1.78.36.1       snj void	mips64_setfunc_trampoline(void);
    118            1.59    simonb void	mips64_cpu_switch_resume(void);
    119            1.75  christos void	mips64_pagezero(void *dst);
    120            1.59    simonb #endif
    121            1.49       cgd 
    122            1.63    simonb #if defined(MIPS3) || defined(MIPS4) || defined(MIPS32) || defined(MIPS64)
    123            1.59    simonb uint32_t mips3_cp0_compare_read(void);
    124            1.59    simonb void	mips3_cp0_compare_write(uint32_t);
    125            1.49       cgd 
    126            1.59    simonb uint32_t mips3_cp0_config_read(void);
    127            1.59    simonb void	mips3_cp0_config_write(uint32_t);
    128            1.63    simonb #if defined(MIPS32) || defined(MIPS64)
    129            1.59    simonb uint32_t mipsNN_cp0_config1_read(void);
    130            1.59    simonb void	mipsNN_cp0_config1_write(uint32_t);
    131            1.63    simonb uint32_t mipsNN_cp0_config2_read(void);
    132            1.63    simonb uint32_t mipsNN_cp0_config3_read(void);
    133            1.63    simonb #endif
    134            1.59    simonb 
    135            1.59    simonb uint32_t mips3_cp0_count_read(void);
    136            1.59    simonb void	mips3_cp0_count_write(uint32_t);
    137            1.59    simonb 
    138            1.59    simonb uint32_t mips3_cp0_wired_read(void);
    139            1.59    simonb void	mips3_cp0_wired_write(uint32_t);
    140            1.69   tsutsui void	mips3_cp0_pg_mask_write(uint32_t);
    141            1.59    simonb 
    142   1.78.36.1.2.1      matt #if defined(__GNUC__) && !defined(__mips_o32)
    143   1.78.36.1.2.1      matt static inline uint64_t
    144   1.78.36.1.2.5      matt mips3_ld(const volatile uint64_t *va)
    145   1.78.36.1.2.1      matt {
    146   1.78.36.1.2.1      matt 	uint64_t rv;
    147   1.78.36.1.2.1      matt #if defined(__mips_o32)
    148   1.78.36.1.2.1      matt 	uint32_t sr;
    149   1.78.36.1.2.1      matt 
    150   1.78.36.1.2.1      matt 	sr = mips_cp0_status_read();
    151   1.78.36.1.2.1      matt 	mips_cp0_status_write(sr & ~MIPS_SR_INT_IE);
    152   1.78.36.1.2.1      matt 
    153   1.78.36.1.2.1      matt 	__asm volatile(
    154   1.78.36.1.2.1      matt 		".set push		\n\t"
    155   1.78.36.1.2.1      matt 		".set mips3		\n\t"
    156   1.78.36.1.2.1      matt 		".set noreorder		\n\t"
    157   1.78.36.1.2.1      matt 		".set noat		\n\t"
    158   1.78.36.1.2.1      matt 		"ld	%M0,0(%1)	\n\t"
    159   1.78.36.1.2.1      matt 		"dsll32	%L0,%M0,0	\n\t"
    160   1.78.36.1.2.1      matt 		"dsra32	%M0,%M0,0	\n\t"		/* high word */
    161   1.78.36.1.2.1      matt 		"dsra32	%L0,%L0,0	\n\t"		/* low word */
    162   1.78.36.1.2.1      matt 		"ld	%0,0(%1)	\n\t"
    163   1.78.36.1.2.1      matt 		".set pop"
    164   1.78.36.1.2.1      matt 	    : "=d"(rv)
    165   1.78.36.1.2.1      matt 	    : "r"(va));
    166   1.78.36.1.2.1      matt 
    167   1.78.36.1.2.1      matt 	mips_cp0_status_write(sr);
    168   1.78.36.1.2.1      matt #elif defined(_LP64)
    169   1.78.36.1.2.1      matt 	rv = *va;
    170   1.78.36.1.2.1      matt #else
    171   1.78.36.1.2.1      matt 	__asm volatile("ld	%0,0(%1)" : "=d"(rv) : "r"(va));
    172   1.78.36.1.2.1      matt #endif
    173   1.78.36.1.2.1      matt 
    174   1.78.36.1.2.1      matt 	return rv;
    175   1.78.36.1.2.1      matt }
    176   1.78.36.1.2.1      matt static inline void
    177   1.78.36.1.2.5      matt mips3_sd(volatile uint64_t *va, uint64_t v)
    178   1.78.36.1.2.1      matt {
    179   1.78.36.1.2.1      matt #if defined(__mips_o32)
    180   1.78.36.1.2.1      matt 	uint32_t sr;
    181   1.78.36.1.2.1      matt 
    182   1.78.36.1.2.1      matt 	sr = mips_cp0_status_read();
    183   1.78.36.1.2.1      matt 	mips_cp0_status_write(sr & ~MIPS_SR_INT_IE);
    184   1.78.36.1.2.1      matt 
    185   1.78.36.1.2.1      matt 	__asm volatile(
    186   1.78.36.1.2.1      matt 		".set push		\n\t"
    187   1.78.36.1.2.1      matt 		".set mips3		\n\t"
    188   1.78.36.1.2.1      matt 		".set noreorder		\n\t"
    189   1.78.36.1.2.1      matt 		".set noat		\n\t"
    190   1.78.36.1.2.1      matt 		"dsll32	%M0,%M0,0	\n\t"
    191   1.78.36.1.2.1      matt 		"dsll32	%L0,%L0,0	\n\t"
    192   1.78.36.1.2.1      matt 		"dsrl32	%L0,%L0,0	\n\t"
    193   1.78.36.1.2.1      matt 		"or	%0,%L0,%M0	\n\t"
    194   1.78.36.1.2.1      matt 		"sd	%0,0(%1)	\n\t"
    195   1.78.36.1.2.1      matt 		".set pop"
    196   1.78.36.1.2.1      matt 	    : "=d"(v) : "0"(v), "r"(va));
    197   1.78.36.1.2.1      matt 
    198   1.78.36.1.2.1      matt 	mips_cp0_status_write(sr);
    199   1.78.36.1.2.1      matt #elif defined(_LP64)
    200   1.78.36.1.2.1      matt 	*va = v;
    201   1.78.36.1.2.1      matt #else
    202   1.78.36.1.2.1      matt 	__asm volatile("sd	%0,0(%1)" :: "r"(v), "r"(va));
    203   1.78.36.1.2.1      matt #endif
    204   1.78.36.1.2.1      matt }
    205   1.78.36.1.2.1      matt #else
    206   1.78.36.1.2.5      matt uint64_t mips3_ld(volatile uint64_t *va);
    207   1.78.36.1.2.5      matt void	mips3_sd(volatile uint64_t *, uint64_t);
    208   1.78.36.1.2.1      matt #endif	/* __GNUC__ */
    209            1.63    simonb #endif	/* MIPS3 || MIPS4 || MIPS32 || MIPS64 */
    210            1.59    simonb 
    211            1.63    simonb #if defined(MIPS3) || defined(MIPS4) || defined(MIPS64)
    212            1.74     perry static __inline uint32_t	mips3_lw_a64(uint64_t addr)
    213            1.59    simonb 		    __attribute__((__unused__));
    214            1.74     perry static __inline void	mips3_sw_a64(uint64_t addr, uint32_t val)
    215            1.59    simonb 		    __attribute__ ((__unused__));
    216            1.59    simonb 
    217            1.74     perry static __inline uint32_t
    218            1.59    simonb mips3_lw_a64(uint64_t addr)
    219            1.59    simonb {
    220            1.59    simonb 	uint32_t rv;
    221   1.78.36.1.2.1      matt #if defined(__mips_o32)
    222            1.59    simonb 	uint32_t sr;
    223            1.59    simonb 
    224            1.59    simonb 	sr = mips_cp0_status_read();
    225   1.78.36.1.2.1      matt 	mips_cp0_status_write((sr & ~MIPS_SR_INT_IE) | MIPS3_SR_KX);
    226            1.59    simonb 
    227   1.78.36.1.2.1      matt 	__asm volatile (
    228   1.78.36.1.2.1      matt 		".set push		\n\t"
    229   1.78.36.1.2.1      matt 		".set mips3		\n\t"
    230   1.78.36.1.2.1      matt 		".set noreorder		\n\t"
    231   1.78.36.1.2.1      matt 		".set noat		\n\t"
    232   1.78.36.1.2.1      matt 		"dsll32	%M1,%M1,0	\n\t"
    233   1.78.36.1.2.1      matt 		"dsll32	%L1,%L1,0	\n\t"
    234  1.78.36.1.2.10     cyber 		"dsrl32	%L1,%L1,0	\n\t"
    235   1.78.36.1.2.1      matt 		"or	%1,%M1,%L1	\n\t"
    236   1.78.36.1.2.1      matt 		"lw	%0, 0(%1)	\n\t"
    237   1.78.36.1.2.1      matt 		".set pop"
    238   1.78.36.1.2.1      matt 	    : "=r"(rv), "=d"(addr)
    239   1.78.36.1.2.1      matt 	    : "1"(addr)
    240   1.78.36.1.2.1      matt 	    );
    241            1.59    simonb 
    242            1.59    simonb 	mips_cp0_status_write(sr);
    243   1.78.36.1.2.1      matt #elif defined(_LP64)
    244   1.78.36.1.2.1      matt 	rv = *(const uint32_t *)addr;
    245   1.78.36.1.2.1      matt #else
    246   1.78.36.1.2.1      matt 	__asm volatile("lw	%0, 0(%1)" : "=r"(rv) : "d"(addr));
    247   1.78.36.1.2.1      matt #endif
    248            1.59    simonb 	return (rv);
    249            1.59    simonb }
    250            1.59    simonb 
    251            1.74     perry static __inline void
    252            1.59    simonb mips3_sw_a64(uint64_t addr, uint32_t val)
    253            1.59    simonb {
    254   1.78.36.1.2.1      matt #if defined(__mips_o32)
    255            1.59    simonb 	uint32_t sr;
    256            1.59    simonb 
    257            1.59    simonb 	sr = mips_cp0_status_read();
    258   1.78.36.1.2.1      matt 	mips_cp0_status_write((sr & ~MIPS_SR_INT_IE) | MIPS3_SR_KX);
    259            1.59    simonb 
    260   1.78.36.1.2.1      matt 	__asm volatile (
    261   1.78.36.1.2.1      matt 		".set push		\n\t"
    262   1.78.36.1.2.1      matt 		".set mips3		\n\t"
    263   1.78.36.1.2.1      matt 		".set noreorder		\n\t"
    264   1.78.36.1.2.1      matt 		".set noat		\n\t"
    265   1.78.36.1.2.1      matt 		"dsll32	%M0,%M0,0	\n\t"
    266   1.78.36.1.2.1      matt 		"dsll32	%L0,%L0,0	\n\t"
    267  1.78.36.1.2.10     cyber 		"dsrl32	%L0,%L0,0	\n\t"
    268   1.78.36.1.2.1      matt 		"or	%0,%M0,%L0	\n\t"
    269   1.78.36.1.2.1      matt 		"sw	%1, 0(%0)	\n\t"
    270   1.78.36.1.2.1      matt 		".set pop"
    271   1.78.36.1.2.1      matt 	    : "=d"(addr): "r"(val), "0"(addr)
    272   1.78.36.1.2.1      matt 	    );
    273            1.44       cgd 
    274            1.59    simonb 	mips_cp0_status_write(sr);
    275   1.78.36.1.2.1      matt #elif defined(_LP64)
    276   1.78.36.1.2.1      matt 	*(uint32_t *)addr = val;
    277   1.78.36.1.2.1      matt #else
    278   1.78.36.1.2.1      matt 	__asm volatile("sw	%1, 0(%0)" :: "d"(addr), "r"(val));
    279   1.78.36.1.2.1      matt #endif
    280            1.59    simonb }
    281            1.63    simonb #endif	/* MIPS3 || MIPS4 || MIPS64 */
    282             1.7  jonathan 
    283             1.1  jonathan /*
    284            1.58   thorpej  * A vector with an entry for each mips-ISA-level dependent
    285             1.1  jonathan  * locore function, and macros which jump through it.
    286            1.58   thorpej  *
    287             1.1  jonathan  * XXX the macro names are chosen to be compatible with the old
    288            1.58   thorpej  * XXX Sprite coding-convention names used in 4.4bsd/pmax.
    289             1.1  jonathan  */
    290             1.1  jonathan typedef struct  {
    291   1.78.36.1.2.8      matt 	void (*ljv_tlb_set_asid)(uint32_t pid);
    292   1.78.36.1.2.9      matt 	void (*ljv_tlb_invalidate_asids)(size_t, uint32_t, uint32_t);
    293   1.78.36.1.2.8      matt 	void (*ljv_tlb_invalidate_addr)(vaddr_t);
    294   1.78.36.1.2.8      matt 	int  (*ljv_tlb_update)(vaddr_t, uint32_t);
    295   1.78.36.1.2.8      matt 	void (*ljv_tlb_read_indexed)(size_t, struct tlbmask *);
    296   1.78.36.1.2.8      matt 	void (*ljv_wbflush)(void);
    297             1.1  jonathan } mips_locore_jumpvec_t;
    298            1.13  jonathan 
    299            1.38       cgd void	mips_set_wbflush(void (*)(void));
    300            1.62    simonb void	mips_wait_idle(void);
    301             1.1  jonathan 
    302            1.38       cgd void	stacktrace(void);
    303            1.38       cgd void	logstacktrace(void);
    304             1.1  jonathan 
    305   1.78.36.1.2.2      matt struct locoresw {
    306   1.78.36.1.2.2      matt 	uintptr_t lsw_cpu_switch_resume;
    307   1.78.36.1.2.2      matt 	uintptr_t lsw_lwp_trampoline;
    308   1.78.36.1.2.2      matt 	void (*lsw_cpu_idle)(void);
    309   1.78.36.1.2.2      matt 	uintptr_t lsw_setfunc_trampoline;
    310   1.78.36.1.2.9      matt 	void (*lsw_boot_secondary_processors)(void);
    311   1.78.36.1.2.2      matt };
    312   1.78.36.1.2.2      matt 
    313   1.78.36.1.2.7      matt struct mips_vmfreelist {
    314   1.78.36.1.2.7      matt 	paddr_t fl_start;
    315   1.78.36.1.2.7      matt 	paddr_t fl_end;
    316   1.78.36.1.2.7      matt 	int fl_freelist;
    317   1.78.36.1.2.7      matt };
    318   1.78.36.1.2.7      matt 
    319             1.1  jonathan /*
    320             1.1  jonathan  * The "active" locore-fuction vector, and
    321             1.1  jonathan  */
    322             1.1  jonathan extern mips_locore_jumpvec_t mips_locore_jumpvec;
    323   1.78.36.1.2.2      matt extern struct locoresw mips_locoresw;
    324             1.1  jonathan 
    325            1.59    simonb #if    defined(MIPS1) && !defined(MIPS3) && !defined(MIPS32) && !defined(MIPS64)
    326   1.78.36.1.2.8      matt #define tlb_set_asid		mips1_tlb_set_asid
    327   1.78.36.1.2.9      matt #define tlb_invalidate_asids(asid_lo, asid_hi) \
    328   1.78.36.1.2.9      matt 		mips1_tlb_invalidate_asids(mips_options.mips_num_tlb_entries, asid_lo, asid_hi)
    329   1.78.36.1.2.8      matt #define tlb_invalidate_addr	mips1_tlb_invalidate_addr
    330   1.78.36.1.2.9      matt #define tlb_invalidate_asid	mips1_tlb_invalidate_asid
    331   1.78.36.1.2.8      matt #define tlb_update		mips1_tlb_update
    332   1.78.36.1.2.8      matt #define tlb_read_indexed	mips1_tlb_read_indexed
    333            1.22  nisimura #define wbflush()		mips1_wbflush()
    334            1.76      yamt #define lwp_trampoline		mips1_lwp_trampoline
    335       1.78.36.1       snj #define setfunc_trampoline	mips1_setfunc_trampoline
    336            1.60       uch #elif !defined(MIPS1) &&  defined(MIPS3) && !defined(MIPS32) && !defined(MIPS64) && !defined(MIPS3_5900)
    337   1.78.36.1.2.8      matt #define tlb_set_asid		mips3_tlb_set_asid
    338   1.78.36.1.2.9      matt #define tlb_invalidate_asids(asid_lo, asid_hi) \
    339   1.78.36.1.2.9      matt 		mips3_tlb_invalidate_asids(mips_options.mips_num_tlb_entries, asid_lo, asid_hi)
    340   1.78.36.1.2.8      matt #define tlb_invalidate_addr	mips3_tlb_invalidate_addr
    341   1.78.36.1.2.9      matt #define tlb_invalidate_asid	mips3_tlb_invalidate_asid
    342   1.78.36.1.2.8      matt #define tlb_update		mips3_tlb_update
    343   1.78.36.1.2.8      matt #define tlb_read_indexed	mips3_tlb_read_indexed
    344   1.78.36.1.2.8      matt #define tlb_write_indexed_VPS	mips3_tlb_write_indexed_VPS
    345            1.76      yamt #define lwp_trampoline		mips3_lwp_trampoline
    346       1.78.36.1       snj #define setfunc_trampoline	mips3_setfunc_trampoline
    347            1.59    simonb #define wbflush()		mips3_wbflush()
    348            1.59    simonb #elif !defined(MIPS1) && !defined(MIPS3) &&  defined(MIPS32) && !defined(MIPS64)
    349   1.78.36.1.2.8      matt #define tlb_set_asid		mips32_tlb_set_asid
    350   1.78.36.1.2.9      matt #define tlb_invalidate_asids(asid_lo, asid_hi) \
    351   1.78.36.1.2.9      matt 		mips32_tlb_invalidate_asids(mips_options.mips_num_tlb_entries, asid_lo, asid_hi)
    352   1.78.36.1.2.8      matt #define tlb_invalidate_addr	mips32_tlb_invalidate_addr
    353   1.78.36.1.2.9      matt #define tlb_invalidate_asid	mips32_tlb_invalidate_asid
    354   1.78.36.1.2.8      matt #define tlb_update		mips32_tlb_update
    355   1.78.36.1.2.8      matt #define tlb_read_indexed	mips32_tlb_read_indexed
    356   1.78.36.1.2.8      matt #define tlb_write_indexed_VPS	mips32_tlb_write_indexed_VPS
    357            1.76      yamt #define lwp_trampoline		mips32_lwp_trampoline
    358       1.78.36.1       snj #define setfunc_trampoline	mips32_setfunc_trampoline
    359            1.59    simonb #define wbflush()		mips32_wbflush()
    360            1.59    simonb #elif !defined(MIPS1) && !defined(MIPS3) && !defined(MIPS32) &&  defined(MIPS64)
    361            1.59    simonb  /* all common with mips3 */
    362   1.78.36.1.2.8      matt #define tlb_set_asid		mips64_tlb_set_asid
    363   1.78.36.1.2.9      matt #define tlb_invalidate_asids(asid_lo, asid_hi) \
    364   1.78.36.1.2.9      matt 		mips64_tlb_invalidate_asids(mips_options.mips_num_tlb_entries, asid_lo, asid_hi)
    365   1.78.36.1.2.8      matt #define tlb_invalidate_addr	mips64_tlb_invalidate_addr
    366   1.78.36.1.2.9      matt #define tlb_invalidate_asid	mips64_tlb_invalidate_asid
    367   1.78.36.1.2.8      matt #define tlb_update		mips64_tlb_update
    368   1.78.36.1.2.8      matt #define tlb_read_indexed	mips64_tlb_read_indexed
    369   1.78.36.1.2.8      matt #define tlb_write_indexed_VPS	mips64_tlb_write_indexed_VPS
    370            1.76      yamt #define lwp_trampoline		mips64_lwp_trampoline
    371       1.78.36.1       snj #define setfunc_trampoline	mips64_setfunc_trampoline
    372            1.59    simonb #define wbflush()		mips64_wbflush()
    373            1.60       uch #elif !defined(MIPS1) &&  defined(MIPS3) && !defined(MIPS32) && !defined(MIPS64) && defined(MIPS3_5900)
    374   1.78.36.1.2.8      matt #define tlb_set_asid		mips5900_tlb_set_asid
    375   1.78.36.1.2.9      matt #define tlb_invalidate_asids(asid_lo, asid_hi) \
    376   1.78.36.1.2.9      matt 		mips5900_tlb_invalidate_asids(mips_options.mips_num_tlb_entries, asid_lo, asid_hi)
    377   1.78.36.1.2.8      matt #define tlb_invalidate_addr	mips5900_tlb_invalidate_addr
    378   1.78.36.1.2.9      matt #define tlb_invalidate_asid	mips5900_tlb_invalidate_asid
    379   1.78.36.1.2.8      matt #define tlb_update		mips5900_tlb_update
    380   1.78.36.1.2.8      matt #define tlb_read_indexed	mips5900_tlb_read_indexed
    381   1.78.36.1.2.8      matt #define tlb_write_indexed_VPS	mips5900_tlb_write_indexed_VPS
    382            1.76      yamt #define lwp_trampoline		mips5900_lwp_trampoline
    383       1.78.36.1       snj #define setfunc_trampoline	mips5900_setfunc_trampoline
    384            1.60       uch #define wbflush()		mips5900_wbflush()
    385            1.59    simonb #else
    386   1.78.36.1.2.8      matt #define tlb_set_asid		(*(mips_locore_jumpvec.ljv_tlb_set_asid))
    387   1.78.36.1.2.9      matt #define tlb_invalidate_asids(asid_lo, asid_hi) \
    388   1.78.36.1.2.9      matt 		(*(mips_locore_jumpvec.ljv_tlb_invalidate_asids))(mips_options.mips_num_tlb_entries, asid_lo, asid_hi)
    389   1.78.36.1.2.8      matt #define tlb_invalidate_addr	(*(mips_locore_jumpvec.ljv_tlb_invalidate_addr))
    390   1.78.36.1.2.8      matt #define tlb_update		(*(mips_locore_jumpvec.ljv_tlb_update))
    391   1.78.36.1.2.8      matt #define tlb_read_indexed	(*(mips_locore_jumpvec.ljv_tlb_read_indexed))
    392   1.78.36.1.2.8      matt #define wbflush()		(*(mips_locore_jumpvec.ljv_wbflush))()
    393   1.78.36.1.2.2      matt #define lwp_trampoline		mips_locoresw.lsw_lwp_trampoline
    394   1.78.36.1.2.2      matt #define setfunc_trampoline	mips_locoresw.lsw_setfunc_trampoline
    395            1.11  jonathan #endif
    396            1.31  nisimura 
    397   1.78.36.1.2.2      matt #define CPU_IDLE		mips_locoresw.lsw_cpu_idle
    398            1.11  jonathan 
    399            1.16    castor /* cpu_switch_resume is called inside locore.S */
    400             1.7  jonathan 
    401             1.7  jonathan /*
    402             1.7  jonathan  * CPU identification, from PRID register.
    403             1.7  jonathan  */
    404            1.40       cgd typedef int mips_prid_t;
    405            1.40       cgd 
    406            1.70   tsutsui #define MIPS_PRID_REV(x)	(((x) >>  0) & 0x00ff)
    407            1.70   tsutsui #define MIPS_PRID_IMPL(x)	(((x) >>  8) & 0x00ff)
    408            1.45       cgd 
    409            1.59    simonb /* pre-MIPS32/64 */
    410            1.70   tsutsui #define MIPS_PRID_RSVD(x)	(((x) >> 16) & 0xffff)
    411            1.70   tsutsui #define MIPS_PRID_REV_MIN(x)	((MIPS_PRID_REV(x) >> 0) & 0x0f)
    412            1.70   tsutsui #define MIPS_PRID_REV_MAJ(x)	((MIPS_PRID_REV(x) >> 4) & 0x0f)
    413            1.45       cgd 
    414            1.59    simonb /* MIPS32/64 */
    415            1.70   tsutsui #define MIPS_PRID_CID(x)	(((x) >> 16) & 0x00ff)	/* Company ID */
    416            1.70   tsutsui #define     MIPS_PRID_CID_PREHISTORIC	0x00	/* Not MIPS32/64 */
    417            1.70   tsutsui #define     MIPS_PRID_CID_MTI		0x01	/* MIPS Technologies, Inc. */
    418            1.70   tsutsui #define     MIPS_PRID_CID_BROADCOM	0x02	/* Broadcom */
    419            1.70   tsutsui #define     MIPS_PRID_CID_ALCHEMY	0x03	/* Alchemy Semiconductor */
    420            1.70   tsutsui #define     MIPS_PRID_CID_SIBYTE	0x04	/* SiByte */
    421            1.70   tsutsui #define     MIPS_PRID_CID_SANDCRAFT	0x05	/* SandCraft */
    422            1.70   tsutsui #define     MIPS_PRID_CID_PHILIPS	0x06	/* Philips */
    423            1.70   tsutsui #define     MIPS_PRID_CID_TOSHIBA	0x07	/* Toshiba */
    424            1.70   tsutsui #define     MIPS_PRID_CID_LSI		0x08	/* LSI */
    425            1.67    simonb 				/*	0x09	unannounced */
    426            1.67    simonb 				/*	0x0a	unannounced */
    427            1.70   tsutsui #define     MIPS_PRID_CID_LEXRA		0x0b	/* Lexra */
    428   1.78.36.1.2.3      matt #define     MIPS_PRID_CID_RMI		0x0c	/* RMI / NetLogic */
    429            1.70   tsutsui #define MIPS_PRID_COPTS(x)	(((x) >> 24) & 0x00ff)	/* Company Options */
    430             1.6  jonathan 
    431             1.6  jonathan #ifdef _KERNEL
    432             1.6  jonathan /*
    433             1.6  jonathan  * Global variables used to communicate CPU type, and parameters
    434             1.6  jonathan  * such as cache size, from locore to higher-level code (e.g., pmap).
    435             1.6  jonathan  */
    436            1.75  christos void mips_pagecopy(void *dst, void *src);
    437            1.75  christos void mips_pagezero(void *dst);
    438            1.19  jonathan 
    439            1.59    simonb #ifdef __HAVE_MIPS_MACHDEP_CACHE_CONFIG
    440            1.59    simonb void mips_machdep_cache_config(void);
    441            1.59    simonb #endif
    442            1.59    simonb 
    443            1.19  jonathan /*
    444            1.20    simonb  * trapframe argument passed to trap()
    445            1.19  jonathan  */
    446            1.64   thorpej 
    447            1.70   tsutsui #define TF_AST		0
    448            1.70   tsutsui #define TF_V0		1
    449            1.70   tsutsui #define TF_V1		2
    450            1.70   tsutsui #define TF_A0		3
    451            1.70   tsutsui #define TF_A1		4
    452            1.70   tsutsui #define TF_A2		5
    453            1.70   tsutsui #define TF_A3		6
    454            1.70   tsutsui #define TF_T0		7
    455            1.70   tsutsui #define TF_T1		8
    456            1.70   tsutsui #define TF_T2		9
    457            1.70   tsutsui #define TF_T3		10
    458            1.64   thorpej 
    459            1.64   thorpej #if defined(__mips_n32) || defined(__mips_n64)
    460            1.70   tsutsui #define TF_A4		11
    461            1.70   tsutsui #define TF_A5		12
    462            1.70   tsutsui #define TF_A6		13
    463            1.70   tsutsui #define TF_A7		14
    464            1.64   thorpej #else
    465            1.70   tsutsui #define TF_T4		11
    466            1.70   tsutsui #define TF_T5		12
    467            1.70   tsutsui #define TF_T6		13
    468            1.70   tsutsui #define TF_T7		14
    469            1.64   thorpej #endif /* __mips_n32 || __mips_n64 */
    470            1.64   thorpej 
    471            1.70   tsutsui #define TF_TA0		11
    472            1.70   tsutsui #define TF_TA1		12
    473            1.70   tsutsui #define TF_TA2		13
    474            1.70   tsutsui #define TF_TA3		14
    475            1.70   tsutsui 
    476            1.70   tsutsui #define TF_T8		15
    477            1.70   tsutsui #define TF_T9		16
    478            1.70   tsutsui 
    479            1.70   tsutsui #define TF_RA		17
    480            1.70   tsutsui #define TF_SR		18
    481            1.70   tsutsui #define TF_MULLO	19
    482            1.70   tsutsui #define TF_MULHI	20
    483            1.70   tsutsui #define TF_EPC		21		/* may be changed by trap() call */
    484            1.65   thorpej 
    485            1.70   tsutsui #define TF_NREGS	22
    486            1.64   thorpej 
    487            1.19  jonathan struct trapframe {
    488            1.64   thorpej 	mips_reg_t tf_regs[TF_NREGS];
    489   1.78.36.1.2.2      matt 	uint32_t   tf_ppl;		/* previous priority level */
    490   1.78.36.1.2.2      matt 	mips_reg_t tf_pad;		/* for 8 byte aligned */
    491            1.19  jonathan };
    492            1.19  jonathan 
    493            1.19  jonathan /*
    494            1.19  jonathan  * Stack frame for kernel traps. four args passed in registers.
    495            1.19  jonathan  * A trapframe is pointed to by the 5th arg, and a dummy sixth argument
    496            1.19  jonathan  * is used to avoid alignment problems
    497            1.19  jonathan  */
    498            1.19  jonathan 
    499            1.19  jonathan struct kernframe {
    500   1.78.36.1.2.1      matt #if defined(__mips_o32) || defined(__mips_o64)
    501            1.19  jonathan 	register_t cf_args[4 + 1];
    502   1.78.36.1.2.1      matt #if defined(__mips_o32)
    503            1.19  jonathan 	register_t cf_pad;		/* (for 8 word alignment) */
    504   1.78.36.1.2.1      matt #endif
    505   1.78.36.1.2.1      matt #endif
    506   1.78.36.1.2.1      matt #if defined(__mips_n32) || defined(__mips_n64)
    507   1.78.36.1.2.4      matt 	register_t cf_pad[2];		/* for 16 byte alignment */
    508   1.78.36.1.2.1      matt #endif
    509            1.19  jonathan 	register_t cf_sp;
    510            1.19  jonathan 	register_t cf_ra;
    511            1.19  jonathan 	struct trapframe cf_frame;
    512            1.19  jonathan };
    513            1.61    simonb #endif	/* _KERNEL */
    514             1.1  jonathan #endif	/* _MIPS_LOCORE_H */
    515