Home | History | Annotate | Line # | Download | only in include
cpu.h revision 1.53.2.2
      1 /*	$NetBSD: cpu.h,v 1.53.2.2 2001/11/17 21:59:09 scw Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1988 University of Utah.
      5  * Copyright (c) 1982, 1990 The Regents of the University of California.
      6  * All rights reserved.
      7  *
      8  * This code is derived from software contributed to Berkeley by
      9  * the Systems Programming Group of the University of Utah Computer
     10  * Science Department.
     11  *
     12  * Redistribution and use in source and binary forms, with or without
     13  * modification, are permitted provided that the following conditions
     14  * are met:
     15  * 1. Redistributions of source code must retain the above copyright
     16  *    notice, this list of conditions and the following disclaimer.
     17  * 2. Redistributions in binary form must reproduce the above copyright
     18  *    notice, this list of conditions and the following disclaimer in the
     19  *    documentation and/or other materials provided with the distribution.
     20  * 3. All advertising materials mentioning features or use of this software
     21  *    must display the following acknowledgement:
     22  *	This product includes software developed by the University of
     23  *	California, Berkeley and its contributors.
     24  * 4. Neither the name of the University nor the names of its contributors
     25  *    may be used to endorse or promote products derived from this software
     26  *    without specific prior written permission.
     27  *
     28  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     29  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     30  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     31  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     32  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     33  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     34  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     35  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     36  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     37  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     38  * SUCH DAMAGE.
     39  *
     40  * from: Utah $Hdr: cpu.h 1.16 91/03/25$
     41  *
     42  *	@(#)cpu.h	7.7 (Berkeley) 6/27/91
     43  */
     44 #ifndef _MACHINE_CPU_H_
     45 #define _MACHINE_CPU_H_
     46 
     47 /*
     48  * Exported definitions unique to amiga/68k cpu support.
     49  */
     50 
     51 #if defined(_KERNEL_OPT)
     52 #include "opt_lockdebug.h"
     53 #endif
     54 
     55 /*
     56  * Get common m68k CPU definitions.
     57  */
     58 #include <m68k/cpu.h>
     59 #define	M68K_MMU_MOTOROLA
     60 
     61 #include <sys/sched.h>
     62 struct cpu_info {
     63 	struct schedstate_percpu ci_schedstate; /* scheduler state */
     64 #if defined(DIAGNOSTIC) || defined(LOCKDEBUG)
     65 	u_long ci_spin_locks;		/* # of spin locks held */
     66 	u_long ci_simple_locks;		/* # of simple locks held */
     67 #endif
     68 };
     69 
     70 #ifdef _KERNEL
     71 extern struct cpu_info cpu_info_store;
     72 
     73 #define	curcpu()	(&cpu_info_store)
     74 
     75 /*
     76  * definitions of cpu-dependent requirements
     77  * referenced in generic code
     78  */
     79 #define	cpu_swapin(p)			/* nothing */
     80 #define	cpu_wait(p)			/* nothing */
     81 #define	cpu_swapout(p)			/* nothing */
     82 #define	cpu_number()			0
     83 
     84 extern volatile unsigned int interrupt_depth;
     85 /*
     86  * Arguments to hardclock and gatherstats encapsulate the previous
     87  * machine state in an opaque clockframe.  One the hp300, we use
     88  * what the hardware pushes on an interrupt (frame format 0).
     89  */
     90 struct clockframe {
     91 	u_short	sr;		/* sr at time of interrupt */
     92 	u_long	pc;		/* pc at time of interrupt */
     93 	u_short	vo;		/* vector offset (4-word frame) */
     94 };
     95 
     96 #define	CLKF_USERMODE(framep)	(((framep)->sr & PSL_S) == 0)
     97 /*#define	CLKF_BASEPRI(framep)	(((framep)->sr & PSL_IPL) == 0)*/
     98 #define	CLKF_BASEPRI(framep)	(0)
     99 #define	CLKF_PC(framep)		((framep)->pc)
    100 #define	CLKF_INTR(framep)	(interrupt_depth > 1)
    101 
    102 
    103 /*
    104  * Preempt the current process if in interrupt from user mode,
    105  * or after the current trap/syscall if in system mode.
    106  */
    107 extern int want_resched;	/* resched() was called */
    108 #define	need_resched(ci)	{want_resched = 1; setsoftast();}
    109 
    110 /*
    111  * Give a profiling tick to the current process from the softclock
    112  * interrupt.  On hp300, request an ast to send us through trap(),
    113  * marking the proc as needing a profiling tick.
    114  */
    115 #define	profile_tick(p, framep)	((p)->p_flag |= P_OWEUPC, setsoftast())
    116 #define	need_proftick(p)	((p)->p_flag |= P_OWEUPC, setsoftast())
    117 
    118 /*
    119  * Notify the current process (p) that it has a signal pending,
    120  * process as soon as possible.
    121  */
    122 #define	signotify(p)	setsoftast()
    123 
    124 extern int astpending;		/* need trap before returning to user mode */
    125 #define setsoftast()	(astpending = 1)
    126 
    127 #endif /* _KERNEL */
    128 
    129 /* include support for software interrupts */
    130 #include <machine/mtpr.h>
    131 
    132 /*
    133  * The rest of this should probably be moved to ../amiga/amigacpu.h,
    134  * although some of it could probably be put into generic 68k headers.
    135  */
    136 
    137 /* values for machineid (happen to be AFF_* settings of AttnFlags) */
    138 #define AMIGA_68020	(1L<<1)
    139 #define AMIGA_68030	(1L<<2)
    140 #define AMIGA_68040	(1L<<3)
    141 #define AMIGA_68881	(1L<<4)
    142 #define AMIGA_68882	(1L<<5)
    143 #define	AMIGA_FPU40	(1L<<6)
    144 #define AMIGA_68060	(1L<<7)
    145 
    146 #ifdef _KERNEL
    147 int machineid;
    148 #endif
    149 
    150 /*
    151  * CTL_MACHDEP definitions.
    152  */
    153 #define CPU_CONSDEV	1	/* dev_t: console terminal device */
    154 #define CPU_MAXID	2	/* number of valid machdep ids */
    155 
    156 #define CTL_MACHDEP_NAMES { \
    157 	{ 0, 0 }, \
    158 	{ "console_device", CTLTYPE_STRUCT }, \
    159 }
    160 
    161 #ifdef _KERNEL
    162 /*
    163  * Prototypes from amiga_init.c
    164  */
    165 void	*alloc_z2mem __P((long));
    166 
    167 /*
    168  * Prototypes from autoconf.c
    169  */
    170 int	is_a1200 __P((void));
    171 int	is_a3000 __P((void));
    172 int	is_a4000 __P((void));
    173 #ifdef DRACO
    174 #define	is_draco() ((machineid >> 24) == 0x7d ? (machineid >> 16) & 0xff : 0)
    175 #endif
    176 
    177 /*
    178  * Prototypes from clock.c
    179  */
    180 u_long	clkread __P((void));
    181 
    182 #ifdef DRACO
    183 /*
    184  * Prototypes from kbd.c
    185  */
    186 void	drkbdintr __P((void));
    187 
    188 /*
    189  * Prototypes from drsc.c
    190  */
    191 void	drsc_handler __P((void));
    192 #endif
    193 
    194 /*
    195  * Prototypes from locore.s
    196  */
    197 struct fpframe;
    198 struct user;
    199 struct pcb;
    200 
    201 void	clearseg __P((vm_offset_t));
    202 void	doboot __P((void)) __attribute__((__noreturn__));
    203 void	loadustp __P((int));
    204 #ifdef FPCOPROC
    205 void	m68881_save __P((struct fpframe *));
    206 void	m68881_restore __P((struct fpframe *));
    207 #endif
    208 void	physcopyseg __P((vm_offset_t, vm_offset_t));
    209 u_int	probeva __P((u_int, u_int));
    210 void	proc_trampoline __P((void));
    211 void	savectx __P((struct pcb *));
    212 void	switch_exit __P((struct lwp *));
    213 void	switch_lwp_exit __P((struct lwp *));
    214 
    215 /*
    216  * Prototypes from machdep.c
    217  */
    218 int	badaddr __P((caddr_t));
    219 int	badbaddr __P((caddr_t));
    220 void	bootsync __P((void));
    221 void	dumpconf __P((void));
    222 
    223 /*
    224  * Prototypes from sys_machdep.c:
    225  */
    226 int	cachectl1 __P((unsigned long, vaddr_t, size_t, struct proc *));
    227 int	dma_cachectl __P((caddr_t, int));
    228 
    229 /*
    230  * Prototypes from vm_machdep.c
    231  */
    232 int	kvtop __P((caddr_t));
    233 void	physaccess __P((caddr_t,  caddr_t, int, int));
    234 void	physunaccess __P((caddr_t, int));
    235 void	setredzone __P((u_int *, caddr_t));
    236 
    237 /*
    238  * Prototypes from pmap.c:
    239  */
    240 void	pmap_bootstrap __P((vm_offset_t, vm_offset_t));
    241 
    242 #endif /* _KERNEL */
    243 
    244 #endif /* !_MACHINE_CPU_H_ */
    245