Home | History | Annotate | Line # | Download | only in include
cpu.h revision 1.49
      1 /*	$NetBSD: cpu.h,v 1.49 2007/02/09 21:55:02 ad Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1982, 1990 The Regents of the University of California.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to Berkeley by
      8  * the Systems Programming Group of the University of Utah Computer
      9  * Science Department.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions and the following disclaimer.
     16  * 2. Redistributions in binary form must reproduce the above copyright
     17  *    notice, this list of conditions and the following disclaimer in the
     18  *    documentation and/or other materials provided with the distribution.
     19  * 3. Neither the name of the University nor the names of its contributors
     20  *    may be used to endorse or promote products derived from this software
     21  *    without specific prior written permission.
     22  *
     23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33  * SUCH DAMAGE.
     34  *
     35  * from: Utah $Hdr: cpu.h 1.16 91/03/25$
     36  *
     37  *	@(#)cpu.h	7.7 (Berkeley) 6/27/91
     38  */
     39 /*
     40  * Copyright (c) 1988 University of Utah.
     41  *
     42  * This code is derived from software contributed to Berkeley by
     43  * the Systems Programming Group of the University of Utah Computer
     44  * Science Department.
     45  *
     46  * Redistribution and use in source and binary forms, with or without
     47  * modification, are permitted provided that the following conditions
     48  * are met:
     49  * 1. Redistributions of source code must retain the above copyright
     50  *    notice, this list of conditions and the following disclaimer.
     51  * 2. Redistributions in binary form must reproduce the above copyright
     52  *    notice, this list of conditions and the following disclaimer in the
     53  *    documentation and/or other materials provided with the distribution.
     54  * 3. All advertising materials mentioning features or use of this software
     55  *    must display the following acknowledgement:
     56  *	This product includes software developed by the University of
     57  *	California, Berkeley and its contributors.
     58  * 4. Neither the name of the University nor the names of its contributors
     59  *    may be used to endorse or promote products derived from this software
     60  *    without specific prior written permission.
     61  *
     62  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     63  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     64  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     65  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     66  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     67  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     68  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     69  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     70  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     71  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     72  * SUCH DAMAGE.
     73  *
     74  * from: Utah $Hdr: cpu.h 1.16 91/03/25$
     75  *
     76  *	@(#)cpu.h	7.7 (Berkeley) 6/27/91
     77  */
     78 
     79 #ifndef _MACHINE_CPU_H_
     80 #define _MACHINE_CPU_H_
     81 
     82 #if defined(_KERNEL)
     83 
     84 /*
     85  * Exported definitions unique to atari/68k cpu support.
     86  */
     87 
     88 #if defined(_KERNEL_OPT)
     89 #include "opt_lockdebug.h"
     90 #endif
     91 
     92 /*
     93  * Get common m68k CPU definitions.
     94  */
     95 #include <m68k/cpu.h>
     96 #define	M68K_MMU_MOTOROLA
     97 
     98 #include <sys/cpu_data.h>
     99 struct cpu_info {
    100 	struct cpu_data ci_data;	/* MI per-cpu data */
    101         int	ci_mtx_count;
    102         int	ci_mtx_oldspl;
    103 };
    104 
    105 extern struct cpu_info cpu_info_store;
    106 
    107 #define	curcpu()	(&cpu_info_store)
    108 
    109 /*
    110  * definitions of cpu-dependent requirements
    111  * referenced in generic code
    112  */
    113 #define	cpu_swapin(p)			/* nothing */
    114 #define cpu_swapout(p)			/* nothing */
    115 #define	cpu_number()			0
    116 
    117 void	cpu_proc_fork(struct proc *, struct proc *);
    118 
    119 /*
    120  * Arguments to hardclock and gatherstats encapsulate the previous
    121  * machine state in an opaque clockframe.  On the hp300, we use
    122  * what the hardware pushes on an interrupt (frame format 0).
    123  */
    124 struct clockframe {
    125 	u_int	cf_regs[4];	/* d0,d1,a0,a1 (see locore.s)	*/
    126 	u_short	cf_sr;		/* sr at time of interrupt	*/
    127 	u_long	cf_pc;		/* pc at time of interrupt	*/
    128 	u_short	cf_vo;		/* vector offset (4-word frame)	*/
    129 } __attribute__((packed));
    130 
    131 #define	CLKF_USERMODE(framep)	(((framep)->cf_sr & PSL_S) == 0)
    132 #define	CLKF_BASEPRI(framep)	(((framep)->cf_sr & PSL_IPL) == 0)
    133 #define	CLKF_PC(framep)		((framep)->cf_pc)
    134 #if 0
    135 /* We would like to do it this way... */
    136 #define	CLKF_INTR(framep)	(((framep)->cf_sr & PSL_M) == 0)
    137 #else
    138 /* but until we start using PSL_M, we have to do this instead */
    139 #define	CLKF_INTR(framep)	(0)	/* XXX */
    140 #endif
    141 
    142 
    143 /*
    144  * Preempt the current process if in interrupt from user mode,
    145  * or after the current trap/syscall if in system mode.
    146  */
    147 #define	cpu_need_resched(ci)	{want_resched = 1; setsoftast();}
    148 
    149 /*
    150  * Give a profiling tick to the current process from the softclock
    151  * interrupt.  On hp300, request an ast to send us through trap(),
    152  * marking the proc as needing a profiling tick.
    153  */
    154 #define	profile_tick(l, framep)	((l)->l_pflag |= LP_OWEUPC, setsoftast())
    155 #define	cpu_need_proftick(l)	((l)->l_pflag |= LP_OWEUPC, setsoftast())
    156 
    157 /*
    158  * Notify the current process (p) that it has a signal pending,
    159  * process as soon as possible.
    160  */
    161 #define	cpu_signotify(l)	setsoftast()
    162 
    163 #define setsoftast()	(astpending = 1)
    164 
    165 extern int	astpending;	/* need trap before returning to user mode */
    166 extern int	want_resched;	/* resched() was called */
    167 
    168 /* include support for software interrupts */
    169 #include <machine/mtpr.h>
    170 
    171 /*
    172  * The rest of this should probably be moved to ../atari/ataricpu.h,
    173  * although some of it could probably be put into generic 68k headers.
    174  */
    175 #define	BASEPRI(sr)	((sr & PSL_IPL) == 0)
    176 #endif /* _KERNEL */
    177 
    178 /*
    179  * Values for machineid.
    180  */
    181 #define	ATARI_68000	1		/* 68000 CPU			*/
    182 #define	ATARI_68010	(1<<1)		/* 68010 CPU			*/
    183 #define ATARI_68020	(1L<<2)		/* 68020 CPU			*/
    184 #define ATARI_68030	(1L<<3)		/* 68030 CPU			*/
    185 #define ATARI_68040	(1L<<4)		/* 68040 CPU			*/
    186 #define ATARI_68060	(1L<<6)		/* 68060 CPU			*/
    187 #define	ATARI_TT	(1L<<11)	/* This is a TT030		*/
    188 #define	ATARI_FALCON	(1L<<12)	/*           Falcon		*/
    189 #define	ATARI_HADES	(1L<<13)	/*           Hades		*/
    190 #define	ATARI_MILAN	(1L<<14)	/*           Milan		*/
    191 
    192 #define	ATARI_CLKBROKEN	(1L<<16)
    193 
    194 #define	ATARI_ANYCPU	(ATARI_68000|ATARI_68010|ATARI_68020|ATARI_68030 \
    195 			|ATARI_68040|ATARI_68060)
    196 
    197 #define	ATARI_ANYMACH	(ATARI_TT|ATARI_FALCON|ATARI_HADES|ATARI_MILAN)
    198 
    199 #if defined(_KERNEL)
    200 extern int machineid;
    201 #endif /* _KERNEL */
    202 
    203 /*
    204  * CTL_MACHDEP definitions.
    205  */
    206 #define CPU_CONSDEV	1	/* dev_t: console terminal device */
    207 #define CPU_MAXID	2	/* number of valid machdep ids */
    208 
    209 #define CTL_MACHDEP_NAMES { \
    210 	{ 0, 0 }, \
    211 	{ "console_device", CTLTYPE_STRUCT }, \
    212 }
    213 
    214 #ifdef _KERNEL
    215 /*
    216  * Prototypes from atari_init.c
    217  */
    218 int	cpu_dump __P((int (*)(dev_t, daddr_t, caddr_t, size_t), daddr_t *));
    219 int	cpu_dumpsize __P((void));
    220 
    221 /*
    222  * Prototypes from autoconf.c
    223  */
    224 void	config_console __P((void));
    225 
    226 /*
    227  * Prototypes from clock.c
    228  */
    229 long	clkread __P((void));
    230 
    231 /*
    232  * Prototypes from fpu.c
    233  */
    234 const char *fpu_describe __P((int));
    235 int	fpu_probe __P((void));
    236 
    237 /*
    238  * Prototypes from vm_machdep.c
    239  */
    240 int	badbaddr __P((caddr_t, int));
    241 void	consinit __P((void));
    242 void	dumpconf __P((void));
    243 int	kvtop __P((caddr_t));
    244 void	physaccess __P((caddr_t, caddr_t, int, int));
    245 void	physunaccess __P((caddr_t, int));
    246 void	setredzone __P((u_int *, caddr_t));
    247 
    248 /*
    249  * Prototypes from locore.s
    250  */
    251 struct fpframe;
    252 struct user;
    253 struct pcb;
    254 
    255 void	clearseg __P((paddr_t));
    256 void	doboot __P((void));
    257 void	loadustp __P((int));
    258 void	m68881_save __P((struct fpframe *));
    259 void	m68881_restore __P((struct fpframe *));
    260 void	physcopyseg __P((paddr_t, paddr_t));
    261 u_int	probeva __P((u_int, u_int));
    262 void	proc_trampoline __P((void));
    263 void	savectx __P((struct pcb *));
    264 int	suline __P((caddr_t, caddr_t));
    265 void	switch_exit __P((struct lwp *));
    266 void	switch_lwp_exit __P((struct lwp *));
    267 
    268 /*
    269  * Prototypes from machdep.c:
    270  */
    271 typedef void (*si_farg)(void *, void *);	/* XXX */
    272 void	add_sicallback __P((si_farg, void *, void *));
    273 void	rem_sicallback __P((si_farg));
    274 void	dumpsys __P((void));
    275 vaddr_t reserve_dumppages __P((vaddr_t));
    276 void	softint __P((void));
    277 
    278 
    279 /*
    280  * Prototypes from nvram.c:
    281  */
    282 struct uio;
    283 int	nvram_uio __P((struct uio *));
    284 
    285 /*
    286  * Prototypes from sys_machdep.c:
    287  */
    288 int	cachectl1 __P((unsigned long, vaddr_t, size_t, struct proc *));
    289 int	dma_cachectl __P((caddr_t, int));
    290 
    291 /*
    292  * Prototypes from pci_machdep.c
    293  */
    294 void init_pci_bus __P((void));
    295 
    296 #endif /* _KERNEL */
    297 #endif /* !_MACHINE_CPU_H_ */
    298