diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/powerpc64/conf/Makefile.powerpc64 | 4 | ||||
-rw-r--r-- | sys/arch/powerpc64/conf/files.powerpc64 | 3 | ||||
-rw-r--r-- | sys/arch/powerpc64/include/_types.h | 4 | ||||
-rw-r--r-- | sys/arch/powerpc64/include/db_machdep.h | 89 | ||||
-rw-r--r-- | sys/arch/powerpc64/include/exec.h | 6 | ||||
-rw-r--r-- | sys/arch/powerpc64/include/opal.h | 6 | ||||
-rw-r--r-- | sys/arch/powerpc64/powerpc64/db_interface.c | 104 | ||||
-rw-r--r-- | sys/arch/powerpc64/powerpc64/db_trace.c | 67 | ||||
-rw-r--r-- | sys/arch/powerpc64/powerpc64/locore.S | 5 | ||||
-rw-r--r-- | sys/arch/powerpc64/powerpc64/machdep.c | 30 | ||||
-rw-r--r-- | sys/arch/powerpc64/powerpc64/trap.c | 14 | ||||
-rw-r--r-- | sys/arch/powerpc64/powerpc64/trap_subr.S | 54 |
12 files changed, 355 insertions, 31 deletions
diff --git a/sys/arch/powerpc64/conf/Makefile.powerpc64 b/sys/arch/powerpc64/conf/Makefile.powerpc64 index 7c339bc98fa..05a5ac38ade 100644 --- a/sys/arch/powerpc64/conf/Makefile.powerpc64 +++ b/sys/arch/powerpc64/conf/Makefile.powerpc64 @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.powerpc64,v 1.1 2020/05/16 17:11:14 kettenis Exp $ +# $OpenBSD: Makefile.powerpc64,v 1.2 2020/05/27 22:22:04 gkoehler Exp $ # For instructions on building kernels consult the config(8) and options(4) # manual pages. @@ -161,6 +161,8 @@ depend obj: locore0.o: ${_machdir}/${_mach}/locore0.S assym.h +trap_subr.o: ${_machdir}/${_mach}/trap_subr.S assym.h + hardlink-obsd: [[ ! -f /bsd ]] || cmp -s bsd /bsd || ln -f /bsd /obsd diff --git a/sys/arch/powerpc64/conf/files.powerpc64 b/sys/arch/powerpc64/conf/files.powerpc64 index 04585908d67..0140d746404 100644 --- a/sys/arch/powerpc64/conf/files.powerpc64 +++ b/sys/arch/powerpc64/conf/files.powerpc64 @@ -1,4 +1,4 @@ -# $OpenBSD: files.powerpc64,v 1.3 2020/05/22 15:07:46 kettenis Exp $ +# $OpenBSD: files.powerpc64,v 1.4 2020/05/27 22:22:04 gkoehler Exp $ maxpartitions 16 maxusers 2 8 128 @@ -19,6 +19,7 @@ file arch/powerpc64/powerpc64/autoconf.c file arch/powerpc64/powerpc64/conf.c file arch/powerpc64/powerpc64/cpu.c file arch/powerpc64/powerpc64/db_disasm.c ddb +file arch/powerpc64/powerpc64/db_interface.c ddb file arch/powerpc64/powerpc64/db_memrw.c ddb file arch/powerpc64/powerpc64/db_trace.c ddb file arch/powerpc64/powerpc64/disksubr.c diff --git a/sys/arch/powerpc64/include/_types.h b/sys/arch/powerpc64/include/_types.h index bc2cc00c0d5..c93d8b0d84e 100644 --- a/sys/arch/powerpc64/include/_types.h +++ b/sys/arch/powerpc64/include/_types.h @@ -1,4 +1,4 @@ -/* $OpenBSD: _types.h,v 1.1 2020/05/16 17:11:14 kettenis Exp $ */ +/* $OpenBSD: _types.h,v 1.2 2020/05/27 22:22:04 gkoehler Exp $ */ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -36,7 +36,7 @@ #if defined(_KERNEL) typedef struct label_t { - long val[13]; + long val[22]; } label_t; #endif diff --git a/sys/arch/powerpc64/include/db_machdep.h b/sys/arch/powerpc64/include/db_machdep.h index 29005daa76a..1b823b3ea02 100644 --- a/sys/arch/powerpc64/include/db_machdep.h +++ b/sys/arch/powerpc64/include/db_machdep.h @@ -1,25 +1,80 @@ -typedef long db_expr_t; +/* $OpenBSD: db_machdep.h,v 1.3 2020/05/27 22:22:04 gkoehler Exp $*/ +/* $NetBSD: db_machdep.h,v 1.13 1996/04/29 20:50:08 leo Exp $ */ -typedef long db_regs_t; +/* + * Mach Operating System + * Copyright (c) 1992 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ -extern db_regs_t ddb_regs; +/* + * Machine-dependent defines for new kernel debugger. + */ +#ifndef _MACHINE_DB_MACHDEP_H_ +#define _MACHINE_DB_MACHDEP_H_ -#define PC_REGS(regs) (*regs) +#include <sys/types.h> +#include <uvm/uvm_param.h> +#include <machine/trap.h> -#define BKPT_SIZE 4 -#define BKPT_SET(inst) 0xdeadbeef +typedef vaddr_t db_addr_t; /* address - unsigned */ +typedef long db_expr_t; /* expression - signed */ +typedef struct trapframe db_regs_t; +extern db_regs_t ddb_regs; /* register state */ -#define db_clear_single_step(regs) (0) -#define db_set_single_step(regs) (0) +#define PC_REGS(regs) ((regs)->srr0) +#define SET_PC_REGS(regs, value) PC_REGS(regs) = (value) -#define IS_BREAKPOINT_TRAP(type, code) (0) -#define IS_WATCHPOINT_TRAP(type, code) (0) +#define BKPT_INST 0x7C810808 /* breakpoint instruction */ -// ALL BROKEN!!! -#define inst_trap_return(ins) ((ins) == 0 && (ins) == 1) -#define inst_return(ins) ((ins) == 0 && (ins) == 1) - -#define inst_call(ins) ((ins) == 0 && (ins) == 1) -#define inst_branch(ins) ((ins) == 0 && (ins) == 1) -#define inst_unconditional_flow_transfer(ins) (0) +#define BKPT_SIZE (4) /* size of breakpoint inst */ +#define BKPT_SET(inst) (BKPT_INST) +#define FIXUP_PC_AFTER_BREAK(regs) ((regs)->srr0 -= 4) + +#define SR_SINGLESTEP 0x8000 +#define db_clear_single_step(regs) ((regs)->srr1 &= ~SR_SINGLESTEP) +#define db_set_single_step(regs) ((regs)->srr1 |= SR_SINGLESTEP) + +#define T_BREAKPOINT 0xffff +#define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BREAKPOINT) +#define IS_WATCHPOINT_TRAP(type, code) 0 + +#define M_RTS 0xfc0007fe +#define I_RTS 0x4c000020 +#define M_BC 0xfc000000 +#define I_BC 0x40000000 +#define M_B 0xfc000000 +#define I_B 0x50000000 +#define M_RFI 0xfc0007fe +#define I_RFI 0x4c000064 + +#define inst_trap_return(ins) (((ins)&M_RFI) == I_RFI) +#define inst_return(ins) (((ins)&M_RTS) == I_RTS) +#define inst_call(ins) (((ins)&M_BC ) == I_BC || \ + ((ins)&M_B ) == I_B ) + +struct trapframe; +void db_ktrap(int, db_regs_t *); + +#endif /* _MACHINE_DB_MACHDEP_H_ */ diff --git a/sys/arch/powerpc64/include/exec.h b/sys/arch/powerpc64/include/exec.h index a65ac47da72..f85c8361bcf 100644 --- a/sys/arch/powerpc64/include/exec.h +++ b/sys/arch/powerpc64/include/exec.h @@ -1,4 +1,4 @@ -/* $OpenBSD: exec.h,v 1.1 2020/05/16 17:11:14 kettenis Exp $ */ +/* $OpenBSD: exec.h,v 1.2 2020/05/27 22:22:04 gkoehler Exp $ */ /* * Copyright (c) 2014 Patrick Wildt <patrick@blueri.se> @@ -24,7 +24,7 @@ #define ARCH_ELFSIZE 64 #define ELF_TARG_CLASS ELFCLASS64 -#define ELF_TARG_DATA ELFDATA2LSB -#define ELF_TARG_MACH EM_AARCH64 +#define ELF_TARG_DATA ELFDATA2MSB +#define ELF_TARG_MACH EM_PPC64 #endif diff --git a/sys/arch/powerpc64/include/opal.h b/sys/arch/powerpc64/include/opal.h index 4cce8a2c18a..886cce8d8e2 100644 --- a/sys/arch/powerpc64/include/opal.h +++ b/sys/arch/powerpc64/include/opal.h @@ -1,4 +1,4 @@ -/* $OpenBSD: opal.h,v 1.1 2020/05/23 11:40:16 kettenis Exp $ */ +/* $OpenBSD: opal.h,v 1.2 2020/05/27 22:22:04 gkoehler Exp $ */ /* * Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org> @@ -21,14 +21,18 @@ #define OPAL_TEST 0 #define OPAL_CONSOLE_WRITE 1 +#define OPAL_CONSOLE_READ 2 #define OPAL_CEC_POWER_DOWN 5 #define OPAL_CEC_REBOOT 6 +#define OPAL_POLL_EVENTS 10 #ifndef _LOCORE int64_t opal_test(uint64_t); int64_t opal_console_write(int64_t, int64_t *, const uint8_t *); +int64_t opal_console_read(int64_t, int64_t *, uint8_t *); int64_t opal_cec_power_down(uint64_t); int64_t opal_cec_reboot(void); +int64_t opal_poll_events(uint64_t *); void opal_printf(const char *fmt, ...); #endif diff --git a/sys/arch/powerpc64/powerpc64/db_interface.c b/sys/arch/powerpc64/powerpc64/db_interface.c new file mode 100644 index 00000000000..02df878b041 --- /dev/null +++ b/sys/arch/powerpc64/powerpc64/db_interface.c @@ -0,0 +1,104 @@ +/* $OpenBSD: db_interface.c,v 1.1 2020/05/27 22:22:04 gkoehler Exp $ */ +/* $NetBSD: db_interface.c,v 1.12 2001/07/22 11:29:46 wiz Exp $ */ + +/* + * Mach Operating System + * Copyright (c) 1991,1990 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + * + * db_interface.c,v 2.4 1991/02/05 17:11:13 mrt (CMU) + */ + +#include <sys/param.h> +#include <sys/systm.h> + +#include <dev/cons.h> +#include <dev/ofw/fdt.h> + +#include <machine/db_machdep.h> +#include <ddb/db_elf.h> +#include <ddb/db_extern.h> +#include <ddb/db_sym.h> + +extern db_regs_t ddb_regs; /* db_trace.c */ +extern db_symtab_t db_symtab; /* ddb/db_elf.c */ +extern struct fdt_reg initrd_reg; /* machdep.c */ + +void +db_machine_init(void) +{ + db_expr_t val; + uint64_t a, b; + char *prop_start, *prop_end; + void *node; + + /* + * petitboot loads the kernel without symbols. + * If an initrd exists, try to load symbols from there. + */ + node = fdt_find_node("/chosen"); + if (fdt_node_property(node, "linux,initrd-start", &prop_start) != 8 && + fdt_node_property(node, "linux,initrd-end", &prop_end) != 8) { + printf("[ no initrd ]\n"); + return; + } + + a = bemtoh64((uint64_t *)prop_start); + b = bemtoh64((uint64_t *)prop_end); + initrd_reg.addr = trunc_page(a); + initrd_reg.size = round_page(b) - initrd_reg.addr; + db_elf_sym_init(b - a, (char *)a, (char *)b, "initrd"); + + /* The kernel is PIE. Add an offset to most symbols. */ + if (db_symbol_by_name("db_machine_init", &val) != NULL) { + Elf_Sym *symp, *symtab_start, *symtab_end; + Elf_Addr offset; + + symtab_start = STAB_TO_SYMSTART(&db_symtab); + symtab_end = STAB_TO_SYMEND(&db_symtab); + + offset = (Elf_Addr)db_machine_init - (Elf_Addr)val; + for (symp = symtab_start; symp < symtab_end; symp++) { + if (symp->st_shndx != SHN_ABS) + symp->st_value += offset; + } + } +} + +void +db_ktrap(int type, db_regs_t *frame) +{ + int s; + + ddb_regs = *frame; + + s = splhigh(); + db_active++; + cnpollc(1); + db_trap(type, 0); + cnpollc(0); + db_active--; + splx(s); + + *frame = ddb_regs; +} diff --git a/sys/arch/powerpc64/powerpc64/db_trace.c b/sys/arch/powerpc64/powerpc64/db_trace.c index f1236a40e9a..44c55dcf6d9 100644 --- a/sys/arch/powerpc64/powerpc64/db_trace.c +++ b/sys/arch/powerpc64/powerpc64/db_trace.c @@ -1,3 +1,32 @@ +/* $OpenBSD: db_trace.c,v 1.2 2020/05/27 22:22:04 gkoehler Exp $ */ +/* $NetBSD: db_trace.c,v 1.15 1996/02/22 23:23:41 gwr Exp $ */ + +/* + * Mach Operating System + * Copyright (c) 1992 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ + #include <sys/param.h> #include <machine/db_machdep.h> @@ -8,6 +37,44 @@ db_regs_t ddb_regs; struct db_variable db_regs[] = { + { "r0", (long *)&ddb_regs.fixreg[0], FCN_NULL }, + { "r1", (long *)&ddb_regs.fixreg[1], FCN_NULL }, + { "r2", (long *)&ddb_regs.fixreg[2], FCN_NULL }, + { "r3", (long *)&ddb_regs.fixreg[3], FCN_NULL }, + { "r4", (long *)&ddb_regs.fixreg[4], FCN_NULL }, + { "r5", (long *)&ddb_regs.fixreg[5], FCN_NULL }, + { "r6", (long *)&ddb_regs.fixreg[6], FCN_NULL }, + { "r7", (long *)&ddb_regs.fixreg[7], FCN_NULL }, + { "r8", (long *)&ddb_regs.fixreg[8], FCN_NULL }, + { "r9", (long *)&ddb_regs.fixreg[9], FCN_NULL }, + { "r10", (long *)&ddb_regs.fixreg[10], FCN_NULL }, + { "r11", (long *)&ddb_regs.fixreg[11], FCN_NULL }, + { "r12", (long *)&ddb_regs.fixreg[12], FCN_NULL }, + { "r13", (long *)&ddb_regs.fixreg[13], FCN_NULL }, + { "r14", (long *)&ddb_regs.fixreg[13], FCN_NULL }, + { "r15", (long *)&ddb_regs.fixreg[13], FCN_NULL }, + { "r16", (long *)&ddb_regs.fixreg[13], FCN_NULL }, + { "r17", (long *)&ddb_regs.fixreg[17], FCN_NULL }, + { "r18", (long *)&ddb_regs.fixreg[18], FCN_NULL }, + { "r19", (long *)&ddb_regs.fixreg[19], FCN_NULL }, + { "r20", (long *)&ddb_regs.fixreg[20], FCN_NULL }, + { "r21", (long *)&ddb_regs.fixreg[21], FCN_NULL }, + { "r22", (long *)&ddb_regs.fixreg[22], FCN_NULL }, + { "r23", (long *)&ddb_regs.fixreg[23], FCN_NULL }, + { "r24", (long *)&ddb_regs.fixreg[24], FCN_NULL }, + { "r25", (long *)&ddb_regs.fixreg[25], FCN_NULL }, + { "r26", (long *)&ddb_regs.fixreg[26], FCN_NULL }, + { "r27", (long *)&ddb_regs.fixreg[27], FCN_NULL }, + { "r28", (long *)&ddb_regs.fixreg[28], FCN_NULL }, + { "r29", (long *)&ddb_regs.fixreg[29], FCN_NULL }, + { "r30", (long *)&ddb_regs.fixreg[30], FCN_NULL }, + { "r31", (long *)&ddb_regs.fixreg[31], FCN_NULL }, + { "lr", (long *)&ddb_regs.lr, FCN_NULL }, + { "cr", (long *)&ddb_regs.cr, FCN_NULL }, + { "xer", (long *)&ddb_regs.xer, FCN_NULL }, + { "ctr", (long *)&ddb_regs.ctr, FCN_NULL }, + { "iar", (long *)&ddb_regs.srr0, FCN_NULL }, + { "msr", (long *)&ddb_regs.srr1, FCN_NULL }, }; struct db_variable *db_eregs = db_regs + nitems(db_regs); diff --git a/sys/arch/powerpc64/powerpc64/locore.S b/sys/arch/powerpc64/powerpc64/locore.S index de3b541ddc4..83760ed4d47 100644 --- a/sys/arch/powerpc64/powerpc64/locore.S +++ b/sys/arch/powerpc64/powerpc64/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.3 2020/05/23 11:40:16 kettenis Exp $ */ +/* $OpenBSD: locore.S,v 1.4 2020/05/27 22:22:04 gkoehler Exp $ */ /* * Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org> @@ -79,8 +79,10 @@ name: \ OPAL_CALL(OPAL_TEST, opal_test) OPAL_CALL(OPAL_CONSOLE_WRITE, opal_console_write) +OPAL_CALL(OPAL_CONSOLE_READ, opal_console_read) OPAL_CALL(OPAL_CEC_POWER_DOWN, opal_cec_power_down) OPAL_CALL(OPAL_CEC_REBOOT, opal_cec_reboot) +OPAL_CALL(OPAL_POLL_EVENTS, opal_poll_events) opal_call: mflr %r11 @@ -112,6 +114,7 @@ opal_call: #ifdef DDB .globl db_enter db_enter: + trap blr .globl setjmp diff --git a/sys/arch/powerpc64/powerpc64/machdep.c b/sys/arch/powerpc64/powerpc64/machdep.c index a0955df0ec2..d7677469bbc 100644 --- a/sys/arch/powerpc64/powerpc64/machdep.c +++ b/sys/arch/powerpc64/powerpc64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.9 2020/05/23 11:40:16 kettenis Exp $ */ +/* $OpenBSD: machdep.c,v 1.10 2020/05/27 22:22:04 gkoehler Exp $ */ /* * Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org> @@ -32,6 +32,12 @@ #include <dev/ofw/fdt.h> #include <dev/cons.h> +#ifdef DDB +#include <machine/db_machdep.h> +#include <ddb/db_extern.h> +#include <ddb/db_interface.h> +#endif + int cacheline_size = 128; struct uvm_constraint_range dma_constraint = { 0x0, (paddr_t)-1 }; @@ -62,6 +68,10 @@ extern char generictrap[]; struct fdt_reg memreg[VM_PHYSSEG_MAX]; int nmemreg; +#ifdef DDB +struct fdt_reg initrd_reg; +#endif + void memreg_add(const struct fdt_reg *); void memreg_remove(const struct fdt_reg *); @@ -159,6 +169,13 @@ init_powernv(void *fdt, void *tocbase) reg.size = round_page((paddr_t)fdt + fdt_get_size(fdt)) - reg.addr; memreg_remove(®); +#ifdef DDB + /* Load symbols from initrd. */ + db_machine_init(); + if (initrd_reg.addr != 0) + memreg_remove(&initrd_reg); +#endif + uvm_setpagesize(); for (i = 0; i < nmemreg; i++) { @@ -295,7 +312,16 @@ opal_cninit(struct consdev *cd) int opal_cngetc(dev_t dev) { - return -1; + uint64_t len; + char ch; + + for (;;) { + len = 1; + opal_console_read(0, &len, &ch); + if (len) + return ch; + opal_poll_events(NULL); + } } void diff --git a/sys/arch/powerpc64/powerpc64/trap.c b/sys/arch/powerpc64/powerpc64/trap.c index 091acdfc15a..7f37d556d7c 100644 --- a/sys/arch/powerpc64/powerpc64/trap.c +++ b/sys/arch/powerpc64/powerpc64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.2 2020/05/22 15:34:43 kettenis Exp $ */ +/* $OpenBSD: trap.c,v 1.3 2020/05/27 22:22:04 gkoehler Exp $ */ /* * Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org> @@ -19,10 +19,22 @@ #include <sys/param.h> #include <sys/systm.h> +#ifdef DDB +#include <machine/db_machdep.h> +#endif #include <machine/trap.h> void trap(struct trapframe *frame) { +#ifdef DDB + /* At a trap instruction, enter the debugger. */ + if (frame->exc == EXC_PGM && (frame->srr1 & EXC_PGM_TRAP)) { + db_ktrap(T_BREAKPOINT, frame); + frame->srr0 += 4; /* Step to next instruction. */ + return; + } +#endif + panic("trap type %lx at lr %lx", frame->exc, frame->lr); } diff --git a/sys/arch/powerpc64/powerpc64/trap_subr.S b/sys/arch/powerpc64/powerpc64/trap_subr.S index eeeaa41b759..332420481a9 100644 --- a/sys/arch/powerpc64/powerpc64/trap_subr.S +++ b/sys/arch/powerpc64/powerpc64/trap_subr.S @@ -1,4 +1,4 @@ -/* $OpenBSD: trap_subr.S,v 1.2 2020/05/22 16:27:49 kettenis Exp $ */ +/* $OpenBSD: trap_subr.S,v 1.3 2020/05/27 22:22:04 gkoehler Exp $ */ /* $NetBSD: trap_subr.S,v 1.20 2002/04/22 23:20:08 kleink Exp $ */ /*- @@ -128,7 +128,54 @@ std %r30, FRAME_SRR0+48(%r1); \ std %r31, FRAME_SRR1+48(%r1); - +#define FRAME_LEAVE(savearea) \ +/* Now restore regs: */ \ + ld %r3, FRAME_LR+48(%r1); \ + ld %r4, FRAME_CR+48(%r1); \ + ld %r5, FRAME_XER+48(%r1); \ + ld %r6, FRAME_CTR+48(%r1); \ + ld %r7, FRAME_SRR0+48(%r1); \ + ld %r8, FRAME_SRR1+48(%r1); \ + mtlr %r3; \ + mtcr %r4; \ + mtxer %r5; \ + mtctr %r6; \ + mtsrr0 %r7; \ + mtsrr1 %r8; \ + ld %r0, FRAME_0+48(%r1); \ + ld %r2, FRAME_2+48(%r1); \ + ld %r3, FRAME_3+48(%r1); \ + ld %r4, FRAME_4+48(%r1); \ + ld %r5, FRAME_5+48(%r1); \ + ld %r6, FRAME_6+48(%r1); \ + ld %r7, FRAME_7+48(%r1); \ + ld %r8, FRAME_8+48(%r1); \ + ld %r9, FRAME_9+48(%r1); \ + ld %r10, FRAME_10+48(%r1); \ + ld %r11, FRAME_11+48(%r1); \ + ld %r12, FRAME_12+48(%r1); \ + ld %r13, FRAME_13+48(%r1); \ + ld %r14, FRAME_14+48(%r1); \ + ld %r15, FRAME_15+48(%r1); \ + ld %r16, FRAME_16+48(%r1); \ + ld %r17, FRAME_17+48(%r1); \ + ld %r18, FRAME_18+48(%r1); \ + ld %r19, FRAME_19+48(%r1); \ + ld %r20, FRAME_20+48(%r1); \ + ld %r21, FRAME_21+48(%r1); \ + ld %r22, FRAME_22+48(%r1); \ + ld %r23, FRAME_23+48(%r1); \ + ld %r24, FRAME_24+48(%r1); \ + ld %r25, FRAME_25+48(%r1); \ + ld %r26, FRAME_26+48(%r1); \ + ld %r27, FRAME_27+48(%r1); \ + ld %r28, FRAME_28+48(%r1); \ + ld %r29, FRAME_29+48(%r1); \ + ld %r30, FRAME_30+48(%r1); \ + ld %r31, FRAME_31+48(%r1); \ + ld %r1, FRAME_1+48(%r1); + + .text .globl trapcode, trapcodeend @@ -184,3 +231,6 @@ generictrap: GET_TOCBASE(%r2) addi %r3, %r1, 48 bl trap + + FRAME_LEAVE(CI_TEMPSAVE) + rfid |