cpu.h revision 66458
166458Sdfr/* $FreeBSD: head/sys/ia64/include/cpu.h 66458 2000-09-29 13:46:07Z dfr $ */
266458Sdfr/* From: NetBSD: cpu.h,v 1.18 1997/09/23 23:17:49 mjacob Exp */
366458Sdfr
466458Sdfr/*
566458Sdfr * Copyright (c) 1988 University of Utah.
666458Sdfr * Copyright (c) 1982, 1990, 1993
766458Sdfr *	The Regents of the University of California.  All rights reserved.
866458Sdfr *
966458Sdfr * This code is derived from software contributed to Berkeley by
1066458Sdfr * the Systems Programming Group of the University of Utah Computer
1166458Sdfr * Science Department.
1266458Sdfr *
1366458Sdfr * Redistribution and use in source and binary forms, with or without
1466458Sdfr * modification, are permitted provided that the following conditions
1566458Sdfr * are met:
1666458Sdfr * 1. Redistributions of source code must retain the above copyright
1766458Sdfr *    notice, this list of conditions and the following disclaimer.
1866458Sdfr * 2. Redistributions in binary form must reproduce the above copyright
1966458Sdfr *    notice, this list of conditions and the following disclaimer in the
2066458Sdfr *    documentation and/or other materials provided with the distribution.
2166458Sdfr * 3. All advertising materials mentioning features or use of this software
2266458Sdfr *    must display the following acknowledgement:
2366458Sdfr *	This product includes software developed by the University of
2466458Sdfr *	California, Berkeley and its contributors.
2566458Sdfr * 4. Neither the name of the University nor the names of its contributors
2666458Sdfr *    may be used to endorse or promote products derived from this software
2766458Sdfr *    without specific prior written permission.
2866458Sdfr *
2966458Sdfr * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
3066458Sdfr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3166458Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3266458Sdfr * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3366458Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3466458Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3566458Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3666458Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3766458Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3866458Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3966458Sdfr * SUCH DAMAGE.
4066458Sdfr *
4166458Sdfr * from: Utah $Hdr: cpu.h 1.16 91/03/25$
4266458Sdfr *
4366458Sdfr *	@(#)cpu.h	8.4 (Berkeley) 1/5/94
4466458Sdfr */
4566458Sdfr
4666458Sdfr#ifndef _MACHINE_CPU_H_
4766458Sdfr#define _MACHINE_CPU_H_
4866458Sdfr
4966458Sdfr/*
5066458Sdfr * Exported definitions unique to Alpha cpu support.
5166458Sdfr */
5266458Sdfr
5366458Sdfr#include <machine/frame.h>
5466458Sdfr
5566458Sdfr/*
5666458Sdfr * Arguments to hardclock and gatherstats encapsulate the previous
5766458Sdfr * machine state in an opaque clockframe.  One the Alpha, we use
5866458Sdfr * what we push on an interrupt (a trapframe).
5966458Sdfr */
6066458Sdfrstruct clockframe {
6166458Sdfr	struct trapframe	cf_tf;
6266458Sdfr};
6366458Sdfr#define	CLKF_USERMODE(framep)						\
6466458Sdfr	(((framep)->cf_tf.tf_cr_ipsr & IA64_PSR_CPL) == IA64_PSR_CPL_USER)
6566458Sdfr#define	CLKF_BASEPRI(framep)						\
6666458Sdfr	(((framep)->cf_tf.tf_cr_ipsr & IA64_PSR_I) == 0)
6766458Sdfr#define	CLKF_PC(framep)		((framep)->cf_tf.tf_cr_iip)
6866458Sdfr#define	CLKF_INTR(framep)	(intr_nesting_level >= 2)
6966458Sdfr
7066458Sdfr/*
7166458Sdfr * Preempt the current process if in interrupt from user mode,
7266458Sdfr * or after the current trap/syscall if in system mode.
7366458Sdfr */
7466458Sdfr#define	need_resched()		do { want_resched = 1; aston(); } while (0)
7566458Sdfr
7666458Sdfr#define	resched_wanted()	want_resched
7766458Sdfr
7866458Sdfr/*
7966458Sdfr * Give a profiling tick to the current process when the user profiling
8066458Sdfr * buffer pages are invalid.  On the hp300, request an ast to send us
8166458Sdfr * through trap, marking the proc as needing a profiling tick.
8266458Sdfr */
8366458Sdfr#define	need_proftick(p) \
8466458Sdfr	do { (p)->p_flag |= P_OWEUPC; aston(); } while (0)
8566458Sdfr
8666458Sdfr/*
8766458Sdfr * Notify the current process (p) that it has a signal pending,
8866458Sdfr * process as soon as possible.
8966458Sdfr */
9066458Sdfr#define	signotify(p)	aston()
9166458Sdfr
9266458Sdfr#define	aston()		PCPU_SET(astpending, 1)
9366458Sdfr
9466458Sdfr#ifdef _KERNEL
9566458Sdfrextern u_int32_t intr_nesting_level;	/* bookeeping only; counts sw intrs */
9666458Sdfrextern u_int32_t want_resched;		/* resched() was called */
9766458Sdfr#endif
9866458Sdfr
9966458Sdfr
10066458Sdfr/*
10166458Sdfr * CTL_MACHDEP definitions.
10266458Sdfr */
10366458Sdfr#define	CPU_CONSDEV		1	/* dev_t: console terminal device */
10466458Sdfr#define	CPU_ROOT_DEVICE		2	/* string: root device name */
10566458Sdfr#define	CPU_UNALIGNED_PRINT	3	/* int: print unaligned accesses */
10666458Sdfr#define	CPU_UNALIGNED_FIX	4	/* int: fix unaligned accesses */
10766458Sdfr#define	CPU_UNALIGNED_SIGBUS	5	/* int: SIGBUS unaligned accesses */
10866458Sdfr#define	CPU_BOOTED_KERNEL	6	/* string: booted kernel name */
10966458Sdfr#define	CPU_ADJKERNTZ		7	/* int:	timezone offset	(seconds) */
11066458Sdfr#define	CPU_DISRTCSET		8	/* int: disable resettodr() call */
11166458Sdfr#define	CPU_WALLCLOCK		9	/* int:	indicates wall CMOS clock */
11266458Sdfr#define	CPU_MAXID		9	/* 9 valid machdep IDs */
11366458Sdfr
11466458Sdfr#define	CTL_MACHDEP_NAMES { \
11566458Sdfr	{ 0, 0 }, \
11666458Sdfr	{ "console_device", CTLTYPE_STRUCT }, \
11766458Sdfr	{ "root_device", CTLTYPE_STRING }, \
11866458Sdfr	{ "unaligned_print", CTLTYPE_INT }, \
11966458Sdfr	{ "unaligned_fix", CTLTYPE_INT }, \
12066458Sdfr	{ "unaligned_sigbus", CTLTYPE_INT }, \
12166458Sdfr	{ "booted_kernel", CTLTYPE_STRING }, \
12266458Sdfr	{ "adjkerntz", CTLTYPE_INT }, \
12366458Sdfr	{ "disable_rtc_set", CTLTYPE_INT }, \
12466458Sdfr	{ "wall_cmos_clock", CTLTYPE_INT }, \
12566458Sdfr}
12666458Sdfr
12766458Sdfr#ifdef _KERNEL
12866458Sdfr
12966458Sdfrstruct pcb;
13066458Sdfrstruct proc;
13166458Sdfrstruct reg;
13266458Sdfrstruct rpb;
13366458Sdfrstruct trapframe;
13466458Sdfr
13566458Sdfrextern struct proc *fpcurproc;
13666458Sdfrextern struct rpb *hwrpb;
13766458Sdfrextern volatile int mc_expected, mc_received;
13866458Sdfr
13966458Sdfrvoid	ast __P((struct trapframe *));
14066458Sdfrint	badaddr	__P((void *, size_t));
14166458Sdfrint	badaddr_read __P((void *, size_t, void *));
14266458Sdfrvoid	child_return __P((struct proc *p));
14366458Sdfru_int64_t console_restart __P((u_int64_t, u_int64_t, u_int64_t));
14466458Sdfrvoid	do_sir __P((void));
14566458Sdfrvoid	dumpconf __P((void));
14666458Sdfrvoid	exception_return __P((void));				/* MAGIC */
14766458Sdfrvoid	frametoreg __P((struct trapframe *, struct reg *));
14866458Sdfrlong	fswintrberr __P((void));				/* MAGIC */
14966458Sdfrint	ia64_pa_access __P((u_long));
15066458Sdfrvoid	ia64_init __P((void));
15166458Sdfrvoid	ia64_fpstate_check __P((struct proc *p));
15266458Sdfrvoid	ia64_fpstate_save __P((struct proc *p, int write));
15366458Sdfrvoid	ia64_fpstate_drop __P((struct proc *p));
15466458Sdfrvoid	ia64_fpstate_switch __P((struct proc *p));
15566458Sdfrvoid	init_prom_interface __P((struct rpb*));
15666458Sdfrvoid	interrupt
15766458Sdfr	__P((unsigned long, unsigned long, unsigned long, struct trapframe *));
15866458Sdfrvoid	machine_check
15966458Sdfr	__P((unsigned long, struct trapframe *, unsigned long, unsigned long));
16066458Sdfru_int64_t hwrpb_checksum __P((void));
16166458Sdfrvoid	hwrpb_restart_setup __P((void));
16266458Sdfrvoid	regdump __P((struct trapframe *));
16366458Sdfrvoid	regtoframe __P((struct reg *, struct trapframe *));
16466458Sdfrint	savectx __P((struct pcb *));
16566458Sdfrvoid	restorectx __P((struct pcb *));
16666458Sdfrvoid	set_iointr __P((void (*)(void *, unsigned long)));
16766458Sdfrvoid    switch_exit __P((struct proc *));			/* MAGIC */
16866458Sdfrvoid	switch_trampoline __P((void));				/* MAGIC */
16966458Sdfrvoid	syscall __P((u_int64_t, struct trapframe *));
17066458Sdfrvoid	trap __P((int vector, struct trapframe *framep));
17166458Sdfr
17266458Sdfr#endif /* _KERNEL */
17366458Sdfr
17466458Sdfr#endif /* _MACHINE_CPU_H_ */
175