Home | History | Annotate | Line # | Download | only in include
cpu.h revision 1.45.4.5
      1  1.45.4.5  nathanw /*	$NetBSD: cpu.h,v 1.45.4.5 2002/02/28 04:12:03 nathanw Exp $ */
      2  1.45.4.2       pk 
      3  1.45.4.2       pk /*
      4  1.45.4.2       pk  * Copyright (c) 1992, 1993
      5  1.45.4.2       pk  *	The Regents of the University of California.  All rights reserved.
      6  1.45.4.2       pk  *
      7  1.45.4.2       pk  * This software was developed by the Computer Systems Engineering group
      8  1.45.4.2       pk  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
      9  1.45.4.2       pk  * contributed to Berkeley.
     10  1.45.4.2       pk  *
     11  1.45.4.2       pk  * All advertising materials mentioning features or use of this software
     12  1.45.4.2       pk  * must display the following acknowledgement:
     13  1.45.4.2       pk  *	This product includes software developed by the University of
     14  1.45.4.2       pk  *	California, Lawrence Berkeley Laboratory.
     15  1.45.4.2       pk  *
     16  1.45.4.2       pk  * Redistribution and use in source and binary forms, with or without
     17  1.45.4.2       pk  * modification, are permitted provided that the following conditions
     18  1.45.4.2       pk  * are met:
     19  1.45.4.2       pk  * 1. Redistributions of source code must retain the above copyright
     20  1.45.4.2       pk  *    notice, this list of conditions and the following disclaimer.
     21  1.45.4.2       pk  * 2. Redistributions in binary form must reproduce the above copyright
     22  1.45.4.2       pk  *    notice, this list of conditions and the following disclaimer in the
     23  1.45.4.2       pk  *    documentation and/or other materials provided with the distribution.
     24  1.45.4.2       pk  * 3. All advertising materials mentioning features or use of this software
     25  1.45.4.2       pk  *    must display the following acknowledgement:
     26  1.45.4.2       pk  *	This product includes software developed by the University of
     27  1.45.4.2       pk  *	California, Berkeley and its contributors.
     28  1.45.4.2       pk  * 4. Neither the name of the University nor the names of its contributors
     29  1.45.4.2       pk  *    may be used to endorse or promote products derived from this software
     30  1.45.4.2       pk  *    without specific prior written permission.
     31  1.45.4.2       pk  *
     32  1.45.4.2       pk  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     33  1.45.4.2       pk  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     34  1.45.4.2       pk  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     35  1.45.4.2       pk  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     36  1.45.4.2       pk  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     37  1.45.4.2       pk  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     38  1.45.4.2       pk  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     39  1.45.4.2       pk  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     40  1.45.4.2       pk  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     41  1.45.4.2       pk  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     42  1.45.4.2       pk  * SUCH DAMAGE.
     43  1.45.4.2       pk  *
     44  1.45.4.2       pk  *	@(#)cpu.h	8.4 (Berkeley) 1/5/94
     45  1.45.4.2       pk  */
     46  1.45.4.2       pk 
     47  1.45.4.2       pk #ifndef _CPU_H_
     48  1.45.4.2       pk #define _CPU_H_
     49  1.45.4.2       pk 
     50  1.45.4.2       pk /*
     51  1.45.4.2       pk  * CTL_MACHDEP definitions.
     52  1.45.4.2       pk  */
     53  1.45.4.2       pk #define	CPU_BOOTED_KERNEL	1	/* string: booted kernel name */
     54  1.45.4.5  nathanw #define	CPU_BOOTED_DEVICE	2	/* string: device booted from */
     55  1.45.4.5  nathanw #define	CPU_BOOT_ARGS		3	/* string: args booted with */
     56  1.45.4.5  nathanw #define	CPU_MAXID		4	/* number of valid machdep ids */
     57  1.45.4.2       pk 
     58  1.45.4.2       pk #define	CTL_MACHDEP_NAMES {			\
     59  1.45.4.2       pk 	{ 0, 0 },				\
     60  1.45.4.2       pk 	{ "booted_kernel", CTLTYPE_STRING },	\
     61  1.45.4.5  nathanw 	{ "booted_device", CTLTYPE_STRING },	\
     62  1.45.4.5  nathanw 	{ "boot_args", CTLTYPE_STRING },	\
     63  1.45.4.2       pk }
     64  1.45.4.2       pk 
     65  1.45.4.2       pk #ifdef _KERNEL
     66  1.45.4.2       pk /*
     67  1.45.4.2       pk  * Exported definitions unique to SPARC cpu support.
     68  1.45.4.2       pk  */
     69  1.45.4.2       pk 
     70  1.45.4.4  nathanw #if !defined(_LKM) && defined(_KERNEL_OPT)
     71  1.45.4.2       pk #include "opt_multiprocessor.h"
     72  1.45.4.2       pk #include "opt_lockdebug.h"
     73  1.45.4.4  nathanw #include "opt_sparc_arch.h"
     74  1.45.4.2       pk #endif
     75  1.45.4.2       pk 
     76  1.45.4.2       pk #include <machine/psl.h>
     77  1.45.4.2       pk #include <machine/intr.h>
     78  1.45.4.2       pk #include <sparc/sparc/cpuvar.h>
     79  1.45.4.2       pk #include <sparc/sparc/intreg.h>
     80  1.45.4.2       pk 
     81  1.45.4.2       pk /*
     82  1.45.4.2       pk  * definitions of cpu-dependent requirements
     83  1.45.4.2       pk  * referenced in generic code
     84  1.45.4.2       pk  */
     85  1.45.4.2       pk #define	curcpu()		(cpuinfo.ci_self)
     86  1.45.4.2       pk #define	curproc			(curcpu()->ci_curproc)
     87  1.45.4.2       pk #define	CPU_IS_PRIMARY(ci)	((ci)->master)
     88  1.45.4.2       pk 
     89  1.45.4.3  thorpej #define	cpu_swapin(p)		/* nothing */
     90  1.45.4.3  thorpej #define	cpu_swapout(p)		/* nothing */
     91  1.45.4.3  thorpej #define	cpu_wait(p)		/* nothing */
     92  1.45.4.3  thorpej #define	cpu_number()		(cpuinfo.ci_cpuid)
     93  1.45.4.3  thorpej #define	cpu_proc_fork(p1, p2)	/* nothing */
     94  1.45.4.2       pk 
     95  1.45.4.2       pk #if defined(MULTIPROCESSOR)
     96  1.45.4.2       pk void	cpu_boot_secondary_processors __P((void));
     97  1.45.4.2       pk #endif
     98  1.45.4.2       pk 
     99  1.45.4.2       pk /*
    100  1.45.4.2       pk  * Arguments to hardclock, softclock and gatherstats encapsulate the
    101  1.45.4.2       pk  * previous machine state in an opaque clockframe.  The ipl is here
    102  1.45.4.2       pk  * as well for strayintr (see locore.s:interrupt and intr.c:strayintr).
    103  1.45.4.2       pk  * Note that CLKF_INTR is valid only if CLKF_USERMODE is false.
    104  1.45.4.2       pk  */
    105  1.45.4.2       pk struct clockframe {
    106  1.45.4.2       pk 	u_int	psr;		/* psr before interrupt, excluding PSR_ET */
    107  1.45.4.2       pk 	u_int	pc;		/* pc at interrupt */
    108  1.45.4.2       pk 	u_int	npc;		/* npc at interrupt */
    109  1.45.4.2       pk 	u_int	ipl;		/* actual interrupt priority level */
    110  1.45.4.2       pk 	u_int	fp;		/* %fp at interrupt */
    111  1.45.4.2       pk };
    112  1.45.4.2       pk typedef struct clockframe clockframe;
    113  1.45.4.2       pk 
    114  1.45.4.2       pk extern int eintstack[];
    115  1.45.4.2       pk 
    116  1.45.4.2       pk #define	CLKF_USERMODE(framep)	(((framep)->psr & PSR_PS) == 0)
    117  1.45.4.2       pk #define	CLKF_BASEPRI(framep)	(((framep)->psr & PSR_PIL) == 0)
    118  1.45.4.2       pk #define	CLKF_PC(framep)		((framep)->pc)
    119  1.45.4.2       pk #if defined(MULTIPROCESSOR)
    120  1.45.4.2       pk #define	CLKF_INTR(framep)						\
    121  1.45.4.2       pk 	((framep)->fp > (u_int)cpuinfo.eintstack - INT_STACK_SIZE &&	\
    122  1.45.4.2       pk 	 (framep)->fp < (u_int)cpuinfo.eintstack)
    123  1.45.4.2       pk #else
    124  1.45.4.2       pk #define	CLKF_INTR(framep)	((framep)->fp < (u_int)eintstack)
    125  1.45.4.2       pk #endif
    126  1.45.4.2       pk 
    127  1.45.4.2       pk #if defined(SUN4M)
    128  1.45.4.2       pk extern void	raise __P((int, int));
    129  1.45.4.2       pk #if !(defined(SUN4) || defined(SUN4C))
    130  1.45.4.2       pk #define setsoftint()	raise(0,1)
    131  1.45.4.2       pk #else /* both defined */
    132  1.45.4.2       pk #define setsoftint()	(cputyp == CPU_SUN4M ? raise(0,1) : ienab_bis(IE_L1))
    133  1.45.4.2       pk #endif /* !4,!4c */
    134  1.45.4.2       pk #else	/* 4m not defined */
    135  1.45.4.2       pk #define setsoftint()	ienab_bis(IE_L1)
    136  1.45.4.2       pk #endif /* SUN4M */
    137  1.45.4.2       pk 
    138  1.45.4.2       pk void	softintr_init __P((void));
    139  1.45.4.2       pk void	*softnet_cookie;
    140  1.45.4.2       pk 
    141  1.45.4.2       pk #define setsoftnet()	softintr_schedule(softnet_cookie);
    142  1.45.4.2       pk 
    143  1.45.4.2       pk extern int	want_ast;
    144  1.45.4.2       pk 
    145  1.45.4.2       pk /*
    146  1.45.4.2       pk  * Preempt the current process if in interrupt from user mode,
    147  1.45.4.2       pk  * or after the current trap/syscall if in system mode.
    148  1.45.4.2       pk  */
    149  1.45.4.2       pk extern int	want_resched;		/* resched() was called */
    150  1.45.4.2       pk #define	need_resched(ci)		(want_resched = 1, want_ast = 1)
    151  1.45.4.2       pk 
    152  1.45.4.2       pk /*
    153  1.45.4.2       pk  * Give a profiling tick to the current process when the user profiling
    154  1.45.4.2       pk  * buffer pages are invalid.  On the sparc, request an ast to send us
    155  1.45.4.2       pk  * through trap(), marking the proc as needing a profiling tick.
    156  1.45.4.2       pk  */
    157  1.45.4.2       pk #define	need_proftick(p)	((p)->p_flag |= P_OWEUPC, want_ast = 1)
    158  1.45.4.2       pk 
    159  1.45.4.2       pk /*
    160  1.45.4.2       pk  * Notify the current process (p) that it has a signal pending,
    161  1.45.4.2       pk  * process as soon as possible.
    162  1.45.4.2       pk  */
    163  1.45.4.2       pk #define	signotify(p)		(want_ast = 1)
    164  1.45.4.2       pk 
    165  1.45.4.2       pk /* Number of CPUs in the system */
    166  1.45.4.2       pk extern int ncpu;
    167  1.45.4.2       pk 
    168  1.45.4.2       pk /*
    169  1.45.4.2       pk  * Only one process may own the FPU state.
    170  1.45.4.2       pk  *
    171  1.45.4.2       pk  * XXX this must be per-cpu (eventually)
    172  1.45.4.2       pk  */
    173  1.45.4.2       pk extern struct lwp *fpproc;	/* FPU owner */
    174  1.45.4.2       pk extern int foundfpu;		/* true => we have an FPU */
    175  1.45.4.2       pk 
    176  1.45.4.2       pk /*
    177  1.45.4.2       pk  * Interrupt handler chains.  Interrupt handlers should return 0 for
    178  1.45.4.2       pk  * ``not me'' or 1 (``I took care of it'').  intr_establish() inserts a
    179  1.45.4.2       pk  * handler into the list.  The handler is called with its (single)
    180  1.45.4.2       pk  * argument, or with a pointer to a clockframe if ih_arg is NULL.
    181  1.45.4.2       pk  */
    182  1.45.4.2       pk extern struct intrhand {
    183  1.45.4.2       pk 	int	(*ih_fun) __P((void *));
    184  1.45.4.2       pk 	void	*ih_arg;
    185  1.45.4.2       pk 	struct	intrhand *ih_next;
    186  1.45.4.2       pk } *intrhand[15];
    187  1.45.4.2       pk 
    188  1.45.4.2       pk void	intr_establish __P((int level, struct intrhand *));
    189  1.45.4.2       pk void	intr_disestablish __P((int level, struct intrhand *));
    190  1.45.4.2       pk 
    191  1.45.4.2       pk /*
    192  1.45.4.2       pk  * intr_fasttrap() is a lot like intr_establish, but is used for ``fast''
    193  1.45.4.2       pk  * interrupt vectors (vectors that are not shared and are handled in the
    194  1.45.4.2       pk  * trap window).  Such functions must be written in assembly.
    195  1.45.4.2       pk  */
    196  1.45.4.2       pk void	intr_fasttrap __P((int level, void (*vec)(void)));
    197  1.45.4.2       pk 
    198  1.45.4.2       pk void	intr_lock_kernel __P((void));
    199  1.45.4.2       pk void	intr_unlock_kernel __P((void));
    200  1.45.4.2       pk 
    201  1.45.4.2       pk /* disksubr.c */
    202  1.45.4.2       pk struct dkbad;
    203  1.45.4.2       pk int isbad __P((struct dkbad *bt, int, int, int));
    204  1.45.4.2       pk /* machdep.c */
    205  1.45.4.2       pk int	ldcontrolb __P((caddr_t));
    206  1.45.4.2       pk void	dumpconf __P((void));
    207  1.45.4.2       pk caddr_t	reserve_dumppages __P((caddr_t));
    208  1.45.4.2       pk /* clock.c */
    209  1.45.4.2       pk struct timeval;
    210  1.45.4.2       pk void	lo_microtime __P((struct timeval *));
    211  1.45.4.2       pk int	clockintr __P((void *));/* level 10 (clock) interrupt code */
    212  1.45.4.2       pk int	statintr __P((void *));	/* level 14 (statclock) interrupt code */
    213  1.45.4.2       pk /* locore.s */
    214  1.45.4.2       pk struct fpstate;
    215  1.45.4.2       pk void	savefpstate __P((struct fpstate *));
    216  1.45.4.2       pk void	loadfpstate __P((struct fpstate *));
    217  1.45.4.2       pk int	probeget __P((caddr_t, int));
    218  1.45.4.2       pk void	write_all_windows __P((void));
    219  1.45.4.2       pk void	write_user_windows __P((void));
    220  1.45.4.2       pk void 	proc_trampoline __P((void));
    221  1.45.4.2       pk void	switchexit __P((struct lwp *));
    222  1.45.4.2       pk void	switchlwpexit __P((struct lwp *));
    223  1.45.4.2       pk struct pcb;
    224  1.45.4.2       pk void	snapshot __P((struct pcb *));
    225  1.45.4.2       pk struct frame *getfp __P((void));
    226  1.45.4.2       pk int	xldcontrolb __P((caddr_t, struct pcb *));
    227  1.45.4.2       pk void	copywords __P((const void *, void *, size_t));
    228  1.45.4.2       pk void	qcopy __P((const void *, void *, size_t));
    229  1.45.4.2       pk void	qzero __P((void *, size_t));
    230  1.45.4.2       pk /* trap.c */
    231  1.45.4.2       pk void	kill_user_windows __P((struct lwp *));
    232  1.45.4.2       pk int	rwindow_save __P((struct lwp *));
    233  1.45.4.2       pk /* amd7930intr.s */
    234  1.45.4.2       pk void	amd7930_trap __P((void));
    235  1.45.4.2       pk /* cons.c */
    236  1.45.4.2       pk int	cnrom __P((void));
    237  1.45.4.2       pk /* zs.c */
    238  1.45.4.2       pk void zsconsole __P((struct tty *, int, int, void (**)(struct tty *, int)));
    239  1.45.4.2       pk #ifdef KGDB
    240  1.45.4.2       pk void zs_kgdb_init __P((void));
    241  1.45.4.2       pk #endif
    242  1.45.4.2       pk /* fb.c */
    243  1.45.4.2       pk void	fb_unblank __P((void));
    244  1.45.4.2       pk /* cache.c */
    245  1.45.4.2       pk void cache_flush __P((caddr_t, u_int));
    246  1.45.4.2       pk /* kgdb_stub.c */
    247  1.45.4.2       pk #ifdef KGDB
    248  1.45.4.2       pk void kgdb_attach __P((int (*)(void *), void (*)(void *, int), void *));
    249  1.45.4.2       pk void kgdb_connect __P((int));
    250  1.45.4.2       pk void kgdb_panic __P((void));
    251  1.45.4.2       pk #endif
    252  1.45.4.2       pk /* emul.c */
    253  1.45.4.2       pk struct trapframe;
    254  1.45.4.2       pk int fixalign __P((struct lwp *, struct trapframe *));
    255  1.45.4.2       pk int emulinstr __P((int, struct trapframe *));
    256  1.45.4.2       pk /* cpu.c */
    257  1.45.4.2       pk void mp_pause_cpus __P((void));
    258  1.45.4.2       pk void mp_resume_cpus __P((void));
    259  1.45.4.2       pk void mp_halt_cpus __P((void));
    260  1.45.4.4  nathanw /* msiiep.c */
    261  1.45.4.4  nathanw void msiiep_swap_endian __P((int));
    262  1.45.4.2       pk 
    263  1.45.4.2       pk /*
    264  1.45.4.2       pk  *
    265  1.45.4.2       pk  * The SPARC has a Trap Base Register (TBR) which holds the upper 20 bits
    266  1.45.4.2       pk  * of the trap vector table.  The next eight bits are supplied by the
    267  1.45.4.2       pk  * hardware when the trap occurs, and the bottom four bits are always
    268  1.45.4.2       pk  * zero (so that we can shove up to 16 bytes of executable code---exactly
    269  1.45.4.2       pk  * four instructions---into each trap vector).
    270  1.45.4.2       pk  *
    271  1.45.4.2       pk  * The hardware allocates half the trap vectors to hardware and half to
    272  1.45.4.2       pk  * software.
    273  1.45.4.2       pk  *
    274  1.45.4.2       pk  * Traps have priorities assigned (lower number => higher priority).
    275  1.45.4.2       pk  */
    276  1.45.4.2       pk 
    277  1.45.4.2       pk struct trapvec {
    278  1.45.4.2       pk 	int	tv_instr[4];		/* the four instructions */
    279  1.45.4.2       pk };
    280  1.45.4.2       pk extern struct trapvec *trapbase;	/* the 256 vectors */
    281  1.45.4.2       pk 
    282  1.45.4.2       pk extern void wzero __P((void *, u_int));
    283  1.45.4.2       pk extern void wcopy __P((const void *, void *, u_int));
    284  1.45.4.2       pk 
    285  1.45.4.2       pk #endif /* _KERNEL */
    286  1.45.4.2       pk #endif /* _CPU_H_ */
    287