add definition for ability to produce a backtrace
[unix-history] / usr / src / sys / sparc / include / cpu.h
CommitLineData
90587a41 1/*
9193edfc
KB
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
90587a41
CT
4 *
5 * This software was developed by the Computer Systems Engineering group
6 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
7 * contributed to Berkeley.
8 *
b480239a
KB
9 * All advertising materials mentioning features or use of this software
10 * must display the following acknowledgement:
11 * This product includes software developed by the University of
062bb472 12 * California, Lawrence Berkeley Laboratory.
b480239a 13 *
90587a41
CT
14 * %sccs.include.redist.c%
15 *
660038a9 16 * @(#)cpu.h 8.5 (Berkeley) %G%
90587a41 17 *
42158806 18 * from: $Header: cpu.h,v 1.12 93/05/25 10:36:34 torek Exp $ (LBL)
90587a41
CT
19 */
20
21#ifndef _CPU_H_
22#define _CPU_H_
23
42158806
CT
24/*
25 * CTL_MACHDEP definitinos.
26 */
27#define CPU_MAXID 1 /* no valid machdep ids */
28
29#define CTL_MACHDEP_NAMES { \
30 { 0, 0 }, \
31}
90587a41 32
42158806 33#ifdef KERNEL
90587a41
CT
34/*
35 * Exported definitions unique to SPARC cpu support.
36 */
37
42158806
CT
38#include <machine/psl.h>
39#include <sparc/sparc/intreg.h>
40
90587a41
CT
41/*
42 * definitions of cpu-dependent requirements
43 * referenced in generic code
44 */
45#define COPY_SIGCODE /* copy sigcode above user stack in exec */
46
301d335f 47#define cpu_exec(p) /* nothing */
0d5163d6 48#define cpu_swapin(p) /* nothing */
301d335f 49#define cpu_wait(p) /* nothing */
90587a41 50#define cpu_setstack(p, ap) ((p)->p_md.md_tf->tf_out[6] = (ap) - 64)
660038a9 51#define BACKTRACE(p) /* not implemented */
90587a41 52
301d335f
KM
53/*
54 * See syscall() for an explanation of the following. Note that the
55 * locore bootstrap code follows the syscall stack protocol. The
56 * framep argument is unused.
57 */
58#define cpu_set_init_frame(p, fp) \
59 (p)->p_md.md_tf = (struct trapframe *) \
60 ((caddr_t)(p)->p_addr + UPAGES * NBPG - sizeof(struct trapframe))
61
90587a41
CT
62/*
63 * Arguments to hardclock, softclock and gatherstats encapsulate the
64 * previous machine state in an opaque clockframe. The ipl is here
65 * as well for strayintr (see locore.s:interrupt and intr.c:strayintr).
66 * Note that CLKF_INTR is valid only if CLKF_USERMODE is false.
67 */
68struct clockframe {
69 u_int psr; /* psr before interrupt, excluding PSR_ET */
70 u_int pc; /* pc at interrupt */
71 u_int npc; /* npc at interrupt */
72 u_int ipl; /* actual interrupt priority level */
73 u_int fp; /* %fp at interrupt */
74};
75
76extern int eintstack[];
77
78#define CLKF_USERMODE(framep) (((framep)->psr & PSR_PS) == 0)
79#define CLKF_BASEPRI(framep) (((framep)->psr & PSR_PIL) == 0)
80#define CLKF_PC(framep) ((framep)->pc)
81#define CLKF_INTR(framep) ((framep)->fp < (u_int)eintstack)
82
83/*
84 * Software interrupt request `register'.
85 */
86union sir {
87 int sir_any;
88 char sir_which[4];
89} sir;
90
91#define SIR_NET 0
92#define SIR_CLOCK 1
93
94#define setsoftint() ienab_bis(IE_L1)
95#define setsoftnet() (sir.sir_which[SIR_NET] = 1, setsoftint())
96#define setsoftclock() (sir.sir_which[SIR_CLOCK] = 1, setsoftint())
97
98int want_ast;
99
100/*
101 * Preempt the current process if in interrupt from user mode,
102 * or after the current trap/syscall if in system mode.
103 */
104int want_resched; /* resched() was called */
105#define need_resched() (want_resched = 1, want_ast = 1)
106
107/*
108 * Give a profiling tick to the current process when the user profiling
109 * buffer pages are invalid. On the sparc, request an ast to send us
110 * through trap(), marking the proc as needing a profiling tick.
111 */
cf5ef508 112#define need_proftick(p) ((p)->p_flag |= P_OWEUPC, want_ast = 1)
90587a41
CT
113
114/*
115 * Notify the current process (p) that it has a signal pending,
116 * process as soon as possible.
117 */
118#define signotify(p) (want_ast = 1)
119
120/*
121 * Only one process may own the FPU state.
122 *
123 * XXX this must be per-cpu (eventually)
124 */
125struct proc *fpproc; /* FPU owner */
126int foundfpu; /* true => we have an FPU */
127
128/*
129 * Interrupt handler chains. Interrupt handlers should return 0 for
130 * ``not me'' or 1 (``I took care of it''). intr_establish() inserts a
131 * handler into the list. The handler is called with its (single)
132 * argument, or with a pointer to a clockframe if ih_arg is NULL.
133 */
134struct intrhand {
135 int (*ih_fun) __P((void *));
136 void *ih_arg;
137 struct intrhand *ih_next;
138} *intrhand[15];
139
140void intr_establish __P((int level, struct intrhand *));
141
142/*
143 * intr_fasttrap() is a lot like intr_establish, but is used for ``fast''
144 * interrupt vectors (vectors that are not shared and are handled in the
145 * trap window). Such functions must be written in assembly.
146 */
147void intr_fasttrap __P((int level, void (*vec)(void)));
148
42158806
CT
149#endif /* KERNEL */
150#endif /* _CPU_H_ */