Home | History | Annotate | Line # | Download | only in include
locore.h revision 1.116.2.1
      1  1.116.2.1   thorpej /* $NetBSD: locore.h,v 1.116.2.1 2021/04/03 22:28:31 thorpej Exp $ */
      2       1.83      matt 
      3       1.83      matt /*
      4       1.83      matt  * This file should not be included by MI code!!!
      5       1.83      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.81       snj  * architecture (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.110    simonb #define	_MIPS_LOCORE_H
     30        1.2  jonathan 
     31      1.111     skrll #if !defined(_MODULE) && defined(_KERNEL_OPT)
     32       1.32     soren #include "opt_cputype.h"
     33       1.17    castor #endif
     34       1.16    castor 
     35      1.101  macallan #ifndef __ASSEMBLER__
     36      1.101  macallan 
     37      1.100      matt #include <sys/cpu.h>
     38      1.100      matt 
     39       1.83      matt #include <mips/mutex.h>
     40       1.59    simonb #include <mips/cpuregs.h>
     41       1.83      matt #include <mips/reg.h>
     42       1.83      matt 
     43      1.100      matt #ifndef __BSD_PTENTRY_T__
     44      1.110    simonb #define	__BSD_PTENTRY_T__
     45      1.100      matt typedef uint32_t pt_entry_t;
     46      1.110    simonb #define	PRIxPTE		PRIx32
     47      1.100      matt #endif
     48      1.100      matt 
     49      1.100      matt #include <uvm/pmap/tlb.h>
     50      1.101  macallan #endif /* !__ASSEMBLER__ */
     51      1.100      matt 
     52      1.100      matt #ifdef _KERNEL
     53      1.100      matt 
     54      1.111     skrll #if defined(_MODULE) || defined(_STANDALONE)
     55      1.111     skrll /* Assume all CPU architectures are valid for modules and standlone progs */
     56      1.100      matt #if !defined(__mips_n32) && !defined(__mips_n64)
     57      1.100      matt #define	MIPS1		1
     58      1.100      matt #endif
     59      1.100      matt #define	MIPS3		1
     60      1.100      matt #define	MIPS4		1
     61      1.100      matt #if !defined(__mips_n32) && !defined(__mips_n64)
     62      1.100      matt #define	MIPS32		1
     63      1.100      matt #define	MIPS32R2	1
     64      1.100      matt #endif
     65      1.100      matt #define	MIPS64		1
     66      1.100      matt #define	MIPS64R2	1
     67      1.111     skrll #endif /* _MODULE || _STANDALONE */
     68      1.100      matt 
     69      1.100      matt #if (MIPS1 + MIPS3 + MIPS4 + MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) == 0
     70      1.100      matt #error at least one of MIPS1, MIPS3, MIPS4, MIPS32, MIPS32R2, MIPS64, or MIPS64R2 must be specified
     71      1.100      matt #endif
     72      1.100      matt 
     73      1.100      matt /* Shortcut for MIPS3 or above defined */
     74      1.100      matt #if defined(MIPS3) || defined(MIPS4) \
     75      1.100      matt     || defined(MIPS32) || defined(MIPS32R2) \
     76      1.100      matt     || defined(MIPS64) || defined(MIPS64R2)
     77      1.100      matt 
     78      1.100      matt #define	MIPS3_PLUS	1
     79      1.100      matt #if !defined(MIPS32) && !defined(MIPS32R2)
     80      1.110    simonb #define	MIPS3_64BIT	1
     81      1.100      matt #endif
     82      1.100      matt #if !defined(MIPS3) && !defined(MIPS4)
     83      1.110    simonb #define	MIPSNN		1
     84      1.100      matt #endif
     85      1.100      matt #if defined(MIPS32R2) || defined(MIPS64R2)
     86      1.110    simonb #define	MIPSNNR2	1
     87      1.100      matt #endif
     88      1.100      matt #else
     89      1.100      matt #undef MIPS3_PLUS
     90      1.100      matt #endif
     91      1.100      matt 
     92      1.116    simonb #if defined(MIPS1) && (ENABLE_MIPS_8KB_PAGE + ENABLE_MIPS_16KB_PAGE) > 0
     93      1.116    simonb #error MIPS1 only supports a 4kB page size.
     94      1.100      matt #endif
     95      1.100      matt 
     96      1.101  macallan /* XXX some .S files look for MIPS3_PLUS */
     97      1.101  macallan #ifndef __ASSEMBLER__
     98      1.115       mrg #ifdef _KERNEL
     99      1.101  macallan 
    100      1.100      matt /* XXX simonb
    101      1.100      matt  * Should the following be in a cpu_info type structure?
    102      1.100      matt  * And how many of these are per-cpu vs. per-system?  (Ie,
    103      1.100      matt  * we can assume that all cpus have the same mmu-type, but
    104      1.100      matt  * maybe not that all cpus run at the same clock speed.
    105      1.100      matt  * Some SGI's apparently support R12k and R14k in the same
    106      1.100      matt  * box.)
    107      1.100      matt  */
    108      1.100      matt struct mips_options {
    109      1.100      matt 	const struct pridtab *mips_cpu;
    110      1.100      matt 
    111      1.100      matt 	u_int mips_cpu_arch;
    112      1.100      matt 	u_int mips_cpu_mhz; /* CPU speed in MHz, estimated by mc_cpuspeed(). */
    113      1.100      matt 	u_int mips_cpu_flags;
    114      1.100      matt 	u_int mips_num_tlb_entries;
    115      1.100      matt 	mips_prid_t mips_cpu_id;
    116      1.100      matt 	mips_prid_t mips_fpu_id;
    117      1.100      matt 	bool mips_has_r4k_mmu;
    118      1.100      matt 	bool mips_has_llsc;
    119      1.100      matt 	u_int mips3_pg_shift;
    120      1.100      matt 	u_int mips3_pg_cached;
    121      1.100      matt 	u_int mips3_cca_devmem;
    122      1.100      matt #ifdef MIPS3_PLUS
    123      1.100      matt #ifndef __mips_o32
    124      1.100      matt 	uint64_t mips3_xkphys_cached;
    125      1.100      matt #endif
    126      1.100      matt 	uint64_t mips3_tlb_vpn_mask;
    127      1.100      matt 	uint64_t mips3_tlb_pfn_mask;
    128      1.100      matt 	uint32_t mips3_tlb_pg_mask;
    129      1.100      matt #endif
    130      1.100      matt };
    131      1.100      matt 
    132      1.101  macallan #endif /* !__ASSEMBLER__ */
    133      1.101  macallan 
    134      1.100      matt /*
    135      1.100      matt  * Macros to find the CPU architecture we're on at run-time,
    136      1.100      matt  * or if possible, at compile-time.
    137      1.100      matt  */
    138      1.100      matt 
    139      1.100      matt #define	CPU_ARCH_MIPSx		0		/* XXX unknown */
    140      1.100      matt #define	CPU_ARCH_MIPS1		(1 << 0)
    141      1.100      matt #define	CPU_ARCH_MIPS2		(1 << 1)
    142      1.100      matt #define	CPU_ARCH_MIPS3		(1 << 2)
    143      1.100      matt #define	CPU_ARCH_MIPS4		(1 << 3)
    144      1.100      matt #define	CPU_ARCH_MIPS5		(1 << 4)
    145      1.100      matt #define	CPU_ARCH_MIPS32		(1 << 5)
    146      1.100      matt #define	CPU_ARCH_MIPS64		(1 << 6)
    147      1.100      matt #define	CPU_ARCH_MIPS32R2	(1 << 7)
    148      1.100      matt #define	CPU_ARCH_MIPS64R2	(1 << 8)
    149      1.100      matt 
    150      1.107    simonb #define	CPU_MIPS_R4K_MMU		0x00001
    151      1.107    simonb #define	CPU_MIPS_NO_LLSC		0x00002
    152      1.107    simonb #define	CPU_MIPS_CAUSE_IV		0x00004
    153      1.107    simonb #define	CPU_MIPS_HAVE_SPECIAL_CCA	0x00008	/* Defaults to '3' if not set. */
    154      1.107    simonb #define	CPU_MIPS_CACHED_CCA_MASK	0x00070
    155      1.100      matt #define	CPU_MIPS_CACHED_CCA_SHIFT	 4
    156      1.107    simonb #define	CPU_MIPS_DOUBLE_COUNT		0x00080	/* 1 cp0 count == 2 clock cycles */
    157      1.107    simonb #define	CPU_MIPS_USE_WAIT		0x00100	/* Use "wait"-based cpu_idle() */
    158      1.107    simonb #define	CPU_MIPS_NO_WAIT		0x00200	/* Inverse of previous, for mips32/64 */
    159      1.107    simonb #define	CPU_MIPS_D_CACHE_COHERENT	0x00400	/* D-cache is fully coherent */
    160      1.107    simonb #define	CPU_MIPS_I_D_CACHE_COHERENT	0x00800	/* I-cache funcs don't need to flush the D-cache */
    161      1.107    simonb #define	CPU_MIPS_NO_LLADDR		0x01000
    162      1.107    simonb #define	CPU_MIPS_HAVE_MxCR		0x02000	/* have mfcr, mtcr insns */
    163      1.107    simonb #define	CPU_MIPS_LOONGSON2		0x04000
    164      1.107    simonb #define	MIPS_NOT_SUPP			0x08000
    165      1.100      matt #define	CPU_MIPS_HAVE_DSP		0x10000
    166      1.107    simonb #define	CPU_MIPS_HAVE_USERLOCAL		0x20000
    167      1.100      matt 
    168      1.100      matt #endif	/* !_LOCORE */
    169      1.100      matt 
    170      1.100      matt #if ((MIPS1 + MIPS3 + MIPS4 + MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) == 1) || defined(_LOCORE)
    171      1.100      matt 
    172      1.100      matt #if defined(MIPS1)
    173      1.100      matt 
    174      1.100      matt # define CPUISMIPS3		0
    175      1.100      matt # define CPUIS64BITS		0
    176      1.100      matt # define CPUISMIPS32		0
    177      1.100      matt # define CPUISMIPS32R2		0
    178      1.100      matt # define CPUISMIPS64		0
    179      1.100      matt # define CPUISMIPS64R2		0
    180      1.100      matt # define CPUISMIPSNN		0
    181      1.100      matt # define CPUISMIPSNNR2		0
    182      1.100      matt # define MIPS_HAS_R4K_MMU	0
    183      1.100      matt # define MIPS_HAS_CLOCK		0
    184      1.100      matt # define MIPS_HAS_LLSC		0
    185      1.100      matt # define MIPS_HAS_LLADDR	0
    186      1.107    simonb # define MIPS_HAS_LMMI		0
    187      1.100      matt # define MIPS_HAS_DSP		0
    188      1.107    simonb # define MIPS_HAS_USERLOCAL	0
    189      1.100      matt 
    190      1.100      matt #elif defined(MIPS3) || defined(MIPS4)
    191      1.100      matt 
    192      1.100      matt # define CPUISMIPS3		1
    193      1.100      matt # define CPUIS64BITS		1
    194      1.100      matt # define CPUISMIPS32		0
    195      1.100      matt # define CPUISMIPS32R2		0
    196      1.100      matt # define CPUISMIPS64		0
    197      1.100      matt # define CPUISMIPS64R2		0
    198      1.100      matt # define CPUISMIPSNN		0
    199      1.100      matt # define CPUISMIPSNNR2		0
    200      1.100      matt # define MIPS_HAS_R4K_MMU	1
    201      1.100      matt # define MIPS_HAS_CLOCK		1
    202      1.100      matt # if defined(_LOCORE)
    203      1.100      matt #  if !defined(MIPS3_4100)
    204      1.100      matt #   define MIPS_HAS_LLSC	1
    205      1.100      matt #  else
    206      1.100      matt #   define MIPS_HAS_LLSC	0
    207      1.100      matt #  endif
    208      1.100      matt # else	/* _LOCORE */
    209      1.100      matt #  define MIPS_HAS_LLSC		(mips_options.mips_has_llsc)
    210      1.100      matt # endif	/* _LOCORE */
    211      1.100      matt # define MIPS_HAS_LLADDR	((mips_options.mips_cpu_flags & CPU_MIPS_NO_LLADDR) == 0)
    212      1.100      matt # if defined(MIPS3_LOONGSON2)
    213      1.100      matt #  define MIPS_HAS_LMMI		((mips_options.mips_cpu_flags & CPU_MIPS_LOONGSON2) != 0)
    214      1.100      matt # else
    215      1.100      matt #  define MIPS_HAS_LMMI		0
    216      1.100      matt # endif
    217      1.107    simonb # define MIPS_HAS_DSP		0
    218      1.107    simonb # define MIPS_HAS_USERLOCAL	0
    219      1.107    simonb 
    220      1.100      matt #elif defined(MIPS32)
    221      1.100      matt 
    222      1.100      matt # define CPUISMIPS3		1
    223      1.100      matt # define CPUIS64BITS		0
    224      1.100      matt # define CPUISMIPS32		1
    225      1.100      matt # define CPUISMIPS32R2		0
    226      1.100      matt # define CPUISMIPS64		0
    227      1.100      matt # define CPUISMIPS64R2		0
    228      1.100      matt # define CPUISMIPSNN		1
    229      1.100      matt # define CPUISMIPSNNR2		0
    230      1.100      matt # define MIPS_HAS_R4K_MMU	1
    231      1.100      matt # define MIPS_HAS_CLOCK		1
    232      1.100      matt # define MIPS_HAS_LLSC		1
    233      1.100      matt # define MIPS_HAS_LLADDR	((mips_options.mips_cpu_flags & CPU_MIPS_NO_LLADDR) == 0)
    234      1.107    simonb # define MIPS_HAS_LMMI		0
    235      1.100      matt # define MIPS_HAS_DSP		0
    236      1.107    simonb # define MIPS_HAS_USERLOCAL	0
    237      1.100      matt 
    238      1.100      matt #elif defined(MIPS32R2)
    239      1.100      matt 
    240      1.100      matt # define CPUISMIPS3		1
    241      1.100      matt # define CPUIS64BITS		0
    242      1.100      matt # define CPUISMIPS32		0
    243      1.100      matt # define CPUISMIPS32R2		1
    244      1.100      matt # define CPUISMIPS64		0
    245      1.100      matt # define CPUISMIPS64R2		0
    246      1.100      matt # define CPUISMIPSNN		1
    247      1.100      matt # define CPUISMIPSNNR2		1
    248      1.100      matt # define MIPS_HAS_R4K_MMU	1
    249      1.100      matt # define MIPS_HAS_CLOCK		1
    250      1.100      matt # define MIPS_HAS_LLSC		1
    251      1.100      matt # define MIPS_HAS_LLADDR	((mips_options.mips_cpu_flags & CPU_MIPS_NO_LLADDR) == 0)
    252      1.107    simonb # define MIPS_HAS_LMMI		0
    253      1.100      matt # define MIPS_HAS_DSP		(mips_options.mips_cpu_flags & CPU_MIPS_HAVE_DSP)
    254      1.107    simonb # define MIPS_HAS_USERLOCAL	(mips_options.mips_cpu_flags & CPU_MIPS_HAVE_USERLOCAL)
    255      1.100      matt 
    256      1.100      matt #elif defined(MIPS64)
    257      1.100      matt 
    258      1.100      matt # define CPUISMIPS3		1
    259      1.100      matt # define CPUIS64BITS		1
    260      1.100      matt # define CPUISMIPS32		0
    261      1.100      matt # define CPUISMIPS32R2		0
    262      1.100      matt # define CPUISMIPS64		1
    263      1.100      matt # define CPUISMIPS64R2		0
    264      1.100      matt # define CPUISMIPSNN		1
    265      1.100      matt # define CPUISMIPSNNR2		0
    266      1.100      matt # define MIPS_HAS_R4K_MMU	1
    267      1.100      matt # define MIPS_HAS_CLOCK		1
    268      1.100      matt # define MIPS_HAS_LLSC		1
    269      1.100      matt # define MIPS_HAS_LLADDR	((mips_options.mips_cpu_flags & CPU_MIPS_NO_LLADDR) == 0)
    270      1.107    simonb # define MIPS_HAS_LMMI		0
    271      1.100      matt # define MIPS_HAS_DSP		0
    272      1.107    simonb # define MIPS_HAS_USERLOCAL	0
    273      1.100      matt 
    274      1.100      matt #elif defined(MIPS64R2)
    275      1.100      matt 
    276      1.100      matt # define CPUISMIPS3		1
    277      1.100      matt # define CPUIS64BITS		1
    278      1.100      matt # define CPUISMIPS32		0
    279      1.100      matt # define CPUISMIPS32R2		0
    280      1.100      matt # define CPUISMIPS64		0
    281      1.100      matt # define CPUISMIPS64R2		1
    282      1.100      matt # define CPUISMIPSNN		1
    283      1.100      matt # define CPUISMIPSNNR2		1
    284      1.100      matt # define MIPS_HAS_R4K_MMU	1
    285      1.100      matt # define MIPS_HAS_CLOCK		1
    286      1.100      matt # define MIPS_HAS_LLSC		1
    287      1.100      matt # define MIPS_HAS_LLADDR	((mips_options.mips_cpu_flags & CPU_MIPS_NO_LLADDR) == 0)
    288      1.107    simonb # define MIPS_HAS_LMMI		0
    289      1.100      matt # define MIPS_HAS_DSP		(mips_options.mips_cpu_flags & CPU_MIPS_HAVE_DSP)
    290      1.107    simonb # define MIPS_HAS_USERLOCAL	(mips_options.mips_cpu_flags & CPU_MIPS_HAVE_USERLOCAL)
    291      1.100      matt 
    292      1.100      matt #endif
    293      1.100      matt 
    294      1.100      matt #else /* run-time test */
    295      1.100      matt 
    296      1.100      matt #ifdef MIPS1
    297      1.100      matt #define	MIPS_HAS_R4K_MMU	(mips_options.mips_has_r4k_mmu)
    298      1.100      matt #define	MIPS_HAS_LLSC		(mips_options.mips_has_llsc)
    299      1.100      matt #else
    300      1.100      matt #define	MIPS_HAS_R4K_MMU	1
    301      1.100      matt #if !defined(MIPS3_4100)
    302      1.110    simonb #define	MIPS_HAS_LLSC		1
    303      1.100      matt #else
    304      1.110    simonb #define	MIPS_HAS_LLSC		(mips_options.mips_has_llsc)
    305      1.100      matt #endif
    306      1.100      matt #endif
    307      1.100      matt #define	MIPS_HAS_LLADDR		((mips_options.mips_cpu_flags & CPU_MIPS_NO_LLADDR) == 0)
    308      1.110    simonb #define	MIPS_HAS_DSP		(mips_options.mips_cpu_flags & CPU_MIPS_HAVE_DSP)
    309      1.107    simonb # define MIPS_HAS_USERLOCAL	(mips_options.mips_cpu_flags & CPU_MIPS_HAVE_USERLOCAL)
    310      1.100      matt 
    311      1.100      matt /* This test is ... rather bogus */
    312      1.100      matt #define	CPUISMIPS3	((mips_options.mips_cpu_arch & \
    313      1.100      matt 	(CPU_ARCH_MIPS3 | CPU_ARCH_MIPS4 | CPU_ARCH_MIPS32 | CPU_ARCH_MIPS64)) != 0)
    314      1.100      matt 
    315      1.100      matt /* And these aren't much better while the previous test exists as is... */
    316      1.100      matt #define	CPUISMIPS4	((mips_options.mips_cpu_arch & CPU_ARCH_MIPS4) != 0)
    317      1.100      matt #define	CPUISMIPS5	((mips_options.mips_cpu_arch & CPU_ARCH_MIPS5) != 0)
    318      1.100      matt #define	CPUISMIPS32	((mips_options.mips_cpu_arch & CPU_ARCH_MIPS32) != 0)
    319      1.100      matt #define	CPUISMIPS32R2	((mips_options.mips_cpu_arch & CPU_ARCH_MIPS32R2) != 0)
    320      1.100      matt #define	CPUISMIPS64	((mips_options.mips_cpu_arch & CPU_ARCH_MIPS64) != 0)
    321      1.100      matt #define	CPUISMIPS64R2	((mips_options.mips_cpu_arch & CPU_ARCH_MIPS64R2) != 0)
    322      1.107    simonb #define	CPUISMIPSNN	((mips_options.mips_cpu_arch & \
    323      1.107    simonb 	(CPU_ARCH_MIPS32 | CPU_ARCH_MIPS32R2 | CPU_ARCH_MIPS64 | CPU_ARCH_MIPS64R2)) != 0)
    324      1.107    simonb #define	CPUISMIPSNNR2	((mips_options.mips_cpu_arch & \
    325      1.107    simonb 	(CPU_ARCH_MIPS32R2 | CPU_ARCH_MIPS64R2)) != 0)
    326      1.100      matt #define	CPUIS64BITS	((mips_options.mips_cpu_arch & \
    327      1.100      matt 	(CPU_ARCH_MIPS3 | CPU_ARCH_MIPS4 | CPU_ARCH_MIPS64 | CPU_ARCH_MIPS64R2)) != 0)
    328      1.100      matt 
    329      1.100      matt #define	MIPS_HAS_CLOCK	(mips_options.mips_cpu_arch >= CPU_ARCH_MIPS3)
    330      1.100      matt 
    331      1.100      matt #endif /* run-time test */
    332      1.100      matt 
    333      1.101  macallan #ifndef __ASSEMBLER__
    334      1.101  macallan 
    335       1.83      matt struct tlbmask;
    336       1.83      matt struct trapframe;
    337       1.59    simonb 
    338       1.83      matt void	trap(uint32_t, uint32_t, vaddr_t, vaddr_t, struct trapframe *);
    339       1.83      matt void	ast(void);
    340       1.83      matt 
    341       1.83      matt void	mips_fpu_trap(vaddr_t, struct trapframe *);
    342       1.83      matt void	mips_fpu_intr(vaddr_t, struct trapframe *);
    343       1.83      matt 
    344       1.83      matt vaddr_t mips_emul_branch(struct trapframe *, vaddr_t, uint32_t, bool);
    345       1.83      matt void	mips_emul_inst(uint32_t, uint32_t, vaddr_t, struct trapframe *);
    346       1.83      matt 
    347       1.83      matt void	mips_emul_fp(uint32_t, struct trapframe *, uint32_t);
    348       1.83      matt void	mips_emul_branchdelayslot(uint32_t, struct trapframe *, uint32_t);
    349       1.83      matt 
    350       1.83      matt void	mips_emul_lwc0(uint32_t, struct trapframe *, uint32_t);
    351       1.83      matt void	mips_emul_swc0(uint32_t, struct trapframe *, uint32_t);
    352       1.83      matt void	mips_emul_special(uint32_t, struct trapframe *, uint32_t);
    353       1.83      matt void	mips_emul_special3(uint32_t, struct trapframe *, uint32_t);
    354       1.83      matt 
    355       1.83      matt void	mips_emul_lwc1(uint32_t, struct trapframe *, uint32_t);
    356       1.83      matt void	mips_emul_swc1(uint32_t, struct trapframe *, uint32_t);
    357       1.83      matt void	mips_emul_ldc1(uint32_t, struct trapframe *, uint32_t);
    358       1.83      matt void	mips_emul_sdc1(uint32_t, struct trapframe *, uint32_t);
    359       1.83      matt 
    360       1.83      matt void	mips_emul_lb(uint32_t, struct trapframe *, uint32_t);
    361       1.83      matt void	mips_emul_lbu(uint32_t, struct trapframe *, uint32_t);
    362       1.83      matt void	mips_emul_lh(uint32_t, struct trapframe *, uint32_t);
    363       1.83      matt void	mips_emul_lhu(uint32_t, struct trapframe *, uint32_t);
    364       1.83      matt void	mips_emul_lw(uint32_t, struct trapframe *, uint32_t);
    365       1.83      matt void	mips_emul_lwl(uint32_t, struct trapframe *, uint32_t);
    366       1.83      matt void	mips_emul_lwr(uint32_t, struct trapframe *, uint32_t);
    367       1.83      matt #if defined(__mips_n32) || defined(__mips_n64) || defined(__mips_o64)
    368       1.83      matt void	mips_emul_lwu(uint32_t, struct trapframe *, uint32_t);
    369       1.83      matt void	mips_emul_ld(uint32_t, struct trapframe *, uint32_t);
    370       1.83      matt void	mips_emul_ldl(uint32_t, struct trapframe *, uint32_t);
    371       1.83      matt void	mips_emul_ldr(uint32_t, struct trapframe *, uint32_t);
    372       1.83      matt #endif
    373       1.83      matt void	mips_emul_sb(uint32_t, struct trapframe *, uint32_t);
    374       1.83      matt void	mips_emul_sh(uint32_t, struct trapframe *, uint32_t);
    375       1.83      matt void	mips_emul_sw(uint32_t, struct trapframe *, uint32_t);
    376       1.83      matt void	mips_emul_swl(uint32_t, struct trapframe *, uint32_t);
    377       1.83      matt void	mips_emul_swr(uint32_t, struct trapframe *, uint32_t);
    378       1.83      matt #if defined(__mips_n32) || defined(__mips_n64) || defined(__mips_o64)
    379       1.83      matt void	mips_emul_sd(uint32_t, struct trapframe *, uint32_t);
    380       1.83      matt void	mips_emul_sdl(uint32_t, struct trapframe *, uint32_t);
    381       1.83      matt void	mips_emul_sdr(uint32_t, struct trapframe *, uint32_t);
    382       1.83      matt #endif
    383       1.38       cgd 
    384       1.59    simonb uint32_t mips_cp0_cause_read(void);
    385       1.59    simonb void	mips_cp0_cause_write(uint32_t);
    386       1.59    simonb uint32_t mips_cp0_status_read(void);
    387       1.59    simonb void	mips_cp0_status_write(uint32_t);
    388       1.29    simonb 
    389       1.83      matt void	softint_process(uint32_t);
    390       1.83      matt void	softint_fast_dispatch(struct lwp *, int);
    391       1.83      matt 
    392       1.83      matt /*
    393       1.83      matt  * Convert an address to an offset used in a MIPS jump instruction.  The offset
    394       1.83      matt  * contains the low 28 bits (allowing a jump to anywhere within the same 256MB
    395       1.83      matt  * segment of address space) of the address but since mips instructions are
    396       1.83      matt  * always on a 4 byte boundary the low 2 bits are always zero so the 28 bits
    397       1.83      matt  * get shifted right by 2 bits leaving us with a 26 bit result.  To make the
    398       1.83      matt  * offset, we shift left to clear the upper four bits and then right by 6.
    399       1.83      matt  */
    400       1.83      matt #define	fixup_addr2offset(x)	((((uint32_t)(uintptr_t)(x)) << 4) >> 6)
    401       1.98      matt typedef bool (*mips_fixup_callback_t)(int32_t, uint32_t [2], void *);
    402       1.83      matt struct mips_jump_fixup_info {
    403       1.83      matt 	uint32_t jfi_stub;
    404       1.83      matt 	uint32_t jfi_real;
    405       1.83      matt };
    406      1.108     skrll 
    407       1.83      matt void	fixup_splcalls(void);				/* splstubs.c */
    408       1.98      matt bool	mips_fixup_exceptions(mips_fixup_callback_t, void *);
    409       1.99      matt bool	mips_fixup_zero_relative(int32_t, uint32_t [2], void *);
    410       1.92      matt intptr_t
    411       1.92      matt 	mips_fixup_addr(const uint32_t *);
    412       1.83      matt void	mips_fixup_stubs(uint32_t *, uint32_t *);
    413       1.83      matt 
    414       1.83      matt /*
    415       1.83      matt  * Define these stubs...
    416       1.83      matt  */
    417       1.83      matt void	mips_cpu_switch_resume(struct lwp *);
    418       1.83      matt void	wbflush(void);
    419       1.77   tsutsui 
    420       1.59    simonb #ifdef MIPS1
    421       1.83      matt void	mips1_tlb_invalidate_all(void);
    422       1.38       cgd 
    423       1.58   thorpej uint32_t tx3900_cp0_config_read(void);
    424       1.59    simonb #endif
    425       1.38       cgd 
    426      1.100      matt #ifdef MIPS3_PLUS
    427       1.59    simonb uint32_t mips3_cp0_compare_read(void);
    428       1.59    simonb void	mips3_cp0_compare_write(uint32_t);
    429       1.49       cgd 
    430       1.59    simonb uint32_t mips3_cp0_config_read(void);
    431       1.59    simonb void	mips3_cp0_config_write(uint32_t);
    432       1.86      matt 
    433      1.100      matt #ifdef MIPSNN
    434       1.59    simonb uint32_t mipsNN_cp0_config1_read(void);
    435       1.59    simonb void	mipsNN_cp0_config1_write(uint32_t);
    436       1.63    simonb uint32_t mipsNN_cp0_config2_read(void);
    437       1.63    simonb uint32_t mipsNN_cp0_config3_read(void);
    438      1.100      matt uint32_t mipsNN_cp0_config4_read(void);
    439      1.100      matt uint32_t mipsNN_cp0_config5_read(void);
    440      1.100      matt uint32_t mipsNN_cp0_config6_read(void);
    441      1.100      matt uint32_t mipsNN_cp0_config7_read(void);
    442       1.85      matt 
    443       1.89      matt intptr_t mipsNN_cp0_watchlo_read(u_int);
    444       1.89      matt void	mipsNN_cp0_watchlo_write(u_int, intptr_t);
    445       1.87      matt uint32_t mipsNN_cp0_watchhi_read(u_int);
    446       1.87      matt void	mipsNN_cp0_watchhi_write(u_int, uint32_t);
    447       1.87      matt 
    448       1.98      matt int32_t mipsNN_cp0_ebase_read(void);
    449       1.98      matt void	mipsNN_cp0_ebase_write(int32_t);
    450       1.98      matt 
    451      1.105    simonb uint32_t mipsNN_cp0_rdhwr_cpunum(void);
    452      1.105    simonb 
    453      1.100      matt #ifdef MIPSNNR2
    454       1.85      matt void	mipsNN_cp0_hwrena_write(uint32_t);
    455       1.85      matt void	mipsNN_cp0_userlocal_write(void *);
    456       1.85      matt #endif
    457      1.100      matt #endif /* MIPSNN */
    458       1.59    simonb 
    459       1.59    simonb uint32_t mips3_cp0_count_read(void);
    460       1.59    simonb void	mips3_cp0_count_write(uint32_t);
    461       1.59    simonb 
    462       1.59    simonb uint32_t mips3_cp0_wired_read(void);
    463       1.59    simonb void	mips3_cp0_wired_write(uint32_t);
    464       1.69   tsutsui void	mips3_cp0_pg_mask_write(uint32_t);
    465       1.59    simonb 
    466      1.100      matt #endif	/* MIPS3_PLUS */
    467      1.100      matt 
    468      1.100      matt /* 64-bit address space accessor for n32, n64 ABI */
    469      1.100      matt /* 32-bit address space accessor for o32 ABI */
    470      1.100      matt static inline uint8_t	mips_lbu(register_t addr) __unused;
    471      1.100      matt static inline void	mips_sb(register_t addr, uint8_t val) __unused;
    472      1.100      matt static inline uint16_t	mips_lhu(register_t addr) __unused;
    473      1.100      matt static inline void	mips_sh(register_t addr, uint16_t val) __unused;
    474      1.100      matt static inline uint32_t	mips_lwu(register_t addr) __unused;
    475      1.100      matt static inline void	mips_sw(register_t addr, uint32_t val) __unused;
    476      1.100      matt #ifdef MIPS3_64BIT
    477       1.80      matt #if defined(__mips_o32)
    478      1.100      matt uint64_t		mips3_ld(register_t addr);
    479      1.100      matt void			mips3_sd(register_t addr, uint64_t val);
    480      1.100      matt #else
    481      1.100      matt static inline uint64_t	mips3_ld(register_t addr) __unused;
    482      1.100      matt static inline void	mips3_sd(register_t addr, uint64_t val) __unused;
    483      1.100      matt #endif
    484      1.100      matt #endif
    485       1.80      matt 
    486      1.100      matt static inline uint8_t
    487      1.100      matt mips_lbu(register_t addr)
    488      1.100      matt {
    489      1.100      matt 	uint8_t rv;
    490      1.100      matt #if defined(__mips_n32)
    491      1.100      matt 	__asm volatile("lbu\t%0, 0(%1)" : "=r"(rv) : "d"(addr));
    492       1.80      matt #else
    493      1.100      matt 	rv = *(const volatile uint8_t *)addr;
    494       1.80      matt #endif
    495       1.80      matt 	return rv;
    496       1.80      matt }
    497      1.100      matt 
    498      1.100      matt static inline uint16_t
    499      1.100      matt mips_lhu(register_t addr)
    500       1.80      matt {
    501      1.100      matt 	uint16_t rv;
    502      1.100      matt #if defined(__mips_n32)
    503      1.100      matt 	__asm volatile("lhu\t%0, 0(%1)" : "=r"(rv) : "d"(addr));
    504       1.80      matt #else
    505      1.100      matt 	rv = *(const volatile uint16_t *)addr;
    506       1.80      matt #endif
    507      1.100      matt 	return rv;
    508       1.80      matt }
    509       1.59    simonb 
    510      1.100      matt static inline uint32_t
    511      1.100      matt mips_lwu(register_t addr)
    512       1.59    simonb {
    513       1.59    simonb 	uint32_t rv;
    514      1.100      matt #if defined(__mips_n32)
    515      1.100      matt 	__asm volatile("lwu\t%0, 0(%1)" : "=r"(rv) : "d"(addr));
    516      1.100      matt #else
    517      1.100      matt 	rv = *(const volatile uint32_t *)addr;
    518      1.100      matt #endif
    519      1.100      matt 	return (rv);
    520      1.100      matt }
    521       1.59    simonb 
    522      1.100      matt #if defined(MIPS3_64BIT) && !defined(__mips_o32)
    523      1.100      matt static inline uint64_t
    524      1.100      matt mips3_ld(register_t addr)
    525      1.100      matt {
    526      1.100      matt 	uint64_t rv;
    527      1.100      matt #if defined(__mips_n32)
    528      1.100      matt 	__asm volatile("ld\t%0, 0(%1)" : "=r"(rv) : "d"(addr));
    529       1.80      matt #elif defined(_LP64)
    530      1.100      matt 	rv = *(const volatile uint64_t *)addr;
    531       1.80      matt #else
    532       1.83      matt #error unknown ABI
    533       1.80      matt #endif
    534       1.59    simonb 	return (rv);
    535       1.59    simonb }
    536      1.100      matt #endif	/* MIPS3_64BIT && !__mips_o32 */
    537       1.59    simonb 
    538      1.100      matt static inline void
    539      1.100      matt mips_sb(register_t addr, uint8_t val)
    540       1.59    simonb {
    541      1.100      matt #if defined(__mips_n32)
    542  1.116.2.1   thorpej 	__asm volatile("sb\t%1, 0(%0)" :: "d"(addr), "r"(val) : "memory");
    543      1.100      matt #else
    544      1.100      matt 	*(volatile uint8_t *)addr = val;
    545      1.100      matt #endif
    546      1.100      matt }
    547       1.59    simonb 
    548      1.100      matt static inline void
    549      1.100      matt mips_sh(register_t addr, uint16_t val)
    550      1.100      matt {
    551      1.100      matt #if defined(__mips_n32)
    552  1.116.2.1   thorpej 	__asm volatile("sh\t%1, 0(%0)" :: "d"(addr), "r"(val) : "memory");
    553       1.80      matt #else
    554      1.100      matt 	*(volatile uint16_t *)addr = val;
    555       1.80      matt #endif
    556       1.59    simonb }
    557        1.7  jonathan 
    558      1.100      matt static inline void
    559      1.100      matt mips_sw(register_t addr, uint32_t val)
    560       1.95    hikaru {
    561       1.95    hikaru #if defined(__mips_n32)
    562  1.116.2.1   thorpej 	__asm volatile("sw\t%1, 0(%0)" :: "d"(addr), "r"(val) : "memory");
    563       1.95    hikaru #else
    564      1.100      matt 	*(volatile uint32_t *)addr = val;
    565       1.95    hikaru #endif
    566       1.95    hikaru }
    567       1.95    hikaru 
    568      1.100      matt #if defined(MIPS3_64BIT) && !defined(__mips_o32)
    569      1.100      matt static inline void
    570      1.100      matt mips3_sd(register_t addr, uint64_t val)
    571       1.95    hikaru {
    572       1.95    hikaru #if defined(__mips_n32)
    573  1.116.2.1   thorpej 	__asm volatile("sd\t%1, 0(%0)" :: "d"(addr), "r"(val) : "memory");
    574      1.100      matt #else
    575       1.95    hikaru 	*(volatile uint64_t *)addr = val;
    576       1.95    hikaru #endif
    577       1.95    hikaru }
    578      1.100      matt #endif	/* MIPS3_64BIT && !__mips_o32 */
    579       1.95    hikaru 
    580        1.1  jonathan /*
    581       1.58   thorpej  * A vector with an entry for each mips-ISA-level dependent
    582        1.1  jonathan  * locore function, and macros which jump through it.
    583        1.1  jonathan  */
    584        1.1  jonathan typedef struct  {
    585       1.83      matt 	void	(*ljv_cpu_switch_resume)(struct lwp *);
    586       1.83      matt 	intptr_t ljv_lwp_trampoline;
    587       1.83      matt 	void	(*ljv_wbflush)(void);
    588      1.100      matt 	tlb_asid_t (*ljv_tlb_get_asid)(void);
    589      1.100      matt 	void	(*ljv_tlb_set_asid)(tlb_asid_t pid);
    590      1.100      matt 	void	(*ljv_tlb_invalidate_asids)(tlb_asid_t, tlb_asid_t);
    591      1.100      matt 	void	(*ljv_tlb_invalidate_addr)(vaddr_t, tlb_asid_t);
    592       1.83      matt 	void	(*ljv_tlb_invalidate_globals)(void);
    593       1.83      matt 	void	(*ljv_tlb_invalidate_all)(void);
    594      1.100      matt 	u_int	(*ljv_tlb_record_asids)(u_long *, tlb_asid_t);
    595      1.100      matt 	int	(*ljv_tlb_update_addr)(vaddr_t, tlb_asid_t, pt_entry_t, bool);
    596      1.100      matt 	void	(*ljv_tlb_read_entry)(size_t, struct tlbmask *);
    597      1.100      matt 	void	(*ljv_tlb_write_entry)(size_t, const struct tlbmask *);
    598        1.1  jonathan } mips_locore_jumpvec_t;
    599       1.13  jonathan 
    600       1.83      matt typedef struct {
    601       1.83      matt 	u_int	(*lav_atomic_cas_uint)(volatile u_int *, u_int, u_int);
    602       1.83      matt 	u_long	(*lav_atomic_cas_ulong)(volatile u_long *, u_long, u_long);
    603      1.104   thorpej 	int	(*lav_ucas_32)(volatile uint32_t *, uint32_t, uint32_t,
    604      1.104   thorpej 			       uint32_t *);
    605      1.104   thorpej 	int	(*lav_ucas_64)(volatile uint64_t *, uint64_t, uint64_t,
    606      1.104   thorpej 			       uint64_t *);
    607       1.83      matt 	void	(*lav_mutex_enter)(kmutex_t *);
    608       1.83      matt 	void	(*lav_mutex_exit)(kmutex_t *);
    609       1.83      matt 	void	(*lav_mutex_spin_enter)(kmutex_t *);
    610       1.83      matt 	void	(*lav_mutex_spin_exit)(kmutex_t *);
    611       1.83      matt } mips_locore_atomicvec_t;
    612       1.83      matt 
    613       1.38       cgd void	mips_set_wbflush(void (*)(void));
    614       1.62    simonb void	mips_wait_idle(void);
    615        1.1  jonathan 
    616       1.38       cgd void	stacktrace(void);
    617       1.38       cgd void	logstacktrace(void);
    618        1.1  jonathan 
    619       1.83      matt struct cpu_info;
    620       1.83      matt struct splsw;
    621       1.83      matt 
    622       1.80      matt struct locoresw {
    623       1.83      matt 	void		(*lsw_wbflush)(void);
    624       1.83      matt 	void		(*lsw_cpu_idle)(void);
    625       1.83      matt 	int		(*lsw_send_ipi)(struct cpu_info *, int);
    626       1.83      matt 	void		(*lsw_cpu_offline_md)(void);
    627       1.83      matt 	void		(*lsw_cpu_init)(struct cpu_info *);
    628       1.88     cliff 	void		(*lsw_cpu_run)(struct cpu_info *);
    629       1.83      matt 	int		(*lsw_bus_error)(unsigned int);
    630       1.83      matt };
    631       1.83      matt 
    632       1.83      matt struct mips_vmfreelist {
    633       1.83      matt 	paddr_t fl_start;
    634       1.83      matt 	paddr_t fl_end;
    635       1.83      matt 	int fl_freelist;
    636       1.80      matt };
    637       1.80      matt 
    638      1.100      matt struct cpu_info *
    639      1.100      matt 	cpu_info_alloc(struct pmap_tlb_info *, cpuid_t, cpuid_t, cpuid_t,
    640      1.100      matt 	    cpuid_t);
    641      1.100      matt void	cpu_attach_common(device_t, struct cpu_info *);
    642      1.100      matt void	cpu_startup_common(void);
    643      1.100      matt 
    644      1.100      matt #ifdef MULTIPROCESSOR
    645      1.100      matt void	cpu_hatch(struct cpu_info *ci);
    646      1.100      matt void	cpu_trampoline(void);
    647      1.100      matt void	cpu_halt(void);
    648      1.100      matt void	cpu_halt_others(void);
    649      1.100      matt void	cpu_pause(struct reg *);
    650      1.100      matt void	cpu_pause_others(void);
    651      1.100      matt void	cpu_resume(cpuid_t);
    652      1.100      matt void	cpu_resume_others(void);
    653      1.100      matt bool	cpu_is_paused(cpuid_t);
    654      1.100      matt void	cpu_debug_dump(void);
    655      1.100      matt 
    656      1.100      matt extern kcpuset_t *cpus_running;
    657      1.100      matt extern kcpuset_t *cpus_hatched;
    658      1.100      matt extern kcpuset_t *cpus_paused;
    659      1.100      matt extern kcpuset_t *cpus_resumed;
    660      1.100      matt extern kcpuset_t *cpus_halted;
    661      1.100      matt #endif
    662      1.100      matt 
    663      1.100      matt /* copy.S */
    664      1.104   thorpej uint32_t mips_ufetch32(const void *);
    665      1.104   thorpej int	mips_ustore32_isync(void *, uint32_t);
    666      1.104   thorpej 
    667      1.100      matt int32_t kfetch_32(volatile uint32_t *, uint32_t);
    668      1.100      matt 
    669      1.100      matt /* trap.c */
    670      1.100      matt void	netintr(void);
    671      1.100      matt 
    672      1.100      matt /* mips_dsp.c */
    673      1.100      matt void	dsp_init(void);
    674      1.102       chs void	dsp_discard(lwp_t *);
    675      1.100      matt void	dsp_load(void);
    676      1.102       chs void	dsp_save(lwp_t *);
    677      1.102       chs bool	dsp_used_p(const lwp_t *);
    678      1.100      matt extern const pcu_ops_t mips_dsp_ops;
    679      1.100      matt 
    680      1.100      matt /* mips_fpu.c */
    681      1.100      matt void	fpu_init(void);
    682      1.102       chs void	fpu_discard(lwp_t *);
    683      1.100      matt void	fpu_load(void);
    684      1.102       chs void	fpu_save(lwp_t *);
    685      1.102       chs bool	fpu_used_p(const lwp_t *);
    686      1.100      matt extern const pcu_ops_t mips_fpu_ops;
    687      1.100      matt 
    688      1.100      matt /* mips_machdep.c */
    689      1.100      matt void	dumpsys(void);
    690      1.100      matt int	savectx(struct pcb *);
    691      1.100      matt void	cpu_identify(device_t);
    692      1.100      matt 
    693      1.100      matt /* locore*.S */
    694      1.100      matt int	badaddr(void *, size_t);
    695      1.100      matt int	badaddr64(uint64_t, size_t);
    696      1.100      matt 
    697      1.100      matt /* vm_machdep.c */
    698      1.100      matt int	ioaccess(vaddr_t, paddr_t, vsize_t);
    699      1.100      matt int	iounaccess(vaddr_t, vsize_t);
    700      1.100      matt 
    701        1.1  jonathan /*
    702       1.81       snj  * The "active" locore-function vector, and
    703        1.1  jonathan  */
    704       1.83      matt extern const mips_locore_atomicvec_t mips_llsc_locore_atomicvec;
    705       1.83      matt 
    706       1.83      matt extern mips_locore_atomicvec_t mips_locore_atomicvec;
    707        1.1  jonathan extern mips_locore_jumpvec_t mips_locore_jumpvec;
    708       1.80      matt extern struct locoresw mips_locoresw;
    709        1.1  jonathan 
    710      1.100      matt extern int mips_poolpage_vmfreelist;	/* freelist to allocate poolpages */
    711      1.100      matt extern struct mips_options mips_options;
    712      1.100      matt 
    713       1.83      matt struct splsw;
    714       1.83      matt struct mips_vmfreelist;
    715       1.83      matt struct phys_ram_seg;
    716       1.83      matt 
    717       1.98      matt void	mips64r2_vector_init(const struct splsw *);
    718       1.83      matt void	mips_vector_init(const struct splsw *, bool);
    719       1.83      matt void	mips_init_msgbuf(void);
    720       1.83      matt void	mips_init_lwp0_uarea(void);
    721       1.83      matt void	mips_page_physload(vaddr_t, vaddr_t,
    722       1.83      matt 	    const struct phys_ram_seg *, size_t,
    723       1.83      matt 	    const struct mips_vmfreelist *, size_t);
    724       1.11  jonathan 
    725        1.7  jonathan 
    726        1.7  jonathan /*
    727        1.7  jonathan  * CPU identification, from PRID register.
    728        1.7  jonathan  */
    729      1.110    simonb #define	MIPS_PRID_REV(x)	(((x) >>  0) & 0x00ff)
    730      1.110    simonb #define	MIPS_PRID_IMPL(x)	(((x) >>  8) & 0x00ff)
    731       1.45       cgd 
    732       1.59    simonb /* pre-MIPS32/64 */
    733      1.110    simonb #define	MIPS_PRID_RSVD(x)	(((x) >> 16) & 0xffff)
    734      1.110    simonb #define	MIPS_PRID_REV_MIN(x)	((MIPS_PRID_REV(x) >> 0) & 0x0f)
    735      1.110    simonb #define	MIPS_PRID_REV_MAJ(x)	((MIPS_PRID_REV(x) >> 4) & 0x0f)
    736       1.45       cgd 
    737       1.59    simonb /* MIPS32/64 */
    738      1.110    simonb #define	MIPS_PRID_CID(x)	(((x) >> 16) & 0x00ff)	/* Company ID */
    739      1.110    simonb #define	    MIPS_PRID_CID_PREHISTORIC	0x00	/* Not MIPS32/64 */
    740      1.110    simonb #define	    MIPS_PRID_CID_MTI		0x01	/* MIPS Technologies, Inc. */
    741      1.110    simonb #define	    MIPS_PRID_CID_BROADCOM	0x02	/* Broadcom */
    742      1.110    simonb #define	    MIPS_PRID_CID_ALCHEMY	0x03	/* Alchemy Semiconductor */
    743      1.110    simonb #define	    MIPS_PRID_CID_SIBYTE	0x04	/* SiByte */
    744      1.110    simonb #define	    MIPS_PRID_CID_SANDCRAFT	0x05	/* SandCraft */
    745      1.110    simonb #define	    MIPS_PRID_CID_PHILIPS	0x06	/* Philips */
    746      1.110    simonb #define	    MIPS_PRID_CID_TOSHIBA	0x07	/* Toshiba */
    747      1.110    simonb #define	    MIPS_PRID_CID_MICROSOFT	0x07	/* Microsoft also, sigh */
    748      1.110    simonb #define	    MIPS_PRID_CID_LSI		0x08	/* LSI */
    749       1.67    simonb 				/*	0x09	unannounced */
    750       1.67    simonb 				/*	0x0a	unannounced */
    751      1.110    simonb #define	    MIPS_PRID_CID_LEXRA		0x0b	/* Lexra */
    752      1.110    simonb #define	    MIPS_PRID_CID_RMI		0x0c	/* RMI / NetLogic */
    753      1.110    simonb #define	    MIPS_PRID_CID_CAVIUM	0x0d	/* Cavium */
    754      1.110    simonb #define	    MIPS_PRID_CID_INGENIC	0xe1
    755      1.110    simonb #define	MIPS_PRID_COPTS(x)	(((x) >> 24) & 0x00ff)	/* Company Options */
    756        1.6  jonathan 
    757        1.6  jonathan /*
    758        1.6  jonathan  * Global variables used to communicate CPU type, and parameters
    759        1.6  jonathan  * such as cache size, from locore to higher-level code (e.g., pmap).
    760        1.6  jonathan  */
    761      1.100      matt void mips_pagecopy(register_t dst, register_t src);
    762      1.100      matt void mips_pagezero(register_t dst);
    763       1.19  jonathan 
    764       1.59    simonb #ifdef __HAVE_MIPS_MACHDEP_CACHE_CONFIG
    765       1.59    simonb void mips_machdep_cache_config(void);
    766       1.59    simonb #endif
    767       1.59    simonb 
    768       1.19  jonathan /*
    769       1.20    simonb  * trapframe argument passed to trap()
    770       1.19  jonathan  */
    771       1.64   thorpej 
    772       1.83      matt #if 0
    773      1.110    simonb #define	TF_AST		0		/* really zero */
    774      1.110    simonb #define	TF_V0		_R_V0
    775      1.110    simonb #define	TF_V1		_R_V1
    776      1.110    simonb #define	TF_A0		_R_A0
    777      1.110    simonb #define	TF_A1		_R_A1
    778      1.110    simonb #define	TF_A2		_R_A2
    779      1.110    simonb #define	TF_A3		_R_A3
    780      1.110    simonb #define	TF_T0		_R_T0
    781      1.110    simonb #define	TF_T1		_R_T1
    782      1.110    simonb #define	TF_T2		_R_T2
    783      1.110    simonb #define	TF_T3		_R_T3
    784       1.64   thorpej 
    785       1.64   thorpej #if defined(__mips_n32) || defined(__mips_n64)
    786      1.110    simonb #define	TF_A4		_R_A4
    787      1.110    simonb #define	TF_A5		_R_A5
    788      1.110    simonb #define	TF_A6		_R_A6
    789      1.110    simonb #define	TF_A7		_R_A7
    790      1.110    simonb #else
    791      1.110    simonb #define	TF_T4		_R_T4
    792      1.110    simonb #define	TF_T5		_R_T5
    793      1.110    simonb #define	TF_T6		_R_T6
    794      1.110    simonb #define	TF_T7		_R_T7
    795       1.64   thorpej #endif /* __mips_n32 || __mips_n64 */
    796       1.64   thorpej 
    797      1.110    simonb #define	TF_TA0		_R_TA0
    798      1.110    simonb #define	TF_TA1		_R_TA1
    799      1.110    simonb #define	TF_TA2		_R_TA2
    800      1.110    simonb #define	TF_TA3		_R_TA3
    801      1.110    simonb 
    802      1.110    simonb #define	TF_T8		_R_T8
    803      1.110    simonb #define	TF_T9		_R_T9
    804      1.110    simonb 
    805      1.110    simonb #define	TF_RA		_R_RA
    806      1.110    simonb #define	TF_SR		_R_SR
    807      1.110    simonb #define	TF_MULLO	_R_MULLO
    808      1.113    simonb #define	TF_MULHI	_R_MULHI
    809      1.110    simonb #define	TF_EPC		_R_PC		/* may be changed by trap() call */
    810       1.65   thorpej 
    811       1.83      matt #define	TF_NREGS	(sizeof(struct reg) / sizeof(mips_reg_t))
    812       1.83      matt #endif
    813       1.64   thorpej 
    814       1.19  jonathan struct trapframe {
    815       1.83      matt 	struct reg tf_registers;
    816       1.83      matt #define	tf_regs	tf_registers.r_regs
    817       1.80      matt 	uint32_t   tf_ppl;		/* previous priority level */
    818       1.80      matt 	mips_reg_t tf_pad;		/* for 8 byte aligned */
    819       1.19  jonathan };
    820       1.19  jonathan 
    821       1.83      matt CTASSERT(sizeof(struct trapframe) % (4*sizeof(mips_reg_t)) == 0);
    822       1.83      matt 
    823       1.19  jonathan /*
    824       1.19  jonathan  * Stack frame for kernel traps. four args passed in registers.
    825       1.19  jonathan  * A trapframe is pointed to by the 5th arg, and a dummy sixth argument
    826       1.19  jonathan  * is used to avoid alignment problems
    827       1.19  jonathan  */
    828       1.19  jonathan 
    829       1.19  jonathan struct kernframe {
    830       1.80      matt #if defined(__mips_o32) || defined(__mips_o64)
    831       1.19  jonathan 	register_t cf_args[4 + 1];
    832       1.80      matt #if defined(__mips_o32)
    833       1.83      matt 	register_t cf_pad;		/* (for 8 byte alignment) */
    834       1.80      matt #endif
    835       1.80      matt #endif
    836       1.80      matt #if defined(__mips_n32) || defined(__mips_n64)
    837       1.80      matt 	register_t cf_pad[2];		/* for 16 byte alignment */
    838       1.80      matt #endif
    839       1.19  jonathan 	register_t cf_sp;
    840       1.19  jonathan 	register_t cf_ra;
    841       1.19  jonathan 	struct trapframe cf_frame;
    842       1.19  jonathan };
    843       1.83      matt 
    844       1.83      matt CTASSERT(sizeof(struct kernframe) % (2*sizeof(mips_reg_t)) == 0);
    845       1.83      matt 
    846       1.83      matt /*
    847       1.83      matt  * PRocessor IDentity TABle
    848       1.83      matt  */
    849       1.83      matt 
    850       1.83      matt struct pridtab {
    851       1.83      matt 	int	cpu_cid;
    852       1.83      matt 	int	cpu_pid;
    853       1.83      matt 	int	cpu_rev;	/* -1 == wildcard */
    854       1.83      matt 	int	cpu_copts;	/* -1 == wildcard */
    855       1.83      matt 	int	cpu_isa;	/* -1 == probed (mips32/mips64) */
    856       1.83      matt 	int	cpu_ntlb;	/* -1 == unknown, 0 == probed */
    857       1.83      matt 	int	cpu_flags;
    858       1.83      matt 	u_int	cpu_cp0flags;	/* presence of some cp0 regs */
    859       1.83      matt 	u_int	cpu_cidflags;	/* company-specific flags */
    860       1.83      matt 	const char	*cpu_name;
    861       1.83      matt };
    862       1.83      matt 
    863       1.83      matt /*
    864       1.83      matt  * bitfield defines for cpu_cp0flags
    865       1.83      matt  */
    866      1.110    simonb #define	 MIPS_CP0FL_USE		__BIT(0)	/* use these flags */
    867      1.110    simonb #define	 MIPS_CP0FL_ECC		__BIT(1)
    868      1.110    simonb #define	 MIPS_CP0FL_CACHE_ERR	__BIT(2)
    869      1.110    simonb #define	 MIPS_CP0FL_EIRR	__BIT(3)
    870      1.110    simonb #define	 MIPS_CP0FL_EIMR	__BIT(4)
    871      1.110    simonb #define	 MIPS_CP0FL_EBASE	__BIT(5)  /* XXX probeable - shouldn't be hard coded */
    872      1.110    simonb #define	 MIPS_CP0FL_CONFIG	__BIT(6)  /* XXX defined - doesn't need to be hard coded */
    873      1.110    simonb #define	 MIPS_CP0FL_CONFIG1	__BIT(7)  /* XXX probeable - shouldn't be hard coded */
    874      1.110    simonb #define	 MIPS_CP0FL_CONFIG2	__BIT(8)  /* XXX probeable - shouldn't be hard coded */
    875      1.110    simonb #define	 MIPS_CP0FL_CONFIG3	__BIT(9)  /* XXX probeable - shouldn't be hard coded */
    876      1.110    simonb #define	 MIPS_CP0FL_CONFIG4	__BIT(10) /* XXX probeable - shouldn't be hard coded */
    877      1.110    simonb #define	 MIPS_CP0FL_CONFIG5	__BIT(11) /* XXX probeable - shouldn't be hard coded */
    878      1.112    simonb #define	 MIPS_CP0FL_CONFIG6	__BIT(12)
    879      1.112    simonb #define	 MIPS_CP0FL_CONFIG7	__BIT(13)
    880       1.83      matt 
    881       1.83      matt /*
    882       1.83      matt  * cpu_cidflags defines, by company
    883       1.83      matt  */
    884       1.83      matt /*
    885       1.83      matt  * RMI company-specific cpu_cidflags
    886       1.83      matt  */
    887      1.110    simonb #define	MIPS_CIDFL_RMI_TYPE		__BITS(2,0)
    888       1.84      matt # define  CIDFL_RMI_TYPE_XLR		0
    889       1.84      matt # define  CIDFL_RMI_TYPE_XLS		1
    890       1.84      matt # define  CIDFL_RMI_TYPE_XLP		2
    891      1.110    simonb #define	MIPS_CIDFL_RMI_THREADS_MASK	__BITS(6,3)
    892       1.83      matt # define MIPS_CIDFL_RMI_THREADS_SHIFT	3
    893      1.110    simonb #define	MIPS_CIDFL_RMI_CORES_MASK	__BITS(10,7)
    894       1.83      matt # define MIPS_CIDFL_RMI_CORES_SHIFT	7
    895       1.83      matt # define LOG2_1	0
    896       1.83      matt # define LOG2_2	1
    897       1.83      matt # define LOG2_4	2
    898       1.83      matt # define LOG2_8	3
    899       1.83      matt # define MIPS_CIDFL_RMI_CPUS(ncores, nthreads)				\
    900       1.83      matt 		((LOG2_ ## ncores << MIPS_CIDFL_RMI_CORES_SHIFT)	\
    901       1.83      matt 		|(LOG2_ ## nthreads << MIPS_CIDFL_RMI_THREADS_SHIFT))
    902       1.83      matt # define MIPS_CIDFL_RMI_NTHREADS(cidfl)					\
    903       1.83      matt 		(1 << (((cidfl) & MIPS_CIDFL_RMI_THREADS_MASK)		\
    904       1.83      matt 			>> MIPS_CIDFL_RMI_THREADS_SHIFT))
    905       1.83      matt # define MIPS_CIDFL_RMI_NCORES(cidfl)					\
    906       1.83      matt 		(1 << (((cidfl) & MIPS_CIDFL_RMI_CORES_MASK)		\
    907       1.83      matt 			>> MIPS_CIDFL_RMI_CORES_SHIFT))
    908      1.110    simonb #define	MIPS_CIDFL_RMI_L2SZ_MASK	__BITS(14,11)
    909       1.83      matt # define MIPS_CIDFL_RMI_L2SZ_SHIFT	11
    910       1.83      matt # define RMI_L2SZ_256KB	 0
    911       1.83      matt # define RMI_L2SZ_512KB  1
    912       1.83      matt # define RMI_L2SZ_1MB    2
    913       1.83      matt # define RMI_L2SZ_2MB    3
    914       1.83      matt # define RMI_L2SZ_4MB    4
    915       1.83      matt # define MIPS_CIDFL_RMI_L2(l2sz)					\
    916       1.83      matt 		(RMI_L2SZ_ ## l2sz << MIPS_CIDFL_RMI_L2SZ_SHIFT)
    917       1.83      matt # define MIPS_CIDFL_RMI_L2SZ(cidfl)					\
    918       1.83      matt 		((256*1024) << (((cidfl) & MIPS_CIDFL_RMI_L2SZ_MASK)	\
    919       1.83      matt 			>> MIPS_CIDFL_RMI_L2SZ_SHIFT))
    920      1.115       mrg #endif	/* _KERNEL */
    921      1.101  macallan #endif /* !__ASSEMBLER__ */
    922      1.100      matt 
    923        1.1  jonathan #endif	/* _MIPS_LOCORE_H */
    924