Home | History | Annotate | Line # | Download | only in include
cpu.h revision 1.90.16.37
      1  1.90.16.37      matt /*	cpu.h,v 1.90.16.36 2011/04/29 08:26:20 matt Exp	*/
      2         1.8       cgd 
      3         1.1   deraadt /*-
      4         1.5     glass  * Copyright (c) 1992, 1993
      5         1.5     glass  *	The Regents of the University of California.  All rights reserved.
      6         1.1   deraadt  *
      7         1.1   deraadt  * This code is derived from software contributed to Berkeley by
      8         1.1   deraadt  * Ralph Campbell and Rick Macklem.
      9         1.1   deraadt  *
     10         1.1   deraadt  * Redistribution and use in source and binary forms, with or without
     11         1.1   deraadt  * modification, are permitted provided that the following conditions
     12         1.1   deraadt  * are met:
     13         1.1   deraadt  * 1. Redistributions of source code must retain the above copyright
     14         1.1   deraadt  *    notice, this list of conditions and the following disclaimer.
     15         1.1   deraadt  * 2. Redistributions in binary form must reproduce the above copyright
     16         1.1   deraadt  *    notice, this list of conditions and the following disclaimer in the
     17         1.1   deraadt  *    documentation and/or other materials provided with the distribution.
     18        1.71       agc  * 3. Neither the name of the University nor the names of its contributors
     19         1.1   deraadt  *    may be used to endorse or promote products derived from this software
     20         1.1   deraadt  *    without specific prior written permission.
     21         1.1   deraadt  *
     22         1.1   deraadt  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     23         1.1   deraadt  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     24         1.1   deraadt  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     25         1.1   deraadt  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     26         1.1   deraadt  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     27         1.1   deraadt  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     28         1.1   deraadt  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     29         1.1   deraadt  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     30         1.1   deraadt  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     31         1.1   deraadt  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     32         1.1   deraadt  * SUCH DAMAGE.
     33         1.1   deraadt  *
     34         1.8       cgd  *	@(#)cpu.h	8.4 (Berkeley) 1/4/94
     35         1.1   deraadt  */
     36         1.1   deraadt 
     37         1.1   deraadt #ifndef _CPU_H_
     38         1.1   deraadt #define _CPU_H_
     39         1.1   deraadt 
     40        1.54    simonb #include <mips/cpuregs.h>
     41        1.53    simonb 
     42         1.1   deraadt /*
     43        1.13  jonathan  * Exported definitions unique to NetBSD/mips cpu support.
     44         1.1   deraadt  */
     45        1.36     soren 
     46        1.68    simonb #ifdef _KERNEL
     47  1.90.16.19      matt 
     48        1.53    simonb #if defined(_KERNEL_OPT)
     49  1.90.16.24      matt #include "opt_cputype.h"
     50        1.53    simonb #include "opt_lockdebug.h"
     51  1.90.16.11      matt #include "opt_multiprocessor.h"
     52        1.53    simonb #endif
     53        1.53    simonb 
     54  1.90.16.36      matt #ifndef _LOCORE
     55  1.90.16.33     cliff #include <sys/cpu_data.h>
     56  1.90.16.33     cliff #include <sys/device.h>
     57  1.90.16.33     cliff #include <sys/evcnt.h>
     58  1.90.16.36      matt 
     59  1.90.16.36      matt typedef struct cpu_watchpoint {
     60  1.90.16.36      matt 	register_t	cw_addr;
     61  1.90.16.36      matt 	register_t	cw_mask;
     62  1.90.16.36      matt 	uint32_t	cw_asid;
     63  1.90.16.36      matt 	uint32_t	cw_mode;
     64  1.90.16.36      matt } cpu_watchpoint_t;
     65  1.90.16.36      matt /* (abstract) mode bits */
     66  1.90.16.36      matt #define CPUWATCH_WRITE	__BIT(0)
     67  1.90.16.36      matt #define CPUWATCH_READ	__BIT(1)
     68  1.90.16.36      matt #define CPUWATCH_EXEC	__BIT(2)
     69  1.90.16.36      matt #define CPUWATCH_MASK	__BIT(3)
     70  1.90.16.36      matt #define CPUWATCH_ASID	__BIT(4)
     71  1.90.16.36      matt #define CPUWATCH_RWX	(CPUWATCH_EXEC|CPUWATCH_READ|CPUWATCH_WRITE)
     72  1.90.16.36      matt 
     73  1.90.16.36      matt #define CPUWATCH_MAX	8	/* max possible number of watchpoints */
     74  1.90.16.36      matt 
     75  1.90.16.36      matt u_int		  cpuwatch_discover(void);
     76  1.90.16.36      matt void		  cpuwatch_free(cpu_watchpoint_t *);
     77  1.90.16.36      matt cpu_watchpoint_t *cpuwatch_alloc(void);
     78  1.90.16.36      matt void		  cpuwatch_set_all(void);
     79  1.90.16.36      matt void		  cpuwatch_clr_all(void);
     80  1.90.16.36      matt void		  cpuwatch_set(cpu_watchpoint_t *);
     81  1.90.16.36      matt void		  cpuwatch_clr(cpu_watchpoint_t *);
     82  1.90.16.33     cliff 
     83        1.53    simonb struct cpu_info {
     84        1.73      yamt 	struct cpu_data ci_data;	/* MI per-cpu data */
     85        1.85        ad 	struct cpu_info *ci_next;	/* Next CPU in list */
     86  1.90.16.26      matt 	struct cpu_softc *ci_softc;	/* chip-dependent hook */
     87  1.90.16.24      matt 	device_t ci_dev;		/* owning device */
     88        1.85        ad 	cpuid_t ci_cpuid;		/* Machine-level identifier */
     89  1.90.16.24      matt 	u_long ci_cctr_freq;		/* cycle counter frequency */
     90        1.58    simonb 	u_long ci_cpu_freq;		/* CPU frequency */
     91        1.58    simonb 	u_long ci_cycles_per_hz;	/* CPU freq / hz */
     92        1.58    simonb 	u_long ci_divisor_delay;	/* for delay/DELAY */
     93        1.90   tsutsui 	u_long ci_divisor_recip;	/* unused, for obsolete microtime(9) */
     94        1.82      yamt 	struct lwp *ci_curlwp;		/* currently running lwp */
     95  1.90.16.24      matt #ifndef NOFPU
     96        1.82      yamt 	struct lwp *ci_fpcurlwp;	/* the current FPU owner */
     97  1.90.16.24      matt #endif
     98  1.90.16.24      matt 	volatile int ci_want_resched;	/* user preemption pending */
     99        1.78        ad 	int ci_mtx_count;		/* negative count of held mutexes */
    100        1.78        ad 	int ci_mtx_oldspl;		/* saved SPL value */
    101        1.86        ad 	int ci_idepth;			/* hardware interrupt depth */
    102  1.90.16.19      matt 	int ci_cpl;			/* current [interrupt] priority level */
    103  1.90.16.28     cliff 	uint32_t ci_next_cp0_clk_intr;	/* for hard clock intr scheduling */
    104  1.90.16.36      matt 	struct evcnt ci_ev_count_compare;		/* hard clock intr counter */
    105  1.90.16.36      matt 	struct evcnt ci_ev_count_compare_missed;	/* hard clock miss counter */
    106  1.90.16.18      matt 	struct lwp *ci_softlwps[SOFTINT_COUNT];
    107  1.90.16.36      matt 	volatile u_int ci_softints;
    108  1.90.16.36      matt 	struct evcnt ci_ev_fpu_loads;	/* fpu load counter */
    109  1.90.16.36      matt 	struct evcnt ci_ev_fpu_saves;	/* fpu save counter */
    110  1.90.16.36      matt 	struct evcnt ci_ev_tlbmisses;
    111  1.90.16.28     cliff 
    112  1.90.16.12      matt 	/*
    113  1.90.16.12      matt 	 * Per-cpu pmap information
    114  1.90.16.12      matt 	 */
    115  1.90.16.23      matt 	int ci_tlb_slot;		/* reserved tlb entry for cpu_info */
    116  1.90.16.32      matt 	u_int ci_pmap_asid_cur;		/* current ASID */
    117  1.90.16.24      matt 	struct pmap_tlb_info *ci_tlb_info; /* tlb information for this cpu */
    118  1.90.16.30      matt 	union segtab *ci_pmap_seg0tab;
    119  1.90.16.30      matt #ifdef _LP64
    120  1.90.16.30      matt 	union segtab *ci_pmap_segtab;
    121  1.90.16.30      matt #else
    122  1.90.16.15      matt 	vaddr_t ci_pmap_srcbase;	/* starting VA of ephemeral src space */
    123  1.90.16.15      matt 	vaddr_t ci_pmap_dstbase;	/* starting VA of ephemeral dst space */
    124  1.90.16.30      matt #endif
    125  1.90.16.28     cliff 
    126  1.90.16.36      matt 	u_int ci_cpuwatch_count;	/* number of watchpoints on this CPU */
    127  1.90.16.36      matt 	cpu_watchpoint_t ci_cpuwatch_tab[CPUWATCH_MAX];
    128  1.90.16.28     cliff 
    129  1.90.16.24      matt #ifdef MULTIPROCESSOR
    130  1.90.16.25      matt 	volatile u_long ci_flags;
    131  1.90.16.28     cliff 	volatile uint64_t ci_request_ipis;
    132  1.90.16.28     cliff 					/* bitmask of IPIs requested */
    133  1.90.16.28     cliff 					/*  use on chips where hw cannot pass tag */
    134  1.90.16.24      matt 	uint64_t ci_active_ipis;	/* bitmask of IPIs being serviced */
    135  1.90.16.24      matt 	uint32_t ci_ksp_tlb_slot;	/* tlb entry for kernel stack */
    136  1.90.16.24      matt 	void *ci_fpsave_si;		/* FP sync softint handler */
    137  1.90.16.24      matt 	struct evcnt ci_evcnt_all_ipis;	/* aggregated IPI counter */
    138  1.90.16.24      matt 	struct evcnt ci_evcnt_per_ipi[NIPIS];	/* individual IPI counters*/
    139  1.90.16.27      matt 	struct evcnt ci_evcnt_synci_activate_rqst;
    140  1.90.16.27      matt 	struct evcnt ci_evcnt_synci_onproc_rqst;
    141  1.90.16.27      matt 	struct evcnt ci_evcnt_synci_deferred_rqst;
    142  1.90.16.27      matt 	struct evcnt ci_evcnt_synci_ipi_rqst;
    143  1.90.16.25      matt 
    144  1.90.16.25      matt #define	CPUF_PRIMARY	0x01		/* CPU is primary CPU */
    145  1.90.16.25      matt #define	CPUF_PRESENT	0x02		/* CPU is present */
    146  1.90.16.25      matt #define	CPUF_RUNNING	0x04		/* CPU is running */
    147  1.90.16.25      matt #define	CPUF_PAUSED	0x08		/* CPU is paused */
    148  1.90.16.25      matt #define	CPUF_FPUSAVE	0x10		/* CPU is currently in fpusave_cpu() */
    149  1.90.16.27      matt #define	CPUF_USERPMAP	0x20		/* CPU has a user pmap activated */
    150  1.90.16.24      matt #endif
    151  1.90.16.28     cliff 
    152        1.53    simonb };
    153        1.68    simonb 
    154        1.85        ad #define	CPU_INFO_ITERATOR		int
    155        1.85        ad #define	CPU_INFO_FOREACH(cii, ci)	\
    156        1.85        ad     (void)(cii), ci = &cpu_info_store; ci != NULL; ci = ci->ci_next
    157        1.85        ad 
    158        1.68    simonb #endif /* !_LOCORE */
    159        1.68    simonb #endif /* _KERNEL */
    160        1.53    simonb 
    161        1.36     soren /*
    162        1.36     soren  * CTL_MACHDEP definitions.
    163        1.36     soren  */
    164        1.36     soren #define CPU_CONSDEV		1	/* dev_t: console terminal device */
    165        1.36     soren #define CPU_BOOTED_KERNEL	2	/* string: booted kernel name */
    166        1.36     soren #define CPU_ROOT_DEVICE		3	/* string: root device name */
    167        1.66  gmcgarry #define CPU_LLSC		4	/* OS/CPU supports LL/SC instruction */
    168        1.43     jeffs 
    169        1.43     jeffs /*
    170        1.51       wiz  * Platform can override, but note this breaks userland compatibility
    171        1.43     jeffs  * with other mips platforms.
    172        1.43     jeffs  */
    173        1.43     jeffs #ifndef CPU_MAXID
    174        1.67      shin #define CPU_MAXID		5	/* number of valid machdep ids */
    175        1.42     jeffs #endif
    176        1.33    simonb 
    177        1.33    simonb #ifdef _KERNEL
    178  1.90.16.36      matt #if defined(_MODULAR) || defined(_LKM) || defined(_STANDALONE)
    179        1.87        he /* Assume all CPU architectures are valid for LKM's and standlone progs */
    180  1.90.16.36      matt #define	MIPS1		1
    181  1.90.16.36      matt #define	MIPS3		1
    182  1.90.16.36      matt #define	MIPS4		1
    183  1.90.16.36      matt #define	MIPS32		1
    184  1.90.16.36      matt #define	MIPS32R2	1
    185  1.90.16.36      matt #define	MIPS64		1
    186  1.90.16.36      matt #define	MIPS64R2	1
    187  1.90.16.37      matt #define	MIPS64_RMIXL	1
    188  1.90.16.37      matt #define	MIPS64R2_RMIXL	1
    189        1.77   tsutsui #endif
    190        1.77   tsutsui 
    191  1.90.16.37      matt #if (MIPS1 + MIPS3 + MIPS4 + MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2 + MIPS64_RMIXL + MIPS64R2_RMIXL) == 0
    192  1.90.16.37      matt #error at least one of MIPS1, MIPS3, MIPS4, MIPS32, MIPS32R2, MIPS64, MIPS64R2, MIPS64_RMIXL, or MIPS64R2_RMIXL must be specified
    193        1.77   tsutsui #endif
    194        1.53    simonb 
    195        1.77   tsutsui /* Shortcut for MIPS3 or above defined */
    196  1.90.16.36      matt #if defined(MIPS3) || defined(MIPS4) \
    197  1.90.16.36      matt     || defined(MIPS32) || defined(MIPS32R2) \
    198  1.90.16.37      matt     || defined(MIPS64) || defined(MIPS64R2) \
    199  1.90.16.37      matt     || defined(MIPS64_RMIXL) || defined(MIPS64R2_RMIXL)
    200  1.90.16.36      matt 
    201        1.77   tsutsui #define	MIPS3_PLUS	1
    202  1.90.16.24      matt #define __HAVE_CPU_COUNTER
    203        1.77   tsutsui #else
    204        1.77   tsutsui #undef MIPS3_PLUS
    205        1.77   tsutsui #endif
    206        1.33    simonb 
    207        1.33    simonb /*
    208        1.21  jonathan  * Macros to find the CPU architecture we're on at run-time,
    209        1.21  jonathan  * or if possible, at compile-time.
    210        1.21  jonathan  */
    211        1.21  jonathan 
    212  1.90.16.36      matt #define	CPU_ARCH_MIPSx		0		/* XXX unknown */
    213  1.90.16.36      matt #define	CPU_ARCH_MIPS1		(1 << 0)
    214  1.90.16.36      matt #define	CPU_ARCH_MIPS2		(1 << 1)
    215  1.90.16.36      matt #define	CPU_ARCH_MIPS3		(1 << 2)
    216  1.90.16.36      matt #define	CPU_ARCH_MIPS4		(1 << 3)
    217  1.90.16.36      matt #define	CPU_ARCH_MIPS5		(1 << 4)
    218  1.90.16.36      matt #define	CPU_ARCH_MIPS32		(1 << 5)
    219  1.90.16.36      matt #define	CPU_ARCH_MIPS64		(1 << 6)
    220  1.90.16.36      matt #define	CPU_ARCH_MIPS32R2	(1 << 7)
    221  1.90.16.36      matt #define	CPU_ARCH_MIPS64R2	(1 << 8)
    222        1.46       cgd 
    223        1.82      yamt /* Note: must be kept in sync with -ffixed-?? Makefile.mips. */
    224  1.90.16.16      matt #define MIPS_CURLWP             $24
    225  1.90.16.16      matt #define MIPS_CURLWP_QUOTED      "$24"
    226  1.90.16.16      matt #define MIPS_CURLWP_LABEL	_L_T8
    227  1.90.16.21      matt #define MIPS_CURLWP_REG		_R_T8
    228  1.90.16.17      matt #define TF_MIPS_CURLWP(x)	TF_REG_T8(x)
    229        1.82      yamt 
    230        1.58    simonb #ifndef _LOCORE
    231        1.82      yamt 
    232        1.77   tsutsui extern struct cpu_info cpu_info_store;
    233        1.82      yamt register struct lwp *mips_curlwp asm(MIPS_CURLWP_QUOTED);
    234        1.77   tsutsui 
    235        1.82      yamt #define	curlwp			mips_curlwp
    236        1.82      yamt #define	curcpu()		(curlwp->l_cpu)
    237  1.90.16.36      matt #define	curpcb			((struct pcb *)lwp_getpcb(curlwp))
    238  1.90.16.13      matt #ifdef MULTIPROCESSOR
    239  1.90.16.34     cliff #define	cpu_number()		(curcpu()->ci_index)
    240  1.90.16.34     cliff #define	CPU_IS_PRIMARY(ci)	((ci)->ci_flags & CPUF_PRIMARY)
    241  1.90.16.13      matt #else
    242  1.90.16.36      matt #define	cpu_number()		(0)
    243  1.90.16.36      matt #define	CPU_IS_PRIMARY(ci)	(true)
    244  1.90.16.13      matt #endif
    245        1.77   tsutsui 
    246        1.58    simonb /* XXX simonb
    247        1.58    simonb  * Should the following be in a cpu_info type structure?
    248        1.58    simonb  * And how many of these are per-cpu vs. per-system?  (Ie,
    249        1.58    simonb  * we can assume that all cpus have the same mmu-type, but
    250        1.58    simonb  * maybe not that all cpus run at the same clock speed.
    251        1.58    simonb  * Some SGI's apparently support R12k and R14k in the same
    252        1.58    simonb  * box.)
    253        1.58    simonb  */
    254  1.90.16.13      matt struct mips_options {
    255  1.90.16.13      matt 	const struct pridtab *mips_cpu;
    256  1.90.16.13      matt 
    257  1.90.16.13      matt 	u_int mips_cpu_arch;
    258  1.90.16.14      matt 	u_int mips_cpu_mhz; /* CPU speed in MHz, estimated by mc_cpuspeed(). */
    259  1.90.16.13      matt 	u_int mips_cpu_flags;
    260  1.90.16.13      matt 	u_int mips_num_tlb_entries;
    261  1.90.16.13      matt 	mips_prid_t mips_cpu_id;
    262  1.90.16.13      matt 	mips_prid_t mips_fpu_id;
    263  1.90.16.13      matt 	bool mips_has_r4k_mmu;
    264  1.90.16.13      matt 	bool mips_has_llsc;
    265  1.90.16.14      matt 	u_int mips3_pg_shift;
    266  1.90.16.14      matt 	u_int mips3_pg_cached;
    267  1.90.16.13      matt #ifdef MIPS3_PLUS
    268   1.90.16.2      matt #ifdef _LP64
    269  1.90.16.13      matt 	uint64_t mips3_xkphys_cached;
    270   1.90.16.2      matt #endif
    271  1.90.16.13      matt 	uint64_t mips3_tlb_vpn_mask;
    272  1.90.16.13      matt 	uint64_t mips3_tlb_pfn_mask;
    273  1.90.16.13      matt 	uint32_t mips3_tlb_pg_mask;
    274  1.90.16.13      matt #endif
    275  1.90.16.13      matt };
    276  1.90.16.13      matt extern struct mips_options mips_options;
    277        1.58    simonb 
    278        1.58    simonb #define	CPU_MIPS_R4K_MMU		0x0001
    279        1.58    simonb #define	CPU_MIPS_NO_LLSC		0x0002
    280        1.58    simonb #define	CPU_MIPS_CAUSE_IV		0x0004
    281        1.58    simonb #define	CPU_MIPS_HAVE_SPECIAL_CCA	0x0008	/* Defaults to '3' if not set. */
    282        1.58    simonb #define	CPU_MIPS_CACHED_CCA_MASK	0x0070
    283        1.58    simonb #define	CPU_MIPS_CACHED_CCA_SHIFT	 4
    284        1.62    simonb #define	CPU_MIPS_DOUBLE_COUNT		0x0080	/* 1 cp0 count == 2 clock cycles */
    285        1.63    simonb #define	CPU_MIPS_USE_WAIT		0x0100	/* Use "wait"-based cpu_idle() */
    286        1.63    simonb #define	CPU_MIPS_NO_WAIT		0x0200	/* Inverse of previous, for mips32/64 */
    287        1.69    simonb #define	CPU_MIPS_D_CACHE_COHERENT	0x0400	/* D-cache is fully coherent */
    288        1.69    simonb #define	CPU_MIPS_I_D_CACHE_COHERENT	0x0800	/* I-cache funcs don't need to flush the D-cache */
    289   1.90.16.3      matt #define	CPU_MIPS_NO_LLADDR		0x1000
    290   1.90.16.5     cliff #define	CPU_MIPS_HAVE_MxCR		0x2000	/* have mfcr, mtcr insns */
    291        1.58    simonb #define	MIPS_NOT_SUPP			0x8000
    292        1.60    simonb 
    293        1.78        ad #endif	/* !_LOCORE */
    294        1.78        ad 
    295  1.90.16.37      matt #if ((MIPS1 + MIPS3 + MIPS4 + MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2 + MIPS64_RMIXL + MIPS64R2_RMIXL) == 1) || defined(_LOCORE)
    296        1.78        ad 
    297        1.78        ad #if defined(MIPS1)
    298        1.78        ad 
    299        1.58    simonb # define CPUISMIPS3		0
    300        1.58    simonb # define CPUIS64BITS		0
    301        1.58    simonb # define CPUISMIPS32		0
    302  1.90.16.36      matt # define CPUISMIPS32R2		0
    303        1.58    simonb # define CPUISMIPS64		0
    304  1.90.16.36      matt # define CPUISMIPS64R2		0
    305        1.58    simonb # define CPUISMIPSNN		0
    306        1.58    simonb # define MIPS_HAS_R4K_MMU	0
    307        1.58    simonb # define MIPS_HAS_CLOCK		0
    308        1.58    simonb # define MIPS_HAS_LLSC		0
    309   1.90.16.4      matt # define MIPS_HAS_LLADDR	0
    310        1.58    simonb 
    311        1.78        ad #elif defined(MIPS3) || defined(MIPS4)
    312        1.78        ad 
    313        1.58    simonb # define CPUISMIPS3		1
    314        1.58    simonb # define CPUIS64BITS		1
    315        1.58    simonb # define CPUISMIPS32		0
    316  1.90.16.36      matt # define CPUISMIPS32R2		0
    317        1.58    simonb # define CPUISMIPS64		0
    318  1.90.16.36      matt # define CPUISMIPS64R2		0
    319        1.58    simonb # define CPUISMIPSNN		0
    320        1.58    simonb # define MIPS_HAS_R4K_MMU	1
    321        1.58    simonb # define MIPS_HAS_CLOCK		1
    322        1.78        ad # if defined(_LOCORE)
    323  1.90.16.36      matt #  if !defined(MIPS3_4100)
    324        1.78        ad #   define MIPS_HAS_LLSC	1
    325        1.78        ad #  else
    326        1.78        ad #   define MIPS_HAS_LLSC	0
    327        1.78        ad #  endif
    328        1.78        ad # else	/* _LOCORE */
    329  1.90.16.13      matt #  define MIPS_HAS_LLSC		(mips_options.mips_has_llsc)
    330        1.78        ad # endif	/* _LOCORE */
    331  1.90.16.13      matt # define MIPS_HAS_LLADDR	((mips_options.mips_cpu_flags & CPU_MIPS_NO_LLADDR) == 0)
    332        1.78        ad 
    333        1.78        ad #elif defined(MIPS32)
    334        1.58    simonb 
    335        1.58    simonb # define CPUISMIPS3		1
    336        1.58    simonb # define CPUIS64BITS		0
    337        1.58    simonb # define CPUISMIPS32		1
    338  1.90.16.36      matt # define CPUISMIPS32R2		0
    339        1.58    simonb # define CPUISMIPS64		0
    340  1.90.16.36      matt # define CPUISMIPS64R2		0
    341  1.90.16.36      matt # define CPUISMIPSNN		1
    342  1.90.16.36      matt # define MIPS_HAS_R4K_MMU	1
    343  1.90.16.36      matt # define MIPS_HAS_CLOCK		1
    344  1.90.16.36      matt # define MIPS_HAS_LLSC		1
    345  1.90.16.36      matt # define MIPS_HAS_LLADDR	((mips_options.mips_cpu_flags & CPU_MIPS_NO_LLADDR) == 0)
    346  1.90.16.36      matt 
    347  1.90.16.36      matt #elif defined(MIPS32R2)
    348  1.90.16.36      matt 
    349  1.90.16.36      matt # define CPUISMIPS3		1
    350  1.90.16.36      matt # define CPUIS64BITS		0
    351  1.90.16.36      matt # define CPUISMIPS32		0
    352  1.90.16.36      matt # define CPUISMIPS32R2		1
    353  1.90.16.36      matt # define CPUISMIPS64		0
    354  1.90.16.36      matt # define CPUISMIPS64R2		0
    355        1.58    simonb # define CPUISMIPSNN		1
    356        1.58    simonb # define MIPS_HAS_R4K_MMU	1
    357        1.58    simonb # define MIPS_HAS_CLOCK		1
    358        1.58    simonb # define MIPS_HAS_LLSC		1
    359  1.90.16.13      matt # define MIPS_HAS_LLADDR	((mips_options.mips_cpu_flags & CPU_MIPS_NO_LLADDR) == 0)
    360        1.58    simonb 
    361  1.90.16.37      matt #elif defined(MIPS64) || defined(MIPS64_RMIXL)
    362        1.78        ad 
    363        1.58    simonb # define CPUISMIPS3		1
    364        1.58    simonb # define CPUIS64BITS		1
    365        1.58    simonb # define CPUISMIPS32		0
    366  1.90.16.36      matt # define CPUISMIPS32R2		0
    367        1.58    simonb # define CPUISMIPS64		1
    368  1.90.16.36      matt # define CPUISMIPS64R2		0
    369  1.90.16.36      matt # define CPUISMIPSNN		1
    370  1.90.16.36      matt # define MIPS_HAS_R4K_MMU	1
    371  1.90.16.36      matt # define MIPS_HAS_CLOCK		1
    372  1.90.16.36      matt # define MIPS_HAS_LLSC		1
    373  1.90.16.36      matt # define MIPS_HAS_LLADDR	((mips_options.mips_cpu_flags & CPU_MIPS_NO_LLADDR) == 0)
    374  1.90.16.36      matt 
    375  1.90.16.37      matt #elif defined(MIPS64R2) || defined(MIPS64R2_RMIXL)
    376  1.90.16.36      matt 
    377  1.90.16.36      matt # define CPUISMIPS3		1
    378  1.90.16.36      matt # define CPUIS64BITS		1
    379  1.90.16.36      matt # define CPUISMIPS32		0
    380  1.90.16.36      matt # define CPUISMIPS32R2		0
    381  1.90.16.36      matt # define CPUISMIPS64		0
    382  1.90.16.36      matt # define CPUISMIPS64R2		1
    383        1.58    simonb # define CPUISMIPSNN		1
    384        1.58    simonb # define MIPS_HAS_R4K_MMU	1
    385        1.58    simonb # define MIPS_HAS_CLOCK		1
    386        1.58    simonb # define MIPS_HAS_LLSC		1
    387  1.90.16.13      matt # define MIPS_HAS_LLADDR	((mips_options.mips_cpu_flags & CPU_MIPS_NO_LLADDR) == 0)
    388        1.78        ad 
    389        1.78        ad #endif
    390        1.21  jonathan 
    391        1.58    simonb #else /* run-time test */
    392        1.21  jonathan 
    393        1.78        ad #ifndef	_LOCORE
    394        1.78        ad 
    395  1.90.16.13      matt #define	MIPS_HAS_R4K_MMU	(mips_options.mips_has_r4k_mmu)
    396  1.90.16.13      matt #define	MIPS_HAS_LLSC		(mips_options.mips_has_llsc)
    397  1.90.16.13      matt #define	MIPS_HAS_LLADDR		((mips_options.mips_cpu_flags & CPU_MIPS_NO_LLADDR) == 0)
    398        1.45       cgd 
    399        1.45       cgd /* This test is ... rather bogus */
    400  1.90.16.13      matt #define	CPUISMIPS3	((mips_options.mips_cpu_arch & \
    401        1.58    simonb 	(CPU_ARCH_MIPS3 | CPU_ARCH_MIPS4 | CPU_ARCH_MIPS32 | CPU_ARCH_MIPS64)) != 0)
    402        1.58    simonb 
    403        1.58    simonb /* And these aren't much better while the previous test exists as is... */
    404  1.90.16.13      matt #define	CPUISMIPS4	((mips_options.mips_cpu_arch & CPU_ARCH_MIPS4) != 0)
    405  1.90.16.13      matt #define	CPUISMIPS5	((mips_options.mips_cpu_arch & CPU_ARCH_MIPS5) != 0)
    406  1.90.16.13      matt #define	CPUISMIPS32	((mips_options.mips_cpu_arch & CPU_ARCH_MIPS32) != 0)
    407  1.90.16.36      matt #define	CPUISMIPS32R2	((mips_options.mips_cpu_arch & CPU_ARCH_MIPS32R2) != 0)
    408  1.90.16.13      matt #define	CPUISMIPS64	((mips_options.mips_cpu_arch & CPU_ARCH_MIPS64) != 0)
    409  1.90.16.36      matt #define	CPUISMIPS64R2	((mips_options.mips_cpu_arch & CPU_ARCH_MIPS64R2) != 0)
    410  1.90.16.36      matt #define	CPUISMIPSNN	((mips_options.mips_cpu_arch & (CPU_ARCH_MIPS32 | CPU_ARCH_MIPS32R2 | CPU_ARCH_MIPS64 | CPU_ARCH_MIPS64R2)) != 0)
    411  1.90.16.13      matt #define	CPUIS64BITS	((mips_options.mips_cpu_arch & \
    412  1.90.16.36      matt 	(CPU_ARCH_MIPS3 | CPU_ARCH_MIPS4 | CPU_ARCH_MIPS64 | CPU_ARCH_MIPS64R2)) != 0)
    413        1.58    simonb 
    414  1.90.16.13      matt #define	MIPS_HAS_CLOCK	(mips_options.mips_cpu_arch >= CPU_ARCH_MIPS3)
    415        1.78        ad 
    416        1.78        ad #else	/* !_LOCORE */
    417        1.78        ad 
    418        1.78        ad #define	MIPS_HAS_LLSC	0
    419        1.78        ad 
    420        1.78        ad #endif	/* !_LOCORE */
    421        1.78        ad 
    422        1.21  jonathan #endif /* run-time test */
    423        1.21  jonathan 
    424        1.78        ad #ifndef	_LOCORE
    425        1.58    simonb 
    426        1.21  jonathan /*
    427         1.1   deraadt  * definitions of cpu-dependent requirements
    428         1.1   deraadt  * referenced in generic code
    429         1.1   deraadt  */
    430        1.11       cgd #define	cpu_swapout(p)			panic("cpu_swapout: can't get here");
    431        1.42     jeffs 
    432  1.90.16.19      matt /*
    433  1.90.16.33     cliff  * Send an inter-processor interupt to each other CPU (excludes curcpu())
    434  1.90.16.33     cliff  */
    435  1.90.16.33     cliff void cpu_broadcast_ipi(int);
    436  1.90.16.33     cliff 
    437  1.90.16.33     cliff /*
    438  1.90.16.33     cliff  * Send an inter-processor interupt to CPUs in cpuset (excludes curcpu())
    439  1.90.16.33     cliff  */
    440  1.90.16.36      matt void cpu_multicast_ipi(__cpuset_t, int);
    441  1.90.16.33     cliff 
    442  1.90.16.33     cliff /*
    443  1.90.16.21      matt  * Send an inter-processor interupt to another CPU.
    444  1.90.16.21      matt  */
    445  1.90.16.21      matt int cpu_send_ipi(struct cpu_info *, int);
    446  1.90.16.21      matt 
    447  1.90.16.21      matt /*
    448  1.90.16.19      matt  * cpu_intr(ppl, pc, status);  (most state needed by clockframe)
    449  1.90.16.19      matt  */
    450  1.90.16.19      matt void cpu_intr(int, vaddr_t, uint32_t);
    451         1.1   deraadt 
    452         1.1   deraadt /*
    453         1.1   deraadt  * Arguments to hardclock and gatherstats encapsulate the previous
    454         1.1   deraadt  * machine state in an opaque clockframe.
    455         1.1   deraadt  */
    456         1.5     glass struct clockframe {
    457  1.90.16.19      matt 	vaddr_t		pc;	/* program counter at time of interrupt */
    458   1.90.16.8     cliff 	uint32_t	sr;	/* status register at time of interrupt */
    459  1.90.16.19      matt 	bool		intr;	/* interrupted a interrupt */
    460         1.5     glass };
    461         1.1   deraadt 
    462        1.14  jonathan /*
    463        1.79        ad  * A port must provde CLKF_USERMODE() for use in machine-independent code.
    464        1.79        ad  * These differ on r4000 and r3000 systems; provide them in the
    465        1.79        ad  * port-dependent file that includes this one, using the macros below.
    466        1.14  jonathan  */
    467        1.14  jonathan 
    468        1.21  jonathan /* mips1 versions */
    469        1.22  jonathan #define	MIPS1_CLKF_USERMODE(framep)	((framep)->sr & MIPS_SR_KU_PREV)
    470        1.14  jonathan 
    471        1.21  jonathan /* mips3 versions */
    472        1.22  jonathan #define	MIPS3_CLKF_USERMODE(framep)	((framep)->sr & MIPS_SR_KSU_USER)
    473        1.56       uch 
    474         1.1   deraadt #define	CLKF_PC(framep)		((framep)->pc)
    475  1.90.16.19      matt #define	CLKF_INTR(framep)	((framep)->intr)
    476        1.18  jonathan 
    477        1.58    simonb #if defined(MIPS3_PLUS) && !defined(MIPS1)		/* XXX bogus! */
    478        1.21  jonathan #define	CLKF_USERMODE(framep)	MIPS3_CLKF_USERMODE(framep)
    479        1.21  jonathan #endif
    480        1.21  jonathan 
    481        1.58    simonb #if !defined(MIPS3_PLUS) && defined(MIPS1)		/* XXX bogus! */
    482        1.21  jonathan #define	CLKF_USERMODE(framep)	MIPS1_CLKF_USERMODE(framep)
    483        1.21  jonathan #endif
    484        1.21  jonathan 
    485        1.58    simonb #if defined(MIPS3_PLUS) && defined(MIPS1)		/* XXX bogus! */
    486        1.21  jonathan #define CLKF_USERMODE(framep) \
    487        1.21  jonathan     ((CPUISMIPS3) ? MIPS3_CLKF_USERMODE(framep):  MIPS1_CLKF_USERMODE(framep))
    488        1.18  jonathan #endif
    489        1.18  jonathan 
    490        1.47   thorpej /*
    491  1.90.16.20      matt  * Misc prototypes and variable declarations.
    492        1.47   thorpej  */
    493  1.90.16.36      matt #define	LWP_PC(l)	cpu_lwp_pc(l)
    494  1.90.16.36      matt 
    495  1.90.16.36      matt struct proc;
    496  1.90.16.20      matt struct lwp;
    497  1.90.16.36      matt struct pcb;
    498  1.90.16.36      matt struct reg;
    499         1.1   deraadt 
    500         1.1   deraadt /*
    501         1.1   deraadt  * Preempt the current process if in interrupt from user mode,
    502         1.1   deraadt  * or after the current trap/syscall if in system mode.
    503         1.1   deraadt  */
    504        1.82      yamt void	cpu_need_resched(struct cpu_info *, int);
    505         1.1   deraadt /*
    506        1.81    simonb  * Notify the current lwp (l) that it has a signal pending,
    507         1.1   deraadt  * process as soon as possible.
    508         1.1   deraadt  */
    509  1.90.16.20      matt void	cpu_signotify(struct lwp *);
    510         1.1   deraadt 
    511        1.23   thorpej /*
    512  1.90.16.20      matt  * Give a profiling tick to the current process when the user profiling
    513  1.90.16.20      matt  * buffer pages are invalid.  On the MIPS, request an ast to send us
    514  1.90.16.20      matt  * through trap, marking the proc as needing a profiling tick.
    515        1.23   thorpej  */
    516  1.90.16.20      matt void	cpu_need_proftick(struct lwp *);
    517  1.90.16.20      matt void	cpu_set_curpri(int);
    518        1.37    simonb 
    519   1.90.16.9      matt extern int mips_poolpage_vmfreelist;	/* freelist to allocate poolpages */
    520        1.25  jonathan 
    521  1.90.16.24      matt struct cpu_info *
    522  1.90.16.32      matt 	cpu_info_alloc(struct pmap_tlb_info *, cpuid_t, cpuid_t, cpuid_t,
    523  1.90.16.32      matt 	    cpuid_t);
    524  1.90.16.24      matt void	cpu_attach_common(device_t, struct cpu_info *);
    525  1.90.16.24      matt void	cpu_startup_common(void);
    526  1.90.16.31      matt #ifdef _LP64
    527  1.90.16.31      matt void	cpu_vmspace_exec(struct lwp *, vaddr_t, vaddr_t);
    528  1.90.16.31      matt #endif
    529  1.90.16.33     cliff 
    530  1.90.16.25      matt #ifdef MULTIPROCESSOR
    531  1.90.16.25      matt void	cpu_hatch(struct cpu_info *ci);
    532  1.90.16.25      matt void	cpu_trampoline(void);
    533  1.90.16.25      matt void	cpu_boot_secondary_processors(void);
    534  1.90.16.33     cliff void	cpu_halt(void);
    535  1.90.16.33     cliff void	cpu_halt_others(void);
    536  1.90.16.33     cliff void	cpu_pause(struct reg *);
    537  1.90.16.33     cliff void	cpu_pause_others(void);
    538  1.90.16.33     cliff void	cpu_resume(int);
    539  1.90.16.33     cliff void	cpu_resume_others(void);
    540  1.90.16.33     cliff int	cpu_is_paused(int);
    541  1.90.16.33     cliff void	cpu_debug_dump(void);
    542  1.90.16.33     cliff 
    543  1.90.16.36      matt extern volatile __cpuset_t cpus_running;
    544  1.90.16.36      matt extern volatile __cpuset_t cpus_hatched;
    545  1.90.16.36      matt extern volatile __cpuset_t cpus_paused;
    546  1.90.16.36      matt extern volatile __cpuset_t cpus_resumed;
    547  1.90.16.36      matt extern volatile __cpuset_t cpus_halted;
    548  1.90.16.25      matt #endif
    549  1.90.16.24      matt 
    550   1.90.16.6      matt /* copy.S */
    551   1.90.16.6      matt int8_t	ufetch_int8(void *);
    552   1.90.16.6      matt int16_t	ufetch_int16(void *);
    553   1.90.16.6      matt int32_t ufetch_int32(void *);
    554   1.90.16.6      matt uint8_t	ufetch_uint8(void *);
    555   1.90.16.6      matt uint16_t ufetch_uint16(void *);
    556   1.90.16.6      matt uint32_t ufetch_uint32(void *);
    557   1.90.16.6      matt int8_t	ufetch_int8_intrsafe(void *);
    558   1.90.16.6      matt int16_t	ufetch_int16_intrsafe(void *);
    559   1.90.16.6      matt int32_t ufetch_int32_intrsafe(void *);
    560   1.90.16.6      matt uint8_t	ufetch_uint8_intrsafe(void *);
    561   1.90.16.6      matt uint16_t ufetch_uint16_intrsafe(void *);
    562   1.90.16.6      matt uint32_t ufetch_uint32_intrsafe(void *);
    563   1.90.16.6      matt #ifdef _LP64
    564   1.90.16.6      matt int64_t ufetch_int64(void *);
    565   1.90.16.6      matt uint64_t ufetch_uint64(void *);
    566   1.90.16.6      matt int64_t ufetch_int64_intrsafe(void *);
    567   1.90.16.6      matt uint64_t ufetch_uint64_intrsafe(void *);
    568   1.90.16.6      matt #endif
    569   1.90.16.6      matt char	ufetch_char(void *);
    570   1.90.16.6      matt short	ufetch_short(void *);
    571   1.90.16.6      matt int	ufetch_int(void *);
    572   1.90.16.6      matt long	ufetch_long(void *);
    573   1.90.16.6      matt char	ufetch_char_intrsafe(void *);
    574   1.90.16.6      matt short	ufetch_short_intrsafe(void *);
    575   1.90.16.6      matt int	ufetch_int_intrsafe(void *);
    576   1.90.16.6      matt long	ufetch_long_intrsafe(void *);
    577   1.90.16.6      matt 
    578   1.90.16.6      matt u_char	ufetch_uchar(void *);
    579   1.90.16.6      matt u_short	ufetch_ushort(void *);
    580   1.90.16.6      matt u_int	ufetch_uint(void *);
    581   1.90.16.6      matt u_long	ufetch_ulong(void *);
    582   1.90.16.6      matt u_char	ufetch_uchar_intrsafe(void *);
    583   1.90.16.6      matt u_short	ufetch_ushort_intrsafe(void *);
    584   1.90.16.6      matt u_int	ufetch_uint_intrsafe(void *);
    585   1.90.16.6      matt u_long	ufetch_ulong_intrsafe(void *);
    586   1.90.16.6      matt void 	*ufetch_ptr(void *);
    587   1.90.16.6      matt 
    588   1.90.16.6      matt int	ustore_int8(void *, int8_t);
    589   1.90.16.6      matt int	ustore_int16(void *, int16_t);
    590   1.90.16.6      matt int	ustore_int32(void *, int32_t);
    591   1.90.16.6      matt int	ustore_uint8(void *, uint8_t);
    592   1.90.16.7      matt int	ustore_uint16(void *, uint16_t);
    593   1.90.16.6      matt int	ustore_uint32(void *, uint32_t);
    594   1.90.16.6      matt int	ustore_int8_intrsafe(void *, int8_t);
    595   1.90.16.6      matt int	ustore_int16_intrsafe(void *, int16_t);
    596   1.90.16.6      matt int	ustore_int32_intrsafe(void *, int32_t);
    597   1.90.16.6      matt int	ustore_uint8_intrsafe(void *, uint8_t);
    598   1.90.16.6      matt int	ustore_uint16_intrsafe(void *, uint16_t);
    599   1.90.16.6      matt int	ustore_uint32_intrsafe(void *, uint32_t);
    600   1.90.16.6      matt #ifdef _LP64
    601   1.90.16.6      matt int	ustore_int64(void *, int64_t);
    602   1.90.16.6      matt int	ustore_uint64(void *, uint64_t);
    603   1.90.16.6      matt int	ustore_int64_intrsafe(void *, int64_t);
    604   1.90.16.6      matt int	ustore_uint64_intrsafe(void *, uint64_t);
    605   1.90.16.6      matt #endif
    606   1.90.16.6      matt int	ustore_char(void *, char);
    607   1.90.16.6      matt int	ustore_char_intrsafe(void *, char);
    608   1.90.16.6      matt int	ustore_short(void *, short);
    609   1.90.16.6      matt int	ustore_short_intrsafe(void *, short);
    610   1.90.16.6      matt int	ustore_int(void *, int);
    611   1.90.16.6      matt int	ustore_int_intrsafe(void *, int);
    612   1.90.16.6      matt int	ustore_long(void *, long);
    613   1.90.16.6      matt int	ustore_long_intrsafe(void *, long);
    614   1.90.16.6      matt int	ustore_uchar(void *, u_char);
    615   1.90.16.6      matt int	ustore_uchar_intrsafe(void *, u_char);
    616   1.90.16.6      matt int	ustore_ushort(void *, u_short);
    617   1.90.16.6      matt int	ustore_ushort_intrsafe(void *, u_short);
    618   1.90.16.6      matt int	ustore_uint(void *, u_int);
    619   1.90.16.6      matt int	ustore_uint_intrsafe(void *, u_int);
    620   1.90.16.6      matt int	ustore_ulong(void *, u_long);
    621   1.90.16.6      matt int	ustore_ulong_intrsafe(void *, u_long);
    622   1.90.16.6      matt int 	ustore_ptr(void *, void *);
    623   1.90.16.6      matt int	ustore_ptr_intrsafe(void *, void *);
    624   1.90.16.6      matt 
    625   1.90.16.6      matt int	ustore_uint32_isync(void *, uint32_t);
    626   1.90.16.6      matt 
    627        1.28    castor /* trap.c */
    628        1.58    simonb void	netintr(void);
    629        1.58    simonb int	kdbpeek(vaddr_t);
    630        1.23   thorpej 
    631  1.90.16.24      matt /* mips_fpu.c */
    632  1.90.16.24      matt void	fpu_init(void);
    633  1.90.16.36      matt void	fpu_discard(void);
    634  1.90.16.36      matt void	fpu_load(void);
    635  1.90.16.36      matt void	fpu_save(void);
    636  1.90.16.36      matt void	fpu_save_lwp(struct lwp *);
    637  1.90.16.24      matt void	fpusave_cpu(struct cpu_info *);
    638  1.90.16.24      matt 
    639        1.28    castor /* mips_machdep.c */
    640        1.58    simonb void	dumpsys(void);
    641  1.90.16.36      matt int	savectx(struct pcb *);
    642  1.90.16.13      matt void	cpu_identify(device_t);
    643        1.13  jonathan 
    644        1.61    simonb /* locore*.S */
    645        1.58    simonb int	badaddr(void *, size_t);
    646        1.61    simonb int	badaddr64(uint64_t, size_t);
    647        1.25  jonathan 
    648  1.90.16.18      matt /* vm_machdep.c */
    649  1.90.16.36      matt void	cpu_proc_fork(struct proc *, struct proc *);
    650  1.90.16.36      matt vaddr_t	cpu_lwp_pc(struct lwp *);
    651  1.90.16.18      matt void	cpu_uarea_remap(struct lwp *);
    652  1.90.16.18      matt 
    653        1.33    simonb #endif /* ! _LOCORE */
    654        1.28    castor #endif /* _KERNEL */
    655         1.1   deraadt #endif /* _CPU_H_ */
    656