From 1c00236ed922d0b2365e523be77fdc7f5ed0fe80 Mon Sep 17 00:00:00 2001 From: miod Date: Fri, 21 Oct 2022 18:55:42 +0000 Subject: [PATCH] Remove vestigial bits of 32-bit binaries support; drop the `64' suffix in struct names when the matching `32' flavour got removed. Joint work with cheloha@, all bugs mine. --- sys/arch/sparc64/dev/creator.c | 5 +- sys/arch/sparc64/fpu/fpu.c | 30 +++--- sys/arch/sparc64/fpu/fpu_emu.h | 6 +- sys/arch/sparc64/fpu/fpu_extern.h | 10 +- sys/arch/sparc64/include/cpu.h | 20 ++-- sys/arch/sparc64/include/db_machdep.h | 10 +- sys/arch/sparc64/include/frame.h | 77 ++++++++------- sys/arch/sparc64/include/pcb.h | 4 +- sys/arch/sparc64/include/proc.h | 4 +- sys/arch/sparc64/include/reg.h | 108 +------------------- sys/arch/sparc64/sparc64/db_interface.c | 8 +- sys/arch/sparc64/sparc64/db_trace.c | 36 +++---- sys/arch/sparc64/sparc64/emul.c | 6 +- sys/arch/sparc64/sparc64/genassym.cf | 12 +-- sys/arch/sparc64/sparc64/intr.c | 10 +- sys/arch/sparc64/sparc64/locore.s | 4 +- sys/arch/sparc64/sparc64/machdep.c | 58 +++++------ sys/arch/sparc64/sparc64/process_machdep.c | 109 +++++---------------- sys/arch/sparc64/sparc64/trap.c | 42 ++++---- sys/arch/sparc64/sparc64/vm_machdep.c | 8 +- 20 files changed, 205 insertions(+), 362 deletions(-) diff --git a/sys/arch/sparc64/dev/creator.c b/sys/arch/sparc64/dev/creator.c index 2f77166f0c9..c22b91e6576 100644 --- a/sys/arch/sparc64/dev/creator.c +++ b/sys/arch/sparc64/dev/creator.c @@ -1,4 +1,4 @@ -/* $OpenBSD: creator.c,v 1.56 2022/10/16 01:22:39 jsg Exp $ */ +/* $OpenBSD: creator.c,v 1.57 2022/10/21 18:55:42 miod Exp $ */ /* * Copyright (c) 2002 Jason L. Wright (jason@thought.net) @@ -33,8 +33,9 @@ #include #include -#include #include +#include +#include #include #include diff --git a/sys/arch/sparc64/fpu/fpu.c b/sys/arch/sparc64/fpu/fpu.c index bdbd1bfd976..27480142747 100644 --- a/sys/arch/sparc64/fpu/fpu.c +++ b/sys/arch/sparc64/fpu/fpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fpu.c,v 1.22 2022/10/16 01:22:39 jsg Exp $ */ +/* $OpenBSD: fpu.c,v 1.23 2022/10/21 18:55:42 miod Exp $ */ /* $NetBSD: fpu.c,v 1.11 2000/12/06 01:47:50 mrg Exp $ */ /* @@ -81,22 +81,22 @@ #include int fpu_regoffset(int, int); -int fpu_insn_fmov(struct fpstate64 *, struct fpemu *, union instr); -int fpu_insn_fabs(struct fpstate64 *, struct fpemu *, union instr); -int fpu_insn_fneg(struct fpstate64 *, struct fpemu *, union instr); +int fpu_insn_fmov(struct fpstate *, struct fpemu *, union instr); +int fpu_insn_fabs(struct fpstate *, struct fpemu *, union instr); +int fpu_insn_fneg(struct fpstate *, struct fpemu *, union instr); int fpu_insn_itof(struct fpemu *, union instr, int, int *, int *, u_int *); int fpu_insn_ftoi(struct fpemu *, union instr, int *, int, u_int *); int fpu_insn_ftof(struct fpemu *, union instr, int *, int *, u_int *); int fpu_insn_fsqrt(struct fpemu *, union instr, int *, int *, u_int *); -int fpu_insn_fcmp(struct fpstate64 *, struct fpemu *, union instr, int); +int fpu_insn_fcmp(struct fpstate *, struct fpemu *, union instr, int); int fpu_insn_fmul(struct fpemu *, union instr, int *, int *, u_int *); int fpu_insn_fmulx(struct fpemu *, union instr, int *, int *, u_int *); int fpu_insn_fdiv(struct fpemu *, union instr, int *, int *, u_int *); int fpu_insn_fadd(struct fpemu *, union instr, int *, int *, u_int *); int fpu_insn_fsub(struct fpemu *, union instr, int *, int *, u_int *); -int fpu_insn_fmovcc(struct proc *, struct fpstate64 *, union instr); -int fpu_insn_fmovr(struct proc *, struct fpstate64 *, union instr); +int fpu_insn_fmovcc(struct proc *, struct fpstate *, union instr); +int fpu_insn_fmovr(struct proc *, struct fpstate *, union instr); void fpu_fcopy(u_int *, u_int *, int); #ifdef DEBUG @@ -115,7 +115,7 @@ fpu_dumpfpn(struct fpn *fp) fp->fp_mant[2], fp->fp_mant[3], fp->fp_exp); } void -fpu_dumpstate(struct fpstate64 *fs) +fpu_dumpstate(struct fpstate *fs) { int i; @@ -185,7 +185,7 @@ fpu_fcopy(u_int *src, u_int *dst, int type) * unknown FPops do enter the queue, however. */ void -fpu_cleanup(register struct proc *p, register struct fpstate64 *fs) +fpu_cleanup(register struct proc *p, register struct fpstate *fs) { register int i, fsr = fs->fs_fsr, error; union instr instr; @@ -446,7 +446,7 @@ fpu_execute(struct proc *p, struct fpemu *fe, union instr instr) * Handler for FMOV[SDQ] emulation. */ int -fpu_insn_fmov(struct fpstate64 *fs, struct fpemu *fe, union instr instr) +fpu_insn_fmov(struct fpstate *fs, struct fpemu *fe, union instr instr) { int opf = instr.i_opf.i_opf, rs, rd, rtype; @@ -466,7 +466,7 @@ fpu_insn_fmov(struct fpstate64 *fs, struct fpemu *fe, union instr instr) * Handler for FABS[SDQ] emulation. */ int -fpu_insn_fabs(struct fpstate64 *fs, struct fpemu *fe, union instr instr) +fpu_insn_fabs(struct fpstate *fs, struct fpemu *fe, union instr instr) { int opf = instr.i_opf.i_opf, rs, rd, rtype; @@ -487,7 +487,7 @@ fpu_insn_fabs(struct fpstate64 *fs, struct fpemu *fe, union instr instr) * Handler for FNEG[SDQ] emulation. */ int -fpu_insn_fneg(struct fpstate64 *fs, struct fpemu *fe, union instr instr) +fpu_insn_fneg(struct fpstate *fs, struct fpemu *fe, union instr instr) { int opf = instr.i_opf.i_opf, rs, rd, rtype; @@ -614,7 +614,7 @@ fpu_insn_fsqrt(struct fpemu *fe, union instr instr, int *rdp, int *rdtypep, * Handler for FCMP{E}[SDQ] emulation. */ int -fpu_insn_fcmp(struct fpstate64 *fs, struct fpemu *fe, union instr instr, +fpu_insn_fcmp(struct fpstate *fs, struct fpemu *fe, union instr instr, int cmpe) { int opf = instr.i_opf.i_opf, rs1, rs2, rtype, cx, fsr; @@ -799,7 +799,7 @@ fpu_insn_fsub(struct fpemu *fe, union instr instr, int *rdp, int *rdtypep, * Handler for FMOV[SDQ][cond] emulation. */ int -fpu_insn_fmovcc(struct proc *p, struct fpstate64 *fs, union instr instr) +fpu_insn_fmovcc(struct proc *p, struct fpstate *fs, union instr instr) { int rtype, rd, rs, cond; @@ -848,7 +848,7 @@ fpu_insn_fmovcc(struct proc *p, struct fpstate64 *fs, union instr instr) * Handler for FMOVR[icond][SDQ] emulation. */ int -fpu_insn_fmovr(struct proc *p, struct fpstate64 *fs, union instr instr) +fpu_insn_fmovr(struct proc *p, struct fpstate *fs, union instr instr) { int rtype, rd, rs2, rs1; diff --git a/sys/arch/sparc64/fpu/fpu_emu.h b/sys/arch/sparc64/fpu/fpu_emu.h index beee885c600..629a7d73fab 100644 --- a/sys/arch/sparc64/fpu/fpu_emu.h +++ b/sys/arch/sparc64/fpu/fpu_emu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fpu_emu.h,v 1.5 2006/06/21 19:24:38 jason Exp $ */ +/* $OpenBSD: fpu_emu.h,v 1.6 2022/10/21 18:55:42 miod Exp $ */ /* $NetBSD: fpu_emu.h,v 1.4 2000/08/03 18:32:07 eeh Exp $ */ /* @@ -136,7 +136,7 @@ struct fpn { * Emulator state. */ struct fpemu { - struct fpstate64 *fe_fpstate; /* registers, etc */ + struct fpstate *fe_fpstate; /* registers, etc */ int fe_fsr; /* fsr copy (modified during op) */ int fe_cx; /* exceptions */ struct fpn fe_f1; /* operand 1 */ @@ -181,7 +181,7 @@ void fpu_implode(struct fpemu *, struct fpn *, int, u_int *); #define FPE_STATE 0x4 extern int fpe_debug; void fpu_dumpfpn(struct fpn *); -void fpu_dumpstate(struct fpstate64 *); +void fpu_dumpstate(struct fpstate *); #define DPRINTF(x, y) if (fpe_debug & (x)) printf y #define DUMPFPN(x, f) if (fpe_debug & (x)) fpu_dumpfpn((f)) #define DUMPSTATE(x, s) if (fpe_debug & (x)) fpu_dumpstate((s)) diff --git a/sys/arch/sparc64/fpu/fpu_extern.h b/sys/arch/sparc64/fpu/fpu_extern.h index 22377f1a084..cdf483e60bb 100644 --- a/sys/arch/sparc64/fpu/fpu_extern.h +++ b/sys/arch/sparc64/fpu/fpu_extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fpu_extern.h,v 1.6 2008/06/26 05:42:13 ray Exp $ */ +/* $OpenBSD: fpu_extern.h,v 1.7 2022/10/21 18:55:42 miod Exp $ */ /* $NetBSD: fpu_extern.h,v 1.4 2000/08/03 18:32:08 eeh Exp $ */ /*- @@ -31,15 +31,15 @@ */ struct proc; -struct fpstate64; -struct trapframe64; +struct fpstate; +struct trapframe; union instr; struct fpemu; struct fpn; /* fpu.c */ -void fpu_cleanup(struct proc *, struct fpstate64 *); -int fpu_emulate(struct proc *, struct trapframe64 *, struct fpstate64 *); +void fpu_cleanup(struct proc *, struct fpstate *); +int fpu_emulate(struct proc *, struct trapframe *, struct fpstate *); int fpu_execute(struct proc *, struct fpemu *, union instr); /* fpu_add.c */ diff --git a/sys/arch/sparc64/include/cpu.h b/sys/arch/sparc64/include/cpu.h index 44a624d431b..3e3e92d31a2 100644 --- a/sys/arch/sparc64/include/cpu.h +++ b/sys/arch/sparc64/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.98 2021/07/06 09:34:07 kettenis Exp $ */ +/* $OpenBSD: cpu.h,v 1.99 2022/10/21 18:55:42 miod Exp $ */ /* $NetBSD: cpu.h,v 1.28 2001/06/14 22:56:58 thorpej Exp $ */ /* @@ -74,7 +74,7 @@ #include #include -#include +#include #include #include @@ -144,7 +144,7 @@ struct cpu_info { paddr_t ci_paddr; /* Phys addr of this structure. */ #ifdef SUN4V - struct rwindow64 ci_rw; + struct rwindow ci_rw; u_int64_t ci_rwsp; paddr_t ci_mmfsa; @@ -271,7 +271,7 @@ do { \ * as well for strayintr (see locore.s:interrupt and intr.c:strayintr). */ struct clockframe { - struct trapframe64 t; + struct trapframe t; int saved_intr_level; }; @@ -316,9 +316,9 @@ struct timeval; int clockintr(void *);/* level 10 (clock) interrupt code */ int statintr(void *); /* level 14 (statclock) interrupt code */ /* locore.s */ -struct fpstate64; -void savefpstate(struct fpstate64 *); -void loadfpstate(struct fpstate64 *); +struct fpstate; +void savefpstate(struct fpstate *); +void loadfpstate(struct fpstate *); void clearfpstate(void); u_int64_t probeget(paddr_t, int, int); #define write_all_windows() __asm volatile("flushw" : : ) @@ -344,11 +344,13 @@ int cnrom(void); void zsconsole(struct tty *, int, int, void (**)(struct tty *, int)); /* fb.c */ void fb_unblank(void); +/* ltc.c */ +void ltc_full_blast(void); /* tda.c */ void tda_full_blast(void); /* emul.c */ -int emul_qf(int32_t, struct proc *, union sigval, struct trapframe64 *); -int emul_popc(int32_t, struct proc *, union sigval, struct trapframe64 *); +int emul_qf(int32_t, struct proc *, union sigval, struct trapframe *); +int emul_popc(int32_t, struct proc *, union sigval, struct trapframe *); /* * diff --git a/sys/arch/sparc64/include/db_machdep.h b/sys/arch/sparc64/include/db_machdep.h index 54074baa4ec..3747de3d658 100644 --- a/sys/arch/sparc64/include/db_machdep.h +++ b/sys/arch/sparc64/include/db_machdep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: db_machdep.h,v 1.22 2021/08/30 08:11:12 jasper Exp $ */ +/* $OpenBSD: db_machdep.h,v 1.23 2022/10/21 18:55:42 miod Exp $ */ /* $NetBSD: db_machdep.h,v 1.12 2001/07/07 15:16:13 eeh Exp $ */ /* @@ -53,11 +53,11 @@ struct trapstate { }; #if 1 typedef struct { - struct trapframe64 ddb_tf; - struct frame64 ddb_fr; + struct trapframe ddb_tf; + struct frame ddb_fr; struct trapstate ddb_ts[5]; int ddb_tl; - struct fpstate64 ddb_fpstate; + struct fpstate ddb_fpstate; } db_regs_t; #else typedef struct db_regs { @@ -129,7 +129,7 @@ vaddr_t db_branch_taken(int inst, vaddr_t pc, db_regs_t *regs); #define DB_MACHINE_COMMANDS void db_machine_init(void); -int db_ktrap(int, struct trapframe64 *); +int db_ktrap(int, struct trapframe *); int db_enter_ddb(void); void db_startcpu(struct cpu_info *); diff --git a/sys/arch/sparc64/include/frame.h b/sys/arch/sparc64/include/frame.h index 662b258dc2f..24957936516 100644 --- a/sys/arch/sparc64/include/frame.h +++ b/sys/arch/sparc64/include/frame.h @@ -1,4 +1,4 @@ -/* $OpenBSD: frame.h,v 1.6 2011/03/23 16:54:37 pirofti Exp $ */ +/* $OpenBSD: frame.h,v 1.7 2022/10/21 18:55:42 miod Exp $ */ /* $NetBSD: frame.h,v 1.9 2001/03/04 09:28:35 mrg Exp $ */ /* @@ -44,39 +44,6 @@ #ifndef _MACHINE_FRAME_H_ #define _MACHINE_FRAME_H_ -/* - * Sparc stack frame format. - * - * Note that the contents of each stack frame may be held only in - * machine register windows. In order to get an accurate picture - * of the frame, you must first force the kernel to write any such - * windows to the stack. - */ -#ifndef _LOCORE -struct frame32 { - int32_t fr_local[8]; /* space to save locals (%l0..%l7) */ - int32_t fr_arg[6]; /* space to save arguments (%i0..%i5) */ - u_int32_t fr_fp; /* space to save frame pointer (%i6) */ - u_int32_t fr_pc; /* space to save return pc (%i7) */ - /* - * SunOS reserves another 8 words here; this is pointless - * but we do it for compatibility. - */ - int32_t fr_xxx; /* `structure return pointer' (unused) */ - int32_t fr_argd[6]; /* `arg dump area' (lunacy) */ - int32_t fr_argx[1]; /* arg extension (args 7..n; variable size) */ -}; -#endif - -/* - * CCFSZ (C Compiler Frame SiZe) is the size of a stack frame required if - * a function is to call C code. It should be just 64, but Sun defined - * their frame with space to hold arguments 0 through 5 (plus some junk), - * and varargs routines (such as kprintf) demand this, and gcc uses this - * area at times anyway. - */ -#define CCFSZ 96 - /* * Sparc v9 stack frame format. * @@ -89,7 +56,7 @@ struct frame32 { * a v8 frame by testing the stack pointer's lsb. */ #if !defined(_LOCORE) && !defined(_LIBC) -struct frame64 { +struct frame { int64_t fr_local[8]; /* space to save locals (%l0..%l7) */ int64_t fr_arg[6]; /* space to save arguments (%i0..%i5) */ u_int64_t fr_fp; /* space to save frame pointer (%i6) */ @@ -101,7 +68,7 @@ struct frame64 { int64_t fr_argx[0]; /* arg extension (args 7..n; variable size) */ }; -#define v9next_frame(f) ((struct frame64*)(f->fr_fp+BIAS)) +#define v9next_frame(f) ((struct frame*)(f->fr_fp+BIAS)) #endif /* @@ -116,4 +83,42 @@ struct frame64 { */ #define BIAS (2048-1) +#ifndef _LOCORE +/* + * The v9 trapframe. Since we don't get a free register window with + * each trap we need some way to keep track of pending traps. We use + * tf_fault to save the faulting address for memory faults and tf_kstack + * to thread trapframes on the kernel stack(s). If tf_kstack == 0 then + * this is the lowest level trap; we came from user mode. + */ +struct trapframe { + int64_t tf_tstate; /* tstate register */ + int64_t tf_pc; /* return pc */ + int64_t tf_npc; /* return npc */ + int64_t tf_fault; /* faulting addr -- need somewhere to save it */ + int64_t tf_kstack; /* kernel stack of prev tf */ + int tf_y; /* %y register -- 32-bits */ + short tf_tt; /* What type of trap this was */ + char tf_pil; /* What IRQ we're handling */ + char tf_oldpil; /* What our old SPL was */ + int64_t tf_global[8]; /* global registers in trap's caller */ + int64_t tf_out[8]; /* output registers in trap's caller */ + int64_t tf_local[8]; /* local registers in trap's caller */ + int64_t tf_in[8]; /* in registers in trap's caller (for debug) */ +}; + +/* + * The v9 register window. Each stack pointer (%o6 aka %sp) in each window + * must ALWAYS point to some place at which it is safe to scribble on + * 64 bytes. (If not, your process gets mangled.) Furthermore, each + * stack pointer should be aligned on a 16-byte boundary (plus the BIAS) + * for v9 stacks (the kernel as currently coded allows arbitrary alignment, + * but with a hefty performance penalty). + */ +struct rwindow { + int64_t rw_local[8]; /* %l0..%l7 */ + int64_t rw_in[8]; /* %i0..%i7 */ +}; +#endif + #endif /* _MACHINE_FRAME_H_ */ diff --git a/sys/arch/sparc64/include/pcb.h b/sys/arch/sparc64/include/pcb.h index 108f669031c..f24fa3d04a5 100644 --- a/sys/arch/sparc64/include/pcb.h +++ b/sys/arch/sparc64/include/pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pcb.h,v 1.10 2015/05/05 02:13:47 guenther Exp $ */ +/* $OpenBSD: pcb.h,v 1.11 2022/10/21 18:55:42 miod Exp $ */ /* $NetBSD: pcb.h,v 1.7 2000/12/29 17:12:05 eeh Exp $ */ /* @@ -139,7 +139,7 @@ struct pcb { u_int64_t pcb_wcookie; /* the following MUST be aligned on a 64-bit boundary */ - struct rwindow64 pcb_rw[PCB_MAXWIN]; /* saved windows */ + struct rwindow pcb_rw[PCB_MAXWIN]; /* saved windows */ u_int64_t pcb_rwsp[PCB_MAXWIN]; }; diff --git a/sys/arch/sparc64/include/proc.h b/sys/arch/sparc64/include/proc.h index 48c39e47aa9..721d856ab50 100644 --- a/sys/arch/sparc64/include/proc.h +++ b/sys/arch/sparc64/include/proc.h @@ -44,7 +44,7 @@ * Machine-dependent part of the proc structure for SPARC. */ struct mdproc { - struct trapframe64 *md_tf; /* trap/syscall registers */ - struct fpstate64 *md_fpstate; /* fpu state, if any; always resident */ + struct trapframe *md_tf; /* trap/syscall registers */ + struct fpstate *md_fpstate; /* fpu state, if any; always resident */ volatile int md_astpending; }; diff --git a/sys/arch/sparc64/include/reg.h b/sys/arch/sparc64/include/reg.h index 89560650b39..4ab009494a2 100644 --- a/sys/arch/sparc64/include/reg.h +++ b/sys/arch/sparc64/include/reg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: reg.h,v 1.5 2008/12/22 23:01:31 kettenis Exp $ */ +/* $OpenBSD: reg.h,v 1.6 2022/10/21 18:55:42 miod Exp $ */ /* $NetBSD: reg.h,v 1.8 2001/06/19 12:59:16 wiz Exp $ */ /* @@ -44,80 +44,7 @@ #ifndef _MACHINE_REG_H_ #define _MACHINE_REG_H_ -/* - * Registers passed to trap/syscall/etc. - * This structure is known to occupy exactly 80 bytes (see locore.s). - * Note, tf_global[0] is not actually written (since g0 is always 0). - * (The slot tf_global[0] is used to send a copy of %wim to kernel gdb. - * This is known as `cheating'.) - */ -struct trapframe32 { - int tf_psr; /* psr */ - int tf_pc; /* return pc */ - int tf_npc; /* return npc */ - int tf_y; /* %y register */ - int tf_global[8]; /* global registers in trap's caller */ - int tf_out[8]; /* output registers in trap's caller */ -}; - -/* - * The v9 trapframe is a bit more complex. Since we don't get a free - * register window with each trap we need some way to keep track of - * pending traps. We use tf_fault to save the faulting address for - * memory faults and tf_kstack to thread trapframes on the kernel - * stack(s). If tf_kstack == 0 then this is the lowest level trap; - * we came from user mode. - */ -struct trapframe64 { - int64_t tf_tstate; /* tstate register */ - int64_t tf_pc; /* return pc */ - int64_t tf_npc; /* return npc */ - int64_t tf_fault; /* faulting addr -- need somewhere to save it */ - int64_t tf_kstack; /* kernel stack of prev tf */ - int tf_y; /* %y register -- 32-bits */ - short tf_tt; /* What type of trap this was */ - char tf_pil; /* What IRQ we're handling */ - char tf_oldpil; /* What our old SPL was */ - int64_t tf_global[8]; /* global registers in trap's caller */ - int64_t tf_out[8]; /* output registers in trap's caller */ - int64_t tf_local[8]; /* local registers in trap's caller */ - int64_t tf_in[8]; /* in registers in trap's caller (for debug) */ -}; - -/* - * Register windows. Each stack pointer (%o6 aka %sp) in each window - * must ALWAYS point to some place at which it is safe to scribble on - * 64 bytes. (If not, your process gets mangled.) Furthermore, each - * stack pointer should be aligned on an 8-byte boundary for v8 stacks - * or a 16-byte boundary (plus the BIAS) for v9 stacks (the kernel - * as currently coded allows arbitrary alignment, but with a hefty - * performance penalty). - */ -struct rwindow32 { - int rw_local[8]; /* %l0..%l7 */ - int rw_in[8]; /* %i0..%i7 */ -}; - -/* Don't forget the BIAS!! */ -struct rwindow64 { - int64_t rw_local[8]; /* %l0..%l7 */ - int64_t rw_in[8]; /* %i0..%i7 */ -}; - -/* - * Clone trapframe for now; this seems to be the more useful - * than the old struct reg above. - */ -struct reg32 { - int r_psr; /* psr */ - int r_pc; /* return pc */ - int r_npc; /* return npc */ - int r_y; /* %y register */ - int r_global[8]; /* global registers in trap's caller */ - int r_out[8]; /* output registers in trap's caller */ -}; - -struct reg64 { +struct reg { int64_t r_tstate; /* tstate register */ int64_t r_pc; /* return pc */ int64_t r_npc; /* return npc */ @@ -142,14 +69,14 @@ struct reg64 { * XXXX UltraSPARC processors don't implement a floating point queue. */ #define FP_QSIZE 16 -#define ALIGNFPSTATE(f) ((struct fpstate64 *)(((long)(f))&(~BLOCK_ALIGN))) +#define ALIGNFPSTATE(f) ((struct fpstate *)(((long)(f))&(~BLOCK_ALIGN))) struct fp_qentry { int *fq_addr; /* the instruction's address */ int fq_instr; /* the instruction itself */ }; -struct fpstate64 { +struct fpstate { u_int fs_regs[64]; /* our view is 64 32-bit registers */ int64_t fs_fsr; /* %fsr */ int fs_gsr; /* graphics state reg */ @@ -157,40 +84,15 @@ struct fpstate64 { struct fp_qentry fs_queue[FP_QSIZE]; /* queue contents */ }; -/* - * For 32-bit emulations. - */ -struct fpstate32 { - u_int fs_regs[32]; /* our view is 32 32-bit registers */ - int fs_fsr; /* %fsr */ - int fs_qsize; /* actual queue depth */ - struct fp_qentry fs_queue[FP_QSIZE]; /* queue contents */ -}; - /* * The actual FP registers are made accessible (c.f. ptrace(2)) through * a `struct fpreg'; relies on the * fact that `fpreg' is a prefix of `fpstate'. */ -struct fpreg64 { +struct fpreg { u_int fr_regs[64]; /* our view is 64 32-bit registers */ int64_t fr_fsr; /* %fsr */ int fr_gsr; /* graphics state reg */ }; -/* - * 32-bit fpreg used by 32-bit sparc CPUs - */ -struct fpreg32 { - u_int fr_regs[32]; /* our view is 32 32-bit registers */ - int fr_fsr; /* %fsr */ -}; - -/* Here we gotta do naughty things to let gdb work on 32-bit binaries */ -#define reg reg64 -#define fpreg fpreg64 -#define fpstate fpstate64 -#define trapframe trapframe64 -#define rwindow rwindow64 - #endif /* _MACHINE_REG_H_ */ diff --git a/sys/arch/sparc64/sparc64/db_interface.c b/sys/arch/sparc64/sparc64/db_interface.c index 32de92bb1bd..343cf4ea59f 100644 --- a/sys/arch/sparc64/sparc64/db_interface.c +++ b/sys/arch/sparc64/sparc64/db_interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_interface.c,v 1.59 2022/10/16 01:22:39 jsg Exp $ */ +/* $OpenBSD: db_interface.c,v 1.60 2022/10/21 18:55:42 miod Exp $ */ /* $NetBSD: db_interface.c,v 1.61 2001/07/31 06:55:47 eeh Exp $ */ /* @@ -200,7 +200,7 @@ extern label_t *db_recover; extern char *trap_type[]; -void kdb_kbd_trap(struct trapframe64 *); +void kdb_kbd_trap(struct trapframe *); void db_prom_cmd(db_expr_t, int, db_expr_t, char *); void db_proc_cmd(db_expr_t, int, db_expr_t, char *); void db_ctx_cmd(db_expr_t, int, db_expr_t, char *); @@ -237,7 +237,7 @@ void db_ddbproc_cmd(db_expr_t, int, db_expr_t, char *); * Received keyboard interrupt sequence. */ void -kdb_kbd_trap(struct trapframe64 *tf) +kdb_kbd_trap(struct trapframe *tf) { if (db_active == 0 /* && (boothowto & RB_KDB) */) { printf("\n\nkernel: keyboard interrupt tf=%p\n", tf); @@ -249,7 +249,7 @@ kdb_kbd_trap(struct trapframe64 *tf) * db_ktrap - field a TRACE or BPT trap */ int -db_ktrap(int type, register struct trapframe64 *tf) +db_ktrap(int type, register struct trapframe *tf) { int s, tl; struct trapstate *ts = &ddb_regs.ddb_ts[0]; diff --git a/sys/arch/sparc64/sparc64/db_trace.c b/sys/arch/sparc64/sparc64/db_trace.c index 6a6bccd2512..885d2a32ea3 100644 --- a/sys/arch/sparc64/sparc64/db_trace.c +++ b/sys/arch/sparc64/sparc64/db_trace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_trace.c,v 1.22 2020/04/18 04:45:20 visa Exp $ */ +/* $OpenBSD: db_trace.c,v 1.23 2022/10/21 18:55:42 miod Exp $ */ /* $NetBSD: db_trace.c,v 1.23 2001/07/10 06:06:16 eeh Exp $ */ /* @@ -104,13 +104,13 @@ db_stack_trace_print(db_expr_t addr, int have_addr, db_expr_t count, db_expr_t offset; char *name; vaddr_t pc; - struct frame64 *f64; + struct frame *f64; /* * Switch to frame that contains arguments */ - f64 = (struct frame64 *)(frame + BIAS); + f64 = (struct frame *)(frame + BIAS); pc = (vaddr_t)KLOAD(f64->fr_pc); frame = KLOAD(f64->fr_fp); @@ -145,7 +145,7 @@ db_stack_trace_print(db_expr_t addr, int have_addr, db_expr_t count, * Print %i0..%i5; hope these still reflect the * actual arguments somewhat... */ - f64 = (struct frame64 *)(frame + BIAS); + f64 = (struct frame *)(frame + BIAS); for (i = 0; i < 5; i++) (*pr)("%lx, ", (long)KLOAD(f64->fr_arg[i])); (*pr)("%lx) at ", (long)KLOAD(f64->fr_arg[i])); @@ -157,7 +157,7 @@ db_stack_trace_print(db_expr_t addr, int have_addr, db_expr_t count, void stacktrace_save_at(struct stacktrace *st, unsigned int skip) { - struct frame64 *f64; + struct frame *f64; vaddr_t pc; vaddr_t frame; @@ -169,7 +169,7 @@ stacktrace_save_at(struct stacktrace *st, unsigned int skip) st->st_count = 0; while (st->st_count < STACKTRACE_MAX) { - f64 = (struct frame64 *)(frame + BIAS); + f64 = (struct frame *)(frame + BIAS); pc = (vaddr_t)KLOAD(f64->fr_pc); frame = KLOAD(f64->fr_fp); @@ -202,7 +202,7 @@ db_dump_window(db_expr_t addr, int have_addr, db_expr_t count, char *modif) for (i = 0; i < addr && frame; i++) { if ((frame & 1) == 0) break; - frame = ((struct frame64 *)(frame + BIAS))->fr_fp; + frame = ((struct frame *)(frame + BIAS))->fr_fp; } if ((frame & 1) == 0) { @@ -217,9 +217,9 @@ db_dump_window(db_expr_t addr, int have_addr, db_expr_t count, char *modif) void db_print_window(u_int64_t frame) { - struct frame64 *f = (struct frame64 *)(frame + BIAS); + struct frame *f = (struct frame *)(frame + BIAS); - db_printf("frame64 %p locals, ins:\n", f); + db_printf("frame %p locals, ins:\n", f); if (INKERNEL(f)) { db_printf("%llx %llx %llx %llx ", (unsigned long long)f->fr_local[0], @@ -245,7 +245,7 @@ db_print_window(u_int64_t frame) db_printsym(f->fr_pc, DB_STGY_PROC, db_printf); db_printf("\n"); } else { - struct frame64 fr; + struct frame fr; if (copyin(f, &fr, sizeof(fr))) return; @@ -309,15 +309,15 @@ db_dump_stack(db_expr_t addr, int have_addr, db_expr_t count, char *modif) } frame += BIAS; - if (!INKERNEL(((struct frame64 *)frame)) + if (!INKERNEL(((struct frame *)frame)) && kernel_only) break; db_printf("Window %x ", i); db_print_window(frame - BIAS); - if (!INKERNEL(((struct frame64 *)frame))) { - copyin(&((struct frame64 *)frame)->fr_fp, &frame, + if (!INKERNEL(((struct frame *)frame))) { + copyin(&((struct frame *)frame)->fr_fp, &frame, sizeof(frame)); } else - frame = ((struct frame64 *)frame)->fr_fp; + frame = ((struct frame *)frame)->fr_fp; } } @@ -326,7 +326,7 @@ db_dump_stack(db_expr_t addr, int have_addr, db_expr_t count, char *modif) void db_dump_trap(db_expr_t addr, int have_addr, db_expr_t count, char *modif) { - struct trapframe64 *tf; + struct trapframe *tf; /* Use our last trapframe? */ tf = &ddb_regs.ddb_tf; @@ -339,7 +339,7 @@ db_dump_trap(db_expr_t addr, int have_addr, db_expr_t count, char *modif) } /* Or an arbitrary trapframe */ if (have_addr) - tf = (struct trapframe64 *)addr; + tf = (struct trapframe *)addr; db_printf("Trapframe %p:\ttstate: %llx\tpc: %llx\tnpc: %llx\n", tf, (unsigned long long)tf->tf_tstate, @@ -409,13 +409,13 @@ db_dump_trap(db_expr_t addr, int have_addr, db_expr_t count, char *modif) void db_dump_fpstate(db_expr_t addr, int have_addr, db_expr_t count, char *modif) { - struct fpstate64 *fpstate; + struct fpstate *fpstate; /* Use our last trapframe? */ fpstate = &ddb_regs.ddb_fpstate; /* Or an arbitrary trapframe */ if (have_addr) - fpstate = (struct fpstate64 *)addr; + fpstate = (struct fpstate *)addr; db_printf("fpstate %p: fsr = %llx gsr = %lx\nfpregs:\n", fpstate, (unsigned long long)fpstate->fs_fsr, diff --git a/sys/arch/sparc64/sparc64/emul.c b/sys/arch/sparc64/sparc64/emul.c index 565df915b24..0a3c89d80af 100644 --- a/sys/arch/sparc64/sparc64/emul.c +++ b/sys/arch/sparc64/sparc64/emul.c @@ -1,4 +1,4 @@ -/* $OpenBSD: emul.c,v 1.26 2020/09/14 13:30:33 deraadt Exp $ */ +/* $OpenBSD: emul.c,v 1.27 2022/10/21 18:55:42 miod Exp $ */ /* $NetBSD: emul.c,v 1.8 2001/06/29 23:58:40 eeh Exp $ */ /*- @@ -67,8 +67,8 @@ swap_quad(int64_t *p) int emul_qf(int32_t insv, struct proc *p, union sigval sv, struct trapframe *tf) { - extern struct fpstate64 initfpstate; - struct fpstate64 *fs = p->p_md.md_fpstate; + extern struct fpstate initfpstate; + struct fpstate *fs = p->p_md.md_fpstate; int64_t addr, buf[2]; union instr ins; int freg, isload, err; diff --git a/sys/arch/sparc64/sparc64/genassym.cf b/sys/arch/sparc64/sparc64/genassym.cf index 4983dac459e..1e389227cf4 100644 --- a/sys/arch/sparc64/sparc64/genassym.cf +++ b/sys/arch/sparc64/sparc64/genassym.cf @@ -1,4 +1,4 @@ -# $OpenBSD: genassym.cf,v 1.38 2019/06/11 15:23:41 mpi Exp $ +# $OpenBSD: genassym.cf,v 1.39 2022/10/21 18:55:42 miod Exp $ # $NetBSD: genassym.cf,v 1.23 2001/08/08 00:09:30 eeh Exp $ # @@ -157,13 +157,13 @@ member ci_mutex_level endif # FPU state -struct fpstate64 +struct fpstate member fs_regs member fs_fsr member fs_gsr member fs_qsize member fs_queue -define FS_SIZE sizeof(struct fpstate64) +define FS_SIZE sizeof(struct fpstate) export FSR_QNE export FPRS_FEF export FPRS_DU @@ -193,8 +193,8 @@ member pcb_pc member PCB_LASTCALL lastcall define PCB_SIZE sizeof(struct pcb) -# trapframe64 fields -struct trapframe64 +# trapframe fields +struct trapframe member tf_tstate member tf_pc member tf_npc @@ -213,7 +213,7 @@ member TF_G tf_global member TF_O tf_out member TF_L tf_local member TF_I tf_in -define TF_SIZE sizeof(struct trapframe64) +define TF_SIZE sizeof(struct trapframe) ifdef notyet # clockframe fields diff --git a/sys/arch/sparc64/sparc64/intr.c b/sys/arch/sparc64/sparc64/intr.c index d2bb078b361..0cfcf99e8ab 100644 --- a/sys/arch/sparc64/sparc64/intr.c +++ b/sys/arch/sparc64/sparc64/intr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.c,v 1.62 2020/12/28 14:23:30 mpi Exp $ */ +/* $OpenBSD: intr.c,v 1.63 2022/10/21 18:55:42 miod Exp $ */ /* $NetBSD: intr.c,v 1.39 2001/07/19 23:38:11 eeh Exp $ */ /* @@ -67,9 +67,9 @@ struct intrhand *intrlev[MAXINTNUM]; #define INTR_DEVINO 0x8000 -void strayintr(const struct trapframe64 *, int); +void strayintr(const struct trapframe *, int); int softintr(void *); -int intr_handler(struct trapframe64 *, struct intrhand *); +int intr_handler(struct trapframe *, struct intrhand *); int intr_list_handler(void *); void intr_ack(struct intrhand *); @@ -81,7 +81,7 @@ int ignore_stray = 1; int straycnt[16]; void -strayintr(const struct trapframe64 *fp, int vectored) +strayintr(const struct trapframe *fp, int vectored) { static int straytime, nstray; int timesince; @@ -116,7 +116,7 @@ strayintr(const struct trapframe64 *fp, int vectored) } int -intr_handler(struct trapframe64 *tf, struct intrhand *ih) +intr_handler(struct trapframe *tf, struct intrhand *ih) { int rc; #ifdef MULTIPROCESSOR diff --git a/sys/arch/sparc64/sparc64/locore.s b/sys/arch/sparc64/sparc64/locore.s index 54a8c6e1492..a5794f9e31d 100644 --- a/sys/arch/sparc64/sparc64/locore.s +++ b/sys/arch/sparc64/sparc64/locore.s @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.s,v 1.192 2022/09/08 17:44:48 miod Exp $ */ +/* $OpenBSD: locore.s,v 1.193 2022/10/21 18:55:42 miod Exp $ */ /* $NetBSD: locore.s,v 1.137 2001/08/13 06:10:10 jdolecek Exp $ */ /* @@ -2183,7 +2183,7 @@ winfixsave: dec %g7 ! Make it into a mask andncc %g2, %g7, %g0 ! XXXXXXXXXX This assumes kernel addresses are unique from user addresses */ \ movz %xcc, %g1, %g6 ! Stay on interrupt stack? - add %g6, -CCFSZ, %g6 ! Allocate a stack frame + add %g6, -CC64FSZ, %g6 ! Allocate a stack frame mov %sp, %l6 ! XXXXX Save old stack pointer mov %g6, %sp ta 1; nop ! Enter debugger diff --git a/sys/arch/sparc64/sparc64/machdep.c b/sys/arch/sparc64/sparc64/machdep.c index f8c896c7043..3fa44e8b97b 100644 --- a/sys/arch/sparc64/sparc64/machdep.c +++ b/sys/arch/sparc64/sparc64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.201 2022/10/16 01:22:39 jsg Exp $ */ +/* $OpenBSD: machdep.c,v 1.202 2022/10/21 18:55:42 miod Exp $ */ /* $NetBSD: machdep.c,v 1.108 2001/07/24 19:30:14 eeh Exp $ */ /*- @@ -265,7 +265,7 @@ void setregs(struct proc *p, struct exec_package *pack, vaddr_t stack, register_t *retval) { - struct trapframe64 *tf = p->p_md.md_tf; + struct trapframe *tf = p->p_md.md_tf; int64_t tstate; int pstate = PSTATE_USER; Elf_Ehdr *eh = pack->ep_hdr; @@ -324,7 +324,7 @@ setregs(struct proc *p, struct exec_package *pack, vaddr_t stack, * to save it. In any case, get rid of our FPU state. */ fpusave_proc(p, 0); - free(p->p_md.md_fpstate, M_SUBPROC, sizeof(struct fpstate64)); + free(p->p_md.md_fpstate, M_SUBPROC, sizeof(struct fpstate)); p->p_md.md_fpstate = NULL; } bzero((caddr_t)tf, sizeof *tf); @@ -405,7 +405,7 @@ sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip, { struct proc *p = curproc; struct sigframe *fp; - struct trapframe64 *tf; + struct trapframe *tf; vaddr_t addr, oldsp, newsp; struct sigframe sf; @@ -507,7 +507,7 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval) syscallarg(struct sigcontext *) sigcntxp; } */ *uap = v; struct sigcontext ksc, *scp = SCARG(uap, sigcntxp); - struct trapframe64 *tf; + struct trapframe *tf; int error = EINVAL; if (PROC_PC(p) != p->p_p->ps_sigcoderet) { @@ -832,12 +832,12 @@ printf("starting dump, blkno %lld\n", (long long)blkno); } } -void trapdump(struct trapframe64*); +void trapdump(struct trapframe *); /* * dump out a trapframe. */ void -trapdump(struct trapframe64* tf) +trapdump(struct trapframe *tf) { printf("TRAPFRAME: tstate=%llx pc=%llx npc=%llx y=%x\n", (unsigned long long)tf->tf_tstate, (unsigned long long)tf->tf_pc, @@ -867,36 +867,24 @@ trapdump(struct trapframe64* tf) void stackdump(void) { - struct frame32 *fp = (struct frame32 *)getfp(), *sfp; - struct frame64 *fp64; + struct frame *sfp = getfp(), *fp64; - sfp = fp; - printf("Frame pointer is at %p\n", fp); + fp64 = sfp = v9next_frame(sfp); + printf("Frame pointer is at %p\n", fp64); printf("Call traceback:\n"); - while (fp && ((u_long)fp >> PGSHIFT) == ((u_long)sfp >> PGSHIFT)) { - if( ((long)fp) & 1 ) { - fp64 = (struct frame64*)(((char *)fp)+BIAS); - /* 64-bit frame */ - printf("%llx(%llx, %llx, %llx, %llx, %llx, %llx, %llx) " - "fp = %llx\n", - (unsigned long long)fp64->fr_pc, - (unsigned long long)fp64->fr_arg[0], - (unsigned long long)fp64->fr_arg[1], - (unsigned long long)fp64->fr_arg[2], - (unsigned long long)fp64->fr_arg[3], - (unsigned long long)fp64->fr_arg[4], - (unsigned long long)fp64->fr_arg[5], - (unsigned long long)fp64->fr_arg[6], - (unsigned long long)fp64->fr_fp); - fp = (struct frame32 *)(u_long)fp64->fr_fp; - } else { - /* 32-bit frame */ - printf(" pc = %x args = (%x, %x, %x, %x, %x, %x) " - "fp = %x\n", fp->fr_pc, fp->fr_arg[0], - fp->fr_arg[1], fp->fr_arg[2], fp->fr_arg[3], - fp->fr_arg[4], fp->fr_arg[5], fp->fr_fp); - fp = (struct frame32*)(u_long)(u_short)fp->fr_fp; - } + while (fp64 && ((u_long)fp64 >> PGSHIFT) == ((u_long)sfp >> PGSHIFT)) { + printf("%llx(%llx, %llx, %llx, %llx, %llx, %llx, %llx) " + "fp = %llx\n", + (unsigned long long)fp64->fr_pc, + (unsigned long long)fp64->fr_arg[0], + (unsigned long long)fp64->fr_arg[1], + (unsigned long long)fp64->fr_arg[2], + (unsigned long long)fp64->fr_arg[3], + (unsigned long long)fp64->fr_arg[4], + (unsigned long long)fp64->fr_arg[5], + (unsigned long long)fp64->fr_arg[6], + (unsigned long long)fp64->fr_fp); + fp64 = v9next_frame(fp64); } } diff --git a/sys/arch/sparc64/sparc64/process_machdep.c b/sys/arch/sparc64/sparc64/process_machdep.c index 59424e8bfe9..8355962133e 100644 --- a/sys/arch/sparc64/sparc64/process_machdep.c +++ b/sys/arch/sparc64/sparc64/process_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: process_machdep.c,v 1.13 2022/10/16 01:22:39 jsg Exp $ */ +/* $OpenBSD: process_machdep.c,v 1.14 2022/10/21 18:55:42 miod Exp $ */ /* $NetBSD: process_machdep.c,v 1.10 2000/09/26 22:05:50 eeh Exp $ */ /* @@ -71,52 +71,32 @@ #include #include -#ifndef P_32 -#define P_32 0 -#endif /* Unfortunately we need to convert v9 trapframe to v8 regs */ int process_read_regs(struct proc *p, struct reg *regs) { - struct trapframe64* tf = p->p_md.md_tf; - struct reg32* regp = (struct reg32*)regs; + struct trapframe *tf = p->p_md.md_tf; int i; - if (!(curproc->p_flag & P_32)) { - /* 64-bit mode -- copy out regs */ - regs->r_tstate = tf->tf_tstate; - regs->r_pc = tf->tf_pc; - regs->r_npc = tf->tf_npc; - regs->r_y = tf->tf_y; - for (i = 0; i < 8; i++) { - regs->r_global[i] = tf->tf_global[i]; - regs->r_out[i] = tf->tf_out[i]; - regs->r_local[i] = tf->tf_local[i]; - regs->r_in[i] = tf->tf_in[i]; - } - return (0); - } - - /* 32-bit mode -- copy out & convert 32-bit regs */ - regp->r_psr = TSTATECCR_TO_PSR(tf->tf_tstate); - regp->r_pc = tf->tf_pc; - regp->r_npc = tf->tf_npc; - regp->r_y = tf->tf_y; + /* copy out regs */ + regs->r_tstate = tf->tf_tstate; + regs->r_pc = tf->tf_pc; + regs->r_npc = tf->tf_npc; + regs->r_y = tf->tf_y; for (i = 0; i < 8; i++) { - regp->r_global[i] = tf->tf_global[i]; - regp->r_out[i] = tf->tf_out[i]; + regs->r_global[i] = tf->tf_global[i]; + regs->r_out[i] = tf->tf_out[i]; + regs->r_local[i] = tf->tf_local[i]; + regs->r_in[i] = tf->tf_in[i]; } - /* We should also write out the ins and locals. See signal stuff */ return (0); } int process_read_fpregs(struct proc *p, struct fpreg *regs) { - extern struct fpstate64 initfpstate; - struct fpstate64 *statep = &initfpstate; - struct fpreg32 *regp = (struct fpreg32 *)regs; - int i; + extern struct fpstate initfpstate; + struct fpstate *statep = &initfpstate; /* NOTE: struct fpreg == struct fpstate */ if (p->p_md.md_fpstate) { @@ -124,15 +104,8 @@ process_read_fpregs(struct proc *p, struct fpreg *regs) statep = p->p_md.md_fpstate; } - if (!(curproc->p_flag & P_32)) { - /* 64-bit mode -- copy in fregs */ - bcopy(statep, regs, sizeof(struct fpreg64)); - return 0; - } - /* 32-bit mode -- copy out & convert 32-bit fregs */ - for (i = 0; i < 32; i++) - regp->fr_regs[i] = statep->fs_regs[i]; - + /* copy in fregs */ + bcopy(statep, regs, sizeof(struct fpreg)); return 0; } @@ -141,36 +114,20 @@ process_read_fpregs(struct proc *p, struct fpreg *regs) int process_write_regs(struct proc *p, struct reg *regs) { - struct trapframe64* tf = p->p_md.md_tf; - struct reg32* regp = (struct reg32*)regs; + struct trapframe *tf = p->p_md.md_tf; int i; - if (!(curproc->p_flag & P_32)) { - /* 64-bit mode -- copy in regs */ - tf->tf_pc = regs->r_pc; - tf->tf_npc = regs->r_npc; - tf->tf_y = regs->r_y; - for (i = 0; i < 8; i++) { - tf->tf_global[i] = regs->r_global[i]; - tf->tf_out[i] = regs->r_out[i]; - } - /* We should also read in the ins and locals. See signal stuff */ - tf->tf_tstate = (tf->tf_tstate & ~TSTATE_CCR) | - (regs->r_tstate & TSTATE_CCR); - return (0); - } - - /* 32-bit mode -- copy in & convert 32-bit regs */ - tf->tf_pc = regp->r_pc; - tf->tf_npc = regp->r_npc; - tf->tf_y = regp->r_y; + /* copy in regs */ + tf->tf_pc = regs->r_pc; + tf->tf_npc = regs->r_npc; + tf->tf_y = regs->r_y; for (i = 0; i < 8; i++) { - tf->tf_global[i] = regp->r_global[i]; - tf->tf_out[i] = regp->r_out[i]; + tf->tf_global[i] = regs->r_global[i]; + tf->tf_out[i] = regs->r_out[i]; } /* We should also read in the ins and locals. See signal stuff */ - tf->tf_tstate = (int64_t)(tf->tf_tstate & ~TSTATE_CCR) | - PSRCC_TO_TSTATE(regp->r_psr); + tf->tf_tstate = (tf->tf_tstate & ~TSTATE_CCR) | + (regs->r_tstate & TSTATE_CCR); return (0); } @@ -195,27 +152,15 @@ process_set_pc(struct proc *p, caddr_t addr) int process_write_fpregs(struct proc *p, struct fpreg *regs) { - struct fpreg32 *regp = (struct fpreg32 *)regs; - int i; - if (p->p_md.md_fpstate == NULL) { - p->p_md.md_fpstate = malloc(sizeof(struct fpstate64), + p->p_md.md_fpstate = malloc(sizeof(struct fpstate), M_SUBPROC, M_WAITOK); } else fpusave_proc(p, 1); - if (!(curproc->p_flag & P_32)) { - /* 64-bit mode -- copy in fregs */ - bcopy(regs, p->p_md.md_fpstate, sizeof(struct fpreg64)); - p->p_md.md_fpstate->fs_qsize = 0; - return 0; - } - /* 32-bit mode -- copy in & convert 32-bit fregs */ - for (i = 0; i < 32; i++) - p->p_md.md_fpstate->fs_regs[i] = regp->fr_regs[i]; - p->p_md.md_fpstate->fs_fsr = regp->fr_fsr; + /* copy in fregs */ + bcopy(regs, p->p_md.md_fpstate, sizeof(struct fpreg)); p->p_md.md_fpstate->fs_qsize = 0; - return 0; } diff --git a/sys/arch/sparc64/sparc64/trap.c b/sys/arch/sparc64/sparc64/trap.c index 0f996f913bf..540b0b48d72 100644 --- a/sys/arch/sparc64/sparc64/trap.c +++ b/sys/arch/sparc64/sparc64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.110 2021/12/09 00:26:11 guenther Exp $ */ +/* $OpenBSD: trap.c,v 1.111 2022/10/21 18:55:42 miod Exp $ */ /* $NetBSD: trap.c,v 1.73 2001/08/09 01:03:01 eeh Exp $ */ /* @@ -117,7 +117,7 @@ int rftkcnt[5] = { 0, 0, 0, 0, 0 }; * seems to imply that we should do this, and it does make sense. */ __asm(".align 64"); -struct fpstate64 initfpstate = { +struct fpstate initfpstate = { { ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0 } }; @@ -309,18 +309,18 @@ const char *trap_type[] = { #define N_TRAP_TYPES (sizeof trap_type / sizeof *trap_type) -static inline void share_fpu(struct proc *, struct trapframe64 *); +static inline void share_fpu(struct proc *, struct trapframe *); -void trap(struct trapframe64 *tf, unsigned type, vaddr_t pc, long tstate); -void data_access_fault(struct trapframe64 *tf, unsigned type, vaddr_t pc, +void trap(struct trapframe *tf, unsigned type, vaddr_t pc, long tstate); +void data_access_fault(struct trapframe *tf, unsigned type, vaddr_t pc, vaddr_t va, vaddr_t sfva, u_long sfsr); -void data_access_error(struct trapframe64 *tf, unsigned type, +void data_access_error(struct trapframe *tf, unsigned type, vaddr_t afva, u_long afsr, vaddr_t sfva, u_long sfsr); -void text_access_fault(struct trapframe64 *tf, unsigned type, +void text_access_fault(struct trapframe *tf, unsigned type, vaddr_t pc, u_long sfsr); -void text_access_error(struct trapframe64 *tf, unsigned type, +void text_access_error(struct trapframe *tf, unsigned type, vaddr_t pc, u_long sfsr, vaddr_t afva, u_long afsr); -void syscall(struct trapframe64 *, register_t code, register_t pc); +void syscall(struct trapframe *, register_t code, register_t pc); /* * If someone stole the FPU while we were away, do not enable it @@ -331,7 +331,7 @@ void syscall(struct trapframe64 *, register_t code, register_t pc); * Oh, and don't touch the FPU bit if we're returning to the kernel. */ static inline void -share_fpu(struct proc *p, struct trapframe64 *tf) +share_fpu(struct proc *p, struct trapframe *tf) { if (!(tf->tf_tstate & TSTATE_PRIV) && (tf->tf_tstate & TSTATE_PEF) && fpproc != p) @@ -343,7 +343,7 @@ share_fpu(struct proc *p, struct trapframe64 *tf) * (MMU-related traps go through mem_access_fault, below.) */ void -trap(struct trapframe64 *tf, unsigned type, vaddr_t pc, long tstate) +trap(struct trapframe *tf, unsigned type, vaddr_t pc, long tstate) { struct proc *p; struct pcb *pcb; @@ -498,7 +498,7 @@ dopanic: break; case T_FPDISABLED: { - struct fpstate64 *fs = p->p_md.md_fpstate; + struct fpstate *fs = p->p_md.md_fpstate; if (fs == NULL) { KERNEL_LOCK(); @@ -697,7 +697,7 @@ rwindow_save(struct proc *p) for (i = 0; i < pcb->pcb_nsaved; i++) { pcb->pcb_rw[i].rw_in[7] ^= pcb->pcb_wcookie; if (copyout(&pcb->pcb_rw[i], (void *)(pcb->pcb_rwsp[i] + BIAS), - sizeof(struct rwindow64))) + sizeof(struct rwindow))) return (-1); } @@ -738,7 +738,7 @@ accesstype(unsigned int type, u_long sfsr) * of them could be recoverable through uvm_fault. */ void -data_access_fault(struct trapframe64 *tf, unsigned type, vaddr_t pc, +data_access_fault(struct trapframe *tf, unsigned type, vaddr_t pc, vaddr_t addr, vaddr_t sfva, u_long sfsr) { struct proc *p = curproc; @@ -858,7 +858,7 @@ out: * special PEEK/POKE code sequence. */ void -data_access_error(struct trapframe64 *tf, unsigned type, vaddr_t afva, +data_access_error(struct trapframe *tf, unsigned type, vaddr_t afva, u_long afsr, vaddr_t sfva, u_long sfsr) { struct proc *p = curproc; @@ -926,7 +926,7 @@ out: * of them could be recoverable through uvm_fault. */ void -text_access_fault(struct trapframe64 *tf, unsigned type, vaddr_t pc, +text_access_fault(struct trapframe *tf, unsigned type, vaddr_t pc, u_long sfsr) { struct proc *p = curproc; @@ -1004,7 +1004,7 @@ out: * special PEEK/POKE code sequence. */ void -text_access_error(struct trapframe64 *tf, unsigned type, vaddr_t pc, +text_access_error(struct trapframe *tf, unsigned type, vaddr_t pc, u_long sfsr, vaddr_t afva, u_long afsr) { struct proc *p = curproc; @@ -1100,7 +1100,7 @@ out: * thing that made the system call, and are named that way here. */ void -syscall(struct trapframe64 *tf, register_t code, register_t pc) +syscall(struct trapframe *tf, register_t code, register_t pc) { int i, nap; int64_t *ap; @@ -1119,7 +1119,7 @@ syscall(struct trapframe64 *tf, register_t code, register_t pc) panic("syscall from kernel"); if (curpcb != &p->p_addr->u_pcb) panic("syscall: cpcb/ppcb mismatch"); - if (tf != (struct trapframe64 *)((caddr_t)curpcb + USPACE) - 1) + if (tf != (struct trapframe *)((caddr_t)curpcb + USPACE) - 1) panic("syscall: trapframe"); #endif p->p_md.md_tf = tf; @@ -1161,7 +1161,7 @@ syscall(struct trapframe64 *tf, register_t code, register_t pc) panic("syscall nargs"); /* Read the whole block in */ if ((error = copyin((caddr_t)tf->tf_out[6] - + BIAS + offsetof(struct frame64, fr_argx), + + BIAS + offsetof(struct frame, fr_argx), &args[nap], (i - nap) * sizeof(register_t)))) goto bad; i = nap; @@ -1227,7 +1227,7 @@ void child_return(void *arg) { struct proc *p = arg; - struct trapframe64 *tf = p->p_md.md_tf; + struct trapframe *tf = p->p_md.md_tf; vaddr_t dest; /* Duplicate efforts of syscall(), but slightly differently */ diff --git a/sys/arch/sparc64/sparc64/vm_machdep.c b/sys/arch/sparc64/sparc64/vm_machdep.c index e6aa1bc2b98..e6e653d1c7e 100644 --- a/sys/arch/sparc64/sparc64/vm_machdep.c +++ b/sys/arch/sparc64/sparc64/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.40 2022/05/27 18:55:30 kettenis Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.41 2022/10/21 18:55:42 miod Exp $ */ /* $NetBSD: vm_machdep.c,v 1.38 2001/06/30 00:02:20 eeh Exp $ */ /* @@ -140,10 +140,10 @@ cpu_fork(struct proc *p1, struct proc *p2, void *stack, void *tcb, bcopy((caddr_t)opcb, (caddr_t)npcb, sizeof(struct pcb)); if (p1->p_md.md_fpstate) { fpusave_proc(p1, 1); - p2->p_md.md_fpstate = malloc(sizeof(struct fpstate64), + p2->p_md.md_fpstate = malloc(sizeof(struct fpstate), M_SUBPROC, M_WAITOK); bcopy(p1->p_md.md_fpstate, p2->p_md.md_fpstate, - sizeof(struct fpstate64)); + sizeof(struct fpstate)); } else p2->p_md.md_fpstate = NULL; @@ -265,7 +265,7 @@ cpu_exit(struct proc *p) { if (p->p_md.md_fpstate != NULL) { fpusave_proc(p, 0); - free(p->p_md.md_fpstate, M_SUBPROC, sizeof(struct fpstate64)); + free(p->p_md.md_fpstate, M_SUBPROC, sizeof(struct fpstate)); } pmap_deactivate(p); -- 2.20.1