cpu.h revision 115913
166458Sdfr/* $FreeBSD: head/sys/ia64/include/cpu.h 115913 2003-06-06 23:27:18Z marcel $ */
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#include <machine/frame.h>
5066458Sdfr
5166458Sdfr/*
52115084Smarcel * Arguments to hardclock and gatherstats encapsulate the previous machine
53115084Smarcel * state in an opaque clockframe.
5466458Sdfr */
5566458Sdfrstruct clockframe {
56115084Smarcel	struct trapframe cf_tf;
5766458Sdfr};
58115084Smarcel#define	CLKF_PC(cf)		((cf)->cf_tf.tf_special.iip)
59115084Smarcel#define	CLKF_USERMODE(cf)	((CLKF_PC(cf) >> 61) < 5)
60115084Smarcel
61115084Smarcel/* Used by signaling code. */
62115084Smarcel#define	cpu_getstack(td)	((td)->td_frame->tf_special.sp)
63115084Smarcel
64115084Smarcel#define	TRAPF_PC(tf)		((tf)->tf_special.iip)
65115913Smarcel#define	TRAPF_CPL(tf)		((tf)->tf_special.psr & IA64_PSR_CPL)
66115913Smarcel/*
67115913Smarcel * User mode for use by ast() and VM faults. It's takes into account
68115913Smarcel * that the gateway page is kernel space when looking at the VA, but
69115913Smarcel * is to be treated as user space when running with user priveleges.
70115913Smarcel */
71115913Smarcel#define	TRAPF_USERMODE(tf)	\
72115913Smarcel	((TRAPF_PC(tf) >> 61) < 5 || TRAPF_CPL(tf) == IA64_PSR_CPL_USER)
7372892Sjhb
7466458Sdfr/*
7566458Sdfr * CTL_MACHDEP definitions.
7666458Sdfr */
7766458Sdfr#define	CPU_CONSDEV		1	/* dev_t: console terminal device */
7866458Sdfr#define	CPU_ROOT_DEVICE		2	/* string: root device name */
79115378Smarcel#define	CPU_BOOTED_KERNEL	3	/* string: booted kernel name */
80115378Smarcel#define	CPU_ADJKERNTZ		4	/* int:	timezone offset	(seconds) */
81115378Smarcel#define	CPU_DISRTCSET		5	/* int: disable resettodr() call */
82115378Smarcel#define	CPU_WALLCLOCK		6	/* int:	indicates wall CMOS clock */
83115378Smarcel#define	CPU_MAXID		7	/* valid machdep IDs */
8466458Sdfr
8566458Sdfr#define	CTL_MACHDEP_NAMES { \
8666458Sdfr	{ 0, 0 }, \
8766458Sdfr	{ "console_device", CTLTYPE_STRUCT }, \
8866458Sdfr	{ "root_device", CTLTYPE_STRING }, \
8966458Sdfr	{ "booted_kernel", CTLTYPE_STRING }, \
9066458Sdfr	{ "adjkerntz", CTLTYPE_INT }, \
9166458Sdfr	{ "disable_rtc_set", CTLTYPE_INT }, \
9266458Sdfr	{ "wall_cmos_clock", CTLTYPE_INT }, \
9366458Sdfr}
9466458Sdfr
9566458Sdfr#ifdef _KERNEL
9666458Sdfr
9766458Sdfrstruct pcb;
9883366Sjulianstruct thread;
9966458Sdfrstruct reg;
10066458Sdfrstruct rpb;
10166458Sdfrstruct trapframe;
10266458Sdfr
10366458Sdfrextern struct rpb *hwrpb;
10466458Sdfrextern volatile int mc_expected, mc_received;
10566458Sdfr
106115084Smarcelint	badaddr(void *, size_t);
10792843Salfredint	badaddr_read(void *, size_t, void *);
10892843Salfredu_int64_t console_restart(u_int64_t, u_int64_t, u_int64_t);
109115084Smarcelint	do_ast(struct trapframe *);
11092843Salfredvoid	dumpconf(void);
11192843Salfredvoid	frametoreg(struct trapframe *, struct reg *);
11292843Salfredlong	fswintrberr(void);				/* MAGIC */
113115084Smarcelint	ia64_highfp_drop(struct thread *);
114115084Smarcelint	ia64_highfp_load(struct thread *);
115115084Smarcelint	ia64_highfp_save(struct thread *);
116115276Smarcelvoid	ia64_init(void);
11792843Salfredint	ia64_pa_access(u_long);
11892843Salfredvoid	init_prom_interface(struct rpb*);
11992843Salfredvoid	interrupt(u_int64_t, struct trapframe *);
120115084Smarcelvoid	machine_check(unsigned long, struct trapframe *, unsigned long,
121115084Smarcel    unsigned long);
12292843Salfredu_int64_t hwrpb_checksum(void);
12392843Salfredvoid	hwrpb_restart_setup(void);
12492843Salfredvoid	regdump(struct trapframe *);
12592843Salfredvoid	regtoframe(struct reg *, struct trapframe *);
12692843Salfredvoid	set_iointr(void (*)(void *, unsigned long));
12792843Salfredvoid	fork_trampoline(void);				/* MAGIC */
128115084Smarcelint	syscall(struct trapframe *);
129115084Smarcelvoid	trap(int vector, struct trapframe *framep);
13092675Spetervoid	ia64_probe_sapics(void);
13196442Smarcelint	ia64_count_cpus(void);
132115084Smarcelvoid	map_gateway_page(void);
13392675Spetervoid	map_pal_code(void);
134107206Smarcelvoid	map_port_space(void);
13592675Spetervoid	cpu_mp_add(uint, uint, uint);
13666458Sdfr
13769003Smarkm/*
13869003Smarkm * Return contents of in-cpu fast counter as a sort of "bogo-time"
13969003Smarkm * for non-critical timing.
14069003Smarkm */
14169003Smarkmstatic __inline u_int64_t
14269003Smarkmget_cyclecount(void)
14369003Smarkm{
14469003Smarkm	return (ia64_get_itc());
14569003Smarkm}
14669003Smarkm
14766458Sdfr#endif /* _KERNEL */
14866458Sdfr
14966458Sdfr#endif /* _MACHINE_CPU_H_ */
150