Home | History | Annotate | Line # | Download | only in include
cpu.h revision 1.8
      1 /*	$NetBSD: cpu.h,v 1.8 2000/05/26 21:20:14 thorpej Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1990 The Regents of the University of California.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to Berkeley by
      8  * William Jolitz.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *	This product includes software developed by the University of
     21  *	California, Berkeley and its contributors.
     22  * 4. Neither the name of the University nor the names of its contributors
     23  *    may be used to endorse or promote products derived from this software
     24  *    without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     36  * SUCH DAMAGE.
     37  *
     38  *	@(#)cpu.h	5.4 (Berkeley) 5/9/91
     39  */
     40 
     41 /*
     42  * SH3 Version
     43  *
     44  *  T.Horiuchi    Brains Corp.   5/22/98
     45  */
     46 
     47 #ifndef _SH3_CPU_H_
     48 #define _SH3_CPU_H_
     49 
     50 #if defined(_KERNEL) && !defined(_LKM)
     51 #include "opt_lockdebug.h"
     52 #endif
     53 
     54 /*
     55  * Definitions unique to sh3 cpu support.
     56  */
     57 #include <machine/psl.h>
     58 #include <machine/frame.h>
     59 #include <machine/segments.h>
     60 
     61 #include <sys/sched.h>
     62 struct cpu_info {
     63 	struct schedstate_percpu ci_schedstate; /* scheduler state */
     64 #if defined(DIAGNOSTIC) || defined(LOCKDEBUG)
     65 	u_long ci_spin_locks;		/* # of spin locks held */
     66 	u_long ci_simple_locks;		/* # of simple locks held */
     67 #endif
     68 };
     69 
     70 #ifdef _KERNEL
     71 extern struct cpu_info cpu_info_store;
     72 
     73 #define	curcpu()			(&cpu_info_store)
     74 #endif
     75 
     76 /*
     77  * definitions of cpu-dependent requirements
     78  * referenced in generic code
     79  */
     80 #define	cpu_swapin(p)			/* nothing */
     81 #define	cpu_wait(p)			/* nothing */
     82 #define	cpu_number()			0
     83 
     84 /*
     85  * Arguments to hardclock, softclock and statclock
     86  * encapsulate the previous machine state in an opaque
     87  * clockframe; for now, use generic intrframe.
     88  *
     89  * XXX intrframe has a lot of gunk we don't need.
     90  */
     91 #define clockframe intrframe
     92 
     93 #if 1
     94 #define	CLKF_USERMODE(frame)	(!KERNELMODE((frame)->if_r15))
     95 #else
     96 #define	CLKF_USERMODE(frame)	USERMODE((frame)->if_spc, (frame)->if_ssr)
     97 #endif
     98 #if 0
     99 #define	CLKF_BASEPRI(frame)	((frame)->if_pri == 0)
    100 #else
    101 /* XXX we should fix this */
    102 #define	CLKF_BASEPRI(frame)	(0)
    103 #endif
    104 #define	CLKF_PC(frame)		((frame)->if_spc)
    105 #define	CLKF_INTR(frame)	(0)	/* XXX should have an interrupt stack */
    106 
    107 /*
    108  * Preempt the current process if in interrupt from user mode,
    109  * or after the current trap/syscall if in system mode.
    110  */
    111 int	want_resched;		/* resched() was called */
    112 #define	need_resched()		(want_resched = 1, setsoftast())
    113 
    114 /*
    115  * Give a profiling tick to the current process when the user profiling
    116  * buffer pages are invalid.  On the i386, request an ast to send us
    117  * through trap(), marking the proc as needing a profiling tick.
    118  */
    119 #define	need_proftick(p)	((p)->p_flag |= P_OWEUPC, setsoftast())
    120 
    121 /*
    122  * Notify the current process (p) that it has a signal pending,
    123  * process as soon as possible.
    124  */
    125 #define	signotify(p)		setsoftast()
    126 
    127 /*
    128  * We need a machine-independent name for this.
    129  */
    130 #define	DELAY(x)		delay(x)
    131 void	delay __P((int));
    132 
    133 /*
    134  * Logical address space of SH3 CPU.
    135  */
    136 #define SH3_P0SEG_BASE	0x00000000
    137 #define SH3_P0SEG_END	0x7fffffff
    138 #define SH3_P1SEG_BASE	0x80000000	/* pa == va */
    139 #define SH3_P1SEG_END	0x9fffffff
    140 #define SH3_P2SEG_BASE	0xa0000000	/* pa == va, non-cacheable */
    141 #define SH3_P2SEG_END	0xbfffffff
    142 #define SH3_P3SEG_BASE	0xc0000000
    143 #define SH3_P3SEG_END	0xdfffffff
    144 #define SH3_P4SEG_BASE	0xe0000000
    145 #define SH3_P4SEG_END	0xffffffff
    146 
    147 #define SH3_PHYS_MASK	0x1fffffff
    148 #define SH3_P1234SEG_SIZE	0x20000000
    149 
    150 #define SH3_P1SEG_TO_PHYS(x)	((unsigned)(x) & SH3_PHYS_MASK)
    151 #define SH3_P2SEG_TO_PHYS(x)	((unsigned)(x) & SH3_PHYS_MASK)
    152 #define SH3_PHYS_TO_P1SEG(x)	((unsigned)(x) | SH3_P1SEG_BASE)
    153 #define SH3_PHYS_TO_P2SEG(x)	((unsigned)(x) | SH3_P2SEG_BASE)
    154 #define SH3_P1SEG_TO_P2SEG(x)	((unsigned)(x) | SH3_P1234SEG_SIZE)
    155 
    156 /*
    157  * pull in #defines for kinds of processors
    158  */
    159 #include <machine/cputypes.h>
    160 
    161 
    162 #ifdef _KERNEL
    163 extern int cpu;
    164 extern int cpu_class;
    165 extern struct cpu_nocpuid_nameclass sh3_nocpuid_cpus[];
    166 extern struct cpu_cpuid_nameclass sh3_cpuid_cpus[];
    167 
    168 /* autoconf.c */
    169 void	configure __P((void));
    170 
    171 /* sh3_machdep.c */
    172 void sh3_startup __P((void));
    173 
    174 /* machdep.c */
    175 void	delay __P((int));
    176 void	dumpconf __P((void));
    177 void	cpu_reset __P((void));
    178 
    179 /* locore.s */
    180 struct region_descriptor;
    181 void	lgdt __P((struct region_descriptor *));
    182 void	fillw __P((short, void *, size_t));
    183 void
    184 bcopyb  __P((caddr_t from, caddr_t to, size_t len));
    185 void
    186 bcopyw __P((caddr_t from, caddr_t to, size_t len));
    187 void
    188 setPageDirReg __P((int pgdir));
    189 
    190 
    191 struct pcb;
    192 void	savectx __P((struct pcb *));
    193 void	switch_exit __P((struct proc *));
    194 void	proc_trampoline __P((void));
    195 
    196 /* clock.c */
    197 void	startrtclock __P((void));
    198 
    199 /* npx.c */
    200 void	npxdrop __P((void));
    201 void	npxsave __P((void));
    202 
    203 /* vm_machdep.c */
    204 int kvtop __P((caddr_t));
    205 
    206 #ifdef MATH_EMULATE
    207 /* math_emulate.c */
    208 int	math_emulate __P((struct trapframe *));
    209 #endif
    210 
    211 
    212 /* trap.c */
    213 void	child_return __P((struct proc *, int, int, int, struct trapframe));
    214 
    215 #endif /* _KERNEL */
    216 
    217 /*
    218  * CTL_MACHDEP definitions.
    219  */
    220 #define	CPU_CONSDEV		1	/* dev_t: console terminal device */
    221 #define	CPU_NKPDE		2	/* int: number of kernel PDEs */
    222 #define	CPU_BOOTED_KERNEL	3	/* string: booted kernel name */
    223 #define	CPU_SETPRIVPROC		4	/* set current proc to piviledged proc
    224 					   */
    225 #define	CPU_DEBUGMODE		5	/* set debug mode */
    226 #define	CPU_LOADANDRESET	6	/* load kernel image and reset */
    227 #define	CPU_MAXID		7	/* number of valid machdep ids */
    228 
    229 #define	CTL_MACHDEP_NAMES { \
    230 	{ 0, 0 }, \
    231 	{ "console_device", CTLTYPE_STRUCT }, \
    232 	{ "nkpde", CTLTYPE_INT }, \
    233 	{ "booted_kernel", CTLTYPE_STRING }, \
    234 	{ "set_priv_proc", CTLTYPE_INT }, \
    235 	{ "debug_mode", CTLTYPE_INT }, \
    236 	{ "load_and_reset", CTLTYPE_INT }, \
    237 }
    238 
    239 #endif /* !_SH3_CPU_H_ */
    240