Home | History | Annotate | Line # | Download | only in include
locore.h revision 1.78.36.1.2.17
      1  1.78.36.1.2.17      matt /* $NetBSD: locore.h,v 1.78.36.1.2.17 2010/02/28 03:21:06 matt Exp $ */
      2  1.78.36.1.2.14      matt 
      3  1.78.36.1.2.14      matt /*
      4  1.78.36.1.2.14      matt  * This file should not be included by MI code!!!
      5  1.78.36.1.2.14      matt  */
      6             1.1  jonathan 
      7             1.1  jonathan /*
      8             1.1  jonathan  * Copyright 1996 The Board of Trustees of The Leland Stanford
      9             1.1  jonathan  * Junior University. All Rights Reserved.
     10             1.1  jonathan  *
     11             1.1  jonathan  * Permission to use, copy, modify, and distribute this
     12             1.1  jonathan  * software and its documentation for any purpose and without
     13             1.1  jonathan  * fee is hereby granted, provided that the above copyright
     14             1.1  jonathan  * notice appear in all copies.  Stanford University
     15             1.1  jonathan  * makes no representations about the suitability of this
     16             1.1  jonathan  * software for any purpose.  It is provided "as is" without
     17             1.1  jonathan  * express or implied warranty.
     18             1.1  jonathan  */
     19             1.1  jonathan 
     20             1.1  jonathan /*
     21            1.68       wiz  * Jump table for MIPS CPU locore functions that are implemented
     22             1.1  jonathan  * differently on different generations, or instruction-level
     23             1.1  jonathan  * archtecture (ISA) level, the Mips family.
     24             1.1  jonathan  *
     25            1.33     soren  * We currently provide support for MIPS I and MIPS III.
     26             1.1  jonathan  */
     27             1.1  jonathan 
     28             1.1  jonathan #ifndef _MIPS_LOCORE_H
     29            1.70   tsutsui #define _MIPS_LOCORE_H
     30             1.2  jonathan 
     31            1.17    castor #ifndef _LKM
     32            1.32     soren #include "opt_cputype.h"
     33            1.17    castor #endif
     34            1.16    castor 
     35            1.59    simonb #include <mips/cpuregs.h>
     36  1.78.36.1.2.11      matt #include <mips/reg.h>
     37            1.59    simonb 
     38   1.78.36.1.2.8      matt struct tlbmask;
     39            1.38       cgd 
     40            1.59    simonb uint32_t mips_cp0_cause_read(void);
     41            1.59    simonb void	mips_cp0_cause_write(uint32_t);
     42            1.59    simonb uint32_t mips_cp0_status_read(void);
     43            1.59    simonb void	mips_cp0_status_write(uint32_t);
     44            1.29    simonb 
     45  1.78.36.1.2.16      matt void	softint_process(uint32_t);
     46  1.78.36.1.2.16      matt void	softint_fast_dispatch(struct lwp *, int);
     47  1.78.36.1.2.16      matt 
     48  1.78.36.1.2.16      matt typedef bool (*mips_fixup_callback_t)(int32_t, uint32_t [2]);
     49  1.78.36.1.2.16      matt 
     50  1.78.36.1.2.17      matt void	fixup_splcalls(void);				/* splstubs.c */
     51  1.78.36.1.2.16      matt bool	mips_fixup_exceptions(mips_fixup_callback_t);
     52  1.78.36.1.2.16      matt bool	mips_fixup_zero_relative(int32_t, uint32_t [2]);
     53  1.78.36.1.2.17      matt void	mips_fixup_stubs(uint32_t *, uint32_t *, const uint32_t *,
     54  1.78.36.1.2.17      matt 	    const uint32_t *, size_t);
     55  1.78.36.1.2.17      matt void	fixup_mips_cpu_switch_resume(void);
     56  1.78.36.1.2.17      matt 
     57  1.78.36.1.2.17      matt void	mips_cpu_switch_resume(struct lwp *);
     58            1.77   tsutsui 
     59            1.59    simonb #ifdef MIPS1
     60   1.78.36.1.2.8      matt void	mips1_tlb_set_asid(uint32_t);
     61  1.78.36.1.2.14      matt void	mips1_tlb_invalidate_all(void);
     62  1.78.36.1.2.14      matt void	mips1_tlb_invalidate_globals(void);
     63  1.78.36.1.2.14      matt void	mips1_tlb_invalidate_asids(uint32_t, uint32_t);
     64   1.78.36.1.2.8      matt void	mips1_tlb_invalidate_addr(vaddr_t);
     65  1.78.36.1.2.15      matt u_int	mips1_tlb_record_asids(u_long *, uint32_t);
     66   1.78.36.1.2.8      matt int	mips1_tlb_update(vaddr_t, uint32_t);
     67  1.78.36.1.2.16      matt void	mips1_tlb_enter(size_t, vaddr_t, uint32_t);
     68   1.78.36.1.2.8      matt void	mips1_tlb_read_indexed(size_t, struct tlbmask *);
     69            1.38       cgd void	mips1_wbflush(void);
     70            1.76      yamt void	mips1_lwp_trampoline(void);
     71       1.78.36.1       snj void	mips1_setfunc_trampoline(void);
     72  1.78.36.1.2.16      matt void	mips1_cpu_switch_resume(struct lwp *);
     73            1.38       cgd 
     74            1.58   thorpej uint32_t tx3900_cp0_config_read(void);
     75            1.59    simonb #endif
     76            1.38       cgd 
     77            1.59    simonb #if defined(MIPS3) || defined(MIPS4)
     78   1.78.36.1.2.8      matt void	mips3_tlb_set_asid(uint32_t);
     79  1.78.36.1.2.14      matt void	mips3_tlb_invalidate_all(void);
     80  1.78.36.1.2.14      matt void	mips3_tlb_invalidate_globals(void);
     81  1.78.36.1.2.14      matt void	mips3_tlb_invalidate_asids(uint32_t, uint32_t);
     82   1.78.36.1.2.8      matt void	mips3_tlb_invalidate_addr(vaddr_t);
     83  1.78.36.1.2.15      matt u_int	mips3_tlb_record_asids(u_long *, uint32_t);
     84   1.78.36.1.2.8      matt int	mips3_tlb_update(vaddr_t, uint32_t);
     85  1.78.36.1.2.16      matt void	mips3_tlb_enter(size_t, vaddr_t, uint32_t);
     86   1.78.36.1.2.8      matt void	mips3_tlb_read_indexed(size_t, struct tlbmask *);
     87   1.78.36.1.2.8      matt void	mips3_tlb_write_indexed_VPS(size_t, struct tlbmask *);
     88            1.38       cgd void	mips3_wbflush(void);
     89            1.76      yamt void	mips3_lwp_trampoline(void);
     90       1.78.36.1       snj void	mips3_setfunc_trampoline(void);
     91  1.78.36.1.2.16      matt void	mips3_cpu_switch_resume(struct lwp *);
     92            1.75  christos void	mips3_pagezero(void *dst);
     93            1.38       cgd 
     94            1.59    simonb #ifdef MIPS3_5900
     95   1.78.36.1.2.8      matt void	mips5900_tlb_set_asid(uint32_t);
     96  1.78.36.1.2.14      matt void	mips5900_tlb_invalidate_all(void);
     97  1.78.36.1.2.14      matt void	mips5900_tlb_invalidate_globals(void);
     98  1.78.36.1.2.14      matt void	mips5900_tlb_invalidate_asids(uint32_t, uint32_t);
     99   1.78.36.1.2.8      matt void	mips5900_tlb_invalidate_addr(vaddr_t);
    100  1.78.36.1.2.15      matt u_int	mips5900_tlb_record_asids(u_long *, uint32_t);
    101   1.78.36.1.2.8      matt int	mips5900_tlb_update(vaddr_t, uint32_t);
    102  1.78.36.1.2.16      matt void	mips5900_tlb_enter(size_t, vaddr_t, uint32_t);
    103   1.78.36.1.2.8      matt void	mips5900_tlb_read_indexed(size_t, struct tlbmask *);
    104   1.78.36.1.2.8      matt void	mips5900_tlb_write_indexed_VPS(size_t, struct tlbmask *);
    105            1.59    simonb void	mips5900_wbflush(void);
    106            1.76      yamt void	mips5900_lwp_trampoline(void);
    107       1.78.36.1       snj void	mips5900_setfunc_trampoline(void);
    108  1.78.36.1.2.16      matt void	mips5900_cpu_switch_resume(struct lwp *);
    109            1.75  christos void	mips5900_pagezero(void *dst);
    110            1.59    simonb #endif
    111            1.59    simonb #endif
    112            1.49       cgd 
    113            1.59    simonb #ifdef MIPS32
    114   1.78.36.1.2.8      matt void	mips32_tlb_set_asid(uint32_t);
    115  1.78.36.1.2.14      matt void	mips32_tlb_invalidate_all(void);
    116  1.78.36.1.2.14      matt void	mips32_tlb_invalidate_globals(void);
    117  1.78.36.1.2.14      matt void	mips32_tlb_invalidate_asids(uint32_t, uint32_t);
    118   1.78.36.1.2.8      matt void	mips32_tlb_invalidate_addr(vaddr_t);
    119  1.78.36.1.2.15      matt u_int	mips32_tlb_record_asids(u_long *, uint32_t);
    120   1.78.36.1.2.8      matt int	mips32_tlb_update(vaddr_t, uint32_t);
    121  1.78.36.1.2.16      matt void	mips32_tlb_enter(size_t, vaddr_t, uint32_t);
    122   1.78.36.1.2.8      matt void	mips32_tlb_read_indexed(size_t, struct tlbmask *);
    123   1.78.36.1.2.8      matt void	mips32_tlb_write_indexed_VPS(size_t, struct tlbmask *);
    124            1.59    simonb void	mips32_wbflush(void);
    125            1.76      yamt void	mips32_lwp_trampoline(void);
    126       1.78.36.1       snj void	mips32_setfunc_trampoline(void);
    127  1.78.36.1.2.16      matt void	mips32_cpu_switch_resume(struct lwp *);
    128            1.59    simonb #endif
    129            1.59    simonb 
    130            1.59    simonb #ifdef MIPS64
    131   1.78.36.1.2.8      matt void	mips64_tlb_set_asid(uint32_t);
    132  1.78.36.1.2.14      matt void	mips64_tlb_invalidate_all(void);
    133  1.78.36.1.2.14      matt void	mips64_tlb_invalidate_globals(void);
    134  1.78.36.1.2.14      matt void	mips64_tlb_invalidate_asids(uint32_t, uint32_t);
    135   1.78.36.1.2.8      matt void	mips64_tlb_invalidate_addr(vaddr_t);
    136  1.78.36.1.2.15      matt u_int	mips64_tlb_record_asids(u_long *, uint32_t);
    137   1.78.36.1.2.8      matt int	mips64_tlb_update(vaddr_t, uint32_t);
    138  1.78.36.1.2.16      matt void	mips64_tlb_enter(size_t, vaddr_t, uint32_t);
    139   1.78.36.1.2.8      matt void	mips64_tlb_read_indexed(size_t, struct tlbmask *);
    140   1.78.36.1.2.8      matt void	mips64_tlb_write_indexed_VPS(size_t, struct tlbmask *);
    141            1.59    simonb void	mips64_wbflush(void);
    142            1.76      yamt void	mips64_lwp_trampoline(void);
    143       1.78.36.1       snj void	mips64_setfunc_trampoline(void);
    144  1.78.36.1.2.16      matt void	mips64_cpu_switch_resume(struct lwp *);
    145            1.75  christos void	mips64_pagezero(void *dst);
    146            1.59    simonb #endif
    147            1.49       cgd 
    148            1.63    simonb #if defined(MIPS3) || defined(MIPS4) || defined(MIPS32) || defined(MIPS64)
    149            1.59    simonb uint32_t mips3_cp0_compare_read(void);
    150            1.59    simonb void	mips3_cp0_compare_write(uint32_t);
    151            1.49       cgd 
    152            1.59    simonb uint32_t mips3_cp0_config_read(void);
    153            1.59    simonb void	mips3_cp0_config_write(uint32_t);
    154            1.63    simonb #if defined(MIPS32) || defined(MIPS64)
    155            1.59    simonb uint32_t mipsNN_cp0_config1_read(void);
    156            1.59    simonb void	mipsNN_cp0_config1_write(uint32_t);
    157            1.63    simonb uint32_t mipsNN_cp0_config2_read(void);
    158            1.63    simonb uint32_t mipsNN_cp0_config3_read(void);
    159            1.63    simonb #endif
    160            1.59    simonb 
    161            1.59    simonb uint32_t mips3_cp0_count_read(void);
    162            1.59    simonb void	mips3_cp0_count_write(uint32_t);
    163            1.59    simonb 
    164            1.59    simonb uint32_t mips3_cp0_wired_read(void);
    165            1.59    simonb void	mips3_cp0_wired_write(uint32_t);
    166            1.69   tsutsui void	mips3_cp0_pg_mask_write(uint32_t);
    167            1.59    simonb 
    168   1.78.36.1.2.1      matt #if defined(__GNUC__) && !defined(__mips_o32)
    169   1.78.36.1.2.1      matt static inline uint64_t
    170   1.78.36.1.2.5      matt mips3_ld(const volatile uint64_t *va)
    171   1.78.36.1.2.1      matt {
    172   1.78.36.1.2.1      matt 	uint64_t rv;
    173   1.78.36.1.2.1      matt #if defined(__mips_o32)
    174   1.78.36.1.2.1      matt 	uint32_t sr;
    175   1.78.36.1.2.1      matt 
    176   1.78.36.1.2.1      matt 	sr = mips_cp0_status_read();
    177   1.78.36.1.2.1      matt 	mips_cp0_status_write(sr & ~MIPS_SR_INT_IE);
    178   1.78.36.1.2.1      matt 
    179   1.78.36.1.2.1      matt 	__asm volatile(
    180   1.78.36.1.2.1      matt 		".set push		\n\t"
    181   1.78.36.1.2.1      matt 		".set mips3		\n\t"
    182   1.78.36.1.2.1      matt 		".set noreorder		\n\t"
    183   1.78.36.1.2.1      matt 		".set noat		\n\t"
    184   1.78.36.1.2.1      matt 		"ld	%M0,0(%1)	\n\t"
    185   1.78.36.1.2.1      matt 		"dsll32	%L0,%M0,0	\n\t"
    186   1.78.36.1.2.1      matt 		"dsra32	%M0,%M0,0	\n\t"		/* high word */
    187   1.78.36.1.2.1      matt 		"dsra32	%L0,%L0,0	\n\t"		/* low word */
    188   1.78.36.1.2.1      matt 		"ld	%0,0(%1)	\n\t"
    189   1.78.36.1.2.1      matt 		".set pop"
    190   1.78.36.1.2.1      matt 	    : "=d"(rv)
    191   1.78.36.1.2.1      matt 	    : "r"(va));
    192   1.78.36.1.2.1      matt 
    193   1.78.36.1.2.1      matt 	mips_cp0_status_write(sr);
    194   1.78.36.1.2.1      matt #elif defined(_LP64)
    195   1.78.36.1.2.1      matt 	rv = *va;
    196   1.78.36.1.2.1      matt #else
    197   1.78.36.1.2.1      matt 	__asm volatile("ld	%0,0(%1)" : "=d"(rv) : "r"(va));
    198   1.78.36.1.2.1      matt #endif
    199   1.78.36.1.2.1      matt 
    200   1.78.36.1.2.1      matt 	return rv;
    201   1.78.36.1.2.1      matt }
    202   1.78.36.1.2.1      matt static inline void
    203   1.78.36.1.2.5      matt mips3_sd(volatile uint64_t *va, uint64_t v)
    204   1.78.36.1.2.1      matt {
    205   1.78.36.1.2.1      matt #if defined(__mips_o32)
    206   1.78.36.1.2.1      matt 	uint32_t sr;
    207   1.78.36.1.2.1      matt 
    208   1.78.36.1.2.1      matt 	sr = mips_cp0_status_read();
    209   1.78.36.1.2.1      matt 	mips_cp0_status_write(sr & ~MIPS_SR_INT_IE);
    210   1.78.36.1.2.1      matt 
    211   1.78.36.1.2.1      matt 	__asm volatile(
    212   1.78.36.1.2.1      matt 		".set push		\n\t"
    213   1.78.36.1.2.1      matt 		".set mips3		\n\t"
    214   1.78.36.1.2.1      matt 		".set noreorder		\n\t"
    215   1.78.36.1.2.1      matt 		".set noat		\n\t"
    216   1.78.36.1.2.1      matt 		"dsll32	%M0,%M0,0	\n\t"
    217   1.78.36.1.2.1      matt 		"dsll32	%L0,%L0,0	\n\t"
    218   1.78.36.1.2.1      matt 		"dsrl32	%L0,%L0,0	\n\t"
    219   1.78.36.1.2.1      matt 		"or	%0,%L0,%M0	\n\t"
    220   1.78.36.1.2.1      matt 		"sd	%0,0(%1)	\n\t"
    221   1.78.36.1.2.1      matt 		".set pop"
    222   1.78.36.1.2.1      matt 	    : "=d"(v) : "0"(v), "r"(va));
    223   1.78.36.1.2.1      matt 
    224   1.78.36.1.2.1      matt 	mips_cp0_status_write(sr);
    225   1.78.36.1.2.1      matt #elif defined(_LP64)
    226   1.78.36.1.2.1      matt 	*va = v;
    227   1.78.36.1.2.1      matt #else
    228   1.78.36.1.2.1      matt 	__asm volatile("sd	%0,0(%1)" :: "r"(v), "r"(va));
    229   1.78.36.1.2.1      matt #endif
    230   1.78.36.1.2.1      matt }
    231   1.78.36.1.2.1      matt #else
    232   1.78.36.1.2.5      matt uint64_t mips3_ld(volatile uint64_t *va);
    233   1.78.36.1.2.5      matt void	mips3_sd(volatile uint64_t *, uint64_t);
    234   1.78.36.1.2.1      matt #endif	/* __GNUC__ */
    235            1.63    simonb #endif	/* MIPS3 || MIPS4 || MIPS32 || MIPS64 */
    236            1.59    simonb 
    237            1.63    simonb #if defined(MIPS3) || defined(MIPS4) || defined(MIPS64)
    238            1.74     perry static __inline uint32_t	mips3_lw_a64(uint64_t addr)
    239            1.59    simonb 		    __attribute__((__unused__));
    240            1.74     perry static __inline void	mips3_sw_a64(uint64_t addr, uint32_t val)
    241            1.59    simonb 		    __attribute__ ((__unused__));
    242            1.59    simonb 
    243            1.74     perry static __inline uint32_t
    244            1.59    simonb mips3_lw_a64(uint64_t addr)
    245            1.59    simonb {
    246            1.59    simonb 	uint32_t rv;
    247   1.78.36.1.2.1      matt #if defined(__mips_o32)
    248            1.59    simonb 	uint32_t sr;
    249            1.59    simonb 
    250            1.59    simonb 	sr = mips_cp0_status_read();
    251   1.78.36.1.2.1      matt 	mips_cp0_status_write((sr & ~MIPS_SR_INT_IE) | MIPS3_SR_KX);
    252            1.59    simonb 
    253   1.78.36.1.2.1      matt 	__asm volatile (
    254   1.78.36.1.2.1      matt 		".set push		\n\t"
    255   1.78.36.1.2.1      matt 		".set mips3		\n\t"
    256   1.78.36.1.2.1      matt 		".set noreorder		\n\t"
    257   1.78.36.1.2.1      matt 		".set noat		\n\t"
    258   1.78.36.1.2.1      matt 		"dsll32	%M1,%M1,0	\n\t"
    259   1.78.36.1.2.1      matt 		"dsll32	%L1,%L1,0	\n\t"
    260  1.78.36.1.2.10     cyber 		"dsrl32	%L1,%L1,0	\n\t"
    261   1.78.36.1.2.1      matt 		"or	%1,%M1,%L1	\n\t"
    262   1.78.36.1.2.1      matt 		"lw	%0, 0(%1)	\n\t"
    263   1.78.36.1.2.1      matt 		".set pop"
    264   1.78.36.1.2.1      matt 	    : "=r"(rv), "=d"(addr)
    265   1.78.36.1.2.1      matt 	    : "1"(addr)
    266   1.78.36.1.2.1      matt 	    );
    267            1.59    simonb 
    268            1.59    simonb 	mips_cp0_status_write(sr);
    269   1.78.36.1.2.1      matt #elif defined(_LP64)
    270   1.78.36.1.2.1      matt 	rv = *(const uint32_t *)addr;
    271   1.78.36.1.2.1      matt #else
    272   1.78.36.1.2.1      matt 	__asm volatile("lw	%0, 0(%1)" : "=r"(rv) : "d"(addr));
    273   1.78.36.1.2.1      matt #endif
    274            1.59    simonb 	return (rv);
    275            1.59    simonb }
    276            1.59    simonb 
    277            1.74     perry static __inline void
    278            1.59    simonb mips3_sw_a64(uint64_t addr, uint32_t val)
    279            1.59    simonb {
    280   1.78.36.1.2.1      matt #if defined(__mips_o32)
    281            1.59    simonb 	uint32_t sr;
    282            1.59    simonb 
    283            1.59    simonb 	sr = mips_cp0_status_read();
    284   1.78.36.1.2.1      matt 	mips_cp0_status_write((sr & ~MIPS_SR_INT_IE) | MIPS3_SR_KX);
    285            1.59    simonb 
    286   1.78.36.1.2.1      matt 	__asm volatile (
    287   1.78.36.1.2.1      matt 		".set push		\n\t"
    288   1.78.36.1.2.1      matt 		".set mips3		\n\t"
    289   1.78.36.1.2.1      matt 		".set noreorder		\n\t"
    290   1.78.36.1.2.1      matt 		".set noat		\n\t"
    291   1.78.36.1.2.1      matt 		"dsll32	%M0,%M0,0	\n\t"
    292   1.78.36.1.2.1      matt 		"dsll32	%L0,%L0,0	\n\t"
    293  1.78.36.1.2.10     cyber 		"dsrl32	%L0,%L0,0	\n\t"
    294   1.78.36.1.2.1      matt 		"or	%0,%M0,%L0	\n\t"
    295   1.78.36.1.2.1      matt 		"sw	%1, 0(%0)	\n\t"
    296   1.78.36.1.2.1      matt 		".set pop"
    297   1.78.36.1.2.1      matt 	    : "=d"(addr): "r"(val), "0"(addr)
    298   1.78.36.1.2.1      matt 	    );
    299            1.44       cgd 
    300            1.59    simonb 	mips_cp0_status_write(sr);
    301   1.78.36.1.2.1      matt #elif defined(_LP64)
    302   1.78.36.1.2.1      matt 	*(uint32_t *)addr = val;
    303   1.78.36.1.2.1      matt #else
    304   1.78.36.1.2.1      matt 	__asm volatile("sw	%1, 0(%0)" :: "d"(addr), "r"(val));
    305   1.78.36.1.2.1      matt #endif
    306            1.59    simonb }
    307            1.63    simonb #endif	/* MIPS3 || MIPS4 || MIPS64 */
    308             1.7  jonathan 
    309             1.1  jonathan /*
    310            1.58   thorpej  * A vector with an entry for each mips-ISA-level dependent
    311             1.1  jonathan  * locore function, and macros which jump through it.
    312             1.1  jonathan  */
    313             1.1  jonathan typedef struct  {
    314  1.78.36.1.2.16      matt 	void	(*ljv_tlb_set_asid)(uint32_t pid);
    315  1.78.36.1.2.16      matt 	void	(*ljv_tlb_invalidate_asids)(uint32_t, uint32_t);
    316  1.78.36.1.2.16      matt 	void	(*ljv_tlb_invalidate_addr)(vaddr_t);
    317  1.78.36.1.2.16      matt 	void	(*ljv_tlb_invalidate_globals)(void);
    318  1.78.36.1.2.16      matt 	void	(*ljv_tlb_invalidate_all)(void);
    319  1.78.36.1.2.16      matt 	u_int	(*ljv_tlb_record_asids)(u_long *, uint32_t);
    320  1.78.36.1.2.16      matt 	int	(*ljv_tlb_update)(vaddr_t, uint32_t);
    321  1.78.36.1.2.16      matt 	void	(*ljv_tlb_enter)(size_t, vaddr_t, uint32_t);
    322  1.78.36.1.2.16      matt 	void	(*ljv_tlb_read_indexed)(size_t, struct tlbmask *);
    323  1.78.36.1.2.16      matt 	void	(*ljv_wbflush)(void);
    324             1.1  jonathan } mips_locore_jumpvec_t;
    325            1.13  jonathan 
    326            1.38       cgd void	mips_set_wbflush(void (*)(void));
    327            1.62    simonb void	mips_wait_idle(void);
    328             1.1  jonathan 
    329            1.38       cgd void	stacktrace(void);
    330            1.38       cgd void	logstacktrace(void);
    331             1.1  jonathan 
    332   1.78.36.1.2.2      matt struct locoresw {
    333  1.78.36.1.2.16      matt 	void		(*lsw_cpu_switch_resume)(struct lwp *);
    334  1.78.36.1.2.16      matt 	uintptr_t	lsw_lwp_trampoline;
    335  1.78.36.1.2.16      matt 	void		(*lsw_cpu_idle)(void);
    336  1.78.36.1.2.16      matt 	uintptr_t	lsw_setfunc_trampoline;
    337  1.78.36.1.2.16      matt 	void		(*lsw_boot_secondary_processors)(void);
    338  1.78.36.1.2.16      matt 	int		(*lsw_send_ipi)(struct cpu_info *, int);
    339  1.78.36.1.2.16      matt 	void		(*lsw_cpu_offline_md)(void);
    340   1.78.36.1.2.2      matt };
    341   1.78.36.1.2.2      matt 
    342   1.78.36.1.2.7      matt struct mips_vmfreelist {
    343   1.78.36.1.2.7      matt 	paddr_t fl_start;
    344   1.78.36.1.2.7      matt 	paddr_t fl_end;
    345   1.78.36.1.2.7      matt 	int fl_freelist;
    346   1.78.36.1.2.7      matt };
    347   1.78.36.1.2.7      matt 
    348             1.1  jonathan /*
    349             1.1  jonathan  * The "active" locore-fuction vector, and
    350             1.1  jonathan  */
    351             1.1  jonathan extern mips_locore_jumpvec_t mips_locore_jumpvec;
    352   1.78.36.1.2.2      matt extern struct locoresw mips_locoresw;
    353             1.1  jonathan 
    354            1.59    simonb #if    defined(MIPS1) && !defined(MIPS3) && !defined(MIPS32) && !defined(MIPS64)
    355   1.78.36.1.2.8      matt #define tlb_set_asid		mips1_tlb_set_asid
    356  1.78.36.1.2.14      matt #define tlb_invalidate_asids	mips1_tlb_invalidate_asids
    357   1.78.36.1.2.8      matt #define tlb_invalidate_addr	mips1_tlb_invalidate_addr
    358  1.78.36.1.2.14      matt #define tlb_invalidate_globals	mips1_tlb_invalidate_globals
    359  1.78.36.1.2.14      matt #define tlb_invalidate_all	mips1_tlb_invalidate_all
    360  1.78.36.1.2.15      matt #define tlb_record_asids	mips1_tlb_record_asids
    361   1.78.36.1.2.8      matt #define tlb_update		mips1_tlb_update
    362  1.78.36.1.2.16      matt #define tlb_enter		mips1_tlb_enter
    363   1.78.36.1.2.8      matt #define tlb_read_indexed	mips1_tlb_read_indexed
    364  1.78.36.1.2.14      matt #define wbflush			mips1_wbflush
    365            1.76      yamt #define lwp_trampoline		mips1_lwp_trampoline
    366       1.78.36.1       snj #define setfunc_trampoline	mips1_setfunc_trampoline
    367            1.60       uch #elif !defined(MIPS1) &&  defined(MIPS3) && !defined(MIPS32) && !defined(MIPS64) && !defined(MIPS3_5900)
    368   1.78.36.1.2.8      matt #define tlb_set_asid		mips3_tlb_set_asid
    369  1.78.36.1.2.14      matt #define tlb_invalidate_asids	mips3_tlb_invalidate_asids
    370   1.78.36.1.2.8      matt #define tlb_invalidate_addr	mips3_tlb_invalidate_addr
    371  1.78.36.1.2.14      matt #define tlb_invalidate_globals	mips3_tlb_invalidate_globals
    372  1.78.36.1.2.14      matt #define tlb_invalidate_all	mips3_tlb_invalidate_all
    373  1.78.36.1.2.15      matt #define tlb_record_asids	mips3_tlb_record_asids
    374   1.78.36.1.2.8      matt #define tlb_update		mips3_tlb_update
    375  1.78.36.1.2.16      matt #define tlb_enter		mips3_tlb_enter
    376   1.78.36.1.2.8      matt #define tlb_read_indexed	mips3_tlb_read_indexed
    377   1.78.36.1.2.8      matt #define tlb_write_indexed_VPS	mips3_tlb_write_indexed_VPS
    378            1.76      yamt #define lwp_trampoline		mips3_lwp_trampoline
    379       1.78.36.1       snj #define setfunc_trampoline	mips3_setfunc_trampoline
    380  1.78.36.1.2.14      matt #define wbflush			mips3_wbflush
    381            1.59    simonb #elif !defined(MIPS1) && !defined(MIPS3) &&  defined(MIPS32) && !defined(MIPS64)
    382   1.78.36.1.2.8      matt #define tlb_set_asid		mips32_tlb_set_asid
    383  1.78.36.1.2.14      matt #define tlb_invalidate_asids	mips32_tlb_invalidate_asids
    384   1.78.36.1.2.8      matt #define tlb_invalidate_addr	mips32_tlb_invalidate_addr
    385  1.78.36.1.2.14      matt #define tlb_invalidate_globals	mips32_tlb_invalidate_globals
    386  1.78.36.1.2.14      matt #define tlb_invalidate_all	mips32_tlb_invalidate_all
    387  1.78.36.1.2.15      matt #define tlb_record_asids	mips32_tlb_record_asids
    388   1.78.36.1.2.8      matt #define tlb_update		mips32_tlb_update
    389  1.78.36.1.2.16      matt #define tlb_enter		mips32_tlb_enter
    390   1.78.36.1.2.8      matt #define tlb_read_indexed	mips32_tlb_read_indexed
    391   1.78.36.1.2.8      matt #define tlb_write_indexed_VPS	mips32_tlb_write_indexed_VPS
    392            1.76      yamt #define lwp_trampoline		mips32_lwp_trampoline
    393       1.78.36.1       snj #define setfunc_trampoline	mips32_setfunc_trampoline
    394  1.78.36.1.2.14      matt #define wbflush			mips32_wbflush
    395            1.59    simonb #elif !defined(MIPS1) && !defined(MIPS3) && !defined(MIPS32) &&  defined(MIPS64)
    396            1.59    simonb  /* all common with mips3 */
    397   1.78.36.1.2.8      matt #define tlb_set_asid		mips64_tlb_set_asid
    398  1.78.36.1.2.14      matt #define tlb_invalidate_asids	mips64_tlb_invalidate_asids
    399   1.78.36.1.2.8      matt #define tlb_invalidate_addr	mips64_tlb_invalidate_addr
    400  1.78.36.1.2.14      matt #define tlb_invalidate_globals	mips64_tlb_invalidate_globals
    401  1.78.36.1.2.14      matt #define tlb_invalidate_all	mips64_tlb_invalidate_all
    402  1.78.36.1.2.15      matt #define tlb_record_asids	mips64_tlb_record_asids
    403   1.78.36.1.2.8      matt #define tlb_update		mips64_tlb_update
    404  1.78.36.1.2.16      matt #define tlb_enter		mips64_tlb_enter
    405   1.78.36.1.2.8      matt #define tlb_read_indexed	mips64_tlb_read_indexed
    406   1.78.36.1.2.8      matt #define tlb_write_indexed_VPS	mips64_tlb_write_indexed_VPS
    407            1.76      yamt #define lwp_trampoline		mips64_lwp_trampoline
    408       1.78.36.1       snj #define setfunc_trampoline	mips64_setfunc_trampoline
    409  1.78.36.1.2.14      matt #define wbflush			mips64_wbflush
    410            1.60       uch #elif !defined(MIPS1) &&  defined(MIPS3) && !defined(MIPS32) && !defined(MIPS64) && defined(MIPS3_5900)
    411   1.78.36.1.2.8      matt #define tlb_set_asid		mips5900_tlb_set_asid
    412  1.78.36.1.2.14      matt #define tlb_invalidate_asids	mips5900_tlb_invalidate_asids
    413   1.78.36.1.2.8      matt #define tlb_invalidate_addr	mips5900_tlb_invalidate_addr
    414  1.78.36.1.2.14      matt #define tlb_invalidate_globals	mips5900_tlb_invalidate_globals
    415  1.78.36.1.2.14      matt #define tlb_invalidate_all	mips5900_tlb_invalidate_all
    416  1.78.36.1.2.15      matt #define tlb_record_asids	mips5900_tlb_record_asids
    417   1.78.36.1.2.8      matt #define tlb_update		mips5900_tlb_update
    418  1.78.36.1.2.16      matt #define tlb_enter		mips5900_tlb_enter
    419   1.78.36.1.2.8      matt #define tlb_read_indexed	mips5900_tlb_read_indexed
    420   1.78.36.1.2.8      matt #define tlb_write_indexed_VPS	mips5900_tlb_write_indexed_VPS
    421            1.76      yamt #define lwp_trampoline		mips5900_lwp_trampoline
    422       1.78.36.1       snj #define setfunc_trampoline	mips5900_setfunc_trampoline
    423  1.78.36.1.2.14      matt #define wbflush			mips5900_wbflush
    424            1.59    simonb #else
    425  1.78.36.1.2.14      matt #define tlb_set_asid		(*mips_locore_jumpvec.ljv_tlb_set_asid)
    426  1.78.36.1.2.14      matt #define tlb_invalidate_asids	(*mips_locore_jumpvec.ljv_tlb_invalidate_asids)
    427  1.78.36.1.2.14      matt #define tlb_invalidate_addr	(*mips_locore_jumpvec.ljv_tlb_invalidate_addr)
    428  1.78.36.1.2.14      matt #define tlb_invalidate_globals	(*mips_locore_jumpvec.ljv_tlb_invalidate_globals)
    429  1.78.36.1.2.14      matt #define tlb_invalidate_all	(*mips_locore_jumpvec.ljv_tlb_invalidate_all)
    430  1.78.36.1.2.15      matt #define tlb_record_asids	(*mips_locore_jumpvec.ljv_tlb_record_asids)
    431  1.78.36.1.2.14      matt #define tlb_update		(*mips_locore_jumpvec.ljv_tlb_update)
    432  1.78.36.1.2.16      matt #define tlb_enter		(*mips_locore_jumpvec.ljv_tlb_enter)
    433  1.78.36.1.2.14      matt #define tlb_read_indexed	(*mips_locore_jumpvec.ljv_tlb_read_indexed)
    434  1.78.36.1.2.14      matt #define wbflush			(*mips_locore_jumpvec.ljv_wbflush)
    435   1.78.36.1.2.2      matt #define lwp_trampoline		mips_locoresw.lsw_lwp_trampoline
    436   1.78.36.1.2.2      matt #define setfunc_trampoline	mips_locoresw.lsw_setfunc_trampoline
    437            1.11  jonathan #endif
    438            1.31  nisimura 
    439   1.78.36.1.2.2      matt #define CPU_IDLE		mips_locoresw.lsw_cpu_idle
    440            1.11  jonathan 
    441            1.16    castor /* cpu_switch_resume is called inside locore.S */
    442             1.7  jonathan 
    443             1.7  jonathan /*
    444             1.7  jonathan  * CPU identification, from PRID register.
    445             1.7  jonathan  */
    446            1.70   tsutsui #define MIPS_PRID_REV(x)	(((x) >>  0) & 0x00ff)
    447            1.70   tsutsui #define MIPS_PRID_IMPL(x)	(((x) >>  8) & 0x00ff)
    448            1.45       cgd 
    449            1.59    simonb /* pre-MIPS32/64 */
    450            1.70   tsutsui #define MIPS_PRID_RSVD(x)	(((x) >> 16) & 0xffff)
    451            1.70   tsutsui #define MIPS_PRID_REV_MIN(x)	((MIPS_PRID_REV(x) >> 0) & 0x0f)
    452            1.70   tsutsui #define MIPS_PRID_REV_MAJ(x)	((MIPS_PRID_REV(x) >> 4) & 0x0f)
    453            1.45       cgd 
    454            1.59    simonb /* MIPS32/64 */
    455            1.70   tsutsui #define MIPS_PRID_CID(x)	(((x) >> 16) & 0x00ff)	/* Company ID */
    456            1.70   tsutsui #define     MIPS_PRID_CID_PREHISTORIC	0x00	/* Not MIPS32/64 */
    457            1.70   tsutsui #define     MIPS_PRID_CID_MTI		0x01	/* MIPS Technologies, Inc. */
    458            1.70   tsutsui #define     MIPS_PRID_CID_BROADCOM	0x02	/* Broadcom */
    459            1.70   tsutsui #define     MIPS_PRID_CID_ALCHEMY	0x03	/* Alchemy Semiconductor */
    460            1.70   tsutsui #define     MIPS_PRID_CID_SIBYTE	0x04	/* SiByte */
    461            1.70   tsutsui #define     MIPS_PRID_CID_SANDCRAFT	0x05	/* SandCraft */
    462            1.70   tsutsui #define     MIPS_PRID_CID_PHILIPS	0x06	/* Philips */
    463            1.70   tsutsui #define     MIPS_PRID_CID_TOSHIBA	0x07	/* Toshiba */
    464            1.70   tsutsui #define     MIPS_PRID_CID_LSI		0x08	/* LSI */
    465            1.67    simonb 				/*	0x09	unannounced */
    466            1.67    simonb 				/*	0x0a	unannounced */
    467            1.70   tsutsui #define     MIPS_PRID_CID_LEXRA		0x0b	/* Lexra */
    468   1.78.36.1.2.3      matt #define     MIPS_PRID_CID_RMI		0x0c	/* RMI / NetLogic */
    469            1.70   tsutsui #define MIPS_PRID_COPTS(x)	(((x) >> 24) & 0x00ff)	/* Company Options */
    470             1.6  jonathan 
    471             1.6  jonathan #ifdef _KERNEL
    472             1.6  jonathan /*
    473             1.6  jonathan  * Global variables used to communicate CPU type, and parameters
    474             1.6  jonathan  * such as cache size, from locore to higher-level code (e.g., pmap).
    475             1.6  jonathan  */
    476            1.75  christos void mips_pagecopy(void *dst, void *src);
    477            1.75  christos void mips_pagezero(void *dst);
    478            1.19  jonathan 
    479            1.59    simonb #ifdef __HAVE_MIPS_MACHDEP_CACHE_CONFIG
    480            1.59    simonb void mips_machdep_cache_config(void);
    481            1.59    simonb #endif
    482            1.59    simonb 
    483            1.19  jonathan /*
    484            1.20    simonb  * trapframe argument passed to trap()
    485            1.19  jonathan  */
    486            1.64   thorpej 
    487  1.78.36.1.2.11      matt #if 0
    488  1.78.36.1.2.11      matt #define TF_AST		0		/* really zero */
    489  1.78.36.1.2.11      matt #define TF_V0		_R_V0
    490  1.78.36.1.2.11      matt #define TF_V1		_R_V1
    491  1.78.36.1.2.11      matt #define TF_A0		_R_A0
    492  1.78.36.1.2.11      matt #define TF_A1		_R_A1
    493  1.78.36.1.2.11      matt #define TF_A2		_R_A2
    494  1.78.36.1.2.11      matt #define TF_A3		_R_A3
    495  1.78.36.1.2.11      matt #define TF_T0		_R_T0
    496  1.78.36.1.2.11      matt #define TF_T1		_R_T1
    497  1.78.36.1.2.11      matt #define TF_T2		_R_T2
    498  1.78.36.1.2.11      matt #define TF_T3		_R_T3
    499            1.64   thorpej 
    500            1.64   thorpej #if defined(__mips_n32) || defined(__mips_n64)
    501  1.78.36.1.2.11      matt #define TF_A4		_R_A4
    502  1.78.36.1.2.11      matt #define TF_A5		_R_A5
    503  1.78.36.1.2.11      matt #define TF_A6		_R_A6
    504  1.78.36.1.2.11      matt #define TF_A7		_R_A7
    505            1.64   thorpej #else
    506  1.78.36.1.2.11      matt #define TF_T4		_R_T4
    507  1.78.36.1.2.11      matt #define TF_T5		_R_T5
    508  1.78.36.1.2.11      matt #define TF_T6		_R_T6
    509  1.78.36.1.2.11      matt #define TF_T7		_R_T7
    510            1.64   thorpej #endif /* __mips_n32 || __mips_n64 */
    511            1.64   thorpej 
    512  1.78.36.1.2.11      matt #define TF_TA0		_R_TA0
    513  1.78.36.1.2.11      matt #define TF_TA1		_R_TA1
    514  1.78.36.1.2.11      matt #define TF_TA2		_R_TA2
    515  1.78.36.1.2.11      matt #define TF_TA3		_R_TA3
    516  1.78.36.1.2.11      matt 
    517  1.78.36.1.2.11      matt #define TF_T8		_R_T8
    518  1.78.36.1.2.11      matt #define TF_T9		_R_T9
    519  1.78.36.1.2.11      matt 
    520  1.78.36.1.2.11      matt #define TF_RA		_R_RA
    521  1.78.36.1.2.11      matt #define TF_SR		_R_SR
    522  1.78.36.1.2.11      matt #define TF_MULLO	_R_MULLO
    523  1.78.36.1.2.11      matt #define TF_MULHI	_R_MULLO
    524  1.78.36.1.2.11      matt #define TF_EPC		_R_PC		/* may be changed by trap() call */
    525            1.65   thorpej 
    526  1.78.36.1.2.11      matt #define	TF_NREGS	(sizeof(struct reg) / sizeof(mips_reg_t))
    527  1.78.36.1.2.11      matt #endif
    528            1.64   thorpej 
    529            1.19  jonathan struct trapframe {
    530  1.78.36.1.2.11      matt 	struct reg tf_registers;
    531  1.78.36.1.2.11      matt #define	tf_regs	tf_registers.r_regs
    532   1.78.36.1.2.2      matt 	uint32_t   tf_ppl;		/* previous priority level */
    533   1.78.36.1.2.2      matt 	mips_reg_t tf_pad;		/* for 8 byte aligned */
    534            1.19  jonathan };
    535            1.19  jonathan 
    536  1.78.36.1.2.11      matt CTASSERT(sizeof(struct trapframe) % (4*sizeof(mips_reg_t)) == 0);
    537  1.78.36.1.2.11      matt 
    538            1.19  jonathan /*
    539            1.19  jonathan  * Stack frame for kernel traps. four args passed in registers.
    540            1.19  jonathan  * A trapframe is pointed to by the 5th arg, and a dummy sixth argument
    541            1.19  jonathan  * is used to avoid alignment problems
    542            1.19  jonathan  */
    543            1.19  jonathan 
    544            1.19  jonathan struct kernframe {
    545   1.78.36.1.2.1      matt #if defined(__mips_o32) || defined(__mips_o64)
    546            1.19  jonathan 	register_t cf_args[4 + 1];
    547   1.78.36.1.2.1      matt #if defined(__mips_o32)
    548  1.78.36.1.2.11      matt 	register_t cf_pad;		/* (for 8 byte alignment) */
    549   1.78.36.1.2.1      matt #endif
    550   1.78.36.1.2.1      matt #endif
    551   1.78.36.1.2.1      matt #if defined(__mips_n32) || defined(__mips_n64)
    552   1.78.36.1.2.4      matt 	register_t cf_pad[2];		/* for 16 byte alignment */
    553   1.78.36.1.2.1      matt #endif
    554            1.19  jonathan 	register_t cf_sp;
    555            1.19  jonathan 	register_t cf_ra;
    556            1.19  jonathan 	struct trapframe cf_frame;
    557            1.19  jonathan };
    558  1.78.36.1.2.11      matt 
    559  1.78.36.1.2.11      matt CTASSERT(sizeof(struct kernframe) % (2*sizeof(mips_reg_t)) == 0);
    560  1.78.36.1.2.11      matt 
    561            1.61    simonb #endif	/* _KERNEL */
    562             1.1  jonathan #endif	/* _MIPS_LOCORE_H */
    563