Home | History | Annotate | Line # | Download | only in include
cpu.h revision 1.29.6.2
      1  1.29.6.2  petrov /*	$NetBSD: cpu.h,v 1.29.6.2 2002/01/03 06:42:33 petrov Exp $ */
      2  1.29.6.2  petrov 
      3  1.29.6.2  petrov /*
      4  1.29.6.2  petrov  * Copyright (c) 1992, 1993
      5  1.29.6.2  petrov  *	The Regents of the University of California.  All rights reserved.
      6  1.29.6.2  petrov  *
      7  1.29.6.2  petrov  * This software was developed by the Computer Systems Engineering group
      8  1.29.6.2  petrov  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
      9  1.29.6.2  petrov  * contributed to Berkeley.
     10  1.29.6.2  petrov  *
     11  1.29.6.2  petrov  * All advertising materials mentioning features or use of this software
     12  1.29.6.2  petrov  * must display the following acknowledgement:
     13  1.29.6.2  petrov  *	This product includes software developed by the University of
     14  1.29.6.2  petrov  *	California, Lawrence Berkeley Laboratory.
     15  1.29.6.2  petrov  *
     16  1.29.6.2  petrov  * Redistribution and use in source and binary forms, with or without
     17  1.29.6.2  petrov  * modification, are permitted provided that the following conditions
     18  1.29.6.2  petrov  * are met:
     19  1.29.6.2  petrov  * 1. Redistributions of source code must retain the above copyright
     20  1.29.6.2  petrov  *    notice, this list of conditions and the following disclaimer.
     21  1.29.6.2  petrov  * 2. Redistributions in binary form must reproduce the above copyright
     22  1.29.6.2  petrov  *    notice, this list of conditions and the following disclaimer in the
     23  1.29.6.2  petrov  *    documentation and/or other materials provided with the distribution.
     24  1.29.6.2  petrov  * 3. All advertising materials mentioning features or use of this software
     25  1.29.6.2  petrov  *    must display the following acknowledgement:
     26  1.29.6.2  petrov  *	This product includes software developed by the University of
     27  1.29.6.2  petrov  *	California, Berkeley and its contributors.
     28  1.29.6.2  petrov  * 4. Neither the name of the University nor the names of its contributors
     29  1.29.6.2  petrov  *    may be used to endorse or promote products derived from this software
     30  1.29.6.2  petrov  *    without specific prior written permission.
     31  1.29.6.2  petrov  *
     32  1.29.6.2  petrov  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     33  1.29.6.2  petrov  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     34  1.29.6.2  petrov  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     35  1.29.6.2  petrov  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     36  1.29.6.2  petrov  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     37  1.29.6.2  petrov  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     38  1.29.6.2  petrov  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     39  1.29.6.2  petrov  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     40  1.29.6.2  petrov  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     41  1.29.6.2  petrov  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     42  1.29.6.2  petrov  * SUCH DAMAGE.
     43  1.29.6.2  petrov  *
     44  1.29.6.2  petrov  *	@(#)cpu.h	8.4 (Berkeley) 1/5/94
     45  1.29.6.2  petrov  */
     46  1.29.6.2  petrov 
     47  1.29.6.2  petrov #ifndef _CPU_H_
     48  1.29.6.2  petrov #define _CPU_H_
     49  1.29.6.2  petrov 
     50  1.29.6.2  petrov /*
     51  1.29.6.2  petrov  * CTL_MACHDEP definitions.
     52  1.29.6.2  petrov  */
     53  1.29.6.2  petrov #define	CPU_BOOTED_KERNEL	1	/* string: booted kernel name */
     54  1.29.6.2  petrov #define	CPU_MAXID		2	/* number of valid machdep ids */
     55  1.29.6.2  petrov 
     56  1.29.6.2  petrov #define	CTL_MACHDEP_NAMES {			\
     57  1.29.6.2  petrov 	{ 0, 0 },				\
     58  1.29.6.2  petrov 	{ "booted_kernel", CTLTYPE_STRING },	\
     59  1.29.6.2  petrov }
     60  1.29.6.2  petrov 
     61  1.29.6.2  petrov #ifdef _KERNEL
     62  1.29.6.2  petrov /*
     63  1.29.6.2  petrov  * Exported definitions unique to SPARC cpu support.
     64  1.29.6.2  petrov  */
     65  1.29.6.2  petrov 
     66  1.29.6.2  petrov #if !defined(_LKM)
     67  1.29.6.2  petrov #include "opt_multiprocessor.h"
     68  1.29.6.2  petrov #include "opt_lockdebug.h"
     69  1.29.6.2  petrov #endif
     70  1.29.6.2  petrov 
     71  1.29.6.2  petrov #include <machine/psl.h>
     72  1.29.6.2  petrov #include <machine/reg.h>
     73  1.29.6.2  petrov #include <machine/intr.h>
     74  1.29.6.2  petrov #include <sparc64/sparc64/intreg.h>
     75  1.29.6.2  petrov 
     76  1.29.6.2  petrov #include <sys/sched.h>
     77  1.29.6.2  petrov /*
     78  1.29.6.2  petrov  * The cpu_info structure is part of a 64KB structure mapped both the kernel
     79  1.29.6.2  petrov  * pmap and a single locked TTE a CPUINFO_VA for that particular processor.
     80  1.29.6.2  petrov  * Each processor's cpu_info is accessible at CPUINFO_VA only for that
     81  1.29.6.2  petrov  * processor.  Other processors can access that through an additional mapping
     82  1.29.6.2  petrov  * in the kernel pmap.
     83  1.29.6.2  petrov  *
     84  1.29.6.2  petrov  * The 64KB page contains:
     85  1.29.6.2  petrov  *
     86  1.29.6.2  petrov  * cpu_info
     87  1.29.6.2  petrov  * interrupt stack (all remaining space)
     88  1.29.6.2  petrov  * idle PCB
     89  1.29.6.2  petrov  * idle stack (STACKSPACE - sizeof(PCB))
     90  1.29.6.2  petrov  * 32KB TSB
     91  1.29.6.2  petrov  */
     92  1.29.6.2  petrov 
     93  1.29.6.2  petrov struct cpu_info {
     94  1.29.6.2  petrov 	/* Most important fields first */
     95  1.29.6.2  petrov 	struct proc		*ci_curproc;
     96  1.29.6.2  petrov 	struct pcb		*ci_cpcb;	/* also initial stack */
     97  1.29.6.2  petrov 	struct cpu_info		*ci_next;
     98  1.29.6.2  petrov 
     99  1.29.6.2  petrov 	struct proc		*ci_fpproc;
    100  1.29.6.2  petrov 	int			ci_number;
    101  1.29.6.2  petrov 	int			ci_upaid;
    102  1.29.6.2  petrov 	struct schedstate_percpu ci_schedstate; /* scheduler state */
    103  1.29.6.2  petrov 
    104  1.29.6.2  petrov 	/* DEBUG/DIAGNOSTIC stuff */
    105  1.29.6.2  petrov 	u_long			ci_spin_locks;	/* # of spin locks held */
    106  1.29.6.2  petrov 	u_long			ci_simple_locks;/* # of simple locks held */
    107  1.29.6.2  petrov 
    108  1.29.6.2  petrov 	/* Spinning up the CPU */
    109  1.29.6.2  petrov 	void			(*ci_spinup) __P((void)); /* spinup routine */
    110  1.29.6.2  petrov 	void			*ci_initstack;
    111  1.29.6.2  petrov 	paddr_t			ci_paddr;	/* Phys addr of this structure. */
    112  1.29.6.2  petrov };
    113  1.29.6.2  petrov 
    114  1.29.6.2  petrov extern struct cpu_info *cpus;
    115  1.29.6.2  petrov extern struct cpu_info cpu_info_store;
    116  1.29.6.2  petrov 
    117  1.29.6.2  petrov #if 1
    118  1.29.6.2  petrov #define	curcpu()	(&cpu_info_store)
    119  1.29.6.2  petrov #else
    120  1.29.6.2  petrov #define	curcpu()	((struct cpu_info *)CPUINFO_VA)
    121  1.29.6.2  petrov #endif
    122  1.29.6.2  petrov 
    123  1.29.6.2  petrov /*
    124  1.29.6.2  petrov  * definitions of cpu-dependent requirements
    125  1.29.6.2  petrov  * referenced in generic code
    126  1.29.6.2  petrov  */
    127  1.29.6.2  petrov #define	cpu_swapin(p)	/* nothing */
    128  1.29.6.2  petrov #define	cpu_swapout(p)	/* nothing */
    129  1.29.6.2  petrov #define	cpu_wait(p)	/* nothing */
    130  1.29.6.2  petrov #if 1
    131  1.29.6.2  petrov #define cpu_number()	0
    132  1.29.6.2  petrov #else
    133  1.29.6.2  petrov #define	cpu_number()	(curcpu()->ci_number)
    134  1.29.6.2  petrov #endif
    135  1.29.6.2  petrov 
    136  1.29.6.2  petrov #define	cpu_proc_fork(p1, p2)	/* nothing */
    137  1.29.6.2  petrov 
    138  1.29.6.2  petrov /*
    139  1.29.6.2  petrov  * Arguments to hardclock, softclock and gatherstats encapsulate the
    140  1.29.6.2  petrov  * previous machine state in an opaque clockframe.  The ipl is here
    141  1.29.6.2  petrov  * as well for strayintr (see locore.s:interrupt and intr.c:strayintr).
    142  1.29.6.2  petrov  * Note that CLKF_INTR is valid only if CLKF_USERMODE is false.
    143  1.29.6.2  petrov  */
    144  1.29.6.2  petrov extern int intstack[];
    145  1.29.6.2  petrov extern int eintstack[];
    146  1.29.6.2  petrov struct clockframe {
    147  1.29.6.2  petrov 	struct trapframe64 t;
    148  1.29.6.2  petrov };
    149  1.29.6.2  petrov 
    150  1.29.6.2  petrov #define	CLKF_USERMODE(framep)	(((framep)->t.tf_tstate & TSTATE_PRIV) == 0)
    151  1.29.6.2  petrov #define	CLKF_BASEPRI(framep)	(((framep)->t.tf_oldpil) == 0)
    152  1.29.6.2  petrov #define	CLKF_PC(framep)		((framep)->t.tf_pc)
    153  1.29.6.2  petrov #define	CLKF_INTR(framep)	((!CLKF_USERMODE(framep))&&\
    154  1.29.6.2  petrov 				(((framep)->t.tf_kstack < (vaddr_t)EINTSTACK)&&\
    155  1.29.6.2  petrov 				((framep)->t.tf_kstack > (vaddr_t)INTSTACK)))
    156  1.29.6.2  petrov 
    157  1.29.6.2  petrov /*
    158  1.29.6.2  petrov  * Software interrupt request `register'.
    159  1.29.6.2  petrov  */
    160  1.29.6.2  petrov #ifdef DEPRECATED
    161  1.29.6.2  petrov union sir {
    162  1.29.6.2  petrov 	int	sir_any;
    163  1.29.6.2  petrov 	char	sir_which[4];
    164  1.29.6.2  petrov } sir;
    165  1.29.6.2  petrov 
    166  1.29.6.2  petrov #define SIR_NET		0
    167  1.29.6.2  petrov #define SIR_CLOCK	1
    168  1.29.6.2  petrov #endif
    169  1.29.6.2  petrov 
    170  1.29.6.2  petrov extern struct intrhand soft01intr, soft01net, soft01clock;
    171  1.29.6.2  petrov 
    172  1.29.6.2  petrov #if 0
    173  1.29.6.2  petrov #define setsoftint()	send_softint(-1, IPL_SOFTINT, &soft01intr)
    174  1.29.6.2  petrov #define setsoftnet()	send_softint(-1, IPL_SOFTNET, &soft01net)
    175  1.29.6.2  petrov #else
    176  1.29.6.2  petrov void setsoftint __P((void));
    177  1.29.6.2  petrov void setsoftnet __P((void));
    178  1.29.6.2  petrov #endif
    179  1.29.6.2  petrov 
    180  1.29.6.2  petrov int	want_ast;
    181  1.29.6.2  petrov 
    182  1.29.6.2  petrov /*
    183  1.29.6.2  petrov  * Preempt the current process if in interrupt from user mode,
    184  1.29.6.2  petrov  * or after the current trap/syscall if in system mode.
    185  1.29.6.2  petrov  */
    186  1.29.6.2  petrov int	want_resched;		/* resched() was called */
    187  1.29.6.2  petrov #define	need_resched(ci)	(want_resched = 1, want_ast = 1)
    188  1.29.6.2  petrov 
    189  1.29.6.2  petrov /*
    190  1.29.6.2  petrov  * Give a profiling tick to the current process when the user profiling
    191  1.29.6.2  petrov  * buffer pages are invalid.  On the sparc, request an ast to send us
    192  1.29.6.2  petrov  * through trap(), marking the proc as needing a profiling tick.
    193  1.29.6.2  petrov  */
    194  1.29.6.2  petrov #define	need_proftick(p)	((p)->p_flag |= P_OWEUPC, want_ast = 1)
    195  1.29.6.2  petrov 
    196  1.29.6.2  petrov /*
    197  1.29.6.2  petrov  * Notify the current process (p) that it has a signal pending,
    198  1.29.6.2  petrov  * process as soon as possible.
    199  1.29.6.2  petrov  */
    200  1.29.6.2  petrov #define	signotify(p)		(want_ast = 1)
    201  1.29.6.2  petrov 
    202  1.29.6.2  petrov /*
    203  1.29.6.2  petrov  * Only one process may own the FPU state.
    204  1.29.6.2  petrov  *
    205  1.29.6.2  petrov  * XXX this must be per-cpu (eventually)
    206  1.29.6.2  petrov  */
    207  1.29.6.2  petrov struct	lwp *fpproc;		/* FPU owner */
    208  1.29.6.2  petrov int	foundfpu;		/* true => we have an FPU */
    209  1.29.6.2  petrov 
    210  1.29.6.2  petrov /*
    211  1.29.6.2  petrov  * Interrupt handler chains.  Interrupt handlers should return 0 for
    212  1.29.6.2  petrov  * ``not me'' or 1 (``I took care of it'').  intr_establish() inserts a
    213  1.29.6.2  petrov  * handler into the list.  The handler is called with its (single)
    214  1.29.6.2  petrov  * argument, or with a pointer to a clockframe if ih_arg is NULL.
    215  1.29.6.2  petrov  */
    216  1.29.6.2  petrov struct intrhand {
    217  1.29.6.2  petrov 	int			(*ih_fun) __P((void *));
    218  1.29.6.2  petrov 	void			*ih_arg;
    219  1.29.6.2  petrov 	short			ih_number;	/* interrupt number */
    220  1.29.6.2  petrov 						/* the H/W provides */
    221  1.29.6.2  petrov 	char			ih_pil;		/* interrupt priority */
    222  1.29.6.2  petrov 	struct intrhand		*ih_next;	/* global list */
    223  1.29.6.2  petrov 	struct intrhand		*ih_pending;	/* interrupt queued */
    224  1.29.6.2  petrov 	volatile u_int64_t	*ih_map;	/* Interrupt map reg */
    225  1.29.6.2  petrov 	volatile u_int64_t	*ih_clr;	/* clear interrupt reg */
    226  1.29.6.2  petrov };
    227  1.29.6.2  petrov extern struct intrhand *intrhand[];
    228  1.29.6.2  petrov extern struct intrhand *intrlev[MAXINTNUM];
    229  1.29.6.2  petrov 
    230  1.29.6.2  petrov void	intr_establish __P((int level, struct intrhand *));
    231  1.29.6.2  petrov 
    232  1.29.6.2  petrov /* cpu.c */
    233  1.29.6.2  petrov paddr_t cpu_alloc __P((void));
    234  1.29.6.2  petrov u_int64_t cpu_init __P((paddr_t, int));
    235  1.29.6.2  petrov /* disksubr.c */
    236  1.29.6.2  petrov struct dkbad;
    237  1.29.6.2  petrov int isbad __P((struct dkbad *bt, int, int, int));
    238  1.29.6.2  petrov /* machdep.c */
    239  1.29.6.2  petrov int	ldcontrolb __P((caddr_t));
    240  1.29.6.2  petrov void	dumpconf __P((void));
    241  1.29.6.2  petrov caddr_t	reserve_dumppages __P((caddr_t));
    242  1.29.6.2  petrov /* clock.c */
    243  1.29.6.2  petrov struct timeval;
    244  1.29.6.2  petrov int	tickintr __P((void *)); /* level 10 (tick) interrupt code */
    245  1.29.6.2  petrov int	clockintr __P((void *));/* level 10 (clock) interrupt code */
    246  1.29.6.2  petrov int	statintr __P((void *));	/* level 14 (statclock) interrupt code */
    247  1.29.6.2  petrov /* locore.s */
    248  1.29.6.2  petrov struct fpstate64;
    249  1.29.6.2  petrov void	savefpstate __P((struct fpstate64 *));
    250  1.29.6.2  petrov void	loadfpstate __P((struct fpstate64 *));
    251  1.29.6.2  petrov u_int64_t	probeget __P((paddr_t, int, int));
    252  1.29.6.2  petrov int	probeset __P((paddr_t, int, int, u_int64_t));
    253  1.29.6.2  petrov #if 0
    254  1.29.6.2  petrov void	write_all_windows __P((void));
    255  1.29.6.2  petrov void	write_user_windows __P((void));
    256  1.29.6.2  petrov #else
    257  1.29.6.2  petrov #define	 write_all_windows() __asm __volatile("flushw" : : )
    258  1.29.6.2  petrov #define	 write_user_windows() __asm __volatile("flushw" : : )
    259  1.29.6.2  petrov #endif
    260  1.29.6.2  petrov void 	proc_trampoline __P((void));
    261  1.29.6.2  petrov struct pcb;
    262  1.29.6.2  petrov void	snapshot __P((struct pcb *));
    263  1.29.6.2  petrov struct frame *getfp __P((void));
    264  1.29.6.2  petrov int	xldcontrolb __P((caddr_t, struct pcb *));
    265  1.29.6.2  petrov void	copywords __P((const void *, void *, size_t));
    266  1.29.6.2  petrov void	qcopy __P((const void *, void *, size_t));
    267  1.29.6.2  petrov void	qzero __P((void *, size_t));
    268  1.29.6.2  petrov void	switchtoctx __P((int));
    269  1.29.6.2  petrov /* locore2.c */
    270  1.29.6.2  petrov void	remrq __P((struct proc *));
    271  1.29.6.2  petrov /* trap.c */
    272  1.29.6.2  petrov void	kill_user_windows __P((struct lwp *));
    273  1.29.6.2  petrov int	rwindow_save __P((struct lwp *));
    274  1.29.6.2  petrov /* amd7930intr.s */
    275  1.29.6.2  petrov void	amd7930_trap __P((void));
    276  1.29.6.2  petrov /* cons.c */
    277  1.29.6.2  petrov int	cnrom __P((void));
    278  1.29.6.2  petrov /* zs.c */
    279  1.29.6.2  petrov void zsconsole __P((struct tty *, int, int, void (**)(struct tty *, int)));
    280  1.29.6.2  petrov #ifdef KGDB
    281  1.29.6.2  petrov void zs_kgdb_init __P((void));
    282  1.29.6.2  petrov #endif
    283  1.29.6.2  petrov /* fb.c */
    284  1.29.6.2  petrov void	fb_unblank __P((void));
    285  1.29.6.2  petrov /* kgdb_stub.c */
    286  1.29.6.2  petrov #ifdef KGDB
    287  1.29.6.2  petrov void kgdb_attach __P((int (*)(void *), void (*)(void *, int), void *));
    288  1.29.6.2  petrov void kgdb_connect __P((int));
    289  1.29.6.2  petrov void kgdb_panic __P((void));
    290  1.29.6.2  petrov #endif
    291  1.29.6.2  petrov /* emul.c */
    292  1.29.6.2  petrov int	fixalign __P((struct lwp *, struct trapframe64 *));
    293  1.29.6.2  petrov int	emulinstr __P((vaddr_t, struct trapframe64 *));
    294  1.29.6.2  petrov 
    295  1.29.6.2  petrov /*
    296  1.29.6.2  petrov  *
    297  1.29.6.2  petrov  * The SPARC has a Trap Base Register (TBR) which holds the upper 20 bits
    298  1.29.6.2  petrov  * of the trap vector table.  The next eight bits are supplied by the
    299  1.29.6.2  petrov  * hardware when the trap occurs, and the bottom four bits are always
    300  1.29.6.2  petrov  * zero (so that we can shove up to 16 bytes of executable code---exactly
    301  1.29.6.2  petrov  * four instructions---into each trap vector).
    302  1.29.6.2  petrov  *
    303  1.29.6.2  petrov  * The hardware allocates half the trap vectors to hardware and half to
    304  1.29.6.2  petrov  * software.
    305  1.29.6.2  petrov  *
    306  1.29.6.2  petrov  * Traps have priorities assigned (lower number => higher priority).
    307  1.29.6.2  petrov  */
    308  1.29.6.2  petrov 
    309  1.29.6.2  petrov struct trapvec {
    310  1.29.6.2  petrov 	int	tv_instr[8];		/* the eight instructions */
    311  1.29.6.2  petrov };
    312  1.29.6.2  petrov extern struct trapvec *trapbase;	/* the 256 vectors */
    313  1.29.6.2  petrov 
    314  1.29.6.2  petrov extern void wzero __P((void *, u_int));
    315  1.29.6.2  petrov extern void wcopy __P((const void *, void *, u_int));
    316  1.29.6.2  petrov 
    317  1.29.6.2  petrov #endif /* _KERNEL */
    318  1.29.6.2  petrov #endif /* _CPU_H_ */
    319