cpu.h revision 72988
1/* $FreeBSD: head/sys/ia64/include/cpu.h 72988 2001-02-24 18:57:34Z jhb $ */ 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#define cpu_getstack(p) ((p)->p_md.md_tf->tf_r[FRAME_SP]) 56 57/* 58 * Arguments to hardclock and gatherstats encapsulate the previous 59 * machine state in an opaque clockframe. One the Alpha, we use 60 * what we push on an interrupt (a trapframe). 61 */ 62struct clockframe { 63 struct trapframe cf_tf; 64}; 65#define TRAPF_USERMODE(framep) \ 66 (((framep)->tf_cr_ipsr & IA64_PSR_CPL) == IA64_PSR_CPL_USER) 67#define TRAPF_PC(framep) ((framep)->tf_cr_iip) 68 69#define CLKF_USERMODE(framep) TRAPF_USERMODE(&(framep)->cf_tf) 70#define CLKF_PC(framep) TRAPF_PC(&(framep)->cf_tf) 71#define CLKF_BASEPRI(framep) \ 72 (((framep)->cf_tf.tf_cr_ipsr & IA64_PSR_I) == 0) 73#define CLKF_INTR(framep) (curproc->p_intr_nesting_level >= 2) 74 75/* 76 * Give a profiling tick to the current process when the user profiling 77 * buffer pages are invalid. On the hp300, request an ast to send us 78 * through trap, marking the proc as needing a profiling tick. 79 */ 80#define need_proftick(p) do { \ 81 mtx_lock_spin(&sched_lock); \ 82 (p)->p_sflag |= PS_OWEUPC; \ 83 aston((p)); \ 84 mtx_unlock_spin(&sched_lock); \ 85} while (0) 86 87 88/* 89 * CTL_MACHDEP definitions. 90 */ 91#define CPU_CONSDEV 1 /* dev_t: console terminal device */ 92#define CPU_ROOT_DEVICE 2 /* string: root device name */ 93#define CPU_UNALIGNED_PRINT 3 /* int: print unaligned accesses */ 94#define CPU_UNALIGNED_FIX 4 /* int: fix unaligned accesses */ 95#define CPU_UNALIGNED_SIGBUS 5 /* int: SIGBUS unaligned accesses */ 96#define CPU_BOOTED_KERNEL 6 /* string: booted kernel name */ 97#define CPU_ADJKERNTZ 7 /* int: timezone offset (seconds) */ 98#define CPU_DISRTCSET 8 /* int: disable resettodr() call */ 99#define CPU_WALLCLOCK 9 /* int: indicates wall CMOS clock */ 100#define CPU_MAXID 9 /* 9 valid machdep IDs */ 101 102#define CTL_MACHDEP_NAMES { \ 103 { 0, 0 }, \ 104 { "console_device", CTLTYPE_STRUCT }, \ 105 { "root_device", CTLTYPE_STRING }, \ 106 { "unaligned_print", CTLTYPE_INT }, \ 107 { "unaligned_fix", CTLTYPE_INT }, \ 108 { "unaligned_sigbus", CTLTYPE_INT }, \ 109 { "booted_kernel", CTLTYPE_STRING }, \ 110 { "adjkerntz", CTLTYPE_INT }, \ 111 { "disable_rtc_set", CTLTYPE_INT }, \ 112 { "wall_cmos_clock", CTLTYPE_INT }, \ 113} 114 115#ifdef _KERNEL 116 117struct pcb; 118struct proc; 119struct reg; 120struct rpb; 121struct trapframe; 122 123extern struct rpb *hwrpb; 124extern volatile int mc_expected, mc_received; 125 126void ast __P((struct trapframe *)); 127int badaddr __P((void *, size_t)); 128int badaddr_read __P((void *, size_t, void *)); 129void child_return __P((struct proc *p)); 130u_int64_t console_restart __P((u_int64_t, u_int64_t, u_int64_t)); 131void do_sir __P((void)); 132void dumpconf __P((void)); 133void exception_restore __P((void)); /* MAGIC */ 134void frametoreg __P((struct trapframe *, struct reg *)); 135long fswintrberr __P((void)); /* MAGIC */ 136int ia64_pa_access __P((u_long)); 137void ia64_init __P((void)); 138void ia64_fpstate_check __P((struct proc *p)); 139void ia64_fpstate_save __P((struct proc *p, int write)); 140void ia64_fpstate_drop __P((struct proc *p)); 141void ia64_fpstate_switch __P((struct proc *p)); 142void init_prom_interface __P((struct rpb*)); 143void interrupt __P((u_int64_t, struct trapframe *)); 144void machine_check 145 __P((unsigned long, struct trapframe *, unsigned long, unsigned long)); 146u_int64_t hwrpb_checksum __P((void)); 147void hwrpb_restart_setup __P((void)); 148void regdump __P((struct trapframe *)); 149void regtoframe __P((struct reg *, struct trapframe *)); 150int savectx __P((struct pcb *)); 151void restorectx __P((struct pcb *)); 152void set_iointr __P((void (*)(void *, unsigned long))); 153void switch_exit __P((struct proc *)); /* MAGIC */ 154void fork_trampoline __P((void)); /* MAGIC */ 155void syscall __P((int, u_int64_t *, struct trapframe *)); 156void trap __P((int vector, int imm, struct trapframe *framep)); 157 158/* 159 * Return contents of in-cpu fast counter as a sort of "bogo-time" 160 * for non-critical timing. 161 */ 162static __inline u_int64_t 163get_cyclecount(void) 164{ 165 return (ia64_get_itc()); 166} 167 168#endif /* _KERNEL */ 169 170#endif /* _MACHINE_CPU_H_ */ 171