Home | History | Annotate | Line # | Download | only in vax
db_disasm.c revision 1.2
      1 /*	$NetBSD: db_disasm.c,v 1.2 1995/11/30 00:59:34 jtc Exp $ */
      2 /*
      3  * Copyright (c) 1995 Ludd, University of Lule}, Sweden.
      4  * All rights reserved.
      5  *
      6  * Redistribution and use in source and binary forms, with or without
      7  * modification, are permitted provided that the following conditions
      8  * are met:
      9  * 1. Redistributions of source code must retain the above copyright
     10  *    notice, this list of conditions and the following disclaimer.
     11  * 2. Redistributions in binary form must reproduce the above copyright
     12  *    notice, this list of conditions and the following disclaimer in the
     13  *    documentation and/or other materials provided with the distribution.
     14  * 3. All advertising materials mentioning features or use of this software
     15  *    must display the following acknowledgement:
     16  *      This product includes software developed at Ludd, University of
     17  *      Lule}, Sweden and its contributors.
     18  * 4. The name of the author may not be used to endorse or promote products
     19  *    derived from this software without specific prior written permission
     20  *
     21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  */
     32 
     33 
     34 #include <sys/param.h>
     35 #include <sys/proc.h>
     36 #include <sys/reboot.h>
     37 
     38 #include <ddb/db_variables.h>
     39 
     40 #include <machine/db_machdep.h>
     41 
     42 
     43 
     44 struct vax_insn {
     45 	char	*insn;
     46 	int 	nargs;
     47 } instr[] = {
     48 	"halt",	0,
     49 	"nop",	0,
     50 	"rei",	0,
     51 	"bpt",	0,
     52 	"ret",	0,
     53 	"rsb",	0,
     54 	"ldpctx",	0,
     55 	"svpctx",	0,
     56 	"cvtps",	4,
     57 	"cvtsp",	4,
     58 	"index",	6,
     59 	"crc",	4,
     60 	"prober",	3,
     61 	"probew",	3,
     62 	"insque",	2,
     63 	"remque",	2,
     64 	"",	-1,
     65 	"",	-1,
     66 	"",	-1,
     67 	"",	-1,
     68 	"",	-1,
     69 	"",	-1,
     70 	"",	-1,
     71 	"",	-1,
     72 	"",	-1,
     73 	"",	-1,
     74 	"",	-1,
     75 	"",	-1,
     76 	"",	-1,
     77 	"",	-1,
     78 	"",	-1,
     79 	"",	-1,
     80 	"",	-1,
     81 	"",	-1,
     82 	"",	-1,
     83 	"",	-1,
     84 	"",	-1,
     85 	"",	-1,
     86 	"",	-1,
     87 	"",	-1,
     88 	"",	-1,
     89 	"",	-1,
     90 	"",	-1,
     91 	"",	-1,
     92 	"",	-1,
     93 	"",	-1,
     94 	"",	-1,
     95 	"",	-1,
     96 	"",	-1,
     97 	"",	-1,
     98 	"",	-1,
     99 	"",	-1,
    100 	"",	-1,
    101 	"",	-1,
    102 	"",	-1,
    103 	"",	-1,
    104 	"",	-1,
    105 	"",	-1,
    106 	"",	-1,
    107 	"",	-1,
    108 	"",	-1,
    109 	"",	-1,
    110 	"",	-1,
    111 	"",	-1,
    112 	"",	-1,
    113 	"",	-1,
    114 	"",	-1,
    115 	"",	-1,
    116 	"",	-1,
    117 	"",	-1,
    118 	"",	-1,
    119 	"",	-1,
    120 	"",	-1,
    121 	"",	-1,
    122 	"",	-1,
    123 	"",	-1,
    124 	"",	-1,
    125 	"",	-1,
    126 	"",	-1,
    127 	"",	-1,
    128 	"",	-1,
    129 	"",	-1,
    130 	"",	-1,
    131 	"",	-1,
    132 	"",	-1,
    133 	"",	-1,
    134 	"",	-1,
    135 	"",	-1,
    136 	"",	-1,
    137 	"",	-1,
    138 	"",	-1,
    139 	"",	-1,
    140 	"",	-1,
    141 	"",	-1,
    142 	"",	-1,
    143 	"",	-1,
    144 	"",	-1,
    145 	"",	-1,
    146 	"",	-1,
    147 	"",	-1,
    148 	"",	-1,
    149 	"",	-1,
    150 	"",	-1,
    151 	"",	-1,
    152 	"",	-1,
    153 	"",	-1,
    154 	"",	-1,
    155 	"",	-1,
    156 	"",	-1,
    157 	"",	-1,
    158 	"",	-1,
    159 	"",	-1,
    160 	"",	-1,
    161 	"",	-1,
    162 	"",	-1,
    163 	"",	-1,
    164 	"",	-1,
    165 	"",	-1,
    166 	"",	-1,
    167 	"",	-1,
    168 	"",	-1,
    169 	"",	-1,
    170 	"",	-1,
    171 	"",	-1,
    172 	"",	-1,
    173 	"",	-1,
    174 	"",	-1,
    175 	"",	-1,
    176 	"",	-1,
    177 	"",	-1,
    178 	"",	-1,
    179 	"",	-1,
    180 	"",	-1,
    181 	"",	-1,
    182 	"",	-1,
    183 	"",	-1,
    184 	"",	-1,
    185 	"",	-1,
    186 	"",	-1,
    187 	"",	-1,
    188 	"",	-1,
    189 	"",	-1,
    190 	"",	-1,
    191 	"",	-1,
    192 	"",	-1,
    193 	"",	-1,
    194 	"",	-1,
    195 	"",	-1,
    196 	"",	-1,
    197 	"",	-1,
    198 	"",	-1,
    199 	"",	-1,
    200 	"",	-1,
    201 	"",	-1,
    202 	"",	-1,
    203 	"",	-1,
    204 	"",	-1,
    205 	"",	-1,
    206 	"",	-1,
    207 	"",	-1,
    208 	"",	-1,
    209 	"",	-1,
    210 	"",	-1,
    211 	"",	-1,
    212 	"",	-1,
    213 	"",	-1,
    214 	"",	-1,
    215 	"",	-1,
    216 	"",	-1,
    217 	"",	-1,
    218 	"",	-1,
    219 	"",	-1,
    220 	"",	-1,
    221 	"",	-1,
    222 	"",	-1,
    223 	"",	-1,
    224 	"",	-1,
    225 	"",	-1,
    226 	"",	-1,
    227 	"",	-1,
    228 	"",	-1,
    229 	"",	-1,
    230 	"",	-1,
    231 	"",	-1,
    232 	"",	-1,
    233 	"",	-1,
    234 	"",	-1,
    235 	"",	-1,
    236 	"",	-1,
    237 	"",	-1,
    238 	"",	-1,
    239 	"",	-1,
    240 	"",	-1,
    241 	"",	-1,
    242 	"",	-1,
    243 	"",	-1,
    244 	"",	-1,
    245 	"",	-1,
    246 	"",	-1,
    247 	"",	-1,
    248 	"",	-1,
    249 	"",	-1,
    250 	"",	-1,
    251 	"",	-1,
    252 	"",	-1,
    253 	"",	-1,
    254 	"",	-1,
    255 	"",	-1,
    256 	"",	-1,
    257 	"",	-1,
    258 	"",	-1,
    259 	"",	-1,
    260 	"",	-1,
    261 	"",	-1,
    262 	"",	-1,
    263 	"",	-1,
    264 	"",	-1,
    265 	"",	-1,
    266 	"",	-1,
    267 	"",	-1,
    268 	"",	-1,
    269 	"",	-1,
    270 	"",	-1,
    271 	"",	-1,
    272 	"",	-1,
    273 	"",	-1,
    274 	"",	-1,
    275 	"",	-1,
    276 	"",	-1,
    277 	"",	-1,
    278 	"",	-1,
    279 	"",	-1,
    280 	"",	-1,
    281 	"",	-1,
    282 	"",	-1,
    283 	"",	-1,
    284 	"",	-1,
    285 	"",	-1,
    286 	"",	-1,
    287 	"",	-1,
    288 	"",	-1,
    289 	"",	-1,
    290 	"",	-1,
    291 	"",	-1,
    292 	"",	-1,
    293 	"",	-1,
    294 	"",	-1,
    295 	"",	-1,
    296 	"",	-1,
    297 	"",	-1,
    298 	"",	-1,
    299 	"",	-1,
    300 	"",	-1,
    301 	"",	-1,
    302 	"",	-1,
    303 	"",	-1,
    304 	"",	-1,
    305 	"",	-1,
    306 	"",	-1,
    307 	"",	-1,
    308 	"",	-1,
    309 	"",	-1,
    310 	"",	-1,
    311 	"",	-1,
    312 	"",	-1,
    313 	"",	-1,
    314 	"",	-1,
    315 	"",	-1,
    316 	"",	-1,
    317 	"",	-1,
    318 	"",	-1,
    319 	"",	-1,
    320 };
    321 
    322 
    323 /*
    324  * Disassemble instruction at 'loc'.  'altfmt' specifies an
    325  * (optional) alternate format.  Return address of start of
    326  * next instruction.
    327  */
    328 db_addr_t
    329 db_disasm(loc, altfmt)
    330         db_addr_t       loc;
    331         boolean_t       altfmt;
    332 {
    333 	char *i_pl;
    334 	int inr, i;
    335 
    336 	i_pl = (char *)loc;
    337 	inr = *i_pl;
    338 
    339 	if (instr[*i_pl].nargs < 0) {
    340 		printf("Ok{nd instruktion: %2x",*i_pl&0xff);
    341 		i_pl++;
    342 	} else {
    343 		printf("\t%s\t",instr[inr].insn);
    344 		i_pl++;
    345 		for (i=0;i<instr[inr].nargs;i++) {
    346 			i_pl = (char *)argprint(i_pl);
    347 			if (i<instr[inr].nargs-1)
    348 				printf(",");
    349 		}
    350 	}
    351 
    352 
    353 
    354         return (int)i_pl;
    355 }
    356 
    357 argprint(plats)
    358 	char *plats;
    359 {
    360 	switch (*plats&0xf0) {
    361 	case 0x00:
    362 	case 0x10:
    363 	case 0x20:
    364 	case 0x30:
    365 		printf("$%x",*plats++);
    366 		break;
    367 
    368 	case 0xe0:
    369 		if (*plats++&15 == 15) {
    370 			printf("%8x",*(unsigned *)plats + plats);
    371 			plats += 4;
    372 		} else {
    373 			printf("Oinpl. s{tt.");
    374 		}
    375 		break;
    376 	default:
    377 		printf("Oinpl. s{tt.");
    378 	}
    379 	return (int)plats;
    380 }
    381