Home | History | Annotate | Line # | Download | only in include
cpu.h revision 1.95.6.1
      1  1.95.6.1     skrll /*	$NetBSD: cpu.h,v 1.95.6.1 2017/02/05 13:40:20 skrll Exp $ */
      2      1.10   deraadt 
      3       1.1   deraadt /*
      4       1.1   deraadt  * Copyright (c) 1992, 1993
      5       1.1   deraadt  *	The Regents of the University of California.  All rights reserved.
      6       1.1   deraadt  *
      7       1.1   deraadt  * This software was developed by the Computer Systems Engineering group
      8       1.1   deraadt  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
      9       1.1   deraadt  * contributed to Berkeley.
     10       1.1   deraadt  *
     11       1.1   deraadt  * All advertising materials mentioning features or use of this software
     12       1.1   deraadt  * must display the following acknowledgement:
     13       1.1   deraadt  *	This product includes software developed by the University of
     14       1.1   deraadt  *	California, Lawrence Berkeley Laboratory.
     15       1.1   deraadt  *
     16       1.1   deraadt  * Redistribution and use in source and binary forms, with or without
     17       1.1   deraadt  * modification, are permitted provided that the following conditions
     18       1.1   deraadt  * are met:
     19       1.1   deraadt  * 1. Redistributions of source code must retain the above copyright
     20       1.1   deraadt  *    notice, this list of conditions and the following disclaimer.
     21       1.1   deraadt  * 2. Redistributions in binary form must reproduce the above copyright
     22       1.1   deraadt  *    notice, this list of conditions and the following disclaimer in the
     23       1.1   deraadt  *    documentation and/or other materials provided with the distribution.
     24      1.64       agc  * 3. Neither the name of the University nor the names of its contributors
     25       1.1   deraadt  *    may be used to endorse or promote products derived from this software
     26       1.1   deraadt  *    without specific prior written permission.
     27       1.1   deraadt  *
     28       1.1   deraadt  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     29       1.1   deraadt  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     30       1.1   deraadt  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     31       1.1   deraadt  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     32       1.1   deraadt  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     33       1.1   deraadt  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     34       1.1   deraadt  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     35       1.1   deraadt  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     36       1.1   deraadt  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     37       1.1   deraadt  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     38       1.1   deraadt  * SUCH DAMAGE.
     39       1.1   deraadt  *
     40       1.7   deraadt  *	@(#)cpu.h	8.4 (Berkeley) 1/5/94
     41       1.1   deraadt  */
     42       1.1   deraadt 
     43       1.1   deraadt #ifndef _CPU_H_
     44       1.1   deraadt #define _CPU_H_
     45       1.1   deraadt 
     46       1.1   deraadt /*
     47      1.21        pk  * CTL_MACHDEP definitions.
     48       1.1   deraadt  */
     49      1.34        pk #define	CPU_BOOTED_KERNEL	1	/* string: booted kernel name */
     50      1.49   darrenr #define	CPU_BOOTED_DEVICE	2	/* string: device booted from */
     51      1.49   darrenr #define	CPU_BOOT_ARGS		3	/* string: args booted with */
     52      1.50        pk #define	CPU_ARCH		4	/* integer: cpu architecture version */
     53      1.50        pk #define	CPU_MAXID		5	/* number of valid machdep ids */
     54       1.1   deraadt 
     55       1.1   deraadt /*
     56       1.1   deraadt  * Exported definitions unique to SPARC cpu support.
     57       1.1   deraadt  */
     58       1.1   deraadt 
     59  1.95.6.1     skrll /* Things needed by crash or the kernel */
     60  1.95.6.1     skrll #if defined(_KERNEL) || defined(_KMEMUSER)
     61  1.95.6.1     skrll 
     62      1.65   tsutsui #if defined(_KERNEL_OPT)
     63      1.35   thorpej #include "opt_multiprocessor.h"
     64      1.36   thorpej #include "opt_lockdebug.h"
     65      1.47   darrenr #include "opt_sparc_arch.h"
     66      1.35   thorpej #endif
     67      1.35   thorpej 
     68  1.95.6.1     skrll #include <sys/cpu_data.h>
     69  1.95.6.1     skrll #include <sys/evcnt.h>
     70  1.95.6.1     skrll 
     71      1.52        pk #include <machine/intr.h>
     72       1.1   deraadt #include <machine/psl.h>
     73  1.95.6.1     skrll 
     74  1.95.6.1     skrll #if defined(_KERNEL)
     75      1.36   thorpej #include <sparc/sparc/cpuvar.h>
     76       1.1   deraadt #include <sparc/sparc/intreg.h>
     77  1.95.6.1     skrll #else
     78  1.95.6.1     skrll #include <arch/sparc/sparc/vaddrs.h>
     79  1.95.6.1     skrll #include <arch/sparc/sparc/cache.h>
     80  1.95.6.1     skrll #endif
     81  1.95.6.1     skrll 
     82  1.95.6.1     skrll struct trapframe;
     83  1.95.6.1     skrll 
     84  1.95.6.1     skrll /*
     85  1.95.6.1     skrll  * Message structure for Inter Processor Communication in MP systems
     86  1.95.6.1     skrll  */
     87  1.95.6.1     skrll struct xpmsg {
     88  1.95.6.1     skrll 	volatile int tag;
     89  1.95.6.1     skrll #define	XPMSG15_PAUSECPU	1
     90  1.95.6.1     skrll #define	XPMSG_FUNC		4
     91  1.95.6.1     skrll #define	XPMSG_FTRP		5
     92  1.95.6.1     skrll 
     93  1.95.6.1     skrll 	volatile union {
     94  1.95.6.1     skrll 		/*
     95  1.95.6.1     skrll 		 * Cross call: ask to run (*func)(arg0,arg1,arg2)
     96  1.95.6.1     skrll 		 * or (*trap)(arg0,arg1,arg2). `trap' should be the
     97  1.95.6.1     skrll 		 * address of a `fast trap' handler that executes in
     98  1.95.6.1     skrll 		 * the trap window (see locore.s).
     99  1.95.6.1     skrll 		 */
    100  1.95.6.1     skrll 		struct xpmsg_func {
    101  1.95.6.1     skrll 			void	(*func)(int, int, int);
    102  1.95.6.1     skrll 			void	(*trap)(int, int, int);
    103  1.95.6.1     skrll 			int	arg0;
    104  1.95.6.1     skrll 			int	arg1;
    105  1.95.6.1     skrll 			int	arg2;
    106  1.95.6.1     skrll 		} xpmsg_func;
    107  1.95.6.1     skrll 	} u;
    108  1.95.6.1     skrll 	volatile int	received;
    109  1.95.6.1     skrll 	volatile int	complete;
    110  1.95.6.1     skrll };
    111  1.95.6.1     skrll 
    112  1.95.6.1     skrll /*
    113  1.95.6.1     skrll  * The cpuinfo structure. This structure maintains information about one
    114  1.95.6.1     skrll  * currently installed CPU (there may be several of these if the machine
    115  1.95.6.1     skrll  * supports multiple CPUs, as on some Sun4m architectures). The information
    116  1.95.6.1     skrll  * in this structure supersedes the old "cpumod", "mmumod", and similar
    117  1.95.6.1     skrll  * fields.
    118  1.95.6.1     skrll  */
    119  1.95.6.1     skrll 
    120  1.95.6.1     skrll struct cpu_info {
    121  1.95.6.1     skrll 	struct cpu_data ci_data;	/* MI per-cpu data */
    122  1.95.6.1     skrll 
    123  1.95.6.1     skrll 	/*
    124  1.95.6.1     skrll 	 * Primary Inter-processor message area.  Keep this aligned
    125  1.95.6.1     skrll 	 * to a cache line boundary if possible, as the structure
    126  1.95.6.1     skrll 	 * itself is one (normal 32 byte) cache-line.
    127  1.95.6.1     skrll 	 */
    128  1.95.6.1     skrll 	struct xpmsg	msg __aligned(32);
    129  1.95.6.1     skrll 
    130  1.95.6.1     skrll 	/* Scheduler flags */
    131  1.95.6.1     skrll 	int	ci_want_ast;
    132  1.95.6.1     skrll 	int	ci_want_resched;
    133  1.95.6.1     skrll 
    134  1.95.6.1     skrll 	/*
    135  1.95.6.1     skrll 	 * SPARC cpu_info structures live at two VAs: one global
    136  1.95.6.1     skrll 	 * VA (so each CPU can access any other CPU's cpu_info)
    137  1.95.6.1     skrll 	 * and an alias VA CPUINFO_VA which is the same on each
    138  1.95.6.1     skrll 	 * CPU and maps to that CPU's cpu_info.  Since the alias
    139  1.95.6.1     skrll 	 * CPUINFO_VA is how we locate our cpu_info, we have to
    140  1.95.6.1     skrll 	 * self-reference the global VA so that we can return it
    141  1.95.6.1     skrll 	 * in the curcpu() macro.
    142  1.95.6.1     skrll 	 */
    143  1.95.6.1     skrll 	struct cpu_info * volatile ci_self;
    144  1.95.6.1     skrll 
    145  1.95.6.1     skrll 	int		ci_cpuid;	/* CPU index (see cpus[] array) */
    146  1.95.6.1     skrll 
    147  1.95.6.1     skrll 	/* Context administration */
    148  1.95.6.1     skrll 	int		*ctx_tbl;	/* [4m] SRMMU-edible context table */
    149  1.95.6.1     skrll 	paddr_t		ctx_tbl_pa;	/* [4m] ctx table physical address */
    150  1.95.6.1     skrll 
    151  1.95.6.1     skrll 	/* Cache information */
    152  1.95.6.1     skrll 	struct cacheinfo	cacheinfo;	/* see cache.h */
    153  1.95.6.1     skrll 
    154  1.95.6.1     skrll 	/* various flags to workaround anomalies in chips */
    155  1.95.6.1     skrll 	volatile int	flags;		/* see CPUFLG_xxx, below */
    156  1.95.6.1     skrll 
    157  1.95.6.1     skrll 	/* Per processor counter register (sun4m only) */
    158  1.95.6.1     skrll 	volatile struct counter_4m	*counterreg_4m;
    159  1.95.6.1     skrll 
    160  1.95.6.1     skrll 	/* Per processor interrupt mask register (sun4m only) */
    161  1.95.6.1     skrll 	volatile struct icr_pi	*intreg_4m;
    162  1.95.6.1     skrll 	/*
    163  1.95.6.1     skrll 	 * Send a IPI to (cpi).  For Ross cpus we need to read
    164  1.95.6.1     skrll 	 * the pending register to avoid a hardware bug.
    165  1.95.6.1     skrll 	 */
    166  1.95.6.1     skrll #define raise_ipi(cpi,lvl)	do {			\
    167  1.95.6.1     skrll 	int x;						\
    168  1.95.6.1     skrll 	(cpi)->intreg_4m->pi_set = PINTR_SINTRLEV(lvl);	\
    169  1.95.6.1     skrll 	x = (cpi)->intreg_4m->pi_pend; __USE(x);	\
    170  1.95.6.1     skrll } while (0)
    171  1.95.6.1     skrll 
    172  1.95.6.1     skrll 	int		sun4_mmu3l;	/* [4]: 3-level MMU present */
    173  1.95.6.1     skrll #if defined(SUN4_MMU3L)
    174  1.95.6.1     skrll #define HASSUN4_MMU3L	(cpuinfo.sun4_mmu3l)
    175  1.95.6.1     skrll #else
    176  1.95.6.1     skrll #define HASSUN4_MMU3L	(0)
    177  1.95.6.1     skrll #endif
    178  1.95.6.1     skrll 	int		ci_idepth;		/* Interrupt depth */
    179  1.95.6.1     skrll 
    180  1.95.6.1     skrll 	/*
    181  1.95.6.1     skrll 	 * The following pointers point to processes that are somehow
    182  1.95.6.1     skrll 	 * associated with this CPU--running on it, using its FPU,
    183  1.95.6.1     skrll 	 * etc.
    184  1.95.6.1     skrll 	 */
    185  1.95.6.1     skrll 	struct	lwp	*ci_curlwp;		/* CPU owner */
    186  1.95.6.1     skrll 	struct	lwp 	*fplwp;			/* FPU owner */
    187  1.95.6.1     skrll 
    188  1.95.6.1     skrll 	int		ci_mtx_count;
    189  1.95.6.1     skrll 	int		ci_mtx_oldspl;
    190  1.95.6.1     skrll 
    191  1.95.6.1     skrll 	/*
    192  1.95.6.1     skrll 	 * Idle PCB and Interrupt stack;
    193  1.95.6.1     skrll 	 */
    194  1.95.6.1     skrll 	void		*eintstack;		/* End of interrupt stack */
    195  1.95.6.1     skrll #define INT_STACK_SIZE	(128 * 128)		/* 128 128-byte stack frames */
    196  1.95.6.1     skrll 	void		*redzone;		/* DEBUG: stack red zone */
    197  1.95.6.1     skrll #define REDSIZE		(8*96)			/* some room for bouncing */
    198  1.95.6.1     skrll 
    199  1.95.6.1     skrll 	struct	pcb	*curpcb;		/* CPU's PCB & kernel stack */
    200  1.95.6.1     skrll 
    201  1.95.6.1     skrll 	/* locore defined: */
    202  1.95.6.1     skrll 	void	(*get_syncflt)(void);		/* Not C-callable */
    203  1.95.6.1     skrll 	int	(*get_asyncflt)(u_int *, u_int *);
    204  1.95.6.1     skrll 
    205  1.95.6.1     skrll 	/* Synchronous Fault Status; temporary storage */
    206  1.95.6.1     skrll 	struct {
    207  1.95.6.1     skrll 		int	sfsr;
    208  1.95.6.1     skrll 		int	sfva;
    209  1.95.6.1     skrll 	} syncfltdump;
    210  1.95.6.1     skrll 
    211  1.95.6.1     skrll 	/*
    212  1.95.6.1     skrll 	 * Cache handling functions.
    213  1.95.6.1     skrll 	 * Most cache flush function come in two flavours: one that
    214  1.95.6.1     skrll 	 * acts only on the CPU it executes on, and another that
    215  1.95.6.1     skrll 	 * uses inter-processor signals to flush the cache on
    216  1.95.6.1     skrll 	 * all processor modules.
    217  1.95.6.1     skrll 	 * The `ft_' versions are fast trap cache flush handlers.
    218  1.95.6.1     skrll 	 */
    219  1.95.6.1     skrll 	void	(*cache_flush)(void *, u_int);
    220  1.95.6.1     skrll 	void	(*vcache_flush_page)(int, int);
    221  1.95.6.1     skrll 	void	(*sp_vcache_flush_page)(int, int);
    222  1.95.6.1     skrll 	void	(*ft_vcache_flush_page)(int, int);
    223  1.95.6.1     skrll 	void	(*vcache_flush_segment)(int, int, int);
    224  1.95.6.1     skrll 	void	(*sp_vcache_flush_segment)(int, int, int);
    225  1.95.6.1     skrll 	void	(*ft_vcache_flush_segment)(int, int, int);
    226  1.95.6.1     skrll 	void	(*vcache_flush_region)(int, int);
    227  1.95.6.1     skrll 	void	(*sp_vcache_flush_region)(int, int);
    228  1.95.6.1     skrll 	void	(*ft_vcache_flush_region)(int, int);
    229  1.95.6.1     skrll 	void	(*vcache_flush_context)(int);
    230  1.95.6.1     skrll 	void	(*sp_vcache_flush_context)(int);
    231  1.95.6.1     skrll 	void	(*ft_vcache_flush_context)(int);
    232  1.95.6.1     skrll 
    233  1.95.6.1     skrll 	/* The are helpers for (*cache_flush)() */
    234  1.95.6.1     skrll 	void	(*sp_vcache_flush_range)(int, int, int);
    235  1.95.6.1     skrll 	void	(*ft_vcache_flush_range)(int, int, int);
    236  1.95.6.1     skrll 
    237  1.95.6.1     skrll 	void	(*pcache_flush_page)(paddr_t, int);
    238  1.95.6.1     skrll 	void	(*pure_vcache_flush)(void);
    239  1.95.6.1     skrll 	void	(*cache_flush_all)(void);
    240  1.95.6.1     skrll 
    241  1.95.6.1     skrll 	/* Support for hardware-assisted page clear/copy */
    242  1.95.6.1     skrll 	void	(*zero_page)(paddr_t);
    243  1.95.6.1     skrll 	void	(*copy_page)(paddr_t, paddr_t);
    244  1.95.6.1     skrll 
    245  1.95.6.1     skrll 	/* Virtual addresses for use in pmap copy_page/zero_page */
    246  1.95.6.1     skrll 	void *	vpage[2];
    247  1.95.6.1     skrll 	int	*vpage_pte[2];		/* pte location of vpage[] */
    248  1.95.6.1     skrll 
    249  1.95.6.1     skrll 	void	(*cache_enable)(void);
    250  1.95.6.1     skrll 
    251  1.95.6.1     skrll 	int	cpu_type;	/* Type: see CPUTYP_xxx below */
    252  1.95.6.1     skrll 
    253  1.95.6.1     skrll 	/* Inter-processor message area (high priority but used infrequently) */
    254  1.95.6.1     skrll 	struct xpmsg	msg_lev15;
    255  1.95.6.1     skrll 
    256  1.95.6.1     skrll 	/* CPU information */
    257  1.95.6.1     skrll 	int		node;		/* PROM node for this CPU */
    258  1.95.6.1     skrll 	int		mid;		/* Module ID for MP systems */
    259  1.95.6.1     skrll 	int		mbus;		/* 1 if CPU is on MBus */
    260  1.95.6.1     skrll 	int		mxcc;		/* 1 if a MBus-level MXCC is present */
    261  1.95.6.1     skrll 	const char	*cpu_longname;	/* CPU model */
    262  1.95.6.1     skrll 	int		cpu_impl;	/* CPU implementation code */
    263  1.95.6.1     skrll 	int		cpu_vers;	/* CPU version code */
    264  1.95.6.1     skrll 	int		mmu_impl;	/* MMU implementation code */
    265  1.95.6.1     skrll 	int		mmu_vers;	/* MMU version code */
    266  1.95.6.1     skrll 	int		master;		/* 1 if this is bootup CPU */
    267  1.95.6.1     skrll 
    268  1.95.6.1     skrll 	vaddr_t		mailbox;	/* VA of CPU's mailbox */
    269  1.95.6.1     skrll 
    270  1.95.6.1     skrll 	int		mmu_ncontext;	/* Number of contexts supported */
    271  1.95.6.1     skrll 	int		mmu_nregion; 	/* Number of regions supported */
    272  1.95.6.1     skrll 	int		mmu_nsegment;	/* [4/4c] Segments */
    273  1.95.6.1     skrll 	int		mmu_npmeg;	/* [4/4c] Pmegs */
    274  1.95.6.1     skrll 
    275  1.95.6.1     skrll /* XXX - we currently don't actually use the following */
    276  1.95.6.1     skrll 	int		arch;		/* Architecture: CPU_SUN4x */
    277  1.95.6.1     skrll 	int		class;		/* Class: SuperSPARC, microSPARC... */
    278  1.95.6.1     skrll 	int		classlvl;	/* Iteration in class: 1, 2, etc. */
    279  1.95.6.1     skrll 	int		classsublvl;	/* stepping in class (version) */
    280  1.95.6.1     skrll 
    281  1.95.6.1     skrll 	int		hz;		/* Clock speed */
    282  1.95.6.1     skrll 
    283  1.95.6.1     skrll 	/* FPU information */
    284  1.95.6.1     skrll 	int		fpupresent;	/* true if FPU is present */
    285  1.95.6.1     skrll 	int		fpuvers;	/* FPU revision */
    286  1.95.6.1     skrll 	const char	*fpu_name;	/* FPU model */
    287  1.95.6.1     skrll 	char		fpu_namebuf[32];/* Buffer for FPU name, if necessary */
    288  1.95.6.1     skrll 
    289  1.95.6.1     skrll 	/* XXX */
    290  1.95.6.1     skrll 	volatile void	*ci_ddb_regs;		/* DDB regs */
    291  1.95.6.1     skrll 
    292  1.95.6.1     skrll 	/*
    293  1.95.6.1     skrll 	 * The following are function pointers to do interesting CPU-dependent
    294  1.95.6.1     skrll 	 * things without having to do type-tests all the time
    295  1.95.6.1     skrll 	 */
    296  1.95.6.1     skrll 
    297  1.95.6.1     skrll 	/* bootup things: access to physical memory */
    298  1.95.6.1     skrll 	u_int	(*read_physmem)(u_int addr, int space);
    299  1.95.6.1     skrll 	void	(*write_physmem)(u_int addr, u_int data);
    300  1.95.6.1     skrll 	void	(*cache_tablewalks)(void);
    301  1.95.6.1     skrll 	void	(*mmu_enable)(void);
    302  1.95.6.1     skrll 	void	(*hotfix)(struct cpu_info *);
    303  1.95.6.1     skrll 
    304  1.95.6.1     skrll 
    305  1.95.6.1     skrll #if 0
    306  1.95.6.1     skrll 	/* hardware-assisted block operation routines */
    307  1.95.6.1     skrll 	void		(*hwbcopy)(const void *from, void *to, size_t len);
    308  1.95.6.1     skrll 	void		(*hwbzero)(void *buf, size_t len);
    309  1.95.6.1     skrll 
    310  1.95.6.1     skrll 	/* routine to clear mbus-sbus buffers */
    311  1.95.6.1     skrll 	void		(*mbusflush)(void);
    312  1.95.6.1     skrll #endif
    313  1.95.6.1     skrll 
    314  1.95.6.1     skrll 	/*
    315  1.95.6.1     skrll 	 * Memory error handler; parity errors, unhandled NMIs and other
    316  1.95.6.1     skrll 	 * unrecoverable faults end up here.
    317  1.95.6.1     skrll 	 */
    318  1.95.6.1     skrll 	void		(*memerr)(unsigned, u_int, u_int, struct trapframe *);
    319  1.95.6.1     skrll 	void		(*idlespin)(struct cpu_info *);
    320  1.95.6.1     skrll 	/* Module Control Registers */
    321  1.95.6.1     skrll 	/*bus_space_handle_t*/ long ci_mbusport;
    322  1.95.6.1     skrll 	/*bus_space_handle_t*/ long ci_mxccregs;
    323  1.95.6.1     skrll 
    324  1.95.6.1     skrll 	u_int	ci_tt;			/* Last trap (if tracing) */
    325  1.95.6.1     skrll 
    326  1.95.6.1     skrll 	/*
    327  1.95.6.1     skrll 	 * Start/End VA's of this cpu_info region; we upload the other pages
    328  1.95.6.1     skrll 	 * in this region that aren't part of the cpu_info to uvm.
    329  1.95.6.1     skrll 	 */
    330  1.95.6.1     skrll 	vaddr_t	ci_free_sva1, ci_free_eva1, ci_free_sva2, ci_free_eva2;
    331  1.95.6.1     skrll 
    332  1.95.6.1     skrll 	struct evcnt ci_savefpstate;
    333  1.95.6.1     skrll 	struct evcnt ci_savefpstate_null;
    334  1.95.6.1     skrll 	struct evcnt ci_xpmsg_mutex_fail;
    335  1.95.6.1     skrll 	struct evcnt ci_xpmsg_mutex_fail_call;
    336  1.95.6.1     skrll 	struct evcnt ci_intrcnt[16];
    337  1.95.6.1     skrll 	struct evcnt ci_sintrcnt[16];
    338  1.95.6.1     skrll };
    339       1.1   deraadt 
    340       1.1   deraadt /*
    341       1.1   deraadt  * definitions of cpu-dependent requirements
    342       1.1   deraadt  * referenced in generic code
    343       1.1   deraadt  */
    344  1.95.6.1     skrll #define	cpuinfo			(*(struct cpu_info *)CPUINFO_VA)
    345      1.39   thorpej #define	curcpu()		(cpuinfo.ci_self)
    346      1.62   thorpej #define	curlwp			(cpuinfo.ci_curlwp)
    347      1.40   thorpej #define	CPU_IS_PRIMARY(ci)	((ci)->master)
    348      1.37   thorpej 
    349      1.62   thorpej #define	cpu_number()		(cpuinfo.ci_cpuid)
    350  1.95.6.1     skrll 
    351  1.95.6.1     skrll #endif /* _KERNEL || _KMEMUSER */
    352  1.95.6.1     skrll 
    353  1.95.6.1     skrll /* Kernel only things. */
    354  1.95.6.1     skrll #if defined(_KERNEL)
    355      1.76       uwe void	cpu_proc_fork(struct proc *, struct proc *);
    356      1.35   thorpej 
    357      1.35   thorpej #if defined(MULTIPROCESSOR)
    358      1.74       uwe void	cpu_boot_secondary_processors(void);
    359      1.35   thorpej #endif
    360       1.1   deraadt 
    361       1.1   deraadt /*
    362      1.60        pk  * Arguments to hardclock, softclock and statclock encapsulate the
    363       1.1   deraadt  * previous machine state in an opaque clockframe.  The ipl is here
    364       1.1   deraadt  * as well for strayintr (see locore.s:interrupt and intr.c:strayintr).
    365       1.1   deraadt  * Note that CLKF_INTR is valid only if CLKF_USERMODE is false.
    366       1.1   deraadt  */
    367       1.1   deraadt struct clockframe {
    368       1.1   deraadt 	u_int	psr;		/* psr before interrupt, excluding PSR_ET */
    369       1.1   deraadt 	u_int	pc;		/* pc at interrupt */
    370       1.1   deraadt 	u_int	npc;		/* npc at interrupt */
    371       1.1   deraadt 	u_int	ipl;		/* actual interrupt priority level */
    372       1.1   deraadt 	u_int	fp;		/* %fp at interrupt */
    373       1.1   deraadt };
    374       1.3   deraadt typedef struct clockframe clockframe;
    375       1.1   deraadt 
    376       1.1   deraadt extern int eintstack[];
    377       1.1   deraadt 
    378       1.1   deraadt #define	CLKF_USERMODE(framep)	(((framep)->psr & PSR_PS) == 0)
    379      1.60        pk #define	CLKF_LOPRI(framep,n)	(((framep)->psr & PSR_PIL) < (n) << 8)
    380       1.1   deraadt #define	CLKF_PC(framep)		((framep)->pc)
    381      1.30        pk #if defined(MULTIPROCESSOR)
    382      1.30        pk #define	CLKF_INTR(framep)						\
    383      1.30        pk 	((framep)->fp > (u_int)cpuinfo.eintstack - INT_STACK_SIZE &&	\
    384      1.30        pk 	 (framep)->fp < (u_int)cpuinfo.eintstack)
    385      1.30        pk #else
    386       1.1   deraadt #define	CLKF_INTR(framep)	((framep)->fp < (u_int)eintstack)
    387      1.30        pk #endif
    388      1.21        pk 
    389      1.83        ad void	sparc_softintr_init(void);
    390       1.1   deraadt 
    391       1.1   deraadt /*
    392      1.57        pk  * Preempt the current process on the target CPU if in interrupt from
    393      1.57        pk  * user mode, or after the current trap/syscall if in system mode.
    394       1.1   deraadt  */
    395      1.81      yamt #define cpu_need_resched(ci, flags) do {				\
    396      1.95  christos 	__USE(flags);							\
    397      1.81      yamt 	(ci)->ci_want_resched = 1;					\
    398      1.81      yamt 	(ci)->ci_want_ast = 1;						\
    399      1.57        pk 									\
    400      1.57        pk 	/* Just interrupt the target CPU, so it can notice its AST */	\
    401      1.81      yamt 	if (((flags) & RESCHED_IMMED) || (ci)->ci_cpuid != cpu_number()) \
    402      1.57        pk 		XCALL0(sparc_noop, 1U << (ci)->ci_cpuid);		\
    403      1.74       uwe } while (/*CONSTCOND*/0)
    404       1.1   deraadt 
    405       1.1   deraadt /*
    406       1.1   deraadt  * Give a profiling tick to the current process when the user profiling
    407      1.21        pk  * buffer pages are invalid.  On the sparc, request an ast to send us
    408       1.1   deraadt  * through trap(), marking the proc as needing a profiling tick.
    409       1.1   deraadt  */
    410      1.81      yamt #define	cpu_need_proftick(l)	((l)->l_pflag |= LP_OWEUPC, cpuinfo.ci_want_ast = 1)
    411       1.1   deraadt 
    412       1.1   deraadt /*
    413       1.1   deraadt  * Notify the current process (p) that it has a signal pending,
    414       1.1   deraadt  * process as soon as possible.
    415       1.1   deraadt  */
    416      1.78        ad #define cpu_signotify(l) do {						\
    417      1.85       mrg 	(l)->l_cpu->ci_want_ast = 1;					\
    418      1.78        ad 									\
    419      1.78        ad 	/* Just interrupt the target CPU, so it can notice its AST */	\
    420      1.85       mrg 	if ((l)->l_cpu->ci_cpuid != cpu_number())			\
    421      1.85       mrg 		XCALL0(sparc_noop, 1U << (l)->l_cpu->ci_cpuid);		\
    422      1.78        ad } while (/*CONSTCOND*/0)
    423      1.51        pk 
    424      1.51        pk /* CPU architecture version */
    425      1.51        pk extern int cpu_arch;
    426       1.1   deraadt 
    427      1.28        pk /* Number of CPUs in the system */
    428      1.72    briggs extern int sparc_ncpus;
    429       1.1   deraadt 
    430      1.91    martin /* Provide %pc of a lwp */
    431      1.91    martin #define LWP_PC(l)       ((l)->l_md.md_tf->tf_pc)
    432      1.91    martin 
    433       1.1   deraadt /*
    434       1.1   deraadt  * Interrupt handler chains.  Interrupt handlers should return 0 for
    435       1.1   deraadt  * ``not me'' or 1 (``I took care of it'').  intr_establish() inserts a
    436       1.1   deraadt  * handler into the list.  The handler is called with its (single)
    437       1.1   deraadt  * argument, or with a pointer to a clockframe if ih_arg is NULL.
    438      1.88       mrg  *
    439      1.88       mrg  * realfun/realarg are used to chain callers, usually with the
    440      1.88       mrg  * biglock wrapper.
    441       1.1   deraadt  */
    442      1.25        tv extern struct intrhand {
    443      1.54        pk 	int	(*ih_fun)(void *);
    444       1.1   deraadt 	void	*ih_arg;
    445       1.1   deraadt 	struct	intrhand *ih_next;
    446      1.52        pk 	int	ih_classipl;
    447      1.88       mrg 	int	(*ih_realfun)(void *);
    448      1.88       mrg 	void	*ih_realarg;
    449       1.1   deraadt } *intrhand[15];
    450       1.1   deraadt 
    451      1.89       mrg void	intr_establish(int, int, struct intrhand *, void (*)(void), bool);
    452      1.74       uwe void	intr_disestablish(int, struct intrhand *);
    453       1.1   deraadt 
    454      1.54        pk void	intr_lock_kernel(void);
    455      1.54        pk void	intr_unlock_kernel(void);
    456      1.19  christos 
    457      1.19  christos /* disksubr.c */
    458      1.19  christos struct dkbad;
    459      1.74       uwe int isbad(struct dkbad *, int, int, int);
    460      1.74       uwe 
    461      1.19  christos /* machdep.c */
    462      1.80  christos int	ldcontrolb(void *);
    463      1.54        pk void	dumpconf(void);
    464      1.80  christos void *	reserve_dumppages(void *);
    465      1.74       uwe void	wcopy(const void *, void *, u_int);
    466      1.74       uwe void	wzero(void *, u_int);
    467      1.74       uwe 
    468      1.19  christos /* clock.c */
    469      1.19  christos struct timeval;
    470      1.54        pk void	lo_microtime(struct timeval *);
    471      1.56        pk void	schedintr(void *);
    472      1.74       uwe 
    473      1.19  christos /* locore.s */
    474      1.19  christos struct fpstate;
    475      1.90       mrg void	ipi_savefpstate(struct fpstate *);
    476      1.54        pk void	savefpstate(struct fpstate *);
    477      1.54        pk void	loadfpstate(struct fpstate *);
    478      1.80  christos int	probeget(void *, int);
    479      1.54        pk void	write_all_windows(void);
    480      1.54        pk void	write_user_windows(void);
    481      1.81      yamt void 	lwp_trampoline(void);
    482      1.19  christos struct pcb;
    483      1.54        pk void	snapshot(struct pcb *);
    484      1.54        pk struct frame *getfp(void);
    485      1.80  christos int	xldcontrolb(void *, struct pcb *);
    486      1.54        pk void	copywords(const void *, void *, size_t);
    487      1.54        pk void	qcopy(const void *, void *, size_t);
    488      1.54        pk void	qzero(void *, size_t);
    489      1.74       uwe 
    490      1.19  christos /* trap.c */
    491      1.92    martin void	cpu_vmspace_exec(struct lwp *, vaddr_t, vaddr_t);
    492      1.62   thorpej int	rwindow_save(struct lwp *);
    493      1.74       uwe 
    494      1.19  christos /* cons.c */
    495      1.54        pk int	cnrom(void);
    496      1.74       uwe 
    497      1.19  christos /* zs.c */
    498      1.54        pk void zsconsole(struct tty *, int, int, void (**)(struct tty *, int));
    499      1.19  christos #ifdef KGDB
    500      1.54        pk void zs_kgdb_init(void);
    501      1.19  christos #endif
    502      1.74       uwe 
    503      1.19  christos /* fb.c */
    504      1.54        pk void	fb_unblank(void);
    505      1.74       uwe 
    506      1.19  christos /* kgdb_stub.c */
    507      1.19  christos #ifdef KGDB
    508      1.54        pk void kgdb_attach(int (*)(void *), void (*)(void *, int), void *);
    509      1.54        pk void kgdb_connect(int);
    510      1.54        pk void kgdb_panic(void);
    511      1.19  christos #endif
    512      1.74       uwe 
    513      1.24        pk /* emul.c */
    514      1.24        pk struct trapframe;
    515      1.94    martin int fixalign(struct lwp *, struct trapframe *, void **);
    516      1.54        pk int emulinstr(int, struct trapframe *);
    517      1.74       uwe 
    518      1.28        pk /* cpu.c */
    519      1.54        pk void mp_pause_cpus(void);
    520      1.54        pk void mp_resume_cpus(void);
    521      1.54        pk void mp_halt_cpus(void);
    522      1.61        pk #ifdef DDB
    523      1.61        pk void mp_pause_cpus_ddb(void);
    524      1.61        pk void mp_resume_cpus_ddb(void);
    525      1.61        pk #endif
    526      1.74       uwe 
    527      1.63        pk /* intr.c */
    528      1.63        pk u_int setitr(u_int);
    529      1.63        pk u_int getitr(void);
    530       1.4   deraadt 
    531      1.74       uwe 
    532       1.4   deraadt /*
    533       1.4   deraadt  *
    534       1.4   deraadt  * The SPARC has a Trap Base Register (TBR) which holds the upper 20 bits
    535       1.4   deraadt  * of the trap vector table.  The next eight bits are supplied by the
    536       1.4   deraadt  * hardware when the trap occurs, and the bottom four bits are always
    537       1.4   deraadt  * zero (so that we can shove up to 16 bytes of executable code---exactly
    538       1.4   deraadt  * four instructions---into each trap vector).
    539       1.4   deraadt  *
    540       1.4   deraadt  * The hardware allocates half the trap vectors to hardware and half to
    541       1.4   deraadt  * software.
    542       1.4   deraadt  *
    543       1.4   deraadt  * Traps have priorities assigned (lower number => higher priority).
    544       1.4   deraadt  */
    545       1.4   deraadt 
    546       1.4   deraadt struct trapvec {
    547       1.4   deraadt 	int	tv_instr[4];		/* the four instructions */
    548       1.4   deraadt };
    549      1.74       uwe 
    550      1.21        pk extern struct trapvec *trapbase;	/* the 256 vectors */
    551      1.11   deraadt 
    552      1.12       jtc #endif /* _KERNEL */
    553       1.1   deraadt #endif /* _CPU_H_ */
    554