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