cpu.h revision 66937
1/* $FreeBSD: head/sys/ia64/include/cpu.h 66937 2000-10-10 14:57:10Z dfr $ */
2/* From: NetBSD: cpu.h,v 1.18 1997/09/23 23:17:49 mjacob Exp */
3
4/*
5 * Copyright (c) 1988 University of Utah.
6 * Copyright (c) 1982, 1990, 1993
7 *	The Regents of the University of California.  All rights reserved.
8 *
9 * This code is derived from software contributed to Berkeley by
10 * the Systems Programming Group of the University of Utah Computer
11 * Science Department.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 *    notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 *    notice, this list of conditions and the following disclaimer in the
20 *    documentation and/or other materials provided with the distribution.
21 * 3. All advertising materials mentioning features or use of this software
22 *    must display the following acknowledgement:
23 *	This product includes software developed by the University of
24 *	California, Berkeley and its contributors.
25 * 4. Neither the name of the University nor the names of its contributors
26 *    may be used to endorse or promote products derived from this software
27 *    without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 * SUCH DAMAGE.
40 *
41 * from: Utah $Hdr: cpu.h 1.16 91/03/25$
42 *
43 *	@(#)cpu.h	8.4 (Berkeley) 1/5/94
44 */
45
46#ifndef _MACHINE_CPU_H_
47#define _MACHINE_CPU_H_
48
49/*
50 * Exported definitions unique to Alpha cpu support.
51 */
52
53#include <machine/frame.h>
54
55/*
56 * Arguments to hardclock and gatherstats encapsulate the previous
57 * machine state in an opaque clockframe.  One the Alpha, we use
58 * what we push on an interrupt (a trapframe).
59 */
60struct clockframe {
61	struct trapframe	cf_tf;
62};
63#define	CLKF_USERMODE(framep)						\
64	(((framep)->cf_tf.tf_cr_ipsr & IA64_PSR_CPL) == IA64_PSR_CPL_USER)
65#define	CLKF_BASEPRI(framep)						\
66	(((framep)->cf_tf.tf_cr_ipsr & IA64_PSR_I) == 0)
67#define	CLKF_PC(framep)		((framep)->cf_tf.tf_cr_iip)
68#define	CLKF_INTR(framep)	(PCPU_GET(intr_nesting_level) >= 2)
69
70/*
71 * Preempt the current process if in interrupt from user mode,
72 * or after the current trap/syscall if in system mode.
73 */
74#define	need_resched()		do { want_resched = 1; aston(); } while (0)
75
76#define	resched_wanted()	want_resched
77
78/*
79 * Give a profiling tick to the current process when the user profiling
80 * buffer pages are invalid.  On the hp300, request an ast to send us
81 * through trap, marking the proc as needing a profiling tick.
82 */
83#define	need_proftick(p) \
84	do { (p)->p_flag |= P_OWEUPC; aston(); } while (0)
85
86/*
87 * Notify the current process (p) that it has a signal pending,
88 * process as soon as possible.
89 */
90#define	signotify(p)	aston()
91
92#define	aston()		PCPU_SET(astpending, 1)
93
94#ifdef _KERNEL
95extern u_int32_t want_resched;		/* resched() was called */
96#endif
97
98
99/*
100 * CTL_MACHDEP definitions.
101 */
102#define	CPU_CONSDEV		1	/* dev_t: console terminal device */
103#define	CPU_ROOT_DEVICE		2	/* string: root device name */
104#define	CPU_UNALIGNED_PRINT	3	/* int: print unaligned accesses */
105#define	CPU_UNALIGNED_FIX	4	/* int: fix unaligned accesses */
106#define	CPU_UNALIGNED_SIGBUS	5	/* int: SIGBUS unaligned accesses */
107#define	CPU_BOOTED_KERNEL	6	/* string: booted kernel name */
108#define	CPU_ADJKERNTZ		7	/* int:	timezone offset	(seconds) */
109#define	CPU_DISRTCSET		8	/* int: disable resettodr() call */
110#define	CPU_WALLCLOCK		9	/* int:	indicates wall CMOS clock */
111#define	CPU_MAXID		9	/* 9 valid machdep IDs */
112
113#define	CTL_MACHDEP_NAMES { \
114	{ 0, 0 }, \
115	{ "console_device", CTLTYPE_STRUCT }, \
116	{ "root_device", CTLTYPE_STRING }, \
117	{ "unaligned_print", CTLTYPE_INT }, \
118	{ "unaligned_fix", CTLTYPE_INT }, \
119	{ "unaligned_sigbus", CTLTYPE_INT }, \
120	{ "booted_kernel", CTLTYPE_STRING }, \
121	{ "adjkerntz", CTLTYPE_INT }, \
122	{ "disable_rtc_set", CTLTYPE_INT }, \
123	{ "wall_cmos_clock", CTLTYPE_INT }, \
124}
125
126#ifdef _KERNEL
127
128struct pcb;
129struct proc;
130struct reg;
131struct rpb;
132struct trapframe;
133
134extern struct proc *fpcurproc;
135extern struct rpb *hwrpb;
136extern volatile int mc_expected, mc_received;
137
138void	ast __P((struct trapframe *));
139int	badaddr	__P((void *, size_t));
140int	badaddr_read __P((void *, size_t, void *));
141void	child_return __P((struct proc *p));
142u_int64_t console_restart __P((u_int64_t, u_int64_t, u_int64_t));
143void	do_sir __P((void));
144void	dumpconf __P((void));
145void	exception_return __P((void));				/* MAGIC */
146void	frametoreg __P((struct trapframe *, struct reg *));
147long	fswintrberr __P((void));				/* MAGIC */
148int	ia64_pa_access __P((u_long));
149void	ia64_init __P((void));
150void	ia64_fpstate_check __P((struct proc *p));
151void	ia64_fpstate_save __P((struct proc *p, int write));
152void	ia64_fpstate_drop __P((struct proc *p));
153void	ia64_fpstate_switch __P((struct proc *p));
154void	init_prom_interface __P((struct rpb*));
155void	interrupt
156	__P((unsigned long, unsigned long, unsigned long, struct trapframe *));
157void	machine_check
158	__P((unsigned long, struct trapframe *, unsigned long, unsigned long));
159u_int64_t hwrpb_checksum __P((void));
160void	hwrpb_restart_setup __P((void));
161void	regdump __P((struct trapframe *));
162void	regtoframe __P((struct reg *, struct trapframe *));
163int	savectx __P((struct pcb *));
164void	restorectx __P((struct pcb *));
165void	set_iointr __P((void (*)(void *, unsigned long)));
166void    switch_exit __P((struct proc *));			/* MAGIC */
167void	switch_trampoline __P((void));				/* MAGIC */
168void	syscall __P((u_int64_t, struct trapframe *));
169void	trap __P((int vector, struct trapframe *framep));
170
171#endif /* _KERNEL */
172
173#endif /* _MACHINE_CPU_H_ */
174