1/* $NetBSD: alpha.h,v 1.47 2021/07/23 03:50:32 thorpej Exp $ */
2
3/*
4 * Copyright (c) 1988 University of Utah.
5 * Copyright (c) 1982, 1990, 1993
6 *	The Regents of the University of California.  All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by
9 * the Systems Programming Group of the University of Utah Computer
10 * Science Department.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 *    notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 *    notice, this list of conditions and the following disclaimer in the
19 *    documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the University nor the names of its contributors
21 *    may be used to endorse or promote products derived from this software
22 *    without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * from: Utah $Hdr: cpu.h 1.16 91/03/25$
37 *
38 *	@(#)cpu.h	8.4 (Berkeley) 1/5/94
39 */
40
41#ifndef _ALPHA_H_
42#define _ALPHA_H_
43
44typedef union alpha_f_float {
45	uint32_t i;
46	uint32_t frac_hi:  7,
47		     exp:  8,
48		    sign:  1,
49		 frac_lo: 16;
50} f_float;
51
52typedef union alpha_s_float {
53	uint32_t i;
54	uint32_t frac: 23,
55		  exp:  8,
56		 sign:  1;
57} s_float;
58
59typedef union alpha_t_float {
60	uint64_t i;
61	uint64_t frac: 52,
62		  exp: 11,
63		 sign:  1;
64} t_float;
65
66#ifdef _KERNEL
67
68#include <sys/bus.h>
69
70#include <sys/pcu.h>
71
72struct pcb;
73struct lwp;
74struct reg;
75struct rpb;
76struct trapframe;
77
78extern bool alpha_is_qemu;
79extern int alpha_use_cctr;
80extern u_long cpu_implver;		/* from IMPLVER instruction */
81extern u_long cpu_amask;		/* from AMASK instruction */
82extern int bootdev_debug;
83extern int alpha_fp_sync_complete;
84extern int alpha_fp_complete_debug;
85extern int alpha_unaligned_print, alpha_unaligned_fix, alpha_unaligned_sigbus;
86extern void (*alpha_delay_fn)(unsigned long);
87
88void	XentArith(uint64_t, uint64_t, uint64_t);	/* MAGIC */
89void	XentIF(uint64_t, uint64_t, uint64_t);		/* MAGIC */
90void	XentInt(uint64_t, uint64_t, uint64_t);		/* MAGIC */
91void	XentMM(uint64_t, uint64_t, uint64_t);		/* MAGIC */
92void	XentRestart(void);				/* MAGIC */
93void	XentSys(uint64_t, uint64_t, uint64_t);		/* MAGIC */
94void	XentUna(uint64_t, uint64_t, uint64_t);		/* MAGIC */
95void	alpha_init(u_long, u_long, u_long, u_long, u_long);
96void	alpha_page_physload_sheltered(u_long, u_long, u_long, u_long);
97void	ast(struct trapframe *);
98int	badaddr(void *, size_t);
99int	badaddr_read(void *, size_t, void *);
100uint64_t console_restart(struct trapframe *);
101void	do_sir(void);
102void	exception_return(void);				/* MAGIC */
103void	alpha_kthread_backstop(void);			/* MAGIC */
104void	frametoreg(const struct trapframe *, struct reg *);
105void	init_bootstrap_console(void);
106void	init_prom_interface(unsigned long, struct rpb *);
107void	interrupt(unsigned long, unsigned long, unsigned long,
108	    struct trapframe *);
109void	machine_check(unsigned long, struct trapframe *, unsigned long,
110	    unsigned long);
111uint64_t hwrpb_checksum(void);
112void	hwrpb_restart_setup(void);
113void	regdump(struct trapframe *);
114void	regtoframe(const struct reg *, struct trapframe *);
115void	savectx(struct pcb *);
116void	trap(unsigned long, unsigned long, unsigned long, unsigned long,
117	    struct trapframe *);
118void	trap_init(void);
119void	enable_nsio_ide(bus_space_tag_t);
120
121extern const pcu_ops_t fpu_ops;
122
123void    fpu_state_load(struct lwp *, u_int);
124void    fpu_state_save(struct lwp *);
125void    fpu_state_release(struct lwp *);
126
127static __inline bool
128fpu_valid_p(struct lwp *l)
129{
130	return pcu_valid_p(&fpu_ops, l);
131}
132
133static __inline void
134fpu_load(void)
135{
136	pcu_load(&fpu_ops);
137}
138
139static __inline void
140fpu_save(lwp_t *l)
141{
142	pcu_save(&fpu_ops, l);
143}
144
145static __inline void
146fpu_discard(lwp_t *l, bool valid_p)
147{
148	pcu_discard(&fpu_ops, l, valid_p);
149}
150
151void	alpha_patch(bool);
152
153/* Multiprocessor glue; cpu.c */
154
155struct cpu_info;
156int	cpu_iccb_send(long, const char *);
157void	cpu_iccb_receive(void);
158void	cpu_hatch(struct cpu_info *);
159void	cpu_halt(void) __attribute__((__noreturn__));
160void	cpu_spinup_trampoline(void);				/* MAGIC */
161void	cpu_pause(unsigned long);
162void	cpu_resume(unsigned long);
163#if defined(DDB)
164void	cpu_debug_dump(void);
165#endif
166
167/* IEEE and VAX FP completion */
168
169void alpha_sts(int, s_float *);					/* MAGIC */
170void alpha_stt(int, t_float *);					/* MAGIC */
171void alpha_lds(int, s_float *);					/* MAGIC */
172void alpha_ldt(int, t_float *);					/* MAGIC */
173
174uint64_t alpha_read_fpcr(void);					/* MAGIC */
175void alpha_write_fpcr(uint64_t);				/* MAGIC */
176
177uint64_t alpha_read_fp_c(struct lwp *);
178void alpha_write_fp_c(struct lwp *, uint64_t);
179
180int alpha_fp_complete(u_long, u_long, struct lwp *, uint64_t *);
181int alpha_fp_complete_at(u_long, struct lwp *, uint64_t *);
182
183/* Security sensitive rate limiting printf */
184
185void rlprintf(struct timeval *t, const char *fmt, ...);
186
187#endif /* _KERNEL */
188#endif /* _ALPHA_H_ */
189