Home | History | Annotate | Line # | Download | only in include
cpu.h revision 1.7
      1 /*	$NetBSD: cpu.h,v 1.7 2000/11/09 14:17:19 tsutsui Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1988 University of Utah.
      5  * Copyright (c) 1982, 1990, 1993
      6  *	The Regents of the University of California.  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	8.4 (Berkeley) 1/5/94
     43  */
     44 
     45 #ifndef _NEWS68K_CPU_H_
     46 #define _NEWS68K_CPU_H_
     47 
     48 /*
     49  * Exported definitions unique to news68k cpu support.
     50  */
     51 
     52 #if defined(_KERNEL) && !defined(_LKM)
     53 #include "opt_lockdebug.h"
     54 #endif
     55 
     56 /*
     57  * Get common m68k CPU definitions.
     58  */
     59 #include <m68k/cpu.h>
     60 
     61 #ifdef news1700
     62 /*
     63  * XXX news1700 L2 cache would be corrupted with DC_BE and IC_BE...
     64  * XXX Should these be defined in machine/cpu.h?
     65  */
     66 #undef CACHE_ON
     67 #undef CACHE_CLR
     68 #undef IC_CLEAR
     69 #undef DC_CLEAR
     70 #define CACHE_ON	(DC_WA|DC_CLR|DC_ENABLE|IC_CLR|IC_ENABLE)
     71 #define CACHE_CLR	CACHE_ON
     72 #define IC_CLEAR	(DC_WA|DC_ENABLE|IC_CLR|IC_ENABLE)
     73 #define DC_CLEAR	(DC_WA|DC_CLR|DC_ENABLE|IC_ENABLE)
     74 
     75 #define DCIC_CLR	(DC_CLR|IC_CLR)
     76 #define CACHE_BE	(DC_BE|IC_BE)
     77 
     78 #endif
     79 
     80 /*
     81  * Get interrupt glue.
     82  */
     83 #include <machine/intr.h>
     84 
     85 #include <sys/sched.h>
     86 struct cpu_info {
     87 	struct schedstate_percpu ci_schedstate; /* scheduler state */
     88 #if defined(DIAGNOSTIC) || defined(LOCKDEBUG)
     89 	u_long ci_spin_locks;		/* # of spin locks held */
     90 	u_long ci_simple_locks;		/* # of simple locks held */
     91 #endif
     92 };
     93 
     94 #ifdef _KERNEL
     95 extern struct cpu_info cpu_info_store;
     96 
     97 #define	curcpu()			(&cpu_info_store)
     98 
     99 /*
    100  * definitions of cpu-dependent requirements
    101  * referenced in generic code
    102  */
    103 #define cpu_swapin(p)			/* nothing */
    104 #define cpu_wait(p)			/* nothing */
    105 #define cpu_swapout(p)			/* nothing */
    106 #define cpu_number()			0
    107 
    108 /*
    109  * Arguments to hardclock and gatherstats encapsulate the previous
    110  * machine state in an opaque clockframe.  One the hp300, we use
    111  * what the hardware pushes on an interrupt (frame format 0).
    112  */
    113 struct clockframe {
    114 	u_short	sr;		/* sr at time of interrupt */
    115 	u_long	pc;		/* pc at time of interrupt */
    116 	u_short	vo;		/* vector offset (4-word frame) */
    117 };
    118 
    119 #define CLKF_USERMODE(framep)	(((framep)->sr & PSL_S) == 0)
    120 #define CLKF_BASEPRI(framep)	(((framep)->sr & PSL_IPL) == 0)
    121 #define CLKF_PC(framep)		((framep)->pc)
    122 #if 0
    123 /* We would like to do it this way... */
    124 #define CLKF_INTR(framep)	(((framep)->sr & PSL_M) == 0)
    125 #else
    126 /* but until we start using PSL_M, we have to do this instead */
    127 #define CLKF_INTR(framep)	(0)	/* XXX */
    128 #endif
    129 
    130 
    131 /*
    132  * Preempt the current process if in interrupt from user mode,
    133  * or after the current trap/syscall if in system mode.
    134  */
    135 extern int want_resched;	/* resched() was called */
    136 #define need_resched(ci)	do { want_resched++; aston(); } while(0)
    137 
    138 /*
    139  * Give a profiling tick to the current process when the user profiling
    140  * buffer pages are invalid.  On the hp300, request an ast to send us
    141  * through trap, marking the proc as needing a profiling tick.
    142  */
    143 #define need_proftick(p)	do { (p)->p_flag |= P_OWEUPC; aston(); } while(0)
    144 
    145 /*
    146  * Notify the current process (p) that it has a signal pending,
    147  * process as soon as possible.
    148  */
    149 #define signotify(p)	aston()
    150 
    151 extern int astpending;		/* need to trap before returning to user mode */
    152 extern volatile u_char *ctrl_ast;
    153 #define aston()		do { astpending++; *ctrl_ast = 0xff; } while(0)
    154 
    155 #endif /* _KERNEL */
    156 
    157 /*
    158  * CTL_MACHDEP definitions.
    159  */
    160 #define CPU_CONSDEV		1	/* dev_t: console terminal device */
    161 #define CPU_MAXID		2	/* number of valid machdep ids */
    162 
    163 #define CTL_MACHDEP_NAMES { \
    164 	{ 0, 0 }, \
    165 	{ "console_device", CTLTYPE_STRUCT }, \
    166 }
    167 
    168 #ifdef _KERNEL
    169 
    170 #if defined(news1700) || defined(news1200)
    171 #ifndef M68030
    172 #define M68030
    173 #endif
    174 #define M68K_MMU_MOTOROLA
    175 #endif
    176 
    177 #if defined(news1700)
    178 #define CACHE_HAVE_PAC
    179 #endif
    180 
    181 #endif
    182 
    183 #ifdef _KERNEL
    184 extern int systype;
    185 #define NEWS1700	0
    186 #define NEWS1200	1
    187 
    188 extern int cpuspeed;
    189 extern char *intiobase, *intiolimit, *extiobase;
    190 extern u_int intiobase_phys, intiotop_phys;
    191 extern u_int extiobase_phys, extiotop_phys;
    192 extern u_int intrcnt[];
    193 
    194 extern void (*vectab[]) __P((void));
    195 
    196 struct frame;
    197 struct fpframe;
    198 struct pcb;
    199 
    200 /* locore.s functions */
    201 void m68881_save __P((struct fpframe *));
    202 void m68881_restore __P((struct fpframe *));
    203 void DCIA __P((void));
    204 void DCIS __P((void));
    205 void DCIU __P((void));
    206 void ICIA __P((void));
    207 void ICPA __P((void));
    208 void PCIA __P((void));
    209 void TBIA __P((void));
    210 void TBIS __P((vaddr_t));
    211 void TBIAS __P((void));
    212 void TBIAU __P((void));
    213 
    214 int suline __P((caddr_t, caddr_t));
    215 void savectx __P((struct pcb *));
    216 void switch_exit __P((struct proc *));
    217 void proc_trampoline __P((void));
    218 void loadustp __P((int));
    219 void badtrap __P((void));
    220 void intrhand_vectored __P((void));
    221 int getsr __P((void));
    222 
    223 
    224 void doboot __P((int))
    225 	__attribute__((__noreturn__));
    226 void nmihand __P((struct frame *));
    227 void ecacheon __P((void));
    228 void ecacheoff __P((void));
    229 
    230 /* machdep.c functions */
    231 int badaddr __P((caddr_t, int));
    232 int badbaddr __P((caddr_t));
    233 
    234 /* sys_machdep.c functions */
    235 int cachectl1 __P((unsigned long, vaddr_t, size_t, struct proc *));
    236 
    237 /* vm_machdep.c functions */
    238 void physaccess __P((caddr_t, caddr_t, int, int));
    239 void physunaccess __P((caddr_t, int));
    240 int kvtop __P((caddr_t));
    241 
    242 /* trap.c functions */
    243 void child_return __P((void *));
    244 
    245 #endif
    246 
    247 /* physical memory sections */
    248 #define ROMBASE		(0xe0000000)
    249 
    250 #define INTIOBASE1700	(0xe0c00000)
    251 #define INTIOTOP1700	(0xe1d00000) /* XXX */
    252 #define EXTIOBASE1700	(0xf0f00000)
    253 #define EXTIOTOP1700	(0xf1000000) /* XXX */
    254 
    255 #define INTIOBASE1200	(0xe1000000)
    256 #define INTIOTOP1200	(0xe1d00000) /* XXX */
    257 #define EXTIOBASE1200	(0xe4000000)
    258 #define EXTIOTOP1200	(0xe4020000) /* XXX */
    259 
    260 #define MAXADDR		(0xfffff000)
    261 
    262 /*
    263  * Internal IO space:
    264  *
    265  * Internal IO space is mapped in the kernel from ``intiobase'' to
    266  * ``intiolimit'' (defined in locore.s).  Since it is always mapped,
    267  * conversion between physical and kernel virtual addresses is easy.
    268  */
    269 #define ISIIOVA(va) \
    270 	((char *)(va) >= intiobase && (char *)(va) < intiolimit)
    271 #define IIOV(pa)	(((u_int)(pa) - intiobase_phys) + (u_int)intiobase)
    272 #define ISIIOPA(pa) \
    273 	((u_int)(pa) >= intiobase_phys && (u_int)(pa) < intiotop_phys)
    274 #define IIOP(va)	(((u_int)(va) - (u_int)intiobase) + intiobase_phys)
    275 #define IIOPOFF(pa)	((u_int)(pa) - intiobase_phys)
    276 
    277 /* XXX EIO space mapping should be modified like hp300 XXX */
    278 #define	EIOSIZE		(extiotop_phys - extiobase_phys)
    279 #define ISEIOVA(va) \
    280 	((char *)(va) >= extiobase && (char *)(va) < (char *)EIOSIZE)
    281 #define EIOV(pa)	(((u_int)(pa) - extiobase_phys) + (u_int)extiobase)
    282 
    283 #endif /* !_NEWS68K_CPU_H_ */
    284