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