Home | History | Annotate | Line # | Download | only in include
cpu.h revision 1.4.2.2
      1  1.4.2.1     skrll /*	$NetBSD: cpu.h,v 1.4.2.2 2004/09/18 14:41:56 skrll Exp $	*/
      2  1.4.2.1     skrll 
      3  1.4.2.1     skrll /*
      4  1.4.2.1     skrll  * Copyright (c) 1982, 1990 The Regents of the University of California.
      5  1.4.2.1     skrll  * All rights reserved.
      6  1.4.2.1     skrll  *
      7  1.4.2.1     skrll  * This code is derived from software contributed to Berkeley by
      8  1.4.2.1     skrll  * the Systems Programming Group of the University of Utah Computer
      9  1.4.2.1     skrll  * Science Department.
     10  1.4.2.1     skrll  *
     11  1.4.2.1     skrll  * Redistribution and use in source and binary forms, with or without
     12  1.4.2.1     skrll  * modification, are permitted provided that the following conditions
     13  1.4.2.1     skrll  * are met:
     14  1.4.2.1     skrll  * 1. Redistributions of source code must retain the above copyright
     15  1.4.2.1     skrll  *    notice, this list of conditions and the following disclaimer.
     16  1.4.2.1     skrll  * 2. Redistributions in binary form must reproduce the above copyright
     17  1.4.2.1     skrll  *    notice, this list of conditions and the following disclaimer in the
     18  1.4.2.1     skrll  *    documentation and/or other materials provided with the distribution.
     19  1.4.2.1     skrll  * 3. Neither the name of the University nor the names of its contributors
     20  1.4.2.1     skrll  *    may be used to endorse or promote products derived from this software
     21  1.4.2.1     skrll  *    without specific prior written permission.
     22  1.4.2.1     skrll  *
     23  1.4.2.1     skrll  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     24  1.4.2.1     skrll  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25  1.4.2.1     skrll  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26  1.4.2.1     skrll  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     27  1.4.2.1     skrll  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28  1.4.2.1     skrll  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29  1.4.2.1     skrll  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30  1.4.2.1     skrll  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31  1.4.2.1     skrll  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32  1.4.2.1     skrll  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33  1.4.2.1     skrll  * SUCH DAMAGE.
     34  1.4.2.1     skrll  *
     35  1.4.2.1     skrll  *	from: Utah Hdr: cpu.h 1.16 91/03/25
     36  1.4.2.1     skrll  *	from: @(#)cpu.h	7.7 (Berkeley) 6/27/91
     37  1.4.2.1     skrll  *	cpu.h,v 1.2 1993/05/22 07:58:17 cgd Exp
     38  1.4.2.1     skrll  */
     39      1.1  fredette 
     40      1.1  fredette /*
     41      1.1  fredette  * Copyright (c) 1994 Gordon W. Ross
     42      1.1  fredette  * Copyright (c) 1993 Adam Glass
     43      1.1  fredette  * Copyright (c) 1988 University of Utah.
     44      1.1  fredette  *
     45      1.1  fredette  * This code is derived from software contributed to Berkeley by
     46      1.1  fredette  * the Systems Programming Group of the University of Utah Computer
     47      1.1  fredette  * Science Department.
     48      1.1  fredette  *
     49      1.1  fredette  * Redistribution and use in source and binary forms, with or without
     50      1.1  fredette  * modification, are permitted provided that the following conditions
     51      1.1  fredette  * are met:
     52      1.1  fredette  * 1. Redistributions of source code must retain the above copyright
     53      1.1  fredette  *    notice, this list of conditions and the following disclaimer.
     54      1.1  fredette  * 2. Redistributions in binary form must reproduce the above copyright
     55      1.1  fredette  *    notice, this list of conditions and the following disclaimer in the
     56      1.1  fredette  *    documentation and/or other materials provided with the distribution.
     57      1.1  fredette  * 3. All advertising materials mentioning features or use of this software
     58      1.1  fredette  *    must display the following acknowledgement:
     59      1.1  fredette  *	This product includes software developed by the University of
     60      1.1  fredette  *	California, Berkeley and its contributors.
     61      1.1  fredette  * 4. Neither the name of the University nor the names of its contributors
     62      1.1  fredette  *    may be used to endorse or promote products derived from this software
     63      1.1  fredette  *    without specific prior written permission.
     64      1.1  fredette  *
     65      1.1  fredette  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     66      1.1  fredette  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     67      1.1  fredette  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     68      1.1  fredette  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     69      1.1  fredette  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     70      1.1  fredette  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     71      1.1  fredette  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     72      1.1  fredette  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     73      1.1  fredette  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     74      1.1  fredette  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     75      1.1  fredette  * SUCH DAMAGE.
     76      1.1  fredette  *
     77      1.1  fredette  *	from: Utah Hdr: cpu.h 1.16 91/03/25
     78      1.1  fredette  *	from: @(#)cpu.h	7.7 (Berkeley) 6/27/91
     79      1.1  fredette  *	cpu.h,v 1.2 1993/05/22 07:58:17 cgd Exp
     80      1.1  fredette  */
     81      1.1  fredette 
     82      1.1  fredette #ifndef _CPU_H_
     83      1.1  fredette #define _CPU_H_
     84      1.1  fredette 
     85      1.2  fredette #if defined(_KERNEL_OPT)
     86      1.1  fredette #include "opt_lockdebug.h"
     87      1.1  fredette #endif
     88      1.1  fredette 
     89      1.1  fredette #include <m68k/m68k.h>
     90      1.1  fredette 
     91      1.1  fredette #ifdef _KERNEL
     92      1.1  fredette 
     93      1.1  fredette /*
     94      1.1  fredette  * External definitions unique to sun68k cpu support.
     95      1.1  fredette  * These are the "public" declarations - those needed in
     96      1.1  fredette  * machine-independent source code.  The "private" ones
     97      1.1  fredette  * are in machdep.h (used only inside sys/arch/sun{2,3,68k}).
     98      1.1  fredette  *
     99      1.1  fredette  * Note that the name of this file is NOT meant to imply
    100      1.1  fredette  * that it has anything to do with Motorola CPU stuff.
    101      1.1  fredette  * The name "cpu" is historical, and used in the common
    102      1.1  fredette  * code to identify machine-dependent functions, etc.
    103      1.1  fredette  */
    104      1.1  fredette 
    105      1.1  fredette #include <sys/sched.h>
    106      1.1  fredette struct cpu_info {
    107      1.1  fredette 	struct schedstate_percpu ci_schedstate; /* scheduler state */
    108      1.1  fredette #if defined(DIAGNOSTIC) || defined(LOCKDEBUG)
    109      1.1  fredette 	u_long ci_spin_locks;		/* # of spin locks held */
    110      1.1  fredette 	u_long ci_simple_locks;		/* # of simple locks held */
    111      1.1  fredette #endif
    112      1.1  fredette };
    113      1.1  fredette 
    114      1.1  fredette extern struct cpu_info cpu_info_store;
    115      1.1  fredette 
    116      1.1  fredette #define	curcpu()			(&cpu_info_store)
    117      1.1  fredette 
    118      1.1  fredette /*
    119      1.1  fredette  * definitions of cpu-dependent requirements
    120      1.1  fredette  * referenced in generic code
    121      1.1  fredette  */
    122      1.3       chs #define	cpu_number()			0
    123      1.3       chs #define	cpu_swapin(p)			/* nothing */
    124      1.3       chs #define	cpu_swapout(p)			/* nothing */
    125      1.1  fredette 
    126  1.4.2.1     skrll void	cpu_proc_fork __P((struct proc *, struct proc *));
    127  1.4.2.1     skrll 
    128      1.1  fredette /*
    129      1.1  fredette  * Arguments to hardclock and gatherstats encapsulate the previous
    130      1.1  fredette  * machine state in an opaque clockframe.  On the sun68k, we use
    131      1.1  fredette  * what the locore.s glue puts on the stack before calling C-code.
    132      1.1  fredette  */
    133      1.1  fredette struct clockframe {
    134      1.1  fredette 	u_int	cf_regs[4];	/* d0,d1,a0,a1 */
    135      1.1  fredette 	u_short	cf_sr;		/* sr at time of interrupt */
    136      1.1  fredette 	u_long	cf_pc;		/* pc at time of interrupt */
    137      1.1  fredette 	u_short	cf_vo;		/* vector offset (4-word frame) */
    138      1.1  fredette } __attribute__((packed));
    139      1.1  fredette 
    140      1.1  fredette #define	CLKF_USERMODE(framep)	(((framep)->cf_sr & PSL_S) == 0)
    141      1.1  fredette #define	CLKF_BASEPRI(framep)	(((framep)->cf_sr & PSL_IPL) == 0)
    142      1.1  fredette #define	CLKF_PC(framep)		((framep)->cf_pc)
    143      1.1  fredette #if 0
    144      1.1  fredette /* We would like to do it this way... */
    145      1.1  fredette #define	CLKF_INTR(framep)	(((framep)->cf_sr & PSL_M) == 0)
    146      1.1  fredette #else
    147      1.1  fredette /* but until we start using PSL_M, we have to do this instead */
    148      1.1  fredette #define	CLKF_INTR(framep)	(0)	/* XXX */
    149      1.1  fredette #endif
    150      1.1  fredette 
    151      1.1  fredette extern int astpending;	 /* need to trap before returning to user mode */
    152      1.1  fredette #define aston() (astpending = 1)
    153      1.1  fredette 
    154      1.1  fredette /*
    155      1.1  fredette  * Preempt the current process if in interrupt from user mode,
    156      1.1  fredette  * or after the current trap/syscall if in system mode.
    157      1.1  fredette  */
    158      1.1  fredette extern int want_resched;	 /* resched() was called */
    159      1.1  fredette #define	need_resched(ci)	{ want_resched = 1; aston(); }
    160      1.1  fredette 
    161      1.1  fredette /*
    162      1.1  fredette  * Give a profiling tick to the current process when the user profiling
    163      1.1  fredette  * buffer pages are invalid.  On the sun68k, request an ast to send us
    164      1.1  fredette  * through trap, marking the proc as needing a profiling tick.
    165      1.1  fredette  */
    166      1.1  fredette #define	need_proftick(p)	((p)->p_flag |= P_OWEUPC, aston())
    167      1.1  fredette 
    168      1.1  fredette /*
    169      1.1  fredette  * Notify the current process (p) that it has a signal pending,
    170      1.1  fredette  * process as soon as possible.
    171      1.1  fredette  */
    172      1.1  fredette #define	signotify(p)	aston()
    173      1.1  fredette 
    174      1.1  fredette #include <machine/intr.h>
    175      1.1  fredette extern void *softnet_cookie;
    176      1.1  fredette #define setsoftnet()	softintr_schedule(softnet_cookie)
    177      1.1  fredette 
    178      1.1  fredette /*
    179      1.1  fredette  * For some reason the sparc has this prototype in its machine/cpu.h,
    180      1.1  fredette  * so for now we do the same.
    181      1.1  fredette  */
    182      1.1  fredette void	fb_unblank __P((void));
    183      1.1  fredette 
    184      1.1  fredette int	cachectl1 __P((unsigned long, vaddr_t, size_t, struct proc *));
    185      1.1  fredette 
    186      1.1  fredette /*
    187      1.1  fredette  * This is needed by sun68k/isr.c.  It's here for lack of a
    188      1.1  fredette  * better place.
    189      1.1  fredette  */
    190      1.1  fredette void	netintr __P((void));
    191      1.3       chs 
    192      1.3       chs /*
    193      1.3       chs  * more stuff here for lack of a better place.
    194      1.3       chs  */
    195      1.3       chs struct pcb;
    196      1.3       chs void	proc_trampoline __P((void));
    197      1.3       chs void	savectx __P((struct pcb *));
    198      1.4   thorpej void	switch_exit __P((struct lwp *));
    199      1.4   thorpej void	switch_lwp_exit __P((struct lwp *));
    200      1.3       chs 
    201      1.3       chs #define M68K_VAC
    202      1.1  fredette 
    203      1.1  fredette #endif	/* _KERNEL */
    204      1.1  fredette 
    205      1.1  fredette #include <m68k/sysctl.h>
    206      1.1  fredette #endif /* _CPU_H_ */
    207