cpu.h revision 96442
166458Sdfr/* $FreeBSD: head/sys/ia64/include/cpu.h 96442 2002-05-12 05:54:21Z 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/*
5066458Sdfr * Exported definitions unique to Alpha cpu support.
5166458Sdfr */
5266458Sdfr
5366458Sdfr#include <machine/frame.h>
5466458Sdfr
5583366Sjulian#define	cpu_getstack(td)	((td)->td_frame->tf_r[FRAME_SP])
5669379Smarcel
5766458Sdfr/*
5866458Sdfr * Arguments to hardclock and gatherstats encapsulate the previous
5966458Sdfr * machine state in an opaque clockframe.  One the Alpha, we use
6066458Sdfr * what we push on an interrupt (a trapframe).
6166458Sdfr */
6266458Sdfrstruct clockframe {
6366458Sdfr	struct trapframe	cf_tf;
6466458Sdfr};
6572892Sjhb#define	TRAPF_USERMODE(framep)						\
6672892Sjhb	(((framep)->tf_cr_ipsr & IA64_PSR_CPL) == IA64_PSR_CPL_USER)
6772892Sjhb#define	TRAPF_PC(framep)	((framep)->tf_cr_iip)
6872892Sjhb
6972892Sjhb#define	CLKF_USERMODE(framep)	TRAPF_USERMODE(&(framep)->cf_tf)
7072988Sjhb#define	CLKF_PC(framep)		TRAPF_PC(&(framep)->cf_tf)
7166458Sdfr
7266458Sdfr/*
7366458Sdfr * CTL_MACHDEP definitions.
7466458Sdfr */
7566458Sdfr#define	CPU_CONSDEV		1	/* dev_t: console terminal device */
7666458Sdfr#define	CPU_ROOT_DEVICE		2	/* string: root device name */
7766458Sdfr#define	CPU_UNALIGNED_PRINT	3	/* int: print unaligned accesses */
7866458Sdfr#define	CPU_UNALIGNED_FIX	4	/* int: fix unaligned accesses */
7966458Sdfr#define	CPU_UNALIGNED_SIGBUS	5	/* int: SIGBUS unaligned accesses */
8066458Sdfr#define	CPU_BOOTED_KERNEL	6	/* string: booted kernel name */
8166458Sdfr#define	CPU_ADJKERNTZ		7	/* int:	timezone offset	(seconds) */
8266458Sdfr#define	CPU_DISRTCSET		8	/* int: disable resettodr() call */
8366458Sdfr#define	CPU_WALLCLOCK		9	/* int:	indicates wall CMOS clock */
8466458Sdfr#define	CPU_MAXID		9	/* 9 valid machdep IDs */
8566458Sdfr
8666458Sdfr#define	CTL_MACHDEP_NAMES { \
8766458Sdfr	{ 0, 0 }, \
8866458Sdfr	{ "console_device", CTLTYPE_STRUCT }, \
8966458Sdfr	{ "root_device", CTLTYPE_STRING }, \
9066458Sdfr	{ "unaligned_print", CTLTYPE_INT }, \
9166458Sdfr	{ "unaligned_fix", CTLTYPE_INT }, \
9266458Sdfr	{ "unaligned_sigbus", CTLTYPE_INT }, \
9366458Sdfr	{ "booted_kernel", CTLTYPE_STRING }, \
9466458Sdfr	{ "adjkerntz", CTLTYPE_INT }, \
9566458Sdfr	{ "disable_rtc_set", CTLTYPE_INT }, \
9666458Sdfr	{ "wall_cmos_clock", CTLTYPE_INT }, \
9766458Sdfr}
9866458Sdfr
9966458Sdfr#ifdef _KERNEL
10066458Sdfr
10166458Sdfrstruct pcb;
10283366Sjulianstruct thread;
10366458Sdfrstruct reg;
10466458Sdfrstruct rpb;
10566458Sdfrstruct trapframe;
10666458Sdfr
10766458Sdfrextern struct rpb *hwrpb;
10866458Sdfrextern volatile int mc_expected, mc_received;
10966458Sdfr
11092843Salfredint	badaddr	(void *, size_t);
11192843Salfredint	badaddr_read(void *, size_t, void *);
11292843Salfredu_int64_t console_restart(u_int64_t, u_int64_t, u_int64_t);
11392843Salfredvoid	do_sir(void);
11492843Salfredvoid	dumpconf(void);
11592843Salfredvoid	exception_restore(void);				/* MAGIC */
11692843Salfredvoid	frametoreg(struct trapframe *, struct reg *);
11792843Salfredlong	fswintrberr(void);				/* MAGIC */
11892843Salfredint	ia64_pa_access(u_long);
11992843Salfredvoid	ia64_init(u_int64_t, u_int64_t);
12092843Salfredvoid	ia64_fpstate_check(struct thread *p);
12192843Salfredvoid	ia64_fpstate_save(struct thread *p, int write);
12292843Salfredvoid	ia64_fpstate_drop(struct thread *p);
12392843Salfredvoid	ia64_fpstate_switch(struct thread *p);
12492843Salfredvoid	init_prom_interface(struct rpb*);
12592843Salfredvoid	interrupt(u_int64_t, struct trapframe *);
12666458Sdfrvoid	machine_check
12792843Salfred	(unsigned long, struct trapframe *, unsigned long, unsigned long);
12892843Salfredu_int64_t hwrpb_checksum(void);
12992843Salfredvoid	hwrpb_restart_setup(void);
13092843Salfredvoid	regdump(struct trapframe *);
13192843Salfredvoid	regtoframe(struct reg *, struct trapframe *);
13292843Salfredint	savectx(struct pcb *);
13392843Salfredvoid	restorectx(struct pcb *);
13492843Salfredvoid	set_iointr(void (*)(void *, unsigned long));
13592843Salfredvoid	fork_trampoline(void);				/* MAGIC */
13692843Salfredvoid	syscall(int, u_int64_t *, struct trapframe *);
13792843Salfredvoid	trap(int vector, int imm, struct trapframe *framep);
13892675Spetervoid	ia64_probe_sapics(void);
13996442Smarcelint	ia64_count_cpus(void);
14092675Spetervoid	map_pal_code(void);
14192675Spetervoid	cpu_mp_add(uint, uint, uint);
14266458Sdfr
14369003Smarkm/*
14469003Smarkm * Return contents of in-cpu fast counter as a sort of "bogo-time"
14569003Smarkm * for non-critical timing.
14669003Smarkm */
14769003Smarkmstatic __inline u_int64_t
14869003Smarkmget_cyclecount(void)
14969003Smarkm{
15069003Smarkm	return (ia64_get_itc());
15169003Smarkm}
15269003Smarkm
15366458Sdfr#endif /* _KERNEL */
15466458Sdfr
15566458Sdfr#endif /* _MACHINE_CPU_H_ */
156