cpu.h revision 1.50
1117397Skan/* $NetBSD: cpu.h,v 1.50 2010/06/06 04:52:01 mrg Exp $ */ 2117397Skan 3169691Skan/* 4117397Skan * Copyright (c) 1982, 1990, 1993 5117397Skan * The Regents of the University of California. All rights reserved. 6117397Skan * 7117397Skan * This code is derived from software contributed to Berkeley by 8117397Skan * the Systems Programming Group of the University of Utah Computer 9117397Skan * Science Department. 10117397Skan * 11117397Skan * Redistribution and use in source and binary forms, with or without 12117397Skan * modification, are permitted provided that the following conditions 13117397Skan * are met: 14117397Skan * 1. Redistributions of source code must retain the above copyright 15117397Skan * notice, this list of conditions and the following disclaimer. 16117397Skan * 2. Redistributions in binary form must reproduce the above copyright 17117397Skan * notice, this list of conditions and the following disclaimer in the 18169691Skan * documentation and/or other materials provided with the distribution. 19117397Skan * 3. Neither the name of the University nor the names of its contributors 20117397Skan * may be used to endorse or promote products derived from this software 21117397Skan * without specific prior written permission. 22117397Skan * 23117397Skan * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24117397Skan * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25117397Skan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26117397Skan * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27117397Skan * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28117397Skan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29117397Skan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30117397Skan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31117397Skan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32117397Skan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33117397Skan * SUCH DAMAGE. 34117397Skan * 35117397Skan * from: Utah $Hdr: cpu.h 1.16 91/03/25$ 36117397Skan * 37117397Skan * @(#)cpu.h 8.4 (Berkeley) 1/5/94 38117397Skan */ 39117397Skan/* 40117397Skan * Copyright (c) 1988 University of Utah. 41117397Skan * 42117397Skan * This code is derived from software contributed to Berkeley by 43117397Skan * the Systems Programming Group of the University of Utah Computer 44117397Skan * Science Department. 45117397Skan * 46117397Skan * Redistribution and use in source and binary forms, with or without 47117397Skan * modification, are permitted provided that the following conditions 48117397Skan * are met: 49117397Skan * 1. Redistributions of source code must retain the above copyright 50117397Skan * notice, this list of conditions and the following disclaimer. 51117397Skan * 2. Redistributions in binary form must reproduce the above copyright 52117397Skan * notice, this list of conditions and the following disclaimer in the 53117397Skan * documentation and/or other materials provided with the distribution. 54117397Skan * 3. All advertising materials mentioning features or use of this software 55117397Skan * must display the following acknowledgement: 56117397Skan * This product includes software developed by the University of 57117397Skan * California, Berkeley and its contributors. 58117397Skan * 4. Neither the name of the University nor the names of its contributors 59117397Skan * may be used to endorse or promote products derived from this software 60117397Skan * without specific prior written permission. 61132720Skan * 62132720Skan * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 63117397Skan * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 64169691Skan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 65169691Skan * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 66117397Skan * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 67117397Skan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 68169691Skan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 69117397Skan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 70117397Skan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 71117397Skan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 72132720Skan * SUCH DAMAGE. 73117397Skan * 74117397Skan * from: Utah $Hdr: cpu.h 1.16 91/03/25$ 75117397Skan * 76169691Skan * @(#)cpu.h 8.4 (Berkeley) 1/5/94 77132720Skan */ 78169691Skan 79169691Skan#ifndef _X68K_CPU_H_ 80132720Skan#define _X68K_CPU_H_ 81169691Skan 82169691Skan#if defined(_KERNEL) 83132720Skan 84132720Skan/* 85132720Skan * Exported definitions unique to x68k/68k cpu support. 86117397Skan */ 87117397Skan 88132720Skan#if defined(_KERNEL_OPT) 89117397Skan#include "opt_m68k_arch.h" 90169691Skan#include "opt_lockdebug.h" 91169691Skan#endif 92117397Skan 93117397Skan/* 94169691Skan * Get common m68k CPU definitions. 95169691Skan */ 96169691Skan#include <m68k/cpu.h> 97169691Skan#define M68K_MMU_MOTOROLA 98169691Skan 99169691Skan/* 100169691Skan * Get interrupt glue. 101117397Skan */ 102117397Skan#include <machine/intr.h> 103169691Skan 104117397Skan#include <sys/cpu_data.h> 105132720Skanstruct cpu_info { 106117397Skan struct cpu_data ci_data; /* MI per-cpu data */ 107169691Skan cpuid_t ci_cpuid; 108169691Skan int ci_mtx_count; 109117397Skan int ci_mtx_oldspl; 110117397Skan int ci_want_resched; 111117397Skan}; 112132720Skan 113132720Skanextern struct cpu_info cpu_info_store; 114169691Skan 115117397Skan#define curcpu() (&cpu_info_store) 116117397Skan 117132720Skan/* 118117397Skan * definitions of cpu-dependent requirements 119169691Skan * referenced in generic code 120169691Skan */ 121117397Skan#define cpu_number() 0 122117397Skan 123169691Skanvoid cpu_proc_fork(struct proc *, struct proc *); 124169691Skan 125169691Skan/* 126117397Skan * Arguments to hardclock and gatherstats encapsulate the previous 127117397Skan * machine state in an opaque clockframe. One the x68k, we use 128132720Skan * what the hardware pushes on an interrupt (frame format 0). 129117397Skan */ 130169691Skanstruct clockframe { 131169691Skan u_short sr; /* sr at time of interrupt */ 132169691Skan u_long pc; /* pc at time of interrupt */ 133117397Skan u_short vo; /* vector offset (4-word frame) */ 134117397Skan}; 135169691Skan 136169691Skan#define CLKF_USERMODE(framep) (((framep)->sr & PSL_S) == 0) 137169691Skan#define CLKF_PC(framep) ((framep)->pc) 138169691Skan#if 0 139169691Skan/* We would like to do it this way... */ 140169691Skan#define CLKF_INTR(framep) (((framep)->sr & PSL_M) == 0) 141169691Skan#else 142169691Skan/* but until we start using PSL_M, we have to do this instead */ 143169691Skan#define CLKF_INTR(framep) (0) /* XXX */ 144169691Skan#endif 145169691Skan 146169691Skan 147169691Skan/* 148169691Skan * Preempt the current process if in interrupt from user mode, 149169691Skan * or after the current trap/syscall if in system mode. 150169691Skan */ 151169691Skan#define cpu_need_resched(ci, flags) \ 152169691Skan do { (ci)->ci_want_resched = 1; aston(); } while (/* CONSTCOND */ 0) 153169691Skan 154169691Skan/* 155169691Skan * Give a profiling tick to the current process when the user profiling 156169691Skan * buffer pages are invalid. On the x68k, request an ast to send us 157169691Skan * through trap, marking the proc as needing a profiling tick. 158169691Skan */ 159169691Skan#define cpu_need_proftick(l) \ 160169691Skan do { (l)->l_pflag |= LP_OWEUPC; aston(); } while (/* CONSTCOND */ 0) 161169691Skan 162169691Skan/* 163169691Skan * Notify the current process (p) that it has a signal pending, 164169691Skan * process as soon as possible. 165117397Skan */ 166117397Skan#define cpu_signotify(l) aston() 167132720Skan 168117397Skanextern int astpending; /* need to trap before returning to user mode */ 169117397Skan#define aston() (astpending++) 170169691Skan 171117397Skan#endif /* _KERNEL */ 172117397Skan 173117397Skan/* 174169691Skan * CTL_MACHDEP definitions. 175169691Skan */ 176169691Skan#define CPU_CONSDEV 1 /* dev_t: console terminal device */ 177169691Skan#define CPU_MAXID 2 /* number of valid machdep ids */ 178117397Skan 179169691Skan/* 180169691Skan * The rest of this should probably be moved to <machine/x68kcpu.h> 181169691Skan * although some of it could probably be put into generic 68k headers. 182169691Skan */ 183169691Skan 184169691Skan#ifdef _KERNEL 185169691Skanextern int machineid; 186117397Skanextern char *intiobase; 187169691Skanextern char *intiolimit; 188117397Skan 189132720Skan/* fpu.c functions */ 190169691Skanint fpu_probe(void); 191169691Skan 192169691Skan/* machdep.c functions */ 193169691Skanvoid dumpsys(void); 194169691Skan 195169691Skan/* locore.s functions */ 196117397Skanstruct fpframe; 197169691Skanint suline(void *, void *); 198169691Skanvoid loadustp(int); 199169691Skanvoid m68881_save(struct fpframe *); 200169691Skanvoid m68881_restore(struct fpframe *); 201169691Skan 202169691Skan/* machdep.c functions */ 203169691Skanint badaddr(volatile void*); 204169691Skanint badbaddr(volatile void*); 205117397Skan 206169691Skan#endif 207169691Skan 208169691Skan/* physical memory sections */ 209169691Skan#define INTIOBASE (0x00C00000) 210169691Skan#define INTIOTOP (0x01000000) 211169691Skan 212169691Skan/* 213117397Skan * Internal IO space: 214169691Skan * 215169691Skan * Ranges from 0xC00000 to 0x1000000 (IIOMAPSIZE). 216169691Skan * 217169691Skan * Internal IO space is mapped in the kernel from ``IODEVbase'' to 218169691Skan * ``intiolimit'' (defined in locore.s). Since it is always mapped, 219169691Skan * conversion between physical and kernel virtual addresses is easy. 220169691Skan */ 221169691Skan#define IIOV(pa) ((u_int)(pa) - INTIOBASE + (u_int)intiobase) 222169691Skan#define IIOP(va) ((u_int)(va) - (u_int)intiobase + INTIOBASE) 223169691Skan#define IIOPOFF(pa) ((int)(pa)-INTIOBASE) 224169691Skan#define IIOMAPSIZE btoc(INTIOTOP-INTIOBASE) /* 4mb */ 225169691Skan 226169691Skan#endif /* _X68K_CPU_H_ */ 227169691Skan