Home | History | Annotate | Line # | Download | only in include
cpu.h revision 1.38
      1 /*	$NetBSD: cpu.h,v 1.38 2011/02/08 20:20:20 rmind 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. Neither the name of the University nor the names of its contributors
     21  *    may be used to endorse or promote products derived from this software
     22  *    without specific prior written permission.
     23  *
     24  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     34  * SUCH DAMAGE.
     35  *
     36  * from: Utah $Hdr: cpu.h 1.16 91/03/25$
     37  *
     38  *	@(#)cpu.h	8.4 (Berkeley) 1/5/94
     39  */
     40 
     41 #ifndef _NEWS68K_CPU_H_
     42 #define _NEWS68K_CPU_H_
     43 
     44 #if defined(_KERNEL)
     45 
     46 /*
     47  * Exported definitions unique to news68k cpu support.
     48  */
     49 
     50 #if defined(_KERNEL_OPT)
     51 #include "opt_lockdebug.h"
     52 #include "opt_m68k_arch.h"
     53 #endif
     54 
     55 /*
     56  * Get common m68k CPU definitions.
     57  */
     58 #include <m68k/cpu.h>
     59 
     60 /*
     61  * XXX news1700 L2 cache would be corrupted with DC_BE and IC_BE...
     62  * XXX Should these be defined in machine/cpu.h?
     63  */
     64 #undef CACHE_ON
     65 #undef CACHE_CLR
     66 #undef IC_CLEAR
     67 #undef DC_CLEAR
     68 #define CACHE_ON	(DC_WA|DC_CLR|DC_ENABLE|IC_CLR|IC_ENABLE)
     69 #define CACHE_CLR	CACHE_ON
     70 #define IC_CLEAR	(DC_WA|DC_ENABLE|IC_CLR|IC_ENABLE)
     71 #define DC_CLEAR	(DC_WA|DC_CLR|DC_ENABLE|IC_ENABLE)
     72 
     73 #define DCIC_CLR	(DC_CLR|IC_CLR)
     74 #define CACHE_BE	(DC_BE|IC_BE)
     75 
     76 /*
     77  * Get interrupt glue.
     78  */
     79 #include <machine/intr.h>
     80 
     81 /*
     82  * Arguments to hardclock and gatherstats encapsulate the previous
     83  * machine state in an opaque clockframe.  One the hp300, we use
     84  * what the hardware pushes on an interrupt (frame format 0).
     85  */
     86 struct clockframe {
     87 	u_short	sr;		/* sr at time of interrupt */
     88 	u_long	pc;		/* pc at time of interrupt */
     89 	u_short	vo;		/* vector offset (4-word frame) */
     90 };
     91 
     92 #define CLKF_USERMODE(framep)	(((framep)->sr & PSL_S) == 0)
     93 #define CLKF_PC(framep)		((framep)->pc)
     94 #if 0
     95 /* We would like to do it this way... */
     96 #define CLKF_INTR(framep)	(((framep)->sr & PSL_M) == 0)
     97 #else
     98 /* but until we start using PSL_M, we have to do this instead */
     99 #include <machine/intr.h>
    100 #define CLKF_INTR(framep)	(idepth > 1)	/* XXX */
    101 #endif
    102 
    103 
    104 /*
    105  * Preempt the current process if in interrupt from user mode,
    106  * or after the current trap/syscall if in system mode.
    107  */
    108 #define cpu_need_resched(ci, flags)	\
    109 	do { ci->ci_want_resched = 1; aston(); } while (/* CONSTCOND */0)
    110 
    111 /*
    112  * Give a profiling tick to the current process when the user profiling
    113  * buffer pages are invalid.  On the hp300, request an ast to send us
    114  * through trap, marking the proc as needing a profiling tick.
    115  */
    116 #define cpu_need_proftick(l)	\
    117 	do { (l)->l_pflag |= LP_OWEUPC; aston(); } while (/* CONSTCOND */0)
    118 
    119 /*
    120  * Notify the current process (p) that it has a signal pending,
    121  * process as soon as possible.
    122  */
    123 #define cpu_signotify(l)	aston()
    124 
    125 extern int astpending;		/* need to trap before returning to user mode */
    126 extern volatile u_char *ctrl_ast;
    127 #define aston()		\
    128 	do { astpending++; *ctrl_ast = 0xff; } while (/* CONSTCOND */0)
    129 
    130 #endif /* _KERNEL */
    131 
    132 /*
    133  * CTL_MACHDEP definitions.
    134  */
    135 #define CPU_CONSDEV		1	/* dev_t: console terminal device */
    136 #define CPU_MAXID		2	/* number of valid machdep ids */
    137 
    138 #ifdef _KERNEL
    139 
    140 #if defined(news1700) || defined(news1200)
    141 #ifndef M68030
    142 #define M68030
    143 #endif
    144 #define M68K_MMU_MOTOROLA
    145 #endif
    146 
    147 #if defined(news1700)
    148 #define CACHE_HAVE_PAC
    149 #endif
    150 
    151 #endif
    152 
    153 #ifdef _KERNEL
    154 extern int systype;
    155 #define NEWS1700	0
    156 #define NEWS1200	1
    157 
    158 extern int cpuspeed;
    159 extern char *intiobase, *intiolimit, *extiobase;
    160 extern u_int intiobase_phys, intiotop_phys;
    161 extern u_int extiobase_phys, extiotop_phys;
    162 extern u_int intrcnt[];
    163 
    164 extern void (*vectab[])(void);
    165 
    166 struct frame;
    167 struct fpframe;
    168 
    169 /* locore.s functions */
    170 void m68881_save(struct fpframe *);
    171 void m68881_restore(struct fpframe *);
    172 
    173 int suline(void *, void *);
    174 void loadustp(int);
    175 void badtrap(void);
    176 void intrhand_vectored(void);
    177 int getsr(void);
    178 
    179 
    180 void doboot(int)
    181 	__attribute__((__noreturn__));
    182 void nmihand(struct frame *);
    183 void ecacheon(void);
    184 void ecacheoff(void);
    185 
    186 /* machdep.c functions */
    187 int badaddr(void *, int);
    188 int badbaddr(void *);
    189 
    190 #endif
    191 
    192 /* physical memory sections */
    193 #define ROMBASE		0xe0000000
    194 
    195 #define INTIOBASE1700	0xe0c00000
    196 #define INTIOTOP1700	0xe1d00000 /* XXX */
    197 #define EXTIOBASE1700	0xf0f00000
    198 #define EXTIOTOP1700	0xf1000000 /* XXX */
    199 #define CTRL_POWER1700	0xe1380000
    200 #define CTRL_LED1700	0xe0dc0000
    201 
    202 #define INTIOBASE1200	0xe1000000
    203 #define INTIOTOP1200	0xe1d00000 /* XXX */
    204 #define EXTIOBASE1200	0xe4000000
    205 #define EXTIOTOP1200	0xe4020000 /* XXX */
    206 #define CTRL_POWER1200	0xe1000000
    207 #define CTRL_LED1200	0xe1500001
    208 
    209 #define MAXADDR		0xfffff000
    210 
    211 /*
    212  * Internal IO space:
    213  *
    214  * Internal IO space is mapped in the kernel from ``intiobase'' to
    215  * ``intiolimit'' (defined in locore.s).  Since it is always mapped,
    216  * conversion between physical and kernel virtual addresses is easy.
    217  */
    218 #define ISIIOVA(va) \
    219 	((char *)(va) >= intiobase && (char *)(va) < intiolimit)
    220 #define IIOV(pa)	(((u_int)(pa) - intiobase_phys) + (u_int)intiobase)
    221 #define ISIIOPA(pa) \
    222 	((u_int)(pa) >= intiobase_phys && (u_int)(pa) < intiotop_phys)
    223 #define IIOP(va)	(((u_int)(va) - (u_int)intiobase) + intiobase_phys)
    224 #define IIOPOFF(pa)	((u_int)(pa) - intiobase_phys)
    225 
    226 /* XXX EIO space mapping should be modified like hp300 XXX */
    227 #define	EIOSIZE		(extiotop_phys - extiobase_phys)
    228 #define ISEIOVA(va) \
    229 	((char *)(va) >= extiobase && (char *)(va) < (char *)EIOSIZE)
    230 #define EIOV(pa)	(((u_int)(pa) - extiobase_phys) + (u_int)extiobase)
    231 
    232 #if defined(CACHE_HAVE_PAC) || defined(CACHE_HAVE_VAC)
    233 #define M68K_CACHEOPS_MACHDEP
    234 #endif
    235 
    236 #ifdef CACHE_HAVE_PAC
    237 #define M68K_CACHEOPS_MACHDEP_PCIA
    238 #endif
    239 
    240 #ifdef CACHE_HAVE_VAC
    241 #define M68K_CACHEOPS_MACHDEP_DCIA
    242 #define M68K_CACHEOPS_MACHDEP_DCIS
    243 #define M68K_CACHEOPS_MACHDEP_DCIU
    244 #endif
    245 
    246 #endif /* !_NEWS68K_CPU_H_ */
    247