From 09a74b063a5e7e41d98144e1733220dfa3c98a2a Mon Sep 17 00:00:00 2001 From: Miod Vallat Date: Thu, 16 May 2002 07:37:45 +0000 Subject: Fix a long standing problem on vax: on "arithmetic fault" exceptions, we schedule a SIGFPE signal delivery to the faulting process. However, arithmetic faults come in two flavors: "traps" that are "regular" exceptions, and "faults" that are restartable exceptions. In the "fault" case, the frame pc points to the faulting instruction, instead of the next instruction, in case we could save the world by tweaking memory and make the instruction not fault again when restarted. In practice, this led to processes blocked in a SIGFPE loop madness. To avoid this, add a skip_opcode() routine to compute the address of the next opcode, effectively skipping the offending instruction ; this routine is a very stripped-down db_disasm(). While there, enhance the ddb disassembler to correctly recognize and disassemble two-byte opcodes. ok hugh@, deraadt@ --- sys/arch/vax/conf/files.vax | 3 +- sys/arch/vax/vax/db_disasm.c | 73 ++++---- sys/arch/vax/vax/db_disasm.h | 310 +++----------------------------- sys/arch/vax/vax/machdep.c | 142 ++++++++++++++- sys/arch/vax/vax/opcodes.c | 411 +++++++++++++++++++++++++++++++++++++++++++ sys/arch/vax/vax/trap.c | 21 ++- 6 files changed, 638 insertions(+), 322 deletions(-) create mode 100644 sys/arch/vax/vax/opcodes.c (limited to 'sys/arch') diff --git a/sys/arch/vax/conf/files.vax b/sys/arch/vax/conf/files.vax index 309dbef3595..f5a5e3dd555 100644 --- a/sys/arch/vax/conf/files.vax +++ b/sys/arch/vax/conf/files.vax @@ -1,4 +1,4 @@ -# $OpenBSD: files.vax,v 1.26 2002/04/04 23:47:47 deraadt Exp $ +# $OpenBSD: files.vax,v 1.27 2002/05/16 07:37:41 miod Exp $ # $NetBSD: files.vax,v 1.60 1999/08/27 20:04:32 ragge Exp $ # # new style config file for vax architecture @@ -350,6 +350,7 @@ file arch/vax/vax/ns_cksum.c ns file arch/vax/vax/disksubr.c disk | tape file arch/vax/vax/db_machdep.c ddb file arch/vax/vax/db_disasm.c ddb +file arch/vax/vax/opcodes.c file arch/vax/uba/uba_dma.c uba # builtin NCR53C95 SCSI Controller on VAXstation 4000 VLC/60/9x diff --git a/sys/arch/vax/vax/db_disasm.c b/sys/arch/vax/vax/db_disasm.c index 9045e326d56..390103e00a5 100644 --- a/sys/arch/vax/vax/db_disasm.c +++ b/sys/arch/vax/vax/db_disasm.c @@ -1,6 +1,7 @@ -/* $OpenBSD: db_disasm.c,v 1.10 2002/03/14 01:26:48 millert Exp $ */ +/* $OpenBSD: db_disasm.c,v 1.11 2002/05/16 07:37:44 miod Exp $ */ /* $NetBSD: db_disasm.c,v 1.10 1998/04/13 12:10:27 ragge Exp $ */ /* + * Copyright (c) 2002, Miodrag Vallat. * Copyright (c) 1996 Ludd, University of Lule}, Sweden. * All rights reserved. * @@ -103,18 +104,11 @@ typedef struct { char dasm[256]; /* disassebled instruction as text */ char *curp; /* pointer into result */ char *ppc; /* pseudo PC */ - int opc; /* op-code */ + u_int opc; /* op-code */ char *argp; /* pointer into argument-list */ - int itype; /* instruction-type, eg. branch, call, unspec */ - int atype; /* argument-type, eg. byte, long, address */ int off; /* offset specified by last argument */ int addr; /* address specified by last argument */ -} inst_buffer; - -#define ITYPE_INVALID -1 -#define ITYPE_UNSPEC 0 -#define ITYPE_BRANCH 1 -#define ITYPE_CALL 2 +} inst_buffer; int get_byte(inst_buffer * ib); int get_word(inst_buffer * ib); @@ -181,29 +175,20 @@ get_opcode(ib) inst_buffer *ib; { ib->opc = get_byte(ib); - if (ib->opc >> 2 == 0x3F) { /* two byte op-code */ + if (ib->opc >= 0xfd) { + /* two byte op-code */ ib->opc = ib->opc << 8; ib->opc += get_byte(ib); } - switch (ib->opc) { - case 0xFA: /* CALLG */ - case 0xFB: /* CALLS */ - case 0xFC: /* XFC */ - ib->itype = ITYPE_CALL; - break; - case 0x16: /* JSB */ - case 0x17: /* JMP */ - ib->itype = ITYPE_BRANCH; - break; - default: - ib->itype = ITYPE_UNSPEC; - } - if (ib->opc < 0 || ib->opc > 0xFF) { - add_str(ib, "invalid or two-byte opcode "); + + if (ib->opc > 0xffff) { + add_str(ib, "invalid opcode "); add_xint(ib, ib->opc); - ib->itype = ITYPE_INVALID; } else { - add_str(ib, vax_inst[ib->opc].mnemonic); + if (ib->opc > 0xff) + add_str(ib, vax_inst2[INDEX_OPCODE(ib->opc)].mnemonic); + else + add_str(ib, vax_inst[ib->opc].mnemonic); add_char(ib, '\t'); } return (ib->opc); @@ -216,12 +201,18 @@ get_operands(ib) int aa = 0; /* absolute address mode ? */ int size; - if (ib->opc < 0 || ib->opc > 0xFF) { - /* invalid or two-byte opcode */ + if (ib->opc > 0xffff) { + /* invalid opcode */ ib->argp = NULL; return (-1); - } - ib->argp = vax_inst[ib->opc].argdesc; + } else if (ib->opc > 0xff) { + /* two-byte opcode */ + ib->argp = vax_inst2[INDEX_OPCODE(ib->opc)].argdesc; + } else + ib->argp = vax_inst[ib->opc].argdesc; + + if (ib->argp == NULL) + return (0); while (*ib->argp) { switch (*ib->argp) { @@ -238,7 +229,8 @@ get_operands(ib) ib->off = get_long(ib); break; default: - err_print("XXX eror\n"); + err_print("invalid branch-type %X (%c) found.\n", + *ib->argp, *ib->argp); } /* add_int(ib, ib->off); */ ib->addr = (u_int) ib->ppc + ib->off; @@ -246,7 +238,8 @@ get_operands(ib) break; case 'a': /* absolute adressing mode */ - aa = 1; /* do not break here ! */ + aa = 1; + /* FALLTHROUGH */ default: switch (*(++ib->argp)) { @@ -291,7 +284,7 @@ get_operands(ib) add_char(ib, ','); add_char(ib, ' '); } else { - err_print("XXX error\n"); + err_print("error in opcodes.c\n"); add_char(ib, '\0'); return (-1); } @@ -453,6 +446,7 @@ get_word(ib) { int tmp; char *p = (void *) &tmp; + *p++ = get_byte(ib); *p++ = get_byte(ib); return (tmp); @@ -464,6 +458,7 @@ get_long(ib) { int tmp; char *p = (void *) &tmp; + *p++ = get_byte(ib); *p++ = get_byte(ib); *p++ = get_byte(ib); @@ -484,6 +479,10 @@ add_str(ib, s) inst_buffer *ib; char *s; { + + if (s == NULL) + s = "-reserved-"; + while ((*ib->curp++ = *s++)); *--ib->curp = '\0'; } @@ -494,6 +493,7 @@ add_int(ib, i) int i; { char buf[32]; + if (i < 100 && i > -100) sprintf(buf, "%d", i); else @@ -507,6 +507,7 @@ add_xint(ib, val) int val; { char buf[32]; + sprintf(buf, "0x%x", val); add_str(ib, buf); } @@ -520,7 +521,7 @@ add_sym(ib, loc) db_sym_t sym; char *symname; - if (! loc) + if (!loc) return; diff = INT_MAX; diff --git a/sys/arch/vax/vax/db_disasm.h b/sys/arch/vax/vax/db_disasm.h index 319bfcfbdba..f37ff38bcaa 100644 --- a/sys/arch/vax/vax/db_disasm.h +++ b/sys/arch/vax/vax/db_disasm.h @@ -1,6 +1,7 @@ -/* $OpenBSD: db_disasm.h,v 1.2 1997/05/29 00:05:15 niklas Exp $ */ +/* $OpenBSD: db_disasm.h,v 1.3 2002/05/16 07:37:44 miod Exp $ */ /* $NetBSD: db_disasm.h,v 1.1 1996/01/28 11:31:27 ragge Exp $ */ /* + * Copyright (c) 2002, Miodrag Vallat. * Copyright (c) 1996 Ludd, University of Lule}, Sweden. * All rights reserved. * @@ -34,8 +35,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - - #define SIZE_BYTE 1 /* Byte */ #define SIZE_WORD 2 /* Word */ #define SIZE_LONG 4 /* Longword */ @@ -51,13 +50,10 @@ * i.e. an address mode plus additional information. * * [VAX Architecture Handbook, p.52: Instruction Format] + * two-byte instruction set from + * [VAX Architecture Reference Manual, appendix A: Opcode Assignments] */ -struct { - char *mnemonic; - char *argdesc; -} vax_inst[256] = { - /* * argdesc describes each arguments by two characters denoting * the access-type and the data-type. @@ -86,277 +82,29 @@ struct { * ?: unknown (variable?) */ -/* 0x00 */ { "halt", "" }, -/* 0x01 */ { "nop", "" }, -/* 0x02 */ { "rei", "" }, -/* 0x03 */ { "bpt", "" }, -/* 0x04 */ { "ret", "" }, -/* 0x05 */ { "rsb", "" }, -/* 0x06 */ { "ldpctx", "" }, -/* 0x07 */ { "svpctx", "" }, -/* 0x08 */ { "cvtps", "rw,ab,rw,ab" }, -/* 0x09 */ { "cvtsp", "rw,ab,rw,ab" }, -/* 0x0a */ { "index", "rl,rl,rl,rl,rl,wl" }, -/* 0x0b */ { "crc", "ab,rl,rw,ab" }, -/* 0x0c */ { "prober", "rb,rw,ab" }, -/* 0x0d */ { "probew", "rb,rw,ab" }, -/* 0x0e */ { "insque", "ab,wl" }, -/* 0x0f */ { "remque", "ab,wl" }, - -/* 0x10 */ { "bsbb", "bb" }, -/* 0x11 */ { "brb", "bb" }, -/* 0x12 */ { "*bneq", "bb" }, -/* 0x13 */ { "*beql", "bb" }, -/* 0x14 */ { "bgtr", "bb" }, -/* 0x15 */ { "bleq", "bb" }, -/* 0x16 */ { "jsb", "ab" }, -/* 0x17 */ { "jmp", "ab" }, -/* 0x18 */ { "bgeq", "bb" }, -/* 0x19 */ { "blss", "bb" }, -/* 0x1a */ { "bgtru", "bb" }, -/* 0x1b */ { "blequ", "bb" }, -/* 0x1c */ { "bvc", "bb" }, -/* 0x1d */ { "bvs", "bb" }, -/* 0x1e */ { "*bcc", "bb" }, -/* 0x1f */ { "*bcs", "bb" }, - -/* 0x20 */ { "addp4", "rw,ab,rw,ab" }, -/* 0x21 */ { "addp6", "rw,ab,rw,ab,rw,ab" }, -/* 0x22 */ { "subp4", "rw,ab,rw,ab" }, -/* 0x23 */ { "subp6", "rw,ab,rw,ab,rw,ab" }, -/* 0x24 */ { "cvtpt", "rw,ab,ab,rw,ab" }, -/* 0x25 */ { "mulp", "rw,ab,rw,ab,rw,ab" }, -/* 0x26 */ { "cvttp", "rw,ab,ab,rw,ab" }, -/* 0x27 */ { "divp", "rw,ab,rw,ab,rw,ab" }, -/* 0x28 */ { "movc3", "rw,ab,ab" }, -/* 0x29 */ { "cmpc3", "rw,ab,ab" }, -/* 0x2a */ { "scanc", "rw,ab,ab,rb" }, -/* 0x2b */ { "spanc", "rw,ab,ab,rb" }, -/* 0x2c */ { "movc5", "rw,ab,rb,rw,ab" }, -/* 0x2d */ { "cmpc5", "rw,ab,rb,rw,ab" }, -/* 0x2e */ { "movtc", "rw,ab,rb,ab,rw,ab" }, -/* 0x2f */ { "movtuc", "rw,ab,rb,ab,rw,ab" }, - -/* 0x30 */ { "bsbw", "bw" }, -/* 0x31 */ { "brw", "bw" }, -/* 0x32 */ { "cvtwl", "rw,wl" }, -/* 0x33 */ { "cvtwb", "rw,wb" }, -/* 0x34 */ { "movp", "rw,ab,ab" }, -/* 0x35 */ { "cmpp3", "rw,ab,ab" }, -/* 0x36 */ { "cvtpl", "rw,ab,wl" }, -/* 0x37 */ { "cmpp4", "rw,ab,rw,ab" }, -/* 0x38 */ { "editpc", "rw,ab,ab,ab" }, -/* 0x39 */ { "matchc", "rw,ab,rw,ab" }, -/* 0x3a */ { "locc", "rb,rw,ab" }, -/* 0x3b */ { "skpc", "rb,rw,ab" }, -/* 0x3c */ { "movzwl", "rw,wl" }, -/* 0x3d */ { "acbw", "rw,rw,mw,bw" }, -/* 0x3e */ { "movaw", "aw,wl" }, -/* 0x3f */ { "pushaw", "aw" }, - -/* 0x40 */ { "addf2", "rf,mf" }, -/* 0x41 */ { "addf3", "rf,rf,wf" }, -/* 0x42 */ { "subf2", "rf,mf" }, -/* 0x43 */ { "subf3", "rf,rf,wf" }, -/* 0x44 */ { "mulf2", "rf,mf" }, -/* 0x45 */ { "mulf3", "rf,rf,wf" }, -/* 0x46 */ { "divf2", "rf,mf" }, -/* 0x47 */ { "divf3", "rf,rf,wf" }, -/* 0x48 */ { "cvtfb", "rf,wb" }, -/* 0x49 */ { "cvtfw", "rf,ww" }, -/* 0x4a */ { "cvtfl", "rf,wl" }, -/* 0x4b */ { "cvtrfl", "rf,wl" }, -/* 0x4c */ { "cvtbf", "rb,wf" }, -/* 0x4d */ { "cvtwf", "rw,wf" }, -/* 0x4e */ { "cvtlf", "rl,wf" }, -/* 0x4f */ { "acbf", "rf,rf,rf,bw" }, - -/* 0x50 */ { "movf", "rf,wf" }, -/* 0x51 */ { "cmpf", "rf,rf" }, -/* 0x52 */ { "mnegf", "rf,wf" }, -/* 0x53 */ { "tstf", "rf" }, -/* 0x54 */ { "emodf", "rf,rb,rf,wl,wf" }, -/* 0x55 */ { "polyf", "rf,rw,ab" }, -/* 0x56 */ { "cvtfd", "rf,wd" }, -/* 0x57 */ { "-reserved-", "" }, -/* 0x58 */ { "adawi", "rw,mw" }, -/* 0x59 */ { "-reserved-", "" }, -/* 0x5a */ { "-reserved-", "" }, -/* 0x5b */ { "-reserved-", "" }, -/* 0x5c */ { "insqhi", "ab,aq" }, -/* 0x5d */ { "insqti", "ab,aq" }, -/* 0x5e */ { "remqhi", "aq,wl" }, -/* 0x5f */ { "remqti", "aq,wl" }, - -/* 0x60 */ { "addd2", "rd,md" }, -/* 0x61 */ { "addd3", "rd,rd,wd" }, -/* 0x62 */ { "subd2", "rd,md" }, -/* 0x63 */ { "subd3", "rd,rd,wd" }, -/* 0x64 */ { "muld2", "rd,md" }, -/* 0x65 */ { "muld3", "rd,rd,wd" }, -/* 0x66 */ { "divd2", "rd,md" }, -/* 0x67 */ { "divd3", "rd,rd,wd" }, -/* 0x68 */ { "cvtdb", "rd,wb" }, -/* 0x69 */ { "cvtdw", "rd,ww" }, -/* 0x6a */ { "cvtdl", "rd,wl" }, -/* 0x6b */ { "cvtrdl", "rd,wl" }, -/* 0x6c */ { "cvtbd", "rb,wd" }, -/* 0x6d */ { "cvtwd", "rw,wd" }, -/* 0x6e */ { "cvtld", "rl,wd" }, -/* 0x6f */ { "acbd", "rd,rd,md,bw" }, - -/* 0x70 */ { "movd", "rd,wd" }, -/* 0x71 */ { "cmpd", "rd,rd" }, -/* 0x72 */ { "mnegd", "rd,wd" }, -/* 0x73 */ { "tstd", "rd" }, -/* 0x74 */ { "emodd", "rd,rb,rd,wl,wd" }, -/* 0x75 */ { "polyd", "rd,rw,ab" }, -/* 0x76 */ { "cvtdf", "rd,wf" }, -/* 0x77 */ { "-reserved-", "" }, -/* 0x78 */ { "ashl", "rb,rl,wl" }, -/* 0x79 */ { "ashq", "rb,rq,wq" }, -/* 0x7a */ { "emul", "rl,rl,rl,wq" }, -/* 0x7b */ { "ediv", "rl,rq,wl,wl" }, -/* 0x7c */ { "*clrq", "wq" }, -/* 0x7d */ { "movq", "rq,wq" }, -/* 0x7e */ { "*movaq", "aq,wl" }, -/* 0x7f */ { "*pushaq", "aq" }, - -/* 0x80 */ { "addb2", "rb,mb" }, -/* 0x81 */ { "addb3", "rb,rb,wb" }, -/* 0x82 */ { "subb2", "rb,mb" }, -/* 0x83 */ { "subb3", "rb,rb,wb" }, -/* 0x84 */ { "mulb2", "rb,mb" }, -/* 0x85 */ { "mulb3", "rb,rb,wb" }, -/* 0x86 */ { "divb2", "rb,mb" }, -/* 0x87 */ { "divb3", "rb,rb,wb" }, -/* 0x88 */ { "bisb2", "rb,mb" }, -/* 0x89 */ { "bisb3", "rb,rb,wb" }, -/* 0x8a */ { "bicb2", "rb,mb" }, -/* 0x8b */ { "bicb3", "rb,rb,wb" }, -/* 0x8c */ { "xorb2", "rb,mb" }, -/* 0x8d */ { "xorb3", "rb,rb,wb" }, -/* 0x8e */ { "mnegb", "rb,wb" }, -/* 0x8f */ { "caseb", "rb,rb,rb,bw-list" }, - -/* 0x90 */ { "movb", "rb,wb" }, -/* 0x91 */ { "cmpb", "rb,rb" }, -/* 0x92 */ { "mcomb", "rb,wb" }, -/* 0x93 */ { "bitb", "rb,rb" }, -/* 0x94 */ { "clrb", "wb" }, -/* 0x95 */ { "tstb", "rb" }, -/* 0x96 */ { "incb", "mb" }, -/* 0x97 */ { "decb", "mb" }, -/* 0x98 */ { "cvtbl", "rb,wl" }, -/* 0x99 */ { "cvtbw", "rb,ww" }, -/* 0x9a */ { "movzbl", "rb,wl" }, -/* 0x9b */ { "movzbw", "wb,ww" }, -/* 0x9c */ { "rotl", "rb,rl,wl" }, -/* 0x9d */ { "acbb", "rb,rb,mb,bw" }, -/* 0x9e */ { "movab", "ab,wl" }, -/* 0x9f */ { "pushab", "ab" }, - -/* 0xa0 */ { "addw2", "rw,mw" }, -/* 0xa1 */ { "addw3", "rw,rw,ww" }, -/* 0xa2 */ { "subw2", "rw,mw" }, -/* 0xa3 */ { "subw3", "rw,rw,ww" }, -/* 0xa4 */ { "mulw2", "rw,mw" }, -/* 0xa5 */ { "mulw3", "rw,rw,ww" }, -/* 0xa6 */ { "divw2", "rw,mw" }, -/* 0xa7 */ { "divw3", "rw,rw,ww" }, -/* 0xa8 */ { "bisw2", "rw,mw" }, -/* 0xa9 */ { "bisw3", "rw,rw,ww" }, -/* 0xaa */ { "bicw2", "rw,mw" }, -/* 0xab */ { "bicw3", "rw,rw,ww" }, -/* 0xac */ { "xorw2", "rw,mw" }, -/* 0xad */ { "xorw3", "rw,rw,ww" }, -/* 0xae */ { "mnegw", "rw,ww" }, -/* 0xaf */ { "casew", "rw,rw,rw,bw-list" }, - -/* 0xb0 */ { "movw", "rw,ww" }, -/* 0xb1 */ { "cmpw", "rw,rw" }, -/* 0xb2 */ { "mcomw", "rw,ww" }, -/* 0xb3 */ { "bitw", "rw,rw" }, -/* 0xb4 */ { "clrw", "mw" }, -/* 0xb5 */ { "tstw", "rw" }, -/* 0xb6 */ { "incw", "mw" }, -/* 0xb7 */ { "decw", "mw" }, -/* 0xb8 */ { "bispsw", "rw" }, -/* 0xb9 */ { "bicpsw", "rw" }, -/* 0xba */ { "popr", "rw" }, -/* 0xbb */ { "pushr", "rw" }, -/* 0xbc */ { "chmk", "rw" }, -/* 0xbd */ { "chme", "rw" }, -/* 0xbe */ { "chms", "rw" }, -/* 0xbf */ { "chmu", "rw" }, - -/* 0xc0 */ { "addl2", "rl,ml" }, -/* 0xc1 */ { "addl3", "rl,rl,wl" }, -/* 0xc2 */ { "subl2", "rl,ml" }, -/* 0xc3 */ { "subl3", "rl,rl,wl" }, -/* 0xc4 */ { "mull2", "rl,ml" }, -/* 0xc5 */ { "mull3", "rl,rl,wl" }, -/* 0xc6 */ { "divl2", "rl,ml" }, -/* 0xc7 */ { "divl3", "rl,rl,wl" }, -/* 0xc8 */ { "bisl2", "rl,ml" }, -/* 0xc9 */ { "bisl3", "rl,rl,wl" }, -/* 0xca */ { "bicl2", "rl,ml" }, -/* 0xcb */ { "bicl3", "rl,rl,wl" }, -/* 0xcc */ { "xorl2", "rl,ml" }, -/* 0xcd */ { "xorl3", "rl,rl,wl" }, -/* 0xce */ { "mnegl", "rl,wl" }, -/* 0xcf */ { "casel", "rl,rl,rl,bw-list" }, - -/* 0xd0 */ { "movl", "rl,wl" }, -/* 0xd1 */ { "cmpl", "rl,rl" }, -/* 0xd2 */ { "mcoml", "rl,wl" }, -/* 0xd3 */ { "bitl", "rl,rl" }, -/* 0xd4 */ { "*clrl", "wl" }, -/* 0xd5 */ { "tstl", "rl" }, -/* 0xd6 */ { "incl", "ml" }, -/* 0xd7 */ { "decl", "ml" }, -/* 0xd8 */ { "adwc", "rl,ml" }, -/* 0xd9 */ { "sbwc", "rl,ml" }, -/* 0xda */ { "mtpr", "rl,rl" }, -/* 0xdb */ { "mfpr", "rl,wl" }, -/* 0xdc */ { "movpsl", "wl" }, -/* 0xdd */ { "pushl", "rl" }, -/* 0xde */ { "*moval", "al,wl" }, -/* 0xdf */ { "*pushal", "al" }, - -/* 0xe0 */ { "bbs", "rl,vb,bb" }, -/* 0xe1 */ { "bbc", "rl,vb,bb" }, -/* 0xe2 */ { "bbss", "rl,vb,bb" }, -/* 0xe3 */ { "bbcs", "rl,vb,bb" }, -/* 0xe4 */ { "bbsc", "rl,vb,bb" }, -/* 0xe5 */ { "bbcc", "rl,vb,bb" }, -/* 0xe6 */ { "bbssi", "rl,vb,bb" }, -/* 0xe7 */ { "bbcci", "rl,vb,bb" }, -/* 0xe8 */ { "blbs", "rl,bb" }, -/* 0xe9 */ { "blbc", "rl,bb" }, -/* 0xea */ { "ffs", "rl,rb,vb" }, -/* 0xeb */ { "ffc", "rl,rb,vb" }, -/* 0xec */ { "cmpv", "rl,rb,vb,rl" }, -/* 0xed */ { "cmpzv", "rl,rb,vb,rl" }, -/* 0xee */ { "extv", "rl,rb,vb,wl" }, -/* 0xef */ { "extzv", "rl,rb,vb,wl" }, - -/* 0xf0 */ { "insv", "rl,rl,rb,vb" }, -/* 0xf1 */ { "acbl", "rl,rl,ml,bw" }, -/* 0xf2 */ { "aoblss", "rl,ml,bb" }, -/* 0xf3 */ { "aobleq", "rl,ml,bb" }, -/* 0xf4 */ { "sobgeq", "ml,bb" }, -/* 0xf5 */ { "sobgtr", "ml,bb" }, -/* 0xf6 */ { "cvtlb", "rl,wb" }, -/* 0xf7 */ { "cvtlw", "rl,ww" }, -/* 0xf8 */ { "ashp", "rb,rw,ab,rb,rw,ab" }, -/* 0xf9 */ { "cvtlp", "rl,rw,ab" }, -/* 0xfa */ { "callg", "ab,ab" }, -/* 0xfb */ { "calls", "rl,ab" }, -/* 0xfc */ { "xfc", "?" }, -/* 0xfd */ { "-reserved-", "" }, -/* 0xfe */ { "-reserved-", "" }, -/* 0xff */ { "-reserved-", "" }, - -}; +typedef struct vax_instr_t { + char *mnemonic; + char *argdesc; +} vax_instr_t; + +/* one-byte instructions */ +extern vax_instr_t vax_inst[]; + +/* two-byte instructions */ + +/* + * reasonably simple macro to gather all the reserved two-byte opcodes + * into only a few table entries... + */ +#define INDEX_OPCODE(x) \ + (((x) & 0xff00) == 0xfe00) ? 0 : \ + ((x) < 0xfd30) ? 0 : \ + ((x) < 0xfd80) ? (x) - 0xfd30 : \ + ((x) == 0xfd98) ? 0x50 : \ + ((x) == 0xfd99) ? 0x51 : \ + ((x) == 0xfdf6) ? 0x52 : \ + ((x) == 0xfdf7) ? 0x53 : \ + ((x) == 0xfffd) ? 0x54 : \ + ((x) == 0xfffe) ? 0x55 : 0 +extern vax_instr_t vax_inst2[]; diff --git a/sys/arch/vax/vax/machdep.c b/sys/arch/vax/vax/machdep.c index c2f8d2b5c2b..f6404516fa3 100644 --- a/sys/arch/vax/vax/machdep.c +++ b/sys/arch/vax/vax/machdep.c @@ -1,8 +1,9 @@ -/* $OpenBSD: machdep.c,v 1.58 2002/04/05 18:14:53 deraadt Exp $ */ +/* $OpenBSD: machdep.c,v 1.59 2002/05/16 07:37:44 miod Exp $ */ /* $NetBSD: machdep.c,v 1.108 2000/09/13 15:00:23 thorpej Exp $ */ /* - * Copyright (c) 1994, 1998 Ludd, University of Lule}, Sweden. + * Copyright (c) 2002, Miodrag Vallat. + * Copyright (c) 1994, 1996, 1998 Ludd, University of Lule}, Sweden. * Copyright (c) 1993 Adam Glass * Copyright (c) 1988 University of Utah. * Copyright (c) 1982, 1986, 1990 The Regents of the University of California. @@ -10,6 +11,9 @@ * * Changed for the VAX port (and for readability) /IC * + * This code is derived from software contributed to Ludd by + * Bertram Barth. + * * This code is derived from software contributed to Berkeley by the Systems * Programming Group of the University of Utah Computer Science Department. * @@ -118,6 +122,7 @@ #include #include #endif +#include #include "smg.h" @@ -838,3 +843,136 @@ allocsys(v) return (v); } +/* + * The following is a very stripped-down db_disasm.c, with only the logic + * to skip instructions. + */ + +long skip_operand(long ib, int size); + +static __inline__ u_int8_t +get_byte(ib) + long ib; +{ + return *((u_int8_t *)ib); +} + +long +skip_opcode(ib) + long ib; +{ + u_int opc; + int size; + char *argp; /* pointer into argument-list */ + + opc = get_byte(ib++); + if (opc >= 0xfd) { + /* two byte op-code */ + opc = opc << 8; + opc += get_byte(ib++); + argp = vax_inst2[INDEX_OPCODE(opc)].argdesc; + } else + argp = vax_inst[opc].argdesc; + + if (argp == NULL) + return ib; + + while (*argp) { + switch (*argp) { + + case 'b': /* branch displacement */ + switch (*(++argp)) { + case 'b': + ib++; + break; + case 'w': + ib += 2; + break; + case 'l': + ib += 4; + break; + } + break; + + case 'a': /* absolute adressing mode */ + /* FALLTHROUGH */ + default: + switch (*(++argp)) { + case 'b': /* Byte */ + size = 1; + break; + case 'w': /* Word */ + size = 2; + break; + case 'l': /* Long-Word */ + case 'f': /* F_Floating */ + size = 4; + break; + case 'q': /* Quad-Word */ + case 'd': /* D_Floating */ + case 'g': /* G_Floating */ + size = 8; + break; + case 'o': /* Octa-Word */ + case 'h': /* H_Floating */ + size = 16; + break; + default: + size = 0; + } + ib = skip_operand(ib, size); + } + + if (!*argp || !*++argp) + break; + if (*argp++ != ',') + break; + } + + return ib; +} + +long +skip_operand(ib, size) + long ib; + int size; +{ + int c = get_byte(ib++); + + switch (c >> 4) { /* mode */ + case 4: /* indexed */ + ib = skip_operand(ib, 0); + break; + + case 9: /* autoincrement deferred */ + if (c == 0x9f) { /* pc: immediate deferred */ + /* + * addresses are always longwords! + */ + ib += 4; + } + break; + case 8: /* autoincrement */ + if (c == 0x8f) { /* pc: immediate ==> special syntax */ + ib += size; + } + break; + + case 11: /* byte displacement deferred/ relative deferred */ + case 10: /* byte displacement / relative mode */ + ib++; + break; + + case 13: /* word displacement deferred */ + case 12: /* word displacement */ + ib += 2; + break; + + case 15: /* long displacement referred */ + case 14: /* long displacement */ + ib += 4; + break; + } + + return ib; +} diff --git a/sys/arch/vax/vax/opcodes.c b/sys/arch/vax/vax/opcodes.c new file mode 100644 index 00000000000..cb886583e04 --- /dev/null +++ b/sys/arch/vax/vax/opcodes.c @@ -0,0 +1,411 @@ +/* $OpenBSD: opcodes.c,v 1.1 2002/05/16 07:37:44 miod Exp $ */ + +/* + * Copyright (c) 2002, Miodrag Vallat. + * Copyright (c) 1996 Ludd, University of Lule}, Sweden. + * All rights reserved. + * + * This code is derived from software contributed to Ludd by + * Bertram Barth. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed at Ludd, University of + * Lule}, Sweden and its contributors. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include + +#include + +/* one-byte instructions */ +vax_instr_t vax_inst[256] = { +/* 0x00 */ { "halt", NULL }, +/* 0x01 */ { "nop", NULL }, +/* 0x02 */ { "rei", NULL }, +/* 0x03 */ { "bpt", NULL }, +/* 0x04 */ { "ret", NULL }, +/* 0x05 */ { "rsb", NULL }, +/* 0x06 */ { "ldpctx", NULL }, +/* 0x07 */ { "svpctx", NULL }, +/* 0x08 */ { "cvtps", "rw,ab,rw,ab" }, +/* 0x09 */ { "cvtsp", "rw,ab,rw,ab" }, +/* 0x0a */ { "index", "rl,rl,rl,rl,rl,wl" }, +/* 0x0b */ { "crc", "ab,rl,rw,ab" }, +/* 0x0c */ { "prober", "rb,rw,ab" }, +/* 0x0d */ { "probew", "rb,rw,ab" }, +/* 0x0e */ { "insque", "ab,wl" }, +/* 0x0f */ { "remque", "ab,wl" }, + +/* 0x10 */ { "bsbb", "bb" }, +/* 0x11 */ { "brb", "bb" }, +/* 0x12 */ { "*bneq", "bb" }, +/* 0x13 */ { "*beql", "bb" }, +/* 0x14 */ { "bgtr", "bb" }, +/* 0x15 */ { "bleq", "bb" }, +/* 0x16 */ { "jsb", "ab" }, +/* 0x17 */ { "jmp", "ab" }, +/* 0x18 */ { "bgeq", "bb" }, +/* 0x19 */ { "blss", "bb" }, +/* 0x1a */ { "bgtru", "bb" }, +/* 0x1b */ { "blequ", "bb" }, +/* 0x1c */ { "bvc", "bb" }, +/* 0x1d */ { "bvs", "bb" }, +/* 0x1e */ { "*bcc", "bb" }, +/* 0x1f */ { "*bcs", "bb" }, + +/* 0x20 */ { "addp4", "rw,ab,rw,ab" }, +/* 0x21 */ { "addp6", "rw,ab,rw,ab,rw,ab" }, +/* 0x22 */ { "subp4", "rw,ab,rw,ab" }, +/* 0x23 */ { "subp6", "rw,ab,rw,ab,rw,ab" }, +/* 0x24 */ { "cvtpt", "rw,ab,ab,rw,ab" }, +/* 0x25 */ { "mulp", "rw,ab,rw,ab,rw,ab" }, +/* 0x26 */ { "cvttp", "rw,ab,ab,rw,ab" }, +/* 0x27 */ { "divp", "rw,ab,rw,ab,rw,ab" }, +/* 0x28 */ { "movc3", "rw,ab,ab" }, +/* 0x29 */ { "cmpc3", "rw,ab,ab" }, +/* 0x2a */ { "scanc", "rw,ab,ab,rb" }, +/* 0x2b */ { "spanc", "rw,ab,ab,rb" }, +/* 0x2c */ { "movc5", "rw,ab,rb,rw,ab" }, +/* 0x2d */ { "cmpc5", "rw,ab,rb,rw,ab" }, +/* 0x2e */ { "movtc", "rw,ab,rb,ab,rw,ab" }, +/* 0x2f */ { "movtuc", "rw,ab,rb,ab,rw,ab" }, + +/* 0x30 */ { "bsbw", "bw" }, +/* 0x31 */ { "brw", "bw" }, +/* 0x32 */ { "cvtwl", "rw,wl" }, +/* 0x33 */ { "cvtwb", "rw,wb" }, +/* 0x34 */ { "movp", "rw,ab,ab" }, +/* 0x35 */ { "cmpp3", "rw,ab,ab" }, +/* 0x36 */ { "cvtpl", "rw,ab,wl" }, +/* 0x37 */ { "cmpp4", "rw,ab,rw,ab" }, +/* 0x38 */ { "editpc", "rw,ab,ab,ab" }, +/* 0x39 */ { "matchc", "rw,ab,rw,ab" }, +/* 0x3a */ { "locc", "rb,rw,ab" }, +/* 0x3b */ { "skpc", "rb,rw,ab" }, +/* 0x3c */ { "movzwl", "rw,wl" }, +/* 0x3d */ { "acbw", "rw,rw,mw,bw" }, +/* 0x3e */ { "movaw", "aw,wl" }, +/* 0x3f */ { "pushaw", "aw" }, + +/* 0x40 */ { "addf2", "rf,mf" }, +/* 0x41 */ { "addf3", "rf,rf,wf" }, +/* 0x42 */ { "subf2", "rf,mf" }, +/* 0x43 */ { "subf3", "rf,rf,wf" }, +/* 0x44 */ { "mulf2", "rf,mf" }, +/* 0x45 */ { "mulf3", "rf,rf,wf" }, +/* 0x46 */ { "divf2", "rf,mf" }, +/* 0x47 */ { "divf3", "rf,rf,wf" }, +/* 0x48 */ { "cvtfb", "rf,wb" }, +/* 0x49 */ { "cvtfw", "rf,ww" }, +/* 0x4a */ { "cvtfl", "rf,wl" }, +/* 0x4b */ { "cvtrfl", "rf,wl" }, +/* 0x4c */ { "cvtbf", "rb,wf" }, +/* 0x4d */ { "cvtwf", "rw,wf" }, +/* 0x4e */ { "cvtlf", "rl,wf" }, +/* 0x4f */ { "acbf", "rf,rf,rf,bw" }, + +/* 0x50 */ { "movf", "rf,wf" }, +/* 0x51 */ { "cmpf", "rf,rf" }, +/* 0x52 */ { "mnegf", "rf,wf" }, +/* 0x53 */ { "tstf", "rf" }, +/* 0x54 */ { "emodf", "rf,rb,rf,wl,wf" }, +/* 0x55 */ { "polyf", "rf,rw,ab" }, +/* 0x56 */ { "cvtfd", "rf,wd" }, +/* 0x57 */ { NULL, NULL }, +/* 0x58 */ { "adawi", "rw,mw" }, +/* 0x59 */ { NULL, NULL }, +/* 0x5a */ { NULL, NULL }, +/* 0x5b */ { NULL, NULL }, +/* 0x5c */ { "insqhi", "ab,aq" }, +/* 0x5d */ { "insqti", "ab,aq" }, +/* 0x5e */ { "remqhi", "aq,wl" }, +/* 0x5f */ { "remqti", "aq,wl" }, + +/* 0x60 */ { "addd2", "rd,md" }, +/* 0x61 */ { "addd3", "rd,rd,wd" }, +/* 0x62 */ { "subd2", "rd,md" }, +/* 0x63 */ { "subd3", "rd,rd,wd" }, +/* 0x64 */ { "muld2", "rd,md" }, +/* 0x65 */ { "muld3", "rd,rd,wd" }, +/* 0x66 */ { "divd2", "rd,md" }, +/* 0x67 */ { "divd3", "rd,rd,wd" }, +/* 0x68 */ { "cvtdb", "rd,wb" }, +/* 0x69 */ { "cvtdw", "rd,ww" }, +/* 0x6a */ { "cvtdl", "rd,wl" }, +/* 0x6b */ { "cvtrdl", "rd,wl" }, +/* 0x6c */ { "cvtbd", "rb,wd" }, +/* 0x6d */ { "cvtwd", "rw,wd" }, +/* 0x6e */ { "cvtld", "rl,wd" }, +/* 0x6f */ { "acbd", "rd,rd,md,bw" }, + +/* 0x70 */ { "movd", "rd,wd" }, +/* 0x71 */ { "cmpd", "rd,rd" }, +/* 0x72 */ { "mnegd", "rd,wd" }, +/* 0x73 */ { "tstd", "rd" }, +/* 0x74 */ { "emodd", "rd,rb,rd,wl,wd" }, +/* 0x75 */ { "polyd", "rd,rw,ab" }, +/* 0x76 */ { "cvtdf", "rd,wf" }, +/* 0x77 */ { NULL, NULL }, +/* 0x78 */ { "ashl", "rb,rl,wl" }, +/* 0x79 */ { "ashq", "rb,rq,wq" }, +/* 0x7a */ { "emul", "rl,rl,rl,wq" }, +/* 0x7b */ { "ediv", "rl,rq,wl,wl" }, +/* 0x7c */ { "*clrq", "wq" }, +/* 0x7d */ { "movq", "rq,wq" }, +/* 0x7e */ { "*movaq", "aq,wl" }, +/* 0x7f */ { "*pushaq", "aq" }, + +/* 0x80 */ { "addb2", "rb,mb" }, +/* 0x81 */ { "addb3", "rb,rb,wb" }, +/* 0x82 */ { "subb2", "rb,mb" }, +/* 0x83 */ { "subb3", "rb,rb,wb" }, +/* 0x84 */ { "mulb2", "rb,mb" }, +/* 0x85 */ { "mulb3", "rb,rb,wb" }, +/* 0x86 */ { "divb2", "rb,mb" }, +/* 0x87 */ { "divb3", "rb,rb,wb" }, +/* 0x88 */ { "bisb2", "rb,mb" }, +/* 0x89 */ { "bisb3", "rb,rb,wb" }, +/* 0x8a */ { "bicb2", "rb,mb" }, +/* 0x8b */ { "bicb3", "rb,rb,wb" }, +/* 0x8c */ { "xorb2", "rb,mb" }, +/* 0x8d */ { "xorb3", "rb,rb,wb" }, +/* 0x8e */ { "mnegb", "rb,wb" }, +/* 0x8f */ { "caseb", "rb,rb,rb,bw-list" }, + +/* 0x90 */ { "movb", "rb,wb" }, +/* 0x91 */ { "cmpb", "rb,rb" }, +/* 0x92 */ { "mcomb", "rb,wb" }, +/* 0x93 */ { "bitb", "rb,rb" }, +/* 0x94 */ { "clrb", "wb" }, +/* 0x95 */ { "tstb", "rb" }, +/* 0x96 */ { "incb", "mb" }, +/* 0x97 */ { "decb", "mb" }, +/* 0x98 */ { "cvtbl", "rb,wl" }, +/* 0x99 */ { "cvtbw", "rb,ww" }, +/* 0x9a */ { "movzbl", "rb,wl" }, +/* 0x9b */ { "movzbw", "wb,ww" }, +/* 0x9c */ { "rotl", "rb,rl,wl" }, +/* 0x9d */ { "acbb", "rb,rb,mb,bw" }, +/* 0x9e */ { "movab", "ab,wl" }, +/* 0x9f */ { "pushab", "ab" }, + +/* 0xa0 */ { "addw2", "rw,mw" }, +/* 0xa1 */ { "addw3", "rw,rw,ww" }, +/* 0xa2 */ { "subw2", "rw,mw" }, +/* 0xa3 */ { "subw3", "rw,rw,ww" }, +/* 0xa4 */ { "mulw2", "rw,mw" }, +/* 0xa5 */ { "mulw3", "rw,rw,ww" }, +/* 0xa6 */ { "divw2", "rw,mw" }, +/* 0xa7 */ { "divw3", "rw,rw,ww" }, +/* 0xa8 */ { "bisw2", "rw,mw" }, +/* 0xa9 */ { "bisw3", "rw,rw,ww" }, +/* 0xaa */ { "bicw2", "rw,mw" }, +/* 0xab */ { "bicw3", "rw,rw,ww" }, +/* 0xac */ { "xorw2", "rw,mw" }, +/* 0xad */ { "xorw3", "rw,rw,ww" }, +/* 0xae */ { "mnegw", "rw,ww" }, +/* 0xaf */ { "casew", "rw,rw,rw,bw-list" }, + +/* 0xb0 */ { "movw", "rw,ww" }, +/* 0xb1 */ { "cmpw", "rw,rw" }, +/* 0xb2 */ { "mcomw", "rw,ww" }, +/* 0xb3 */ { "bitw", "rw,rw" }, +/* 0xb4 */ { "clrw", "mw" }, +/* 0xb5 */ { "tstw", "rw" }, +/* 0xb6 */ { "incw", "mw" }, +/* 0xb7 */ { "decw", "mw" }, +/* 0xb8 */ { "bispsw", "rw" }, +/* 0xb9 */ { "bicpsw", "rw" }, +/* 0xba */ { "popr", "rw" }, +/* 0xbb */ { "pushr", "rw" }, +/* 0xbc */ { "chmk", "rw" }, +/* 0xbd */ { "chme", "rw" }, +/* 0xbe */ { "chms", "rw" }, +/* 0xbf */ { "chmu", "rw" }, + +/* 0xc0 */ { "addl2", "rl,ml" }, +/* 0xc1 */ { "addl3", "rl,rl,wl" }, +/* 0xc2 */ { "subl2", "rl,ml" }, +/* 0xc3 */ { "subl3", "rl,rl,wl" }, +/* 0xc4 */ { "mull2", "rl,ml" }, +/* 0xc5 */ { "mull3", "rl,rl,wl" }, +/* 0xc6 */ { "divl2", "rl,ml" }, +/* 0xc7 */ { "divl3", "rl,rl,wl" }, +/* 0xc8 */ { "bisl2", "rl,ml" }, +/* 0xc9 */ { "bisl3", "rl,rl,wl" }, +/* 0xca */ { "bicl2", "rl,ml" }, +/* 0xcb */ { "bicl3", "rl,rl,wl" }, +/* 0xcc */ { "xorl2", "rl,ml" }, +/* 0xcd */ { "xorl3", "rl,rl,wl" }, +/* 0xce */ { "mnegl", "rl,wl" }, +/* 0xcf */ { "casel", "rl,rl,rl,bw-list" }, + +/* 0xd0 */ { "movl", "rl,wl" }, +/* 0xd1 */ { "cmpl", "rl,rl" }, +/* 0xd2 */ { "mcoml", "rl,wl" }, +/* 0xd3 */ { "bitl", "rl,rl" }, +/* 0xd4 */ { "*clrl", "wl" }, +/* 0xd5 */ { "tstl", "rl" }, +/* 0xd6 */ { "incl", "ml" }, +/* 0xd7 */ { "decl", "ml" }, +/* 0xd8 */ { "adwc", "rl,ml" }, +/* 0xd9 */ { "sbwc", "rl,ml" }, +/* 0xda */ { "mtpr", "rl,rl" }, +/* 0xdb */ { "mfpr", "rl,wl" }, +/* 0xdc */ { "movpsl", "wl" }, +/* 0xdd */ { "pushl", "rl" }, +/* 0xde */ { "*moval", "al,wl" }, +/* 0xdf */ { "*pushal", "al" }, + +/* 0xe0 */ { "bbs", "rl,vb,bb" }, +/* 0xe1 */ { "bbc", "rl,vb,bb" }, +/* 0xe2 */ { "bbss", "rl,vb,bb" }, +/* 0xe3 */ { "bbcs", "rl,vb,bb" }, +/* 0xe4 */ { "bbsc", "rl,vb,bb" }, +/* 0xe5 */ { "bbcc", "rl,vb,bb" }, +/* 0xe6 */ { "bbssi", "rl,vb,bb" }, +/* 0xe7 */ { "bbcci", "rl,vb,bb" }, +/* 0xe8 */ { "blbs", "rl,bb" }, +/* 0xe9 */ { "blbc", "rl,bb" }, +/* 0xea */ { "ffs", "rl,rb,vb" }, +/* 0xeb */ { "ffc", "rl,rb,vb" }, +/* 0xec */ { "cmpv", "rl,rb,vb,rl" }, +/* 0xed */ { "cmpzv", "rl,rb,vb,rl" }, +/* 0xee */ { "extv", "rl,rb,vb,wl" }, +/* 0xef */ { "extzv", "rl,rb,vb,wl" }, + +/* 0xf0 */ { "insv", "rl,rl,rb,vb" }, +/* 0xf1 */ { "acbl", "rl,rl,ml,bw" }, +/* 0xf2 */ { "aoblss", "rl,ml,bb" }, +/* 0xf3 */ { "aobleq", "rl,ml,bb" }, +/* 0xf4 */ { "sobgeq", "ml,bb" }, +/* 0xf5 */ { "sobgtr", "ml,bb" }, +/* 0xf6 */ { "cvtlb", "rl,wb" }, +/* 0xf7 */ { "cvtlw", "rl,ww" }, +/* 0xf8 */ { "ashp", "rb,rw,ab,rb,rw,ab" }, +/* 0xf9 */ { "cvtlp", "rl,rw,ab" }, +/* 0xfa */ { "callg", "ab,ab" }, +/* 0xfb */ { "calls", "rl,ab" }, +/* 0xfc */ { "xfc", "?" }, +/* 0xfd */ { "-two-byte-", NULL }, +/* 0xfe */ { "-two-byte-", NULL }, +/* 0xff */ { "-two-byte-", NULL }, +}; + +/* two-byte instructions */ +vax_instr_t vax_inst2[0x56] = { +/* reserved */ { NULL, NULL }, +/* 0xfd31 */ { NULL, NULL }, +/* 0xfd32 */ { "cvtdh", "rd,wh" }, +/* 0xfd33 */ { "cvtgf", "rg,wf" }, +/* 0xfd34 */ { NULL, NULL }, +/* 0xfd35 */ { NULL, NULL }, +/* 0xfd36 */ { NULL, NULL }, +/* 0xfd37 */ { NULL, NULL }, +/* 0xfd38 */ { NULL, NULL }, +/* 0xfd39 */ { NULL, NULL }, +/* 0xfd3a */ { NULL, NULL }, +/* 0xfd3b */ { NULL, NULL }, +/* 0xfd3c */ { NULL, NULL }, +/* 0xfd3d */ { NULL, NULL }, +/* 0xfd3e */ { NULL, NULL }, +/* 0xfd3f */ { NULL, NULL }, + +/* 0xfd40 */ { "addg2", "rg,mg" }, +/* 0xfd41 */ { "addg3", "rg,rg,wg" }, +/* 0xfd42 */ { "subg2", "rg,mg" }, +/* 0xfd43 */ { "subg3", "rg,rg,wg" }, +/* 0xfd44 */ { "mulg2", "rg,mg" }, +/* 0xfd45 */ { "mulg3", "rg,rg,wg" }, +/* 0xfd46 */ { "divg2", "rg,mg" }, +/* 0xfd47 */ { "divg3", "rg,rg,wg" }, +/* 0xfd48 */ { "cvtgb", "rg,wb" }, +/* 0xfd49 */ { "cvtgw", "rg,ww" }, +/* 0xfd4a */ { "cvtgl", "rg,wl" }, +/* 0xfd4b */ { "cvtrgl", "rg,wl" }, +/* 0xfd4c */ { "cvtbg", "rb,wg" }, +/* 0xfd4d */ { "cvtwg", "rw,wg" }, +/* 0xfd4e */ { "cvtlg", "rl,wg" }, +/* 0xfd4f */ { "acbg", "rg,rg,mg,bg" }, + +/* 0xfd50 */ { "movg", "rg,wg" }, +/* 0xfd51 */ { "cmpg", "rg,rg" }, +/* 0xfd52 */ { "mnegg", "rg,wg" }, +/* 0xfd53 */ { "tstg", "rg" }, +/* 0xfd54 */ { "emodg", "rg,rb,rg,wl,wg" }, +/* 0xfd55 */ { "polyg", "rg,rw,ab" }, +/* 0xfd56 */ { "cvtgh", "rg,wh" }, +/* 0xfd57 */ { NULL, NULL }, +/* 0xfd58 */ { NULL, NULL }, +/* 0xfd59 */ { NULL, NULL }, +/* 0xfd5a */ { NULL, NULL }, +/* 0xfd5b */ { NULL, NULL }, +/* 0xfd5c */ { NULL, NULL }, +/* 0xfd5d */ { NULL, NULL }, +/* 0xfd5e */ { NULL, NULL }, +/* 0xfd5f */ { NULL, NULL }, + +/* 0xfd60 */ { "addh2", "rh,mh" }, +/* 0xfd61 */ { "addh3", "rh,rh,wh" }, +/* 0xfd62 */ { "subh2", "rh,mh" }, +/* 0xfd63 */ { "subh3", "rh,rh,wh" }, +/* 0xfd64 */ { "mulh2", "rh,mh" }, +/* 0xfd65 */ { "mulh3", "rh,rh,wh" }, +/* 0xfd66 */ { "divh2", "rh,mh" }, +/* 0xfd67 */ { "divh3", "rh,rh,wh" }, +/* 0xfd68 */ { "cvthb", "wh,rb" }, +/* 0xfd69 */ { "cvthw", "rh,ww" }, +/* 0xfd6a */ { "cvthl", "rh,wl" }, +/* 0xfd6b */ { "cvtrhl", "rh,wl" }, +/* 0xfd6c */ { "cvtbh", "rb,wh" }, +/* 0xfd6d */ { "cvtwh", "rw,wh" }, +/* 0xfd6e */ { "cvtlh", "rl,wh" }, +/* 0xfd6f */ { "acbh", "rh,rh,mh,bh" }, + +/* 0xfd70 */ { "movh", "rh,wh" }, +/* 0xfd71 */ { "cmph", "rh,rh" }, +/* 0xfd72 */ { "mnegh", "rh,wh" }, +/* 0xfd73 */ { "tsth", "rh" }, +/* 0xfd74 */ { "emodh" "rh,rb,rh,wl,wh" }, +/* 0xfd75 */ { "polyh", "rh,rw,ab" }, +/* 0xfd76 */ { "cvthg", "rh,wg" }, +/* 0xfd77 */ { NULL, NULL }, +/* 0xfd78 */ { NULL, NULL }, +/* 0xfd79 */ { NULL, NULL }, +/* 0xfd7a */ { NULL, NULL }, +/* 0xfd7b */ { NULL, NULL }, +/* 0xfd7c */ { "clrh", "wh" }, +/* 0xfd7d */ { "movo", "ro,wo" }, +/* 0xfd7e */ { "*mova", "ao,wl" }, +/* 0xfd7f */ { "*pusha", "ao" }, + +/* 0xfd98 */ { "cvtfh", "rf,wh" }, +/* 0xfd99 */ { "cvtfg", "rf,wg" }, +/* 0xfdf6 */ { "cvthf", "rh,wf" }, +/* 0xfdf7 */ { "cvthd", "rh,wd" }, +/* 0xfffd */ { "bugl", "bl" }, +/* 0xfffe */ { "bugw", "bw" }, +}; diff --git a/sys/arch/vax/vax/trap.c b/sys/arch/vax/vax/trap.c index 25dec04a9ee..d9291ea47c1 100644 --- a/sys/arch/vax/vax/trap.c +++ b/sys/arch/vax/vax/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.22 2002/03/14 03:16:02 millert Exp $ */ +/* $OpenBSD: trap.c,v 1.23 2002/05/16 07:37:44 miod Exp $ */ /* $NetBSD: trap.c,v 1.47 1999/08/21 19:26:20 matt Exp $ */ /* * Copyright (c) 1994 Ludd, University of Lule}, Sweden. @@ -313,8 +313,25 @@ if(faultdebug)printf("trap accflt type %lx, code %lx, pc %lx, psl %lx\n", } if (trapsig) { - sv.sival_ptr = (caddr_t)frame->pc; + sv.sival_ptr = (caddr_t)frame->pc; trapsignal(p, sig, frame->code, typ, sv); + + /* + * Arithmetic exceptions can be of two kinds: + * - traps (codes 1..7), where pc points to the + * next instruction to execute. + * - faults (codes 8..10), where pc points to the + * faulting instruction. + * In the latter case, we need to advance pc by ourselves + * to prevent a signal loop. + * + * XXX this is gross -- miod + */ + if (type == (T_ARITHFLT | T_USER) && frame->code >= 8) { + extern long skip_opcode(long); + + frame->pc = skip_opcode(frame->pc); + } } if (umode == 0) -- cgit v1.2.3