Home | History | Annotate | Line # | Download | only in include
cpu.h revision 1.7
      1  1.7  tsutsui /*	$NetBSD: cpu.h,v 1.7 2000/11/09 14:17:19 tsutsui Exp $	*/
      2  1.1  tsutsui 
      3  1.1  tsutsui /*
      4  1.1  tsutsui  * Copyright (c) 1988 University of Utah.
      5  1.1  tsutsui  * Copyright (c) 1982, 1990, 1993
      6  1.1  tsutsui  *	The Regents of the University of California.  All rights reserved.
      7  1.1  tsutsui  *
      8  1.1  tsutsui  * This code is derived from software contributed to Berkeley by
      9  1.1  tsutsui  * the Systems Programming Group of the University of Utah Computer
     10  1.1  tsutsui  * Science Department.
     11  1.1  tsutsui  *
     12  1.1  tsutsui  * Redistribution and use in source and binary forms, with or without
     13  1.1  tsutsui  * modification, are permitted provided that the following conditions
     14  1.1  tsutsui  * are met:
     15  1.1  tsutsui  * 1. Redistributions of source code must retain the above copyright
     16  1.1  tsutsui  *    notice, this list of conditions and the following disclaimer.
     17  1.1  tsutsui  * 2. Redistributions in binary form must reproduce the above copyright
     18  1.1  tsutsui  *    notice, this list of conditions and the following disclaimer in the
     19  1.1  tsutsui  *    documentation and/or other materials provided with the distribution.
     20  1.1  tsutsui  * 3. All advertising materials mentioning features or use of this software
     21  1.1  tsutsui  *    must display the following acknowledgement:
     22  1.1  tsutsui  *	This product includes software developed by the University of
     23  1.1  tsutsui  *	California, Berkeley and its contributors.
     24  1.1  tsutsui  * 4. Neither the name of the University nor the names of its contributors
     25  1.1  tsutsui  *    may be used to endorse or promote products derived from this software
     26  1.1  tsutsui  *    without specific prior written permission.
     27  1.1  tsutsui  *
     28  1.1  tsutsui  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     29  1.1  tsutsui  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     30  1.1  tsutsui  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     31  1.1  tsutsui  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     32  1.1  tsutsui  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     33  1.1  tsutsui  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     34  1.1  tsutsui  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     35  1.1  tsutsui  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     36  1.1  tsutsui  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     37  1.1  tsutsui  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     38  1.1  tsutsui  * SUCH DAMAGE.
     39  1.1  tsutsui  *
     40  1.1  tsutsui  * from: Utah $Hdr: cpu.h 1.16 91/03/25$
     41  1.1  tsutsui  *
     42  1.1  tsutsui  *	@(#)cpu.h	8.4 (Berkeley) 1/5/94
     43  1.1  tsutsui  */
     44  1.1  tsutsui 
     45  1.1  tsutsui #ifndef _NEWS68K_CPU_H_
     46  1.2  tsutsui #define _NEWS68K_CPU_H_
     47  1.1  tsutsui 
     48  1.1  tsutsui /*
     49  1.1  tsutsui  * Exported definitions unique to news68k cpu support.
     50  1.1  tsutsui  */
     51  1.1  tsutsui 
     52  1.4  thorpej #if defined(_KERNEL) && !defined(_LKM)
     53  1.4  thorpej #include "opt_lockdebug.h"
     54  1.4  thorpej #endif
     55  1.4  thorpej 
     56  1.1  tsutsui /*
     57  1.1  tsutsui  * Get common m68k CPU definitions.
     58  1.1  tsutsui  */
     59  1.1  tsutsui #include <m68k/cpu.h>
     60  1.1  tsutsui 
     61  1.2  tsutsui #ifdef news1700
     62  1.1  tsutsui /*
     63  1.1  tsutsui  * XXX news1700 L2 cache would be corrupted with DC_BE and IC_BE...
     64  1.1  tsutsui  * XXX Should these be defined in machine/cpu.h?
     65  1.1  tsutsui  */
     66  1.1  tsutsui #undef CACHE_ON
     67  1.1  tsutsui #undef CACHE_CLR
     68  1.1  tsutsui #undef IC_CLEAR
     69  1.1  tsutsui #undef DC_CLEAR
     70  1.1  tsutsui #define CACHE_ON	(DC_WA|DC_CLR|DC_ENABLE|IC_CLR|IC_ENABLE)
     71  1.1  tsutsui #define CACHE_CLR	CACHE_ON
     72  1.1  tsutsui #define IC_CLEAR	(DC_WA|DC_ENABLE|IC_CLR|IC_ENABLE)
     73  1.1  tsutsui #define DC_CLEAR	(DC_WA|DC_CLR|DC_ENABLE|IC_ENABLE)
     74  1.1  tsutsui 
     75  1.7  tsutsui #define DCIC_CLR	(DC_CLR|IC_CLR)
     76  1.7  tsutsui #define CACHE_BE	(DC_BE|IC_BE)
     77  1.7  tsutsui 
     78  1.2  tsutsui #endif
     79  1.2  tsutsui 
     80  1.1  tsutsui /*
     81  1.1  tsutsui  * Get interrupt glue.
     82  1.1  tsutsui  */
     83  1.1  tsutsui #include <machine/intr.h>
     84  1.1  tsutsui 
     85  1.4  thorpej #include <sys/sched.h>
     86  1.4  thorpej struct cpu_info {
     87  1.4  thorpej 	struct schedstate_percpu ci_schedstate; /* scheduler state */
     88  1.4  thorpej #if defined(DIAGNOSTIC) || defined(LOCKDEBUG)
     89  1.4  thorpej 	u_long ci_spin_locks;		/* # of spin locks held */
     90  1.4  thorpej 	u_long ci_simple_locks;		/* # of simple locks held */
     91  1.4  thorpej #endif
     92  1.4  thorpej };
     93  1.4  thorpej 
     94  1.4  thorpej #ifdef _KERNEL
     95  1.4  thorpej extern struct cpu_info cpu_info_store;
     96  1.4  thorpej 
     97  1.4  thorpej #define	curcpu()			(&cpu_info_store)
     98  1.4  thorpej 
     99  1.1  tsutsui /*
    100  1.1  tsutsui  * definitions of cpu-dependent requirements
    101  1.1  tsutsui  * referenced in generic code
    102  1.1  tsutsui  */
    103  1.2  tsutsui #define cpu_swapin(p)			/* nothing */
    104  1.2  tsutsui #define cpu_wait(p)			/* nothing */
    105  1.2  tsutsui #define cpu_swapout(p)			/* nothing */
    106  1.2  tsutsui #define cpu_number()			0
    107  1.1  tsutsui 
    108  1.1  tsutsui /*
    109  1.1  tsutsui  * Arguments to hardclock and gatherstats encapsulate the previous
    110  1.1  tsutsui  * machine state in an opaque clockframe.  One the hp300, we use
    111  1.1  tsutsui  * what the hardware pushes on an interrupt (frame format 0).
    112  1.1  tsutsui  */
    113  1.1  tsutsui struct clockframe {
    114  1.1  tsutsui 	u_short	sr;		/* sr at time of interrupt */
    115  1.1  tsutsui 	u_long	pc;		/* pc at time of interrupt */
    116  1.1  tsutsui 	u_short	vo;		/* vector offset (4-word frame) */
    117  1.1  tsutsui };
    118  1.1  tsutsui 
    119  1.2  tsutsui #define CLKF_USERMODE(framep)	(((framep)->sr & PSL_S) == 0)
    120  1.2  tsutsui #define CLKF_BASEPRI(framep)	(((framep)->sr & PSL_IPL) == 0)
    121  1.2  tsutsui #define CLKF_PC(framep)		((framep)->pc)
    122  1.1  tsutsui #if 0
    123  1.1  tsutsui /* We would like to do it this way... */
    124  1.2  tsutsui #define CLKF_INTR(framep)	(((framep)->sr & PSL_M) == 0)
    125  1.1  tsutsui #else
    126  1.1  tsutsui /* but until we start using PSL_M, we have to do this instead */
    127  1.2  tsutsui #define CLKF_INTR(framep)	(0)	/* XXX */
    128  1.1  tsutsui #endif
    129  1.1  tsutsui 
    130  1.1  tsutsui 
    131  1.1  tsutsui /*
    132  1.1  tsutsui  * Preempt the current process if in interrupt from user mode,
    133  1.1  tsutsui  * or after the current trap/syscall if in system mode.
    134  1.1  tsutsui  */
    135  1.1  tsutsui extern int want_resched;	/* resched() was called */
    136  1.5  thorpej #define need_resched(ci)	do { want_resched++; aston(); } while(0)
    137  1.1  tsutsui 
    138  1.1  tsutsui /*
    139  1.1  tsutsui  * Give a profiling tick to the current process when the user profiling
    140  1.1  tsutsui  * buffer pages are invalid.  On the hp300, request an ast to send us
    141  1.1  tsutsui  * through trap, marking the proc as needing a profiling tick.
    142  1.1  tsutsui  */
    143  1.3  tsutsui #define need_proftick(p)	do { (p)->p_flag |= P_OWEUPC; aston(); } while(0)
    144  1.1  tsutsui 
    145  1.1  tsutsui /*
    146  1.1  tsutsui  * Notify the current process (p) that it has a signal pending,
    147  1.1  tsutsui  * process as soon as possible.
    148  1.1  tsutsui  */
    149  1.2  tsutsui #define signotify(p)	aston()
    150  1.1  tsutsui 
    151  1.1  tsutsui extern int astpending;		/* need to trap before returning to user mode */
    152  1.3  tsutsui extern volatile u_char *ctrl_ast;
    153  1.3  tsutsui #define aston()		do { astpending++; *ctrl_ast = 0xff; } while(0)
    154  1.4  thorpej 
    155  1.4  thorpej #endif /* _KERNEL */
    156  1.1  tsutsui 
    157  1.1  tsutsui /*
    158  1.1  tsutsui  * CTL_MACHDEP definitions.
    159  1.1  tsutsui  */
    160  1.2  tsutsui #define CPU_CONSDEV		1	/* dev_t: console terminal device */
    161  1.2  tsutsui #define CPU_MAXID		2	/* number of valid machdep ids */
    162  1.1  tsutsui 
    163  1.1  tsutsui #define CTL_MACHDEP_NAMES { \
    164  1.1  tsutsui 	{ 0, 0 }, \
    165  1.1  tsutsui 	{ "console_device", CTLTYPE_STRUCT }, \
    166  1.1  tsutsui }
    167  1.1  tsutsui 
    168  1.1  tsutsui #ifdef _KERNEL
    169  1.1  tsutsui 
    170  1.2  tsutsui #if defined(news1700) || defined(news1200)
    171  1.2  tsutsui #ifndef M68030
    172  1.1  tsutsui #define M68030
    173  1.1  tsutsui #endif
    174  1.2  tsutsui #define M68K_MMU_MOTOROLA
    175  1.2  tsutsui #endif
    176  1.2  tsutsui 
    177  1.2  tsutsui #if defined(news1700)
    178  1.2  tsutsui #define CACHE_HAVE_PAC
    179  1.2  tsutsui #endif
    180  1.1  tsutsui 
    181  1.1  tsutsui #endif
    182  1.1  tsutsui 
    183  1.1  tsutsui #ifdef _KERNEL
    184  1.2  tsutsui extern int systype;
    185  1.2  tsutsui #define NEWS1700	0
    186  1.2  tsutsui #define NEWS1200	1
    187  1.2  tsutsui 
    188  1.2  tsutsui extern int cpuspeed;
    189  1.7  tsutsui extern char *intiobase, *intiolimit, *extiobase;
    190  1.2  tsutsui extern u_int intiobase_phys, intiotop_phys;
    191  1.2  tsutsui extern u_int extiobase_phys, extiotop_phys;
    192  1.2  tsutsui extern u_int intrcnt[];
    193  1.1  tsutsui 
    194  1.2  tsutsui extern void (*vectab[]) __P((void));
    195  1.1  tsutsui 
    196  1.1  tsutsui struct frame;
    197  1.1  tsutsui struct fpframe;
    198  1.1  tsutsui struct pcb;
    199  1.1  tsutsui 
    200  1.1  tsutsui /* locore.s functions */
    201  1.2  tsutsui void m68881_save __P((struct fpframe *));
    202  1.2  tsutsui void m68881_restore __P((struct fpframe *));
    203  1.2  tsutsui void DCIA __P((void));
    204  1.2  tsutsui void DCIS __P((void));
    205  1.2  tsutsui void DCIU __P((void));
    206  1.2  tsutsui void ICIA __P((void));
    207  1.2  tsutsui void ICPA __P((void));
    208  1.2  tsutsui void PCIA __P((void));
    209  1.2  tsutsui void TBIA __P((void));
    210  1.2  tsutsui void TBIS __P((vaddr_t));
    211  1.2  tsutsui void TBIAS __P((void));
    212  1.2  tsutsui void TBIAU __P((void));
    213  1.2  tsutsui 
    214  1.2  tsutsui int suline __P((caddr_t, caddr_t));
    215  1.2  tsutsui void savectx __P((struct pcb *));
    216  1.2  tsutsui void switch_exit __P((struct proc *));
    217  1.2  tsutsui void proc_trampoline __P((void));
    218  1.2  tsutsui void loadustp __P((int));
    219  1.2  tsutsui void badtrap __P((void));
    220  1.2  tsutsui void intrhand_vectored __P((void));
    221  1.2  tsutsui int getsr __P((void));
    222  1.1  tsutsui 
    223  1.1  tsutsui 
    224  1.2  tsutsui void doboot __P((int))
    225  1.1  tsutsui 	__attribute__((__noreturn__));
    226  1.2  tsutsui void nmihand __P((struct frame *));
    227  1.2  tsutsui void ecacheon __P((void));
    228  1.2  tsutsui void ecacheoff __P((void));
    229  1.1  tsutsui 
    230  1.1  tsutsui /* machdep.c functions */
    231  1.2  tsutsui int badaddr __P((caddr_t, int));
    232  1.2  tsutsui int badbaddr __P((caddr_t));
    233  1.1  tsutsui 
    234  1.1  tsutsui /* sys_machdep.c functions */
    235  1.2  tsutsui int cachectl1 __P((unsigned long, vaddr_t, size_t, struct proc *));
    236  1.1  tsutsui 
    237  1.1  tsutsui /* vm_machdep.c functions */
    238  1.2  tsutsui void physaccess __P((caddr_t, caddr_t, int, int));
    239  1.2  tsutsui void physunaccess __P((caddr_t, int));
    240  1.2  tsutsui int kvtop __P((caddr_t));
    241  1.1  tsutsui 
    242  1.1  tsutsui /* trap.c functions */
    243  1.2  tsutsui void child_return __P((void *));
    244  1.1  tsutsui 
    245  1.1  tsutsui #endif
    246  1.1  tsutsui 
    247  1.1  tsutsui /* physical memory sections */
    248  1.2  tsutsui #define ROMBASE		(0xe0000000)
    249  1.2  tsutsui 
    250  1.2  tsutsui #define INTIOBASE1700	(0xe0c00000)
    251  1.1  tsutsui #define INTIOTOP1700	(0xe1d00000) /* XXX */
    252  1.2  tsutsui #define EXTIOBASE1700	(0xf0f00000)
    253  1.1  tsutsui #define EXTIOTOP1700	(0xf1000000) /* XXX */
    254  1.2  tsutsui 
    255  1.2  tsutsui #define INTIOBASE1200	(0xe1000000)
    256  1.2  tsutsui #define INTIOTOP1200	(0xe1d00000) /* XXX */
    257  1.2  tsutsui #define EXTIOBASE1200	(0xe4000000)
    258  1.2  tsutsui #define EXTIOTOP1200	(0xe4020000) /* XXX */
    259  1.2  tsutsui 
    260  1.2  tsutsui #define MAXADDR		(0xfffff000)
    261  1.1  tsutsui 
    262  1.1  tsutsui /*
    263  1.1  tsutsui  * Internal IO space:
    264  1.1  tsutsui  *
    265  1.1  tsutsui  * Internal IO space is mapped in the kernel from ``intiobase'' to
    266  1.1  tsutsui  * ``intiolimit'' (defined in locore.s).  Since it is always mapped,
    267  1.1  tsutsui  * conversion between physical and kernel virtual addresses is easy.
    268  1.1  tsutsui  */
    269  1.2  tsutsui #define ISIIOVA(va) \
    270  1.1  tsutsui 	((char *)(va) >= intiobase && (char *)(va) < intiolimit)
    271  1.2  tsutsui #define IIOV(pa)	(((u_int)(pa) - intiobase_phys) + (u_int)intiobase)
    272  1.2  tsutsui #define ISIIOPA(pa) \
    273  1.2  tsutsui 	((u_int)(pa) >= intiobase_phys && (u_int)(pa) < intiotop_phys)
    274  1.2  tsutsui #define IIOP(va)	(((u_int)(va) - (u_int)intiobase) + intiobase_phys)
    275  1.2  tsutsui #define IIOPOFF(pa)	((u_int)(pa) - intiobase_phys)
    276  1.6  tsutsui 
    277  1.6  tsutsui /* XXX EIO space mapping should be modified like hp300 XXX */
    278  1.6  tsutsui #define	EIOSIZE		(extiotop_phys - extiobase_phys)
    279  1.6  tsutsui #define ISEIOVA(va) \
    280  1.6  tsutsui 	((char *)(va) >= extiobase && (char *)(va) < (char *)EIOSIZE)
    281  1.6  tsutsui #define EIOV(pa)	(((u_int)(pa) - extiobase_phys) + (u_int)extiobase)
    282  1.1  tsutsui 
    283  1.1  tsutsui #endif /* !_NEWS68K_CPU_H_ */
    284