1*57090Sakito /* 2*57090Sakito * Copyright (c) 1992 OMRON Corporation. 3*57090Sakito * Copyright (c) 1992 The Regents of the University of California. 4*57090Sakito * All rights reserved. 5*57090Sakito * 6*57090Sakito * This code is derived from software contributed to Berkeley by 7*57090Sakito * OMRON Corporation. 8*57090Sakito * 9*57090Sakito * %sccs.include.redist.c% 10*57090Sakito * 11*57090Sakito * @(#)machdep.c 7.1 (Berkeley) 12/13/92 12*57090Sakito */ 13*57090Sakito 14*57090Sakito #include <sys/param.h> 15*57090Sakito #include <luna68k/include/reg.h> 16*57090Sakito 17*57090Sakito straytrap(addr) 18*57090Sakito register int addr; 19*57090Sakito { 20*57090Sakito printf("stray trap, addr 0x%x\n", addr); 21*57090Sakito } 22*57090Sakito 23*57090Sakito int *nofault = 0; 24*57090Sakito 25*57090Sakito badaddr(addr) 26*57090Sakito register caddr_t addr; 27*57090Sakito { 28*57090Sakito register int i; 29*57090Sakito label_t faultbuf; 30*57090Sakito 31*57090Sakito #ifdef lint 32*57090Sakito i = *addr; if (i) return(0); 33*57090Sakito #endif 34*57090Sakito nofault = (int *) &faultbuf; 35*57090Sakito if (setjmp((label_t *)nofault)) { 36*57090Sakito nofault = (int *) 0; 37*57090Sakito return(1); 38*57090Sakito } 39*57090Sakito i = *(volatile short *)addr; 40*57090Sakito nofault = (int *) 0; 41*57090Sakito return(0); 42*57090Sakito } 43*57090Sakito 44*57090Sakito regdump(rp, sbytes) 45*57090Sakito int *rp; /* must not be register */ 46*57090Sakito int sbytes; 47*57090Sakito { 48*57090Sakito static int doingdump = 0; 49*57090Sakito register int i; 50*57090Sakito int s; 51*57090Sakito extern char *hexstr(); 52*57090Sakito 53*57090Sakito if (doingdump) 54*57090Sakito return; 55*57090Sakito s = splhigh(); 56*57090Sakito doingdump = 1; 57*57090Sakito /* printf("pid = %d, pc = %s, ", u.u_procp->p_pid, hexstr(rp[PC], 8)); */ 58*57090Sakito printf("pc = %s, ", hexstr(rp[PC], 8)); 59*57090Sakito printf("ps = %s, ", hexstr(rp[PS], 4)); 60*57090Sakito printf("sfc = %s, ", hexstr(getsfc(), 4)); 61*57090Sakito printf("dfc = %s\n", hexstr(getdfc(), 4)); 62*57090Sakito /* 63*57090Sakito printf("p0 = %x@%s, ", 64*57090Sakito u.u_pcb.pcb_p0lr, hexstr((int)u.u_pcb.pcb_p0br, 8)); 65*57090Sakito printf("p1 = %x@%s\n\n", 66*57090Sakito u.u_pcb.pcb_p1lr, hexstr((int)u.u_pcb.pcb_p1br, 8)); 67*57090Sakito */ 68*57090Sakito printf("Registers:\n "); 69*57090Sakito for (i = 0; i < 8; i++) 70*57090Sakito printf(" %d", i); 71*57090Sakito printf("\ndreg:"); 72*57090Sakito for (i = 0; i < 8; i++) 73*57090Sakito printf(" %s", hexstr(rp[i], 8)); 74*57090Sakito printf("\nareg:"); 75*57090Sakito for (i = 0; i < 8; i++) 76*57090Sakito printf(" %s", hexstr(rp[i+8], 8)); 77*57090Sakito if (sbytes > 0) { 78*57090Sakito /* if (rp[PS] & PSL_S) { */ 79*57090Sakito printf("\n\nKernel stack (%s):", 80*57090Sakito hexstr((int)(((int *)&rp)-1), 8)); 81*57090Sakito dumpmem(((int *)&rp)-1, sbytes, 0); 82*57090Sakito /* 83*57090Sakito } else { 84*57090Sakito printf("\n\nUser stack (%s):", hexstr(rp[SP], 8)); 85*57090Sakito dumpmem((int *)rp[SP], sbytes, 1); 86*57090Sakito } 87*57090Sakito */ 88*57090Sakito } 89*57090Sakito doingdump = 0; 90*57090Sakito splx(s); 91*57090Sakito } 92*57090Sakito 93*57090Sakito /* #define KSADDR ((int *)&(((char *)&u)[(UPAGES-1)*NBPG])) */ 94*57090Sakito 95*57090Sakito dumpmem(ptr, sz, ustack) 96*57090Sakito register int *ptr; 97*57090Sakito int sz; 98*57090Sakito { 99*57090Sakito register int i, val; 100*57090Sakito extern char *hexstr(); 101*57090Sakito 102*57090Sakito for (i = 0; i < sz; i++) { 103*57090Sakito if ((i & 7) == 0) 104*57090Sakito printf("\n%s: ", hexstr((int)ptr, 6)); 105*57090Sakito else 106*57090Sakito printf(" "); 107*57090Sakito /* 108*57090Sakito if (ustack == 1) { 109*57090Sakito if ((val = fuword(ptr++)) == -1) 110*57090Sakito break; 111*57090Sakito } else { 112*57090Sakito if (ustack == 0 && (ptr < KSADDR || ptr > KSADDR+(NBPG/4-1))) 113*57090Sakito break; 114*57090Sakito */ 115*57090Sakito val = *ptr++; 116*57090Sakito /* } */ 117*57090Sakito printf("%s", hexstr(val, 8)); 118*57090Sakito } 119*57090Sakito printf("\n"); 120*57090Sakito } 121*57090Sakito 122*57090Sakito char * 123*57090Sakito hexstr(val, len) 124*57090Sakito register int val; 125*57090Sakito { 126*57090Sakito static char nbuf[9]; 127*57090Sakito register int x, i; 128*57090Sakito 129*57090Sakito if (len > 8) 130*57090Sakito return(""); 131*57090Sakito nbuf[len] = '\0'; 132*57090Sakito for (i = len-1; i >= 0; --i) { 133*57090Sakito x = val & 0xF; 134*57090Sakito if (x > 9) 135*57090Sakito nbuf[i] = x - 10 + 'A'; 136*57090Sakito else 137*57090Sakito nbuf[i] = x + '0'; 138*57090Sakito val >>= 4; 139*57090Sakito } 140*57090Sakito return(nbuf); 141*57090Sakito } 142