1 /* $NetBSD: db_interface.c,v 1.142 2026/11/10 03:43:26 thorpej Exp $ */ 2 3 /* 4 * Copyright (c) 1996-2002 Eduardo Horvath. All rights reserved. 5 * Mach Operating System 6 * Copyright (c) 1991,1990 Carnegie Mellon University 7 * All Rights Reserved. 8 * 9 * Permission to use, copy, modify and distribute this software and its 10 * documentation is hereby granted, provided that both the copyright 11 * notice and this permission notice appear in all copies of the 12 * software, derivative works or modified versions, and any portions 13 * thereof, and that both notices appear in supporting documentation. 14 * 15 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 16 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 17 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 18 * 19 * Carnegie Mellon requests users of this software to return to 20 * 21 * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU 22 * School of Computer Science 23 * Carnegie Mellon University 24 * Pittsburgh PA 15213-3890 25 * 26 * any improvements or extensions that they make and grant Carnegie the 27 * rights to redistribute these changes. 28 * 29 * From: db_interface.c,v 2.4 1991/02/05 17:11:13 mrt (CMU) 30 */ 31 32 /* 33 * Interface to new debugger. 34 */ 35 36 #include <sys/cdefs.h> 37 __KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.142 2026/11/10 03:43:26 thorpej Exp $"); 38 39 #ifdef _KERNEL_OPT 40 #include "opt_ddb.h" 41 #include "opt_multiprocessor.h" 42 #endif 43 44 #include <sys/param.h> 45 #include <sys/proc.h> 46 #include <sys/reboot.h> 47 #include <sys/systm.h> 48 #include <sys/atomic.h> 49 50 #include <uvm/uvm.h> 51 52 #include <dev/cons.h> 53 54 #include <machine/db_machdep.h> 55 #include <ddb/db_command.h> 56 #include <ddb/db_sym.h> 57 #include <ddb/db_variables.h> 58 #include <ddb/db_user.h> 59 #include <ddb/db_extern.h> 60 #include <ddb/db_access.h> 61 #include <ddb/db_active.h> 62 #include <ddb/db_output.h> 63 #include <ddb/db_interface.h> 64 #include <ddb/ddbvar.h> 65 66 #include <machine/instr.h> 67 #include <machine/cpu.h> 68 #ifdef _KERNEL 69 #include <machine/promlib.h> 70 #endif 71 #include <machine/ctlreg.h> 72 #include <machine/pmap.h> 73 #include <machine/intr.h> 74 #include <machine/vmparam.h> 75 76 #ifdef _KERNEL 77 #include "fb.h" 78 #else 79 #include <stddef.h> 80 #include <stdbool.h> 81 #endif 82 83 extern struct traptrace { 84 unsigned short tl:3, /* Trap level */ 85 ns:4, /* PCB nsaved */ 86 tt:9; /* Trap type */ 87 unsigned short pid; /* PID */ 88 u_int tstate; /* tstate */ 89 u_int tsp; /* sp */ 90 u_int tpc; /* pc */ 91 u_int tfault; /* MMU tag access */ 92 } trap_trace[], trap_trace_end[]; 93 94 void fill_ddb_regs_from_tf(struct trapframe64 *tf); 95 void ddb_restore_state(void); 96 bool ddb_running_on_this_cpu(void); 97 98 extern char *trap_type[]; 99 100 void kdb_kbd_trap(struct trapframe64 *); 101 void db_prom_cmd(db_expr_t, bool, db_expr_t, const char *); 102 void db_lwp_cmd(db_expr_t, bool, db_expr_t, const char *); 103 void db_proc_cmd(db_expr_t, bool, db_expr_t, const char *); 104 void db_ctx_cmd(db_expr_t, bool, db_expr_t, const char *); 105 void db_dump_pcb(db_expr_t, bool, db_expr_t, const char *); 106 void db_dump_pv(db_expr_t, bool, db_expr_t, const char *); 107 void db_setpcb(db_expr_t, bool, db_expr_t, const char *); 108 void db_dump_dtlb(db_expr_t, bool, db_expr_t, const char *); 109 void db_dump_itlb(db_expr_t, bool, db_expr_t, const char *); 110 void db_dump_dtsb(db_expr_t, bool, db_expr_t, const char *); 111 void db_dump_itsb(db_expr_t, bool, db_expr_t, const char *); 112 void db_pmap_kernel(db_expr_t, bool, db_expr_t, const char *); 113 void db_pload_cmd(db_expr_t, bool, db_expr_t, const char *); 114 void db_pmap_cmd(db_expr_t, bool, db_expr_t, const char *); 115 void db_traptrace(db_expr_t, bool, db_expr_t, const char *); 116 void db_watch(db_expr_t, bool, db_expr_t, const char *); 117 void db_pm_extract(db_expr_t, bool, db_expr_t, const char *); 118 void db_cpu_cmd(db_expr_t, bool, db_expr_t, const char *); 119 void db_sir_cmd(db_expr_t, bool, db_expr_t, const char *); 120 121 #ifdef DDB 122 static void db_dump_pmap(struct pmap *); 123 static void db_print_trace_entry(struct traptrace *, int); 124 125 #ifdef MULTIPROCESSOR 126 127 #define NOCPU -1 128 129 static int db_suspend_others(void); 130 static void ddb_suspend(struct trapframe64 *); 131 void db_resume_others(void); 132 133 int ddb_cpu = NOCPU; 134 135 bool 136 ddb_running_on_this_cpu(void) 137 { 138 return ddb_cpu == cpu_number(); 139 } 140 141 static int 142 db_suspend_others(void) 143 { 144 int cpu_me = cpu_number(); 145 bool win; 146 147 if (cpus == NULL) 148 return 1; 149 150 win = atomic_cas_32(&ddb_cpu, NOCPU, cpu_me) == (uint32_t)NOCPU; 151 if (win) 152 mp_pause_cpus(); 153 154 return win; 155 } 156 157 void 158 db_resume_others(void) 159 { 160 int cpu_me = cpu_number(); 161 162 if (atomic_cas_32(&ddb_cpu, cpu_me, NOCPU) == cpu_me) 163 mp_resume_cpus(); 164 } 165 166 static void 167 ddb_suspend(struct trapframe64 *tf) 168 { 169 170 sparc64_ipi_pause_thiscpu(tf); 171 } 172 #endif /* MULTIPROCESSOR */ 173 174 /* 175 * Received keyboard interrupt sequence. 176 */ 177 void 178 kdb_kbd_trap(struct trapframe64 *tf) 179 { 180 if (db_active == 0 /* && (boothowto & RB_KDB) */) { 181 printf("\n\nkernel: keyboard interrupt tf=%p\n", tf); 182 kdb_trap(-1, tf); 183 } 184 } 185 186 void 187 fill_ddb_regs_from_tf(struct trapframe64 *tf) 188 { 189 extern int savetstate(struct trapstate *); 190 191 #ifdef MULTIPROCESSOR 192 static db_regs_t ddbregs[CPUSET_MAXNUMCPU]; 193 194 curcpu()->ci_ddb_regs = &ddbregs[cpu_number()]; 195 #else 196 static db_regs_t ddbregs; 197 198 curcpu()->ci_ddb_regs = &ddbregs; 199 #endif 200 201 DDB_REGS->db_tf = *tf; 202 #ifdef __arch64__ 203 DDB_REGS->db_fr = *(struct frame64 *)(uintptr_t)tf->tf_out[6]; 204 #else 205 { 206 struct frame32 *tf32 = (struct frame32 *)(uintptr_t)tf->tf_out[6]; 207 int i; 208 209 for (i = 0; i < 8; i++) 210 DDB_REGS->db_fr.fr_local[i] = (uint32_t)tf32->fr_local[i]; 211 for (i = 0; i < 6; i++) 212 DDB_REGS->db_fr.fr_arg[i] = (uint32_t)tf32->fr_arg[i]; 213 DDB_REGS->db_fr.fr_fp = tf32->fr_fp; 214 DDB_REGS->db_fr.fr_pc = tf32->fr_pc; 215 } 216 #endif 217 218 if (fplwp) { 219 savefpstate(fplwp->l_md.md_fpstate); 220 DDB_REGS->db_fpstate = *fplwp->l_md.md_fpstate; 221 loadfpstate(fplwp->l_md.md_fpstate); 222 } 223 /* We should do a proper copyin and xlate 64-bit stack frames, but... */ 224 /* if (tf->tf_tstate & TSTATE_PRIV) { .. } */ 225 226 #if 0 227 /* make sure this is not causing ddb problems. */ 228 if (tf->tf_out[6] & 1) { 229 if ((unsigned)(tf->tf_out[6] + BIAS) > (unsigned)KERNBASE) 230 DDB_REGS->db_fr = *(struct frame64 *)(tf->tf_out[6] + BIAS); 231 else 232 copyin((void *)(tf->tf_out[6] + BIAS), &DDB_REGS->db_fr, sizeof(struct frame64)); 233 } else { 234 struct frame32 tfr; 235 int i; 236 237 /* First get a local copy of the frame32 */ 238 if ((unsigned)(tf->tf_out[6]) > (unsigned)KERNBASE) 239 tfr = *(struct frame32 *)tf->tf_out[6]; 240 else 241 copyin((void *)(tf->tf_out[6]), &tfr, sizeof(struct frame32)); 242 /* Now copy each field from the 32-bit value to the 64-bit value */ 243 for (i=0; i<8; i++) 244 DDB_REGS->db_fr.fr_local[i] = tfr.fr_local[i]; 245 for (i=0; i<6; i++) 246 DDB_REGS->db_fr.fr_arg[i] = tfr.fr_arg[i]; 247 DDB_REGS->db_fr.fr_fp = (long)tfr.fr_fp; 248 DDB_REGS->db_fr.fr_pc = tfr.fr_pc; 249 } 250 #else 251 int i; 252 for (i=0; i<8; i++) 253 DDB_REGS->db_fr.fr_local[i] = tf->tf_local[i]; 254 for (i=0; i<6; i++) 255 DDB_REGS->db_fr.fr_arg[i] = tf->tf_in[i]; 256 /* XXX tp and pc are missing */ 257 #endif 258 DDB_REGS->db_tl = savetstate(&DDB_REGS->db_ts[0]); 259 } 260 261 void 262 ddb_restore_state(void) 263 { 264 extern void restoretstate(int, struct trapstate *); 265 266 restoretstate(DDB_REGS->db_tl, &DDB_REGS->db_ts[0]); 267 if (fplwp) { 268 *fplwp->l_md.md_fpstate = DDB_REGS->db_fpstate; 269 loadfpstate(fplwp->l_md.md_fpstate); 270 } 271 } 272 273 /* 274 * kdb_trap - field a TRACE or BPT trap 275 */ 276 int 277 kdb_trap(int type, struct trapframe64 *tf) 278 { 279 int s; 280 extern int trap_trace_dis; 281 extern int doing_shutdown; 282 283 trap_trace_dis++; 284 doing_shutdown++; 285 #if NFB > 0 286 fb_unblank(); 287 #endif 288 switch (type) { 289 case T_BREAKPOINT: /* breakpoint */ 290 break; 291 case -1: /* keyboard interrupt */ 292 printf("kdb tf=%p\n", tf); 293 break; 294 default: 295 if (!db_onpanic && db_recover==0) 296 return (0); 297 298 printf("kernel trap %x: %s\n", type, trap_type[type & 0x1ff]); 299 if (db_recover != 0) { 300 prom_abort(); 301 db_error("Faulted in DDB; continuing...\n"); 302 prom_abort(); 303 /*NOTREACHED*/ 304 } 305 db_recover = (label_t *)1; 306 } 307 308 /* Should switch to kdb`s own stack here. */ 309 write_all_windows(); 310 311 #if defined(MULTIPROCESSOR) 312 if (!db_suspend_others()) { 313 ddb_suspend(tf); 314 return 1; 315 } 316 #endif 317 318 /* Initialise local dbregs storage from trap frame */ 319 fill_ddb_regs_from_tf(tf); 320 321 s = splhigh(); 322 db_active++; 323 cnpollc(true); 324 /* Need to do spl stuff till cnpollc works */ 325 db_dump_ts(0, 0, 0, 0); 326 db_trap(type, 0/*code*/); 327 ddb_restore_state(); 328 cnpollc(false); 329 db_active--; 330 331 splx(s); 332 333 *tf = DDB_REGS->db_tf; 334 curcpu()->ci_ddb_regs = NULL; 335 336 trap_trace_dis--; 337 doing_shutdown--; 338 339 #if defined(MULTIPROCESSOR) 340 db_resume_others(); 341 #endif 342 343 return (1); 344 } 345 #endif /* DDB */ 346 347 #ifdef _KERNEL 348 /* 349 * Read bytes from kernel address space for debugger. 350 */ 351 void 352 db_read_bytes(db_addr_t addr, size_t size, char *data) 353 { 354 char *src; 355 356 src = (char *)(uintptr_t)addr; 357 while (size-- > 0) { 358 *data++ = probeget((paddr_t)(u_long)src++, ASI_P, 1); 359 } 360 } 361 362 363 /* 364 * Write bytes to kernel address space for debugger. 365 */ 366 void 367 db_write_bytes(db_addr_t addr, size_t size, const char *data) 368 { 369 char *dst; 370 extern paddr_t pmap_kextract(vaddr_t va); 371 extern vaddr_t ektext; 372 373 dst = (char *)(uintptr_t)addr; 374 while (size-- > 0) { 375 if ((dst >= (char *)VM_MIN_KERNEL_ADDRESS) && 376 (dst < (char *)ektext)) 377 /* Read Only mapping -- need to do a bypass access */ 378 stba(pmap_kextract((vaddr_t)dst), ASI_PHYS_CACHED, *data); 379 else 380 *dst = *data; 381 dst++, data++; 382 } 383 384 } 385 #endif 386 387 #ifdef DDB 388 void 389 Debugger(void) 390 { 391 /* We use the breakpoint to trap into DDB */ 392 __asm("ta 1; nop"); 393 } 394 395 void 396 db_prom_cmd(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif) 397 { 398 prom_abort(); 399 } 400 401 /* 402 * Dump the [ID]TLB's. 403 * 404 * Spitfire has 64 entry TLBs for instruction and data. 405 * 406 * Cheetah has 5 TLBs in total: 407 * instruction tlbs - it16, it128 -- 16 and 128 entry TLBs 408 * data tlbs - dt16, dt512_0, dt512_1 -- 16, and 2*512 entry TLBs 409 * 410 * The TLB chosen is chosen depending on the values in bits 16/17, 411 * and the address is the index shifted 3 bits left. 412 * 413 * These are in db_tlb_access.S: 414 * void print_dtlb(size_t tlbsize, int tlbmask) 415 * void print_itlb(size_t tlbsize, int tlbmask) 416 */ 417 418 void 419 db_dump_dtlb(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif) 420 { 421 extern void print_dtlb(size_t /*tlbsize*/, int /*tlbmask*/); 422 423 if (CPU_IS_USIII_UP()) { 424 print_dtlb(TLB_SIZE_CHEETAH_D16, TLB_CHEETAH_D16); 425 db_printf("DT512_0:\n"); 426 print_dtlb(TLB_SIZE_CHEETAH_D512_0, TLB_CHEETAH_D512_0); 427 db_printf("DT512_1:\n"); 428 print_dtlb(TLB_SIZE_CHEETAH_D512_1, TLB_CHEETAH_D512_1); 429 } else 430 print_dtlb(TLB_SIZE_SPITFIRE, 0); 431 } 432 433 void 434 db_dump_itlb(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif) 435 { 436 extern void print_itlb(size_t /*tlbsize*/, int /*tlbmask*/); 437 438 if (CPU_IS_USIII_UP()) { 439 print_itlb(TLB_SIZE_CHEETAH_I16, TLB_CHEETAH_I16); 440 db_printf("IT128:\n"); 441 print_itlb(TLB_SIZE_CHEETAH_I128, TLB_CHEETAH_I128); 442 } else 443 print_itlb(TLB_SIZE_SPITFIRE, 0); 444 } 445 446 void 447 db_pload_cmd(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif) 448 { 449 static paddr_t oldaddr = -1; 450 int asi = ASI_PHYS_CACHED; 451 452 if (!have_addr) { 453 addr = oldaddr; 454 } 455 if (addr == -1) { 456 db_printf("no address\n"); 457 return; 458 } 459 addr &= ~0x7; /* align */ 460 { 461 register char c; 462 register const char *cp = modif; 463 while ((c = *cp++) != 0) 464 if (c == 'u') 465 asi = ASI_AIUS; 466 } 467 while (count--) { 468 if (db_print_position() == 0) { 469 /* Always print the address. */ 470 db_printf("%16.16lx:\t", (long)addr); 471 } 472 oldaddr=addr; 473 db_printf("%8.8lx\n", (long)ldxa(addr, asi)); 474 addr += 8; 475 if (db_print_position() != 0) 476 db_end_line(); 477 } 478 } 479 480 /* XXX no locking; shouldn't matter */ 481 int64_t pseg_get_real(struct pmap *, vaddr_t); 482 483 void 484 db_dump_pmap(struct pmap *pm) 485 { 486 /* print all valid pages in the kernel pmap */ 487 unsigned long long i, j, k, data0, data1; 488 paddr_t *pdir, *ptbl; 489 490 for (i = 0; i < STSZ; i++) { 491 pdir = (paddr_t *)(u_long)ldxa((vaddr_t)&pm->pm_segs[i], ASI_PHYS_CACHED); 492 if (!pdir) { 493 continue; 494 } 495 db_printf("pdir %lld at %lx:\n", i, (long)pdir); 496 for (k = 0; k < PDSZ; k++) { 497 ptbl = (paddr_t *)(u_long)ldxa((vaddr_t)&pdir[k], ASI_PHYS_CACHED); 498 if (!ptbl) { 499 continue; 500 } 501 db_printf("\tptable %lld:%lld at %lx:\n", i, k, (long)ptbl); 502 for (j = 0; j < PTSZ; j++) { 503 data0 = ldxa((vaddr_t)&ptbl[j], ASI_PHYS_CACHED); 504 j++; 505 data1 = ldxa((vaddr_t)&ptbl[j], ASI_PHYS_CACHED); 506 if (!data0 && !data1) { 507 continue; 508 } 509 db_printf("%016llx: %016llx\t", 510 (i << STSHIFT) | (k << PDSHIFT) | ((j - 1) << PTSHIFT), 511 data0); 512 db_printf("%016llx: %016llx\n", 513 (i << STSHIFT) | (k << PDSHIFT) | (j << PTSHIFT), 514 data1); 515 } 516 } 517 } 518 } 519 520 void 521 db_pmap_kernel(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif) 522 { 523 int i, j, full = 0; 524 uint64_t data; 525 526 { 527 register char c; 528 register const char *cp = modif; 529 while ((c = *cp++) != 0) 530 if (c == 'f') 531 full = 1; 532 } 533 if (have_addr) { 534 /* lookup an entry for this VA */ 535 536 if ((data = pseg_get_real(pmap_kernel(), (vaddr_t)addr))) { 537 db_printf("pmap_kernel(%p)->pm_segs[%lx][%lx][%lx]=>%qx\n", 538 (void *)(uintptr_t)addr, (u_long)va_to_seg(addr), 539 (u_long)va_to_dir(addr), (u_long)va_to_pte(addr), 540 (unsigned long long)data); 541 } else { 542 db_printf("No mapping for %p\n", (void *)(uintptr_t)addr); 543 } 544 return; 545 } 546 547 db_printf("pmap_kernel(%p) psegs %p phys %llx\n", 548 pmap_kernel(), pmap_kernel()->pm_segs, 549 (unsigned long long)pmap_kernel()->pm_physaddr); 550 if (full) { 551 db_dump_pmap(pmap_kernel()); 552 } else { 553 for (j=i=0; i<STSZ; i++) { 554 long seg = (long)ldxa((vaddr_t)pmap_kernel()->pm_segs[i], ASI_PHYS_CACHED); 555 if (seg) 556 db_printf("seg %d => %lx%c", i, seg, (j++%4)?'\t':'\n'); 557 } 558 } 559 } 560 561 void 562 db_pm_extract(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif) 563 { 564 if (have_addr) { 565 paddr_t pa; 566 567 if (pmap_extract(pmap_kernel(), addr, &pa)) 568 db_printf("pa = %llx\n", (long long)pa); 569 else 570 db_printf("%p not found\n", (void *)(uintptr_t)addr); 571 } else 572 db_printf("pmap_extract: no address\n"); 573 } 574 575 void 576 db_pmap_cmd(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif) 577 { 578 struct pmap* pm=NULL; 579 int i, j=0, full = 0; 580 581 { 582 register char c; 583 register const char *cp = modif; 584 if (modif) 585 while ((c = *cp++) != 0) 586 if (c == 'f') 587 full = 1; 588 } 589 if (curlwp && curlwp->l_proc->p_vmspace) 590 pm = curlwp->l_proc->p_vmspace->vm_map.pmap; 591 if (have_addr) 592 pm = (struct pmap*)(uintptr_t)addr; 593 594 db_printf("pmap %p: ctx %x refs %d physaddr %llx psegs %p\n", 595 pm, pmap_ctx(pm), pm->pm_refs, 596 (unsigned long long)pm->pm_physaddr, pm->pm_segs); 597 598 if (full) { 599 db_dump_pmap(pm); 600 } else { 601 for (i=0; i<STSZ; i++) { 602 long seg = (long)ldxa((vaddr_t)pmap_kernel()->pm_segs[i], ASI_PHYS_CACHED); 603 if (seg) 604 db_printf("seg %d => %lx%c", i, seg, (j++%4)?'\t':'\n'); 605 } 606 } 607 } 608 609 #define TSBENTS (512 << tsbsize) 610 extern pte_t *tsb_dmmu, *tsb_immu; 611 extern int tsbsize; 612 613 void db_dump_tsb_common(pte_t *); 614 615 void 616 db_dump_dtsb(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif) 617 { 618 619 db_printf("DTSB:\n"); 620 db_dump_tsb_common(curcpu()->ci_tsb_dmmu); 621 } 622 623 void 624 db_dump_itsb(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif) 625 { 626 627 db_printf("ITSB:\n"); 628 db_dump_tsb_common(curcpu()->ci_tsb_immu); 629 } 630 631 void 632 db_dump_tsb_common(pte_t *tsb) 633 { 634 uint64_t tag, data; 635 int i; 636 637 for (i = 0; i < TSBENTS; i++) { 638 tag = tsb[i].tag; 639 data = tsb[i].data; 640 db_printf("%4d:%4d:%08x %08x:%08x ", i, 641 (int)((tag & TSB_TAG_G) ? -1 : TSB_TAG_CTX(tag)), 642 (int)((i << 13) | TSB_TAG_VA(tag)), 643 (int)(data >> 32), (int)data); 644 i++; 645 tag = tsb[i].tag; 646 data = tsb[i].data; 647 db_printf("%4d:%4d:%08x %08x:%08x\n", i, 648 (int)((tag & TSB_TAG_G) ? -1 : TSB_TAG_CTX(tag)), 649 (int)((i << 13) | TSB_TAG_VA(tag)), 650 (int)(data >> 32), (int)data); 651 } 652 } 653 654 void db_page_cmd(db_expr_t, bool, db_expr_t, const char *); 655 void 656 db_page_cmd(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif) 657 { 658 659 if (!have_addr) { 660 db_printf("Need paddr for page\n"); 661 return; 662 } 663 664 db_printf("pa %llx pg %p\n", (unsigned long long)addr, 665 PHYS_TO_VM_PAGE(addr)); 666 } 667 668 void 669 db_lwp_cmd(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif) 670 { 671 struct lwp *l; 672 673 l = curlwp; 674 if (have_addr) 675 l = (struct lwp*)(uintptr_t)addr; 676 if (l == NULL) { 677 db_printf("no current lwp\n"); 678 return; 679 } 680 db_printf("lwp %p: lid %d\n", l, l->l_lid); 681 db_printf("wchan:%p pri:%d epri:%d tf:%p\n", 682 l->l_wchan, l->l_priority, lwp_eprio(l), l->l_md.md_tf); 683 db_printf("pcb: %p fpstate: %p\n", lwp_getpcb(l), 684 l->l_md.md_fpstate); 685 return; 686 } 687 688 void 689 db_proc_cmd(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif) 690 { 691 struct proc *p = NULL; 692 693 if (curlwp) 694 p = curlwp->l_proc; 695 if (have_addr) 696 p = (struct proc*)(uintptr_t)addr; 697 if (p == NULL) { 698 db_printf("no current process\n"); 699 return; 700 } 701 db_printf("process %p:", p); 702 db_printf("pid:%d vmspace:%p pmap:%p ctx:%x\n", 703 p->p_pid, p->p_vmspace, p->p_vmspace->vm_map.pmap, 704 pmap_ctx(p->p_vmspace->vm_map.pmap)); 705 db_printf("maxsaddr:%p ssiz:%dpg or %llxB\n", 706 p->p_vmspace->vm_maxsaddr, p->p_vmspace->vm_ssize, 707 (unsigned long long)ctob(p->p_vmspace->vm_ssize)); 708 db_printf("profile timer: %" PRId64 " sec %ld nsec\n", 709 p->p_stats->p_timer[ITIMER_PROF].it_value.tv_sec, 710 p->p_stats->p_timer[ITIMER_PROF].it_value.tv_nsec); 711 return; 712 } 713 714 void 715 db_ctx_cmd(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif) 716 { 717 struct proc *p; 718 struct lwp *l; 719 struct pcb *pcb; 720 721 /* XXX LOCKING XXX */ 722 LIST_FOREACH(p, &allproc, p_list) { 723 if (p->p_stat) { 724 db_printf("process %p:", p); 725 db_printf("pid:%d pmap:%p ctx:%x\n", 726 p->p_pid, p->p_vmspace->vm_map.pmap, 727 pmap_ctx(p->p_vmspace->vm_map.pmap)); 728 LIST_FOREACH(l, &p->p_lwps, l_sibling) { 729 pcb = lwp_getpcb(l); 730 db_printf("\tlwp %p: lid:%d tf:%p fpstate %p " 731 "lastcall:%s\n", 732 l, l->l_lid, l->l_md.md_tf, l->l_md.md_fpstate, 733 (pcb->lastcall) ? 734 pcb->lastcall : "Null"); 735 } 736 } 737 } 738 return; 739 } 740 741 void 742 db_dump_pcb(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif) 743 { 744 struct pcb *pcb; 745 int i; 746 747 pcb = curpcb; 748 if (have_addr) 749 pcb = (struct pcb*)(uintptr_t)addr; 750 751 db_printf("pcb@%p sp:%p pc:%p cwp:%d pil:%d nsaved:%x onfault:%p\nlastcall:%s\nfull windows:\n", 752 pcb, (void *)(long)pcb->pcb_sp, (void *)(long)pcb->pcb_pc, pcb->pcb_cwp, 753 pcb->pcb_pil, pcb->pcb_nsaved, (void *)pcb->pcb_onfault, 754 (pcb->lastcall)?pcb->lastcall:"Null"); 755 756 for (i=0; i<pcb->pcb_nsaved; i++) { 757 db_printf("win %d: at %llx local, in\n", i, 758 (unsigned long long)pcb->pcb_rw[i+1].rw_in[6]); 759 db_printf("%16llx %16llx %16llx %16llx\n", 760 (unsigned long long)pcb->pcb_rw[i].rw_local[0], 761 (unsigned long long)pcb->pcb_rw[i].rw_local[1], 762 (unsigned long long)pcb->pcb_rw[i].rw_local[2], 763 (unsigned long long)pcb->pcb_rw[i].rw_local[3]); 764 db_printf("%16llx %16llx %16llx %16llx\n", 765 (unsigned long long)pcb->pcb_rw[i].rw_local[4], 766 (unsigned long long)pcb->pcb_rw[i].rw_local[5], 767 (unsigned long long)pcb->pcb_rw[i].rw_local[6], 768 (unsigned long long)pcb->pcb_rw[i].rw_local[7]); 769 db_printf("%16llx %16llx %16llx %16llx\n", 770 (unsigned long long)pcb->pcb_rw[i].rw_in[0], 771 (unsigned long long)pcb->pcb_rw[i].rw_in[1], 772 (unsigned long long)pcb->pcb_rw[i].rw_in[2], 773 (unsigned long long)pcb->pcb_rw[i].rw_in[3]); 774 db_printf("%16llx %16llx %16llx %16llx\n", 775 (unsigned long long)pcb->pcb_rw[i].rw_in[4], 776 (unsigned long long)pcb->pcb_rw[i].rw_in[5], 777 (unsigned long long)pcb->pcb_rw[i].rw_in[6], 778 (unsigned long long)pcb->pcb_rw[i].rw_in[7]); 779 } 780 } 781 782 783 void 784 db_setpcb(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif) 785 { 786 struct proc *p; 787 int ctx; 788 789 if (!have_addr) { 790 db_printf("What PID do you want to map in?\n"); 791 return; 792 } 793 794 LIST_FOREACH(p, &allproc, p_list) { 795 if (p->p_stat && p->p_pid == addr) { 796 if (p->p_vmspace->vm_map.pmap == pmap_kernel()) { 797 db_printf("PID %ld has a kernel context.\n", 798 (long)addr); 799 return; 800 } 801 ctx = pmap_ctx(p->p_vmspace->vm_map.pmap); 802 if (ctx < 0) { 803 ctx = -ctx; 804 pmap_ctx(p->p_vmspace->vm_map.pmap) = ctx; 805 } else if (ctx == 0) { 806 pmap_activate_pmap(p->p_vmspace->vm_map.pmap); 807 ctx = pmap_ctx(p->p_vmspace->vm_map.pmap); 808 } 809 if (ctx > 0) { 810 if (CPU_IS_USIII_UP()) 811 switchtoctx_usiii(ctx); 812 else 813 switchtoctx_us(ctx); 814 return; 815 } 816 db_printf("could not activate pmap for PID %ld.\n", 817 (long)addr); 818 return; 819 } 820 } 821 db_printf("PID %ld not found.\n", (long)addr); 822 } 823 824 static void 825 db_print_trace_entry(struct traptrace *te, int i) 826 { 827 db_printf("%d:%d p:%d tt:%x:%llx:%llx %llx:%llx ", i, 828 (int)te->tl, (int)te->pid, 829 (int)te->tt, (unsigned long long)te->tstate, 830 (unsigned long long)te->tfault, (unsigned long long)te->tsp, 831 (unsigned long long)te->tpc); 832 db_printsym((u_long)te->tpc, DB_STGY_PROC, db_printf); 833 db_printf(": "); 834 if ((te->tpc && !(te->tpc&0x3)) && 835 curlwp && 836 (curproc->p_pid == te->pid)) { 837 db_disasm((u_long)te->tpc, 0); 838 } else db_printf("\n"); 839 } 840 841 void 842 db_traptrace(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif) 843 { 844 int i, start = 0, full = 0, reverse = 0; 845 struct traptrace *end; 846 847 start = 0; 848 end = &trap_trace_end[0]; 849 850 { 851 register char c; 852 register const char *cp = modif; 853 if (modif) 854 while ((c = *cp++) != 0) { 855 if (c == 'f') 856 full = 1; 857 if (c == 'r') 858 reverse = 1; 859 } 860 } 861 862 if (have_addr) { 863 start = addr / (sizeof (struct traptrace)); 864 if (&trap_trace[start] > &trap_trace_end[0]) { 865 db_printf("Address out of range.\n"); 866 return; 867 } 868 if (!full) end = &trap_trace[start+1]; 869 } 870 871 db_printf("#:tl p:pid tt:tt:tstate:tfault sp:pc\n"); 872 if (reverse) { 873 if (full && start) 874 for (i=start; --i;) { 875 db_print_trace_entry(&trap_trace[i], i); 876 } 877 i = (end - &trap_trace[0]); 878 while(--i > start) { 879 db_print_trace_entry(&trap_trace[i], i); 880 } 881 } else { 882 for (i=start; &trap_trace[i] < end ; i++) { 883 db_print_trace_entry(&trap_trace[i], i); 884 } 885 if (full && start) 886 for (i=0; i < start ; i++) { 887 db_print_trace_entry(&trap_trace[i], i); 888 } 889 } 890 } 891 892 /* 893 * Use physical or virtual watchpoint registers -- ugh 894 * 895 * UltraSPARC I and II have both a virtual and physical 896 * watchpoint register. They are controlled by the LSU 897 * control register. 898 */ 899 void 900 db_watch(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif) 901 { 902 int phys = 0; 903 int read = 0; 904 int width = 8; /* Default to 8 bytes */ 905 int64_t mask = 0xff; 906 907 #define WATCH_VR (1L<<22) 908 #define WATCH_VW (1L<<21) 909 #define WATCH_PR (1L<<24) 910 #define WATCH_PW (1L<<23) 911 #define WATCH_PM_SHIFT 33 912 #define WATCH_PM (((uint64_t)0xffffL)<<WATCH_PM_SHIFT) 913 #define WATCH_VM_SHIFT 25 914 #define WATCH_VM (((uint64_t)0xffffL)<<WATCH_VM_SHIFT) 915 916 { 917 register char c; 918 register const char *cp = modif; 919 if (modif) 920 while ((c = *cp++) != 0) 921 switch (c) { 922 case 'p': 923 /* Physical watchpoint */ 924 phys = 1; 925 break; 926 case 'r': 927 /* Trap reads too */ 928 read = 1; 929 break; 930 case 'b': 931 width = 1; 932 mask = 0x1 << (addr & 0x7); 933 break; 934 case 'h': 935 width = 2; 936 mask = 0x3 << (addr & 0x6); 937 break; 938 case 'l': 939 width = 4; 940 mask = 0x7 << (addr & 0x4); 941 break; 942 case 'L': 943 width = 8; 944 mask = 0xf; 945 break; 946 default: 947 break; 948 } 949 } 950 951 if (have_addr) { 952 /* turn on the watchpoint */ 953 int64_t tmp = ldxa(0, ASI_MCCR); 954 955 if (phys) { 956 tmp &= ~WATCH_PM; 957 tmp |= WATCH_PW | (mask << WATCH_PM_SHIFT); 958 if (read) tmp |= WATCH_PR; 959 960 stxa(PHYSICAL_WATCHPOINT, ASI_DMMU, addr); 961 db_printf("Setting physical watchpoint to %llx-%llx\n", 962 (long long)addr, (long long)addr + width); 963 } else { 964 tmp &= ~WATCH_VM; 965 tmp |= WATCH_VW | (mask << WATCH_VM_SHIFT); 966 if (read) tmp |= WATCH_VR; 967 968 stxa(VIRTUAL_WATCHPOINT, ASI_DMMU, addr); 969 db_printf("Setting virtual watchpoint to %llx-%llx\n", 970 (long long)addr, (long long)addr + width); 971 } 972 stxa(0, ASI_MCCR, tmp); 973 } else { 974 /* turn off the watchpoint */ 975 int64_t tmp = ldxa(0, ASI_MCCR); 976 if (phys) { 977 tmp &= ~(WATCH_PM|WATCH_PR|WATCH_PW); 978 db_printf("Disabling physical watchpoint\n"); 979 } else { 980 tmp &= ~(WATCH_VM|WATCH_VR|WATCH_VW); 981 db_printf("Disabling virtual watchpoint\n"); 982 } 983 stxa(0, ASI_MCCR, tmp); 984 } 985 } 986 987 /* XXX this belongs in cpu.c */ 988 static void cpu_debug_dump(void); 989 static void 990 cpu_debug_dump(void) 991 { 992 struct cpu_info *ci; 993 994 for (ci = cpus; ci; ci = ci->ci_next) { 995 db_printf("cpu%d: self 0x%08lx lwp 0x%08lx pcb 0x%08lx " 996 "fplwp 0x%08lx\n", ci->ci_index, (u_long)ci->ci_self, 997 (u_long)ci->ci_curlwp, (u_long)ci->ci_cpcb, 998 (u_long)ci->ci_fplwp); 999 } 1000 } 1001 1002 void 1003 db_cpu_cmd(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif) 1004 { 1005 #ifdef MULTIPROCESSOR 1006 struct cpu_info *ci; 1007 #endif 1008 1009 if (!have_addr) { 1010 cpu_debug_dump(); 1011 return; 1012 } 1013 #ifdef MULTIPROCESSOR 1014 for (ci = cpus; ci != NULL; ci = ci->ci_next) 1015 if (ci->ci_index == addr) 1016 break; 1017 if (ci == NULL) { 1018 db_printf("CPU %ld not configured\n", (long)addr); 1019 return; 1020 } 1021 if (ci != curcpu()) { 1022 if (!mp_cpu_is_paused(ci->ci_index)) { 1023 db_printf("CPU %ld not paused\n", (long)addr); 1024 return; 1025 } 1026 /* no locking needed - all other cpus are paused */ 1027 ddb_cpu = ci->ci_index; 1028 mp_resume_cpu(ddb_cpu); 1029 sparc64_do_pause(); 1030 } 1031 #endif 1032 } 1033 1034 void 1035 db_sir_cmd(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif) 1036 { 1037 1038 __asm("sir; nop"); 1039 } 1040 1041 const struct db_command db_machine_command_table[] = { 1042 { DDB_ADD_CMD("ctx", db_ctx_cmd, 0, 1043 "Print process MMU context information", NULL,NULL) }, 1044 #ifdef MULTIPROCESSOR 1045 { DDB_ADD_CMD("cpu", db_cpu_cmd, 0, 1046 "switch to another cpu", "cpu-no", NULL) }, 1047 #endif 1048 { DDB_ADD_CMD("dtlb", db_dump_dtlb, 0, 1049 "Display data translation look-aside buffer context information.", 1050 NULL,NULL) }, 1051 { DDB_ADD_CMD("itlb", db_dump_itlb, 0, 1052 "Display instruction translation look-aside buffer information.", 1053 NULL,NULL) }, 1054 { DDB_ADD_CMD("dtsb", db_dump_dtsb, 0, 1055 "Display data translation storage buffer information.", NULL,NULL) }, 1056 { DDB_ADD_CMD("itsb", db_dump_itsb, 0, 1057 "Display instruction translation storage buffer information.", 1058 NULL,NULL) }, 1059 { DDB_ADD_CMD("extract", db_pm_extract, 0, 1060 "Extract the physical address from the kernel pmap.", 1061 "address", " address:\tvirtual address to look up") }, 1062 { DDB_ADD_CMD("fpstate", db_dump_fpstate,0, 1063 "Dump the FPU state." ,NULL,NULL) }, 1064 { DDB_ADD_CMD("kmap", db_pmap_kernel, 0, 1065 "Display information about mappings in the kernel pmap.", 1066 "[/f] [address]", 1067 " address:\tdisplay the mapping for this virtual address\n" 1068 " /f:\tif no address is given, display a full dump of the pmap") }, 1069 { DDB_ADD_CMD("lwp", db_lwp_cmd, 0, 1070 "Display a struct lwp", 1071 "[address]", 1072 " address:\tthe struct lwp to print (curlwp otherwise)") }, 1073 { DDB_ADD_CMD("pcb", db_dump_pcb, 0, 1074 "Display information about a struct pcb", 1075 "[address]", 1076 " address:\tthe struct pcb to print (curpcb otherwise)") }, 1077 { DDB_ADD_CMD("pctx", db_setpcb, 0, 1078 "Attempt to change MMU process context","pid", 1079 " pid:\tthe process id to switch the MMU context to") }, 1080 { DDB_ADD_CMD("page", db_page_cmd, 0, 1081 "Display the address of a struct vm_page given a physical address", 1082 "pa", " pa:\tphysical address to look up") }, 1083 { DDB_ADD_CMD("phys", db_pload_cmd, 0, 1084 "Display physical memory.", "[address][,count]", 1085 " address:\tphysical address to start (8 byte aligned)\n" 1086 " count:\tnumber of bytes to display") }, 1087 { DDB_ADD_CMD("pmap", db_pmap_cmd, 0, 1088 "Display the pmap", "[/f] [pm_addr]", 1089 " pm_addr:\tAddress of struct pmap to display\n" 1090 " /f:\tdo a full dump of the pmap") }, 1091 { DDB_ADD_CMD("proc", db_proc_cmd, 0, 1092 "Display some information about a process", 1093 "[addr]"," addr:\tstruct proc address (curproc otherwise)") }, 1094 { DDB_ADD_CMD("prom", db_prom_cmd, 0, 1095 "Enter the OFW PROM.", NULL,NULL) }, 1096 { DDB_ADD_CMD("pv", db_dump_pv, 0, 1097 "Display a struct pv for a physical address", 1098 "pa", " pa:\tphysical address of a managed page") }, 1099 { DDB_ADD_CMD("sir", db_sir_cmd, 0, 1100 "do a Software Initiated Reset (entering PROM)", NULL,NULL) }, 1101 { DDB_ADD_CMD("stack", db_dump_stack, 0, 1102 "Dump the window stack.", "[/u] [addr]", 1103 " addr:\tstart address of dump (current stack otherwise)\n" 1104 " /u:\tcontinue trace into userland") }, 1105 { DDB_ADD_CMD("tf", db_dump_trap, 0, 1106 "Display full trap frame state.", 1107 "[/u] [addr]", 1108 " addr:\tdisplay this trap frame (current kernel frame otherwise)\n" 1109 " /u:\tdisplay the current userland trap frame") }, 1110 { DDB_ADD_CMD("ts", db_dump_ts, 0, 1111 "Display trap state.", NULL,NULL) }, 1112 { DDB_ADD_CMD("traptrace", db_traptrace, 0, 1113 "Display or set trap trace information.", 1114 "[/fr] [addr]", 1115 " addr:\tstart address of trace\n" 1116 " /f:\tdisplay full information\n" 1117 " /r:\treverse the trace order") }, 1118 { DDB_ADD_CMD("watch", db_watch, 0, 1119 "Set or clear a physical or virtual hardware watchpoint.", 1120 "[/prbhlL] [addr]", 1121 " addr:\tset the breakpoint (clear watchpoint if not present)\n" 1122 " /p:\taddress is physical\n" 1123 " /r:\ttrap on reads too (otherwise only write access)\n" 1124 " /b:\t8 bit\n" 1125 " /h:\t16 bit\n" 1126 " /l:\t32 bit\n" 1127 " /L:\t64 bit") }, 1128 { DDB_ADD_CMD("window", db_dump_window, 0, 1129 "Print register window information", 1130 "[no]", " no:\tstack frame number (0, i.e. top, if missing)") }, 1131 { DDB_END_CMD }, 1132 }; 1133 #endif /* DDB */ 1134 1135 /* 1136 * support for SOFTWARE_SSTEP: 1137 * return the next pc if the given branch is taken. 1138 * 1139 * note: in the case of conditional branches with annul, 1140 * this actually returns the next pc in the "not taken" path, 1141 * but in that case next_instr_address() will return the 1142 * next pc in the "taken" path. so even tho the breakpoints 1143 * are backwards, everything will still work, and the logic is 1144 * much simpler this way. 1145 */ 1146 db_addr_t 1147 db_branch_taken(int inst, db_addr_t pc, db_regs_t *regs) 1148 { 1149 union instr insn; 1150 db_addr_t npc; 1151 1152 npc = DDB_REGS->db_tf.tf_npc; 1153 1154 insn.i_int = inst; 1155 1156 /* 1157 * if this is not an annulled conditional branch, the next pc is "npc". 1158 */ 1159 1160 if (insn.i_any.i_op != IOP_OP2 || insn.i_branch.i_annul != 1) 1161 return npc; 1162 1163 switch (insn.i_op2.i_op2) { 1164 case IOP2_Bicc: 1165 case IOP2_FBfcc: 1166 case IOP2_BPcc: 1167 case IOP2_FBPfcc: 1168 case IOP2_CBccc: 1169 /* branch on some condition-code */ 1170 switch (insn.i_branch.i_cond) 1171 { 1172 case Icc_A: /* always */ 1173 return pc + ((inst << 10) >> 8); 1174 1175 default: /* all other conditions */ 1176 return npc + 4; 1177 } 1178 1179 case IOP2_BPr: 1180 /* branch on register, always conditional */ 1181 return npc + 4; 1182 1183 default: 1184 /* not a branch */ 1185 printf("branch_taken() on non-branch"); 1186 return pc; 1187 } 1188 } 1189 1190 bool 1191 db_inst_branch(int inst) 1192 { 1193 union instr insn; 1194 1195 insn.i_int = inst; 1196 1197 if (insn.i_any.i_op != IOP_OP2) 1198 return false; 1199 1200 switch (insn.i_op2.i_op2) { 1201 case IOP2_BPcc: 1202 case IOP2_Bicc: 1203 case IOP2_BPr: 1204 case IOP2_FBPfcc: 1205 case IOP2_FBfcc: 1206 case IOP2_CBccc: 1207 return true; 1208 1209 default: 1210 return false; 1211 } 1212 } 1213 1214 1215 bool 1216 db_inst_call(int inst) 1217 { 1218 union instr insn; 1219 1220 insn.i_int = inst; 1221 1222 switch (insn.i_any.i_op) { 1223 case IOP_CALL: 1224 return true; 1225 1226 case IOP_reg: 1227 return (insn.i_op3.i_op3 == IOP3_JMPL) && !db_inst_return(inst); 1228 1229 default: 1230 return false; 1231 } 1232 } 1233 1234 1235 bool 1236 db_inst_unconditional_flow_transfer(int inst) 1237 { 1238 union instr insn; 1239 1240 insn.i_int = inst; 1241 1242 if (db_inst_call(inst)) 1243 return true; 1244 1245 if (insn.i_any.i_op != IOP_OP2) 1246 return false; 1247 1248 switch (insn.i_op2.i_op2) 1249 { 1250 case IOP2_BPcc: 1251 case IOP2_Bicc: 1252 case IOP2_FBPfcc: 1253 case IOP2_FBfcc: 1254 case IOP2_CBccc: 1255 return insn.i_branch.i_cond == Icc_A; 1256 1257 default: 1258 return false; 1259 } 1260 } 1261 1262 1263 bool 1264 db_inst_return(int inst) 1265 { 1266 return (inst == I_JMPLri(I_G0, I_O7, 8) || /* ret */ 1267 inst == I_JMPLri(I_G0, I_I7, 8)); /* retl */ 1268 } 1269 1270 bool 1271 db_inst_trap_return(int inst) 1272 { 1273 union instr insn; 1274 1275 insn.i_int = inst; 1276 1277 return (insn.i_any.i_op == IOP_reg && 1278 insn.i_op3.i_op3 == IOP3_RETT); 1279 } 1280 1281 1282 int 1283 db_inst_load(int inst) 1284 { 1285 union instr insn; 1286 1287 insn.i_int = inst; 1288 1289 if (insn.i_any.i_op != IOP_mem) 1290 return 0; 1291 1292 switch (insn.i_op3.i_op3) { 1293 case IOP3_LD: 1294 case IOP3_LDUB: 1295 case IOP3_LDUH: 1296 case IOP3_LDD: 1297 case IOP3_LDSB: 1298 case IOP3_LDSH: 1299 case IOP3_LDSTUB: 1300 case IOP3_SWAP: 1301 case IOP3_LDA: 1302 case IOP3_LDUBA: 1303 case IOP3_LDUHA: 1304 case IOP3_LDDA: 1305 case IOP3_LDSBA: 1306 case IOP3_LDSHA: 1307 case IOP3_LDSTUBA: 1308 case IOP3_SWAPA: 1309 case IOP3_LDF: 1310 case IOP3_LDFSR: 1311 case IOP3_LDDF: 1312 case IOP3_LFC: 1313 case IOP3_LDCSR: 1314 case IOP3_LDDC: 1315 return 1; 1316 1317 default: 1318 return 0; 1319 } 1320 } 1321 1322 int 1323 db_inst_store(int inst) 1324 { 1325 union instr insn; 1326 1327 insn.i_int = inst; 1328 1329 if (insn.i_any.i_op != IOP_mem) 1330 return 0; 1331 1332 switch (insn.i_op3.i_op3) { 1333 case IOP3_ST: 1334 case IOP3_STB: 1335 case IOP3_STH: 1336 case IOP3_STD: 1337 case IOP3_LDSTUB: 1338 case IOP3_SWAP: 1339 case IOP3_STA: 1340 case IOP3_STBA: 1341 case IOP3_STHA: 1342 case IOP3_STDA: 1343 case IOP3_LDSTUBA: 1344 case IOP3_SWAPA: 1345 case IOP3_STF: 1346 case IOP3_STFSR: 1347 case IOP3_STDFQ: 1348 case IOP3_STDF: 1349 case IOP3_STC: 1350 case IOP3_STCSR: 1351 case IOP3_STDCQ: 1352 case IOP3_STDC: 1353 return 1; 1354 1355 default: 1356 return 0; 1357 } 1358 } 1359