|
|
1.1 ! root 1: /* $Header: /kernel/kersrc/i286/RCS/dump.c,v 1.1 92/07/17 15:21:26 bin Exp Locker: bin $ ! 2: * ! 3: * Function to dump Kernel data inforation. ! 4: * ! 5: * $Log: dump.c,v $ ! 6: * Revision 1.1 92/07/17 15:21:26 bin ! 7: * Initial revision ! 8: * ! 9: * Revision 1.1 88/03/24 17:33:35 src ! 10: * Initial revision ! 11: * ! 12: */ ! 13: #include <ascii.h> ! 14: #include <coherent.h> ! 15: #include <sys/i8086.h> ! 16: #include <sys/proc.h> ! 17: #include <sys/seg.h> ! 18: ! 19: int nodump = 1; ! 20: ! 21: /* ! 22: * Note: ip1 is a dummy parameter facilitating access to calling stack frame. ! 23: */ ! 24: dumpall( ip1 ) ! 25: int ip1; ! 26: { ! 27: register PROC * pp; ! 28: register SEG * sp; ! 29: faddr_t gp; ! 30: faddr_t fp; ! 31: int s; ! 32: extern saddr_t gdtsel; ! 33: extern saddr_t uasa, ucs, uds, scs, sds; ! 34: extern int nesterr; ! 35: ! 36: if ( nodump ) ! 37: return; ! 38: ! 39: s = sphi(); ! 40: ! 41: printf("\nuasa=%x ucs=%x uds=%x scs=%x sds=%x nesterr=%u\n", ! 42: uasa, ucs, uds, scs, sds, nesterr ); ! 43: ! 44: ! 45: printf("\nGlobal Descriptor Table:\n"); ! 46: FP_SEL(gp) = gdtsel; ! 47: FP_OFF(gp) = 5; /* offset of flags byte */ ! 48: FP_SEL(fp) = 0; ! 49: FP_OFF(fp) = 0; ! 50: do { ! 51: if ( ffbyte(gp) ) ! 52: vprint(fp); ! 53: FP_OFF(gp) += 8; ! 54: FP_SEL(fp) += 8; ! 55: } while ( FP_SEL(fp) != 0 ); ! 56: ! 57: showevq(); ! 58: showtim(); ! 59: putchar( A_FF ); ! 60: ! 61: printf("\nProcesses:\n"); ! 62: for ( pp = procq.p_nforw; pp != &procq; pp = pp->p_nforw ) ! 63: showproc( pp ); ! 64: putchar( A_FF ); ! 65: ! 66: printf( "\nMemory Segments:\n\n" ); ! 67: for ( sp = segmq.s_forw; sp != &segmq; sp = sp->s_forw ) ! 68: showseg( sp, "" ); ! 69: putchar( A_FF ); ! 70: ! 71: if ( segdq.s_forw != &segdq ) { ! 72: printf( "\nDisk Segments:\n\n"); ! 73: for ( sp = segdq.s_forw; sp != &segdq; sp = sp->s_forw ) ! 74: showseg( sp, "" ); ! 75: putchar( A_FF ); ! 76: } ! 77: ! 78: printf("\nLocal Stack: sp=%x\n", (&ip1)-1 ); ! 79: FP_SEL(fp) = sds; ! 80: FP_OFF(fp) = (char*)(&u) + 1022; ! 81: do { ! 82: printf(" %x: %x\n", FP_OFF(fp), ffword(fp) ); ! 83: FP_OFF(fp) -= 2; ! 84: } while ( FP_OFF(fp) >= (&ip1)-1 ); ! 85: putchar( A_FF ); ! 86: ! 87: printf("\nUser Stack: ss:sp = %x:%x\n", regl[OSS], regl[OSP] ); ! 88: FP_SEL(gp) = gdtsel; ! 89: FP_OFF(gp) = regl[OSS] & ~7; ! 90: if ( ((regl[OSS]&7) == 0) && regl[OSS] && regl[OSP] && ffbyte(gp+5) ) { ! 91: FP_SEL(fp) = regl[OSS]; ! 92: FP_OFF(fp) = regl[OSP] + 120; ! 93: if ( FP_OFF(fp) > udl ) ! 94: FP_OFF(fp) = udl & ~1; ! 95: do { ! 96: printf(" %x: %x\n", FP_OFF(fp), ffword(fp) ); ! 97: FP_OFF(fp) -= 2; ! 98: } while ( FP_OFF(fp) >= regl[OSP] ); ! 99: } ! 100: putchar( A_FF ); ! 101: ! 102: putchar( A_LF ); ! 103: spl( s ); ! 104: } ! 105: ! 106: static ! 107: showevq() ! 108: { ! 109: register PROC * pp; ! 110: register int i; ! 111: ! 112: printf("\nEvent Queues:\n"); ! 113: ! 114: for ( i = 0; i < nel(linkq); i++ ) { ! 115: ! 116: if ( linkq[i].p_lforw == linkq[i].p_lback ) ! 117: continue; ! 118: ! 119: pp = linkq[i].p_lforw; ! 120: printf("%x:", i ); ! 121: ! 122: do { ! 123: printf("\t%x: lforw=%x lback=%x pid=%d event=%x\n", ! 124: pp, ! 125: pp->p_lforw, ! 126: pp->p_lback, ! 127: pp->p_pid, ! 128: pp->p_event ! 129: ); ! 130: } while ((pp = pp->p_lforw) != (PROC *) &linkq[i] ); ! 131: } ! 132: } ! 133: ! 134: static ! 135: showtim() ! 136: { ! 137: register TIM * tp; ! 138: register int i; ! 139: ! 140: printf("\nTiming Queues: lbolt=%lx\n", lbolt ); ! 141: ! 142: for ( i = 0; i < nel(timq); i++ ) { ! 143: ! 144: if ( ! (tp = timq[i]) ) ! 145: continue; ! 146: ! 147: printf("%x:", i ); ! 148: ! 149: do { ! 150: printf("\t%x: next=%x last=%x func=%x farg=%x lbolt=%lx\n", ! 151: tp, ! 152: tp->t_next, ! 153: tp->t_last, ! 154: tp->t_func, ! 155: tp->t_farg, ! 156: tp->t_lbolt ! 157: ); ! 158: } while ( tp = tp->t_next ); ! 159: } ! 160: } ! 161: ! 162: static ! 163: showproc( pp ) ! 164: register PROC * pp; ! 165: { ! 166: register int i; ! 167: ! 168: printf("\n%x:\tnforw=%x nback=%x pid=%d ppid=%d state=%x flags=%x\n", ! 169: pp, ! 170: pp->p_nforw, /* Forward pointer */ ! 171: pp->p_nback, /* Backward pointer */ ! 172: pp->p_pid, /* Process id */ ! 173: pp->p_ppid, /* Process id of parent */ ! 174: pp->p_state, ! 175: pp->p_flags ! 176: ); ! 177: ! 178: if ( pp->p_polltim.t_last ) ! 179: printf("\tpolltim@%x: next=%x last=%x func=%x farg=%x lbolt=%lx\n", ! 180: &pp->p_polltim, ! 181: pp->p_polltim.t_next, ! 182: pp->p_polltim.t_last, ! 183: pp->p_polltim.t_func, ! 184: pp->p_polltim.t_farg, ! 185: pp->p_polltim.t_lbolt ! 186: ); ! 187: ! 188: if ( pp->p_alrmtim.t_last ) ! 189: printf("\talrmtim@%x: next=%x last=%x func=%x farg=%x lbolt=%lx\n", ! 190: &pp->p_alrmtim, ! 191: pp->p_alrmtim.t_next, ! 192: pp->p_alrmtim.t_last, ! 193: pp->p_alrmtim.t_func, ! 194: pp->p_alrmtim.t_farg, ! 195: pp->p_alrmtim.t_lbolt ! 196: ); ! 197: ! 198: for ( i = 0; i <= NUSEG; i++ ) { ! 199: static char * nam[] = { "UA", "SS", "SI", "PI", "SD", "PD", "UX" }; ! 200: if ( pp->p_segp[i] ) { ! 201: printf("\n %s: ", nam[i] ); ! 202: showseg( pp->p_segp[i], " " ); ! 203: } ! 204: } ! 205: } ! 206: ! 207: static ! 208: showseg( sp, prefix ) ! 209: register SEG * sp; ! 210: char * prefix; ! 211: { ! 212: printf("%x: forw=%x back=%x ip=%x flags=%x urefc=%d lrefc=%d\n", ! 213: sp, ! 214: sp->s_forw, /* Forward pointer */ ! 215: sp->s_back, /* Backward pointer */ ! 216: sp->s_ip, /* Inode pointer for shared text */ ! 217: sp->s_flags, /* Flags */ ! 218: sp->s_urefc, /* Reference count of segment */ ! 219: sp->s_lrefc /* Lock reference count */ ! 220: ); ! 221: ! 222: printf( "%s faddr=%X size=%X paddr=%X\n", ! 223: prefix, ! 224: sp->s_faddr, /* Memory access selector */ ! 225: sp->s_size, /* Size in bytes */ ! 226: sp->s_paddr /* Physical base address */ ! 227: ); ! 228: ! 229: printf("%s ", prefix); ! 230: vprint( sp->s_faddr ); ! 231: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.