Annotation of XNU/osfmk/ppc/db_low_trace.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
        !             3:  *
        !             4:  * @APPLE_LICENSE_HEADER_START@
        !             5:  * 
        !             6:  * The contents of this file constitute Original Code as defined in and
        !             7:  * are subject to the Apple Public Source License Version 1.1 (the
        !             8:  * "License").  You may not use this file except in compliance with the
        !             9:  * License.  Please obtain a copy of the License at
        !            10:  * http://www.apple.com/publicsource and read it before using this file.
        !            11:  * 
        !            12:  * This Original Code and all software distributed under the License are
        !            13:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
        !            14:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
        !            15:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
        !            16:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
        !            17:  * License for the specific language governing rights and limitations
        !            18:  * under the License.
        !            19:  * 
        !            20:  * @APPLE_LICENSE_HEADER_END@
        !            21:  */
        !            22: /*
        !            23:  * @OSF_FREE_COPYRIGHT@
        !            24:  */
        !            25: /*
        !            26:  * @APPLE_FREE_COPYRIGHT@
        !            27:  */
        !            28: 
        !            29: /*
        !            30:  *     Author: Bill Angell, Apple
        !            31:  *     Date:   6/97
        !            32:  *
        !            33:  * exceptions and certain C functions write into a trace table which
        !            34:  * can be examined via the machine 'lt' command under kdb
        !            35:  */
        !            36: 
        !            37: 
        !            38: #include <string.h>                    /* For strcpy() */
        !            39: #include <mach/boolean.h>
        !            40: #include <machine/db_machdep.h>
        !            41: 
        !            42: #include <ddb/db_access.h>
        !            43: #include <ddb/db_lex.h>
        !            44: #include <ddb/db_output.h>
        !            45: #include <ddb/db_command.h>
        !            46: #include <ddb/db_sym.h>
        !            47: #include <ddb/db_task_thread.h>
        !            48: #include <ddb/db_command.h>            /* For db_option() */
        !            49: #include <ddb/db_examine.h>
        !            50: #include <ddb/db_expr.h>
        !            51: #include <kern/thread.h>
        !            52: #include <kern/task.h>
        !            53: #include <mach/vm_param.h>
        !            54: #include <ppc/Firmware.h>
        !            55: #include <ppc/low_trace.h>
        !            56: #include <ppc/db_low_trace.h>
        !            57: #include <ppc/mappings.h>
        !            58: #include <ppc/pmap.h>
        !            59: #include <ppc/mem.h>
        !            60: #include <ppc/pmap_internals.h>
        !            61: #include <ppc/savearea.h>
        !            62: 
        !            63: void db_dumpphys(struct phys_entry *pp);                                               /* Dump from physent */
        !            64: void db_dumppca(struct mapping *mp);                                           /* PCA */
        !            65: void db_dumpmapping(struct mapping *mp);                                       /* Dump out a mapping */
        !            66: 
        !            67: db_addr_t      db_low_trace_prev = 0;
        !            68: 
        !            69: /*
        !            70:  *             Print out the low level trace table:
        !            71:  *
        !            72:  *             Displays the entry and 15 before it in newest to oldest order
        !            73:  *             
        !            74:  *             lt [entaddr]
        !            75:  
        !            76:  *             If entaddr is omitted, it starts with the most current
        !            77:  *             If entaddr = 0, it starts with the most current and does the whole table
        !            78:  */
        !            79: void db_low_trace(db_expr_t addr, int have_addr, db_expr_t count, char * modif) {
        !            80: 
        !            81:        int             c, i;
        !            82:        unsigned int tempx, cnt;
        !            83:        unsigned int xbuf[8];
        !            84:        unsigned int xTraceCurr, xTraceStart, xTraceEnd, cxltr, xxltr;
        !            85:        db_addr_t       next_addr;
        !            86:        LowTraceRecord xltr;
        !            87:        unsigned char cmark;
        !            88:        
        !            89:        cnt = 16;                                                                                                       /* Default to 16 entries */
        !            90:        
        !            91:        ReadReal(((unsigned int)&traceCurr)&0x00000FFF, &xbuf[0]);      /* Get trace pointers (it's been moved to page 0) */
        !            92:        xTraceCurr=xbuf[0];                                                                                     /* Transfer current pointer */
        !            93:        xTraceStart=xbuf[1];                                                                            /* Transfer start of table */
        !            94:        xTraceEnd=xbuf[2];                                                                                      /* Transfer end of table */
        !            95:        
        !            96:        if(addr == -1) cnt = 0x7FFFFFFF;                                                        /* Max the count */
        !            97: 
        !            98:        if(!addr || (addr == -1)) {
        !            99:                addr=xTraceCurr-sizeof(LowTraceRecord);                                 /* Start at the newest */
        !           100:                if((unsigned int)addr<xTraceStart) addr=xTraceEnd-sizeof(LowTraceRecord);       /* Wrap low back to high */
        !           101:        }
        !           102:        
        !           103:        if((unsigned int)addr<xTraceStart||(unsigned int)addr>=xTraceEnd) {     /* In the table? */
        !           104:                db_printf("address not in low memory trace table\n");   /* Tell the fool */
        !           105:                return;                                                                                                 /* Leave... */
        !           106:        }
        !           107: 
        !           108:        if((unsigned int)addr&0x0000003F) {                                                     /* Proper alignment? */
        !           109:                db_printf("address not aligned on trace entry boundary (0x40)\n");      /* Tell 'em */
        !           110:                return;                                                                                                 /* Leave... */
        !           111:        }
        !           112:        
        !           113:        xxltr=(unsigned int)addr;                                                                       /* Set the start */
        !           114:        cxltr=((xTraceCurr==xTraceStart ? xTraceEnd : xTraceCurr)-sizeof(LowTraceRecord));      /* Get address of newest entry */
        !           115: 
        !           116:        db_low_trace_prev = addr;                                                                       /* Starting point */
        !           117: 
        !           118:        for(i=0; i < cnt; i++) {                                                                        /* Dump the 16 (or all) entries */
        !           119:        
        !           120:                ReadReal(xxltr, (unsigned int *)&xltr);                                 /* Get the first half */
        !           121:                ReadReal(xxltr+32, &(((unsigned int *)&xltr)[8]));              /* Get the second half */
        !           122:                
        !           123:                db_printf("\n%s%08X  %1X  %08X %08X - %04X\n", (xxltr!=cxltr ? " " : "*"), 
        !           124:                        xxltr,
        !           125:                        xltr.LTR_cpu, xltr.LTR_timeHi, xltr.LTR_timeLo, 
        !           126:                        (xltr.LTR_excpt&0x8000 ? 0xFFFF : xltr.LTR_excpt*64));  /* Print the first line */
        !           127:                db_printf("              %08X %08X %08X %08X %08X %08X %08X\n",
        !           128:                        xltr.LTR_cr, xltr.LTR_srr0, xltr.LTR_srr1, xltr.LTR_dar, xltr.LTR_save, xltr.LTR_lr, xltr.LTR_ctr);
        !           129:                db_printf("              %08X %08X %08X %08X %08X %08X\n",
        !           130:                        xltr.LTR_r0, xltr.LTR_r1, xltr.LTR_r2, xltr.LTR_r3, xltr.LTR_r4, xltr.LTR_r5);
        !           131:        
        !           132:                if((cnt != 16) && (xxltr == xTraceCurr)) break;                 /* If whole table dump, exit when we hit start again... */
        !           133: 
        !           134:                xxltr-=sizeof(LowTraceRecord);                                                  /* Back it on up */
        !           135:                if(xxltr<xTraceStart)
        !           136:                        xxltr=(xTraceEnd-sizeof(LowTraceRecord));                       /* Wrap low back to high */
        !           137:        
        !           138:        }
        !           139:        db_next = (db_expr_t)(xxltr);
        !           140:        return;
        !           141: }
        !           142: 
        !           143: 
        !           144: /*
        !           145:  *             Print out 256 bytes
        !           146:  *
        !           147:  *             
        !           148:  *             dl [entaddr]
        !           149:  */
        !           150: void db_display_long(db_expr_t addr, int have_addr, db_expr_t count, char * modif) {
        !           151: 
        !           152:        int                             i;
        !           153: 
        !           154:        for(i=0; i<8; i++) {                                                                    /* Print 256 bytes */
        !           155:                db_printf("%08X   %08X %08X %08X %08X  %08X %08X %08X %08X\n", addr,    /* Print a line */
        !           156:                        ((unsigned long *)addr)[0], ((unsigned long *)addr)[1], ((unsigned long *)addr)[2], ((unsigned long *)addr)[3], 
        !           157:                        ((unsigned long *)addr)[4], ((unsigned long *)addr)[5], ((unsigned long *)addr)[6], ((unsigned long *)addr)[7]);
        !           158:                addr=(db_expr_t)((unsigned int)addr+0x00000020);        /* Point to next address */
        !           159:        }
        !           160:        db_next = addr;
        !           161: 
        !           162: 
        !           163: }
        !           164: 
        !           165: /*
        !           166:  *             Print out 256 bytes of real storage
        !           167:  *
        !           168:  *             Displays the entry and 15 before it in newest to oldest order
        !           169:  *             
        !           170:  *             dr [entaddr]
        !           171:  */
        !           172: void db_display_real(db_expr_t addr, int have_addr, db_expr_t count, char * modif) {
        !           173: 
        !           174:        int                             i;
        !           175:        unsigned int xbuf[8];
        !           176: 
        !           177:        for(i=0; i<8; i++) {                                                                    /* Print 256 bytes */
        !           178:                ReadReal((unsigned int)addr, &xbuf[0]);                         /* Get the real storage data */
        !           179:                db_printf("%08X   %08X %08X %08X %08X  %08X %08X %08X %08X\n", addr,    /* Print a line */
        !           180:                        xbuf[0], xbuf[1], xbuf[2], xbuf[3], 
        !           181:                        xbuf[4], xbuf[5], xbuf[6], xbuf[7]);
        !           182:                addr=(db_expr_t)((unsigned int)addr+0x00000020);        /* Point to next address */
        !           183:        }
        !           184:        db_next = addr;
        !           185: 
        !           186: 
        !           187: }
        !           188: 
        !           189: unsigned int   dvspace = 0;
        !           190: 
        !           191: /*
        !           192:  *             Print out virtual to real translation information
        !           193:  *
        !           194:  *             
        !           195:  *             dm vaddr [space] (defaults to last entered) 
        !           196:  */
        !           197: void db_display_mappings(db_expr_t addr, int have_addr, db_expr_t count, char * modif) {
        !           198: 
        !           199:        int                             i;
        !           200:        unsigned int    xspace;
        !           201: 
        !           202:        mapping         *mp, *mpv;
        !           203:        vm_offset_t     pa;
        !           204:        
        !           205:        if (db_expression(&xspace)) dvspace = xspace;                   /* Get the space or set default */
        !           206:        
        !           207:        db_printf("mapping information for %08X in space %08X:\n", addr, dvspace);
        !           208:        mp = hw_lock_phys_vir(dvspace, addr);                                   /* Lock the physical entry for this mapping */
        !           209:        if(!mp) {                                                                                               /* Did we find one? */
        !           210:                db_printf("Not mapped\n");      
        !           211:                return;                                                                                         /* Didn't find any, return FALSE... */
        !           212:        }
        !           213:        if((unsigned int)mp&1) {                                                                /* Did we timeout? */
        !           214:                db_printf("Timeout locking physical entry for virtual address (%08X)\n", addr); /* Yeah, scream about it! */
        !           215:                return;                                                                                         /* Bad hair day, return FALSE... */
        !           216:        }
        !           217:        printf("dumpaddr: space=%08X; vaddr=%08X\n", dvspace, addr);    /* Say what address were dumping */
        !           218:        mpv = hw_cpv(mp);                                                                               /* Get virtual address of mapping */
        !           219:        dumpmapping(mpv);
        !           220:        if(mpv->physent) {
        !           221:                hw_unlock_bit((unsigned int *)&mpv->physent->phys_link, PHYS_LOCK);     /* Unlock physical entry associated with mapping */
        !           222:        }
        !           223:        return;                                                                                                 /* Tell them we did it */
        !           224: 
        !           225: 
        !           226: }
        !           227: 
        !           228: /*
        !           229:  *             Prints out a mapping control block
        !           230:  *
        !           231:  */
        !           232:  
        !           233: void db_dumpmapping(struct mapping *mp) {                                      /* Dump out a mapping */
        !           234: 
        !           235:        db_printf("Dump of mapping block: %08X\n", mp);                 /* Header */
        !           236:        db_printf("                 next: %08X\n", mp->next);                 
        !           237:        db_printf("             hashnext: %08X\n", mp->hashnext);                 
        !           238:        db_printf("              PTEhash: %08X\n", mp->PTEhash);                 
        !           239:        db_printf("               PTEent: %08X\n", mp->PTEent);                 
        !           240:        db_printf("              physent: %08X\n", mp->physent);                 
        !           241:        db_printf("                 PTEv: %08X\n", mp->PTEv);                 
        !           242:        db_printf("                 PTEr: %08X\n", mp->PTEr);                 
        !           243:        db_printf("                 pmap: %08X\n", mp->pmap);
        !           244:        
        !           245:        if(mp->physent) {                                                                       /* Print physent if it exists */
        !           246:                db_printf("Associated physical entry: %08X %08X\n", mp->physent->phys_link, mp->physent->pte1);
        !           247:        }
        !           248:        else {
        !           249:                db_printf("Associated physical entry: none\n");
        !           250:        }
        !           251:        
        !           252:        db_dumppca(mp);                                                                         /* Dump out the PCA information */
        !           253:        
        !           254:        return;
        !           255: }
        !           256: 
        !           257: /*
        !           258:  *             Prints out a PTEG control area
        !           259:  *
        !           260:  */
        !           261:  
        !           262: void db_dumppca(struct mapping *mp) {                                          /* PCA */
        !           263: 
        !           264:        PCA                             *pca;
        !           265:        unsigned int    *pteg;
        !           266:        
        !           267:        pca = (PCA *)((unsigned int)mp->PTEhash&-64);           /* Back up to the start of the PCA */
        !           268:        pteg=(unsigned int *)((unsigned int)pca-(((hash_table_base&0x0000FFFF)+1)<<16));
        !           269:        db_printf(" Dump of PCA: %08X\n", pca);         /* Header */
        !           270:        db_printf("     PCAlock: %08X\n", pca->PCAlock);                 
        !           271:        db_printf("     PCAallo: %08X\n", pca->flgs.PCAallo);                 
        !           272:        db_printf("     PCAhash: %08X %08X %08X %08X\n", pca->PCAhash[0], pca->PCAhash[1], pca->PCAhash[2], pca->PCAhash[3]);                 
        !           273:        db_printf("              %08X %08X %08X %08X\n", pca->PCAhash[4], pca->PCAhash[5], pca->PCAhash[6], pca->PCAhash[7]);                 
        !           274:        db_printf("Dump of PTEG: %08X\n", pteg);                /* Header */
        !           275:        db_printf("              %08X %08X %08X %08X\n", pteg[0], pteg[1], pteg[2], pteg[3]);                 
        !           276:        db_printf("              %08X %08X %08X %08X\n", pteg[4], pteg[5], pteg[6], pteg[7]);                 
        !           277:        db_printf("              %08X %08X %08X %08X\n", pteg[8], pteg[9], pteg[10], pteg[11]);                 
        !           278:        db_printf("              %08X %08X %08X %08X\n", pteg[12], pteg[13], pteg[14], pteg[15]);                 
        !           279:        return;
        !           280: }
        !           281: 
        !           282: /*
        !           283:  *             Dumps starting with a physical entry
        !           284:  */
        !           285:  
        !           286: void db_dumpphys(struct phys_entry *pp) {                                              /* Dump from physent */
        !           287: 
        !           288:        mapping                 *mp;
        !           289:        PCA                             *pca;
        !           290:        unsigned int    *pteg;
        !           291: 
        !           292:        db_printf("Dump from physical entry %08X: %08X %08X\n", pp, pp->phys_link, pp->pte1);
        !           293:        mp = hw_cpv(pp->phys_link);
        !           294:        while(mp) {
        !           295:                db_dumpmapping(mp);
        !           296:                db_dumppca(mp);
        !           297:                mp = hw_cpv(mp->next);
        !           298:        }
        !           299:        
        !           300:        return;
        !           301: }
        !           302: 
        !           303: 
        !           304: /*
        !           305:  *             Print out 256 bytes of virtual storage
        !           306:  *
        !           307:  *             
        !           308:  *             dv [entaddr] [space]
        !           309:  *             address must be on 32-byte boundary.  It will be rounded down if not
        !           310:  */
        !           311: void db_display_virtual(db_expr_t addr, int have_addr, db_expr_t count, char * modif) {
        !           312: 
        !           313:        int                             i, size, lines, rlines;
        !           314:        unsigned int    xbuf[8];
        !           315:        unsigned int    xspace;
        !           316: 
        !           317:        mapping         *mp, *mpv;
        !           318:        vm_offset_t     pa;
        !           319:        
        !           320:        if (db_expression(&xspace)) dvspace = xspace;                   /* Get the space or set default */
        !           321:        
        !           322:        addr&=-32;
        !           323:        
        !           324:        size = 4096 - (addr & 0x00000FFF);                                              /* Bytes left on page */
        !           325:        lines = size / 32;                                                                              /* Number of lines in first or only part */
        !           326:        if(lines > 8) lines = 8;
        !           327:        rlines = 8 - lines;
        !           328:        if(rlines < 0) lines = 0;
        !           329:        
        !           330:        db_printf("Dumping %08X (space=%08X); ", addr, dvspace);
        !           331:        mp = hw_lock_phys_vir(dvspace, addr);                                   /* Lock the physical entry for this mapping */
        !           332:        if(!mp) {                                                                                               /* Did we find one? */
        !           333:                db_printf("Not mapped\n");      
        !           334:                return;                                                                                         /* Didn't find any, return FALSE... */
        !           335:        }
        !           336:        if((unsigned int)mp&1) {                                                                /* Did we timeout? */
        !           337:                db_printf("Timeout locking physical entry for virtual address (%08X)\n", addr); /* Yeah, scream about it! */
        !           338:                return;                                                                                         /* Bad hair day, return FALSE... */
        !           339:        }
        !           340:        mpv = hw_cpv(mp);                                                                               /* Get virtual address of mapping */
        !           341:        if(!mpv->physent) {                                                                             /* Was there a physical entry? */
        !           342:                pa = (vm_offset_t)((mpv->PTEr & -PAGE_SIZE) | ((unsigned int)addr & (PAGE_SIZE-1)));    /* Get physical address from physent */
        !           343:        }
        !           344:        else {
        !           345:                pa = (vm_offset_t)((mpv->physent->pte1 & -PAGE_SIZE) | ((unsigned int)addr & (PAGE_SIZE-1)));   /* Get physical address from physent */
        !           346:                hw_unlock_bit((unsigned int *)&mpv->physent->phys_link, PHYS_LOCK);             /* Unlock the physical entry */
        !           347:        }
        !           348:        db_printf("phys=%08X\n", pa);
        !           349:        for(i=0; i<lines; i++) {                                                                /* Print n bytes */
        !           350:                ReadReal((unsigned int)pa, &xbuf[0]);                           /* Get the real storage data */
        !           351:                db_printf("%08X   %08X %08X %08X %08X  %08X %08X %08X %08X\n", addr,    /* Print a line */
        !           352:                        xbuf[0], xbuf[1], xbuf[2], xbuf[3], 
        !           353:                        xbuf[4], xbuf[5], xbuf[6], xbuf[7]);
        !           354:                addr=(db_expr_t)((unsigned int)addr+0x00000020);        /* Point to next address */
        !           355:                pa=(unsigned int)pa+0x00000020;                                         /* Point to next address */
        !           356:        }
        !           357:        db_next = addr;
        !           358:        
        !           359:        if(!rlines) return;
        !           360:        
        !           361:        db_printf("Dumping %08X (space=%08X); ", addr, dvspace);
        !           362:        mp = hw_lock_phys_vir(dvspace, addr);                                   /* Lock the physical entry for this mapping */
        !           363:        if(!mp) {                                                                                               /* Did we find one? */
        !           364:                db_printf("Not mapped\n");      
        !           365:                return;                                                                                         /* Didn't find any, return FALSE... */
        !           366:        }
        !           367:        if((unsigned int)mp&1) {                                                                /* Did we timeout? */
        !           368:                db_printf("Timeout locking physical entry for virtual address (%08X)\n", addr); /* Yeah, scream about it! */
        !           369:                return;                                                                                         /* Bad hair day, return FALSE... */
        !           370:        }
        !           371:        mpv = hw_cpv(mp);                                                                               /* Get virtual address of mapping */
        !           372:        if(!mpv->physent) {                                                                             /* Was there a physical entry? */
        !           373:                pa = (vm_offset_t)((mpv->PTEr & -PAGE_SIZE) | ((unsigned int)addr & (PAGE_SIZE-1)));    /* Get physical address from physent */
        !           374:        }
        !           375:        else {
        !           376:                pa = (vm_offset_t)((mpv->physent->pte1 & -PAGE_SIZE) | ((unsigned int)addr & (PAGE_SIZE-1)));   /* Get physical address from physent */
        !           377:                hw_unlock_bit((unsigned int *)&mp->physent->phys_link, PHYS_LOCK);      /* Unlock the physical entry */
        !           378:        }
        !           379:        db_printf("phys=%08X\n", pa);
        !           380:        for(i=0; i<rlines; i++) {                                                               /* Print n bytes */
        !           381:                ReadReal((unsigned int)pa, &xbuf[0]);                           /* Get the real storage data */
        !           382:                db_printf("%08X   %08X %08X %08X %08X  %08X %08X %08X %08X\n", addr,    /* Print a line */
        !           383:                        xbuf[0], xbuf[1], xbuf[2], xbuf[3], 
        !           384:                        xbuf[4], xbuf[5], xbuf[6], xbuf[7]);
        !           385:                addr=(db_expr_t)((unsigned int)addr+0x00000020);        /* Point to next address */
        !           386:                pa=(unsigned int)pa+0x00000020;                                         /* Point to next address */
        !           387:        }
        !           388:        db_next = addr;
        !           389: 
        !           390: 
        !           391: }
        !           392: 
        !           393: 
        !           394: /*
        !           395:  *             Print out savearea stuff
        !           396:  *
        !           397:  *             
        !           398:  *             ds 
        !           399:  */
        !           400: 
        !           401: #define chainmax 32
        !           402: 
        !           403: void db_display_save(db_expr_t addr, int have_addr, db_expr_t count, char * modif) {
        !           404: 
        !           405:        int                             i, j, totsaves, tottasks, taskact, chainsize;
        !           406:        processor_set_t pset;
        !           407:        task_t                  task;
        !           408:        thread_act_t    act;
        !           409:        savearea                *save;
        !           410:        
        !           411:        tottasks = 0;
        !           412:        totsaves = 0;
        !           413:        
        !           414:        for(pset = (processor_set_t)all_psets.next; pset != (processor_set_t)&all_psets; pset = (processor_set_t)pset->all_psets.next) {        /* Go through PSETs */
        !           415:                for(task = (task_t)pset->tasks.next; task != (task_t)&pset->tasks.next; task = (task_t)task->pset_tasks.next) { /* Go through the tasks */
        !           416:                        taskact = 0;                                                            /* Reset activation count */
        !           417:                        db_printf("\nTask %4d @%08X:\n", tottasks, task);       /* Show where we're at */
        !           418:                        for(act = (thread_act_t)task->thr_acts.next; act != (thread_act_t)&task->thr_acts; act = (thread_act_t)act->thr_acts.next) {    /* Go through activations */
        !           419:                                db_printf("   Act %4d @%08X - p: %08X  fp: %08X  fl: %08X  fc: %d  vp: %08X  vl: %08X  vp: %d\n",
        !           420:                                        taskact, act, act->mact.pcb, act->mact.FPU_pcb, act->mact.FPU_lvl, act->mact.FPU_cpu,           
        !           421:                                        act->mact.VMX_pcb, act->mact.VMX_lvl, act->mact.VMX_cpu);
        !           422:                                        
        !           423:                                        
        !           424:                                save = (savearea *)act->mact.pcb;               /* Set the start of the normal chain */
        !           425:                                chainsize = 0;
        !           426:                                while(save) {                                                   /* Do them all */
        !           427:                                        totsaves++;                                                     /* Count savearea */
        !           428:                                        db_printf("      Norm %08X: %08X %08X - tot = %d\n", save, save->save_srr0, save->save_srr1, totsaves);
        !           429:                                        save = save->save_prev;                         /* Next one */
        !           430:                                        if(chainsize++ > chainmax) {            /* See if we might be in a loop */
        !           431:                                                db_printf("      Chain terminated by count (%d) before %08X\n", chainmax, save);
        !           432:                                                break;
        !           433:                                        }
        !           434:                                }
        !           435:                        
        !           436:                                save = (savearea *)act->mact.FPU_pcb;   /* Set the start of the floating point chain */
        !           437:                                chainsize = 0;
        !           438:                                while(save) {                                                   /* Do them all */
        !           439:                                        if(!(save->save_flags & SAVattach)) totsaves++; /* Count savearea only if not a normal one also */
        !           440:                                        db_printf("      FPU  %08X: %08X - tot = %d\n", save, save->save_level_fp, totsaves);
        !           441:                                        save = save->save_prev_float;           /* Next one */
        !           442:                                        if(chainsize++ > chainmax) {            /* See if we might be in a loop */
        !           443:                                                db_printf("      Chain terminated by count (%d) before %08X\n", chainmax, save);
        !           444:                                                break;
        !           445:                                        }
        !           446:                                }
        !           447:                        
        !           448:                                save = (savearea *)act->mact.VMX_pcb;   /* Set the start of the floating point chain */
        !           449:                                chainsize = 0;
        !           450:                                while(save) {                                                   /* Do them all */
        !           451:                                        if(!(save->save_flags & (SAVattach | SAVfpuvalid))) totsaves++; /* Count savearea only if not a normal one also */
        !           452:                                        db_printf("      Vec  %08X: %08X - tot = %d\n", save, save->save_level_vec, totsaves);
        !           453:                                        save = save->save_prev_vector;          /* Next one */
        !           454:                                        if(chainsize++ > chainmax) {            /* See if we might be in a loop */
        !           455:                                                db_printf("      Chain terminated by count (%d) before %08X\n", chainmax, save);
        !           456:                                                break;
        !           457:                                        }
        !           458:                                }
        !           459:                                taskact++;
        !           460:                        }
        !           461:                        tottasks++;
        !           462:                }
        !           463:        }
        !           464:        
        !           465:        db_printf("Total saveareas accounted for: %d\n", totsaves);
        !           466:        return;
        !           467: }
        !           468: 
        !           469: /*
        !           470:  *             Print out extra registers
        !           471:  *
        !           472:  *             
        !           473:  *             dx 
        !           474:  */
        !           475: 
        !           476: extern unsigned int dbfloats[33][2];
        !           477: extern unsigned int dbvecs[33][4];
        !           478: extern unsigned int dbspecrs[40];
        !           479: 
        !           480: void db_display_xregs(db_expr_t addr, int have_addr, db_expr_t count, char * modif) {
        !           481: 
        !           482:        int                             i, j, pents;
        !           483: 
        !           484:        stSpecrs(dbspecrs);                                                                             /* Save special registers */
        !           485:        db_printf("PIR:  %08X\n", dbspecrs[0]);
        !           486:        db_printf("PVR:  %08X\n", dbspecrs[1]);
        !           487:        db_printf("SDR1: %08X\n", dbspecrs[22]);
        !           488:        db_printf("DBAT: %08X %08X  %08X %08X\n", dbspecrs[2], dbspecrs[3], dbspecrs[4], dbspecrs[5]);
        !           489:        db_printf("      %08X %08X  %08X %08X\n", dbspecrs[6], dbspecrs[7], dbspecrs[8], dbspecrs[9]);
        !           490:        db_printf("IBAT: %08X %08X  %08X %08X\n", dbspecrs[10], dbspecrs[11], dbspecrs[12], dbspecrs[13]);
        !           491:        db_printf("      %08X %08X  %08X %08X\n", dbspecrs[14], dbspecrs[15], dbspecrs[16], dbspecrs[17]);
        !           492:        db_printf("SPRG: %08X %08X  %08X %08X\n", dbspecrs[18], dbspecrs[19], dbspecrs[20], dbspecrs[21]);
        !           493:        for(i = 0; i < 16; i += 8) {                                                    /* Print 8 at a time */
        !           494:                db_printf("SR%02d: %08X %08X %08X %08X %08X %08X %08X %08X\n", i,
        !           495:                        dbspecrs[23+i], dbspecrs[24+i], dbspecrs[25+i], dbspecrs[26+i], 
        !           496:                        dbspecrs[27+i], dbspecrs[28+i], dbspecrs[29+i], dbspecrs[30+i]); 
        !           497:        }
        !           498:        
        !           499:        db_printf("\n");
        !           500: 
        !           501: 
        !           502:        stFloat(dbfloats);                                                                              /* Save floating point registers */
        !           503:        for(i = 0; i < 32; i += 4) {                                                    /* Print 4 at a time */
        !           504:                db_printf("F%02d: %08X %08X  %08X %08X  %08X %08X  %08X %08X\n", i,
        !           505:                        dbfloats[i][0], dbfloats[i][1], dbfloats[i+1][0], dbfloats[i+1][1], 
        !           506:                        dbfloats[i+2][0], dbfloats[i+2][1], dbfloats[i+3][0], dbfloats[i+3][1]); 
        !           507:        }
        !           508:        db_printf("FCR: %08X %08X\n", dbfloats[32][0], dbfloats[32][1]);        /* Print FSCR */
        !           509:        
        !           510:        if(!stVectors(dbvecs)) return;                                                  /* Return if not Altivec capable */
        !           511:        
        !           512:        for(i = 0; i < 32; i += 2) {                                                    /* Print 2 at a time */
        !           513:                db_printf("V%02d: %08X %08X %08X %08X  %08X %08X %08X %08X\n", i,
        !           514:                        dbvecs[i][0], dbvecs[i][1], dbvecs[i][2], dbvecs[i][3], 
        !           515:                        dbvecs[i+1][0], dbvecs[i+1][1], dbvecs[i+1][2], dbvecs[i+1][3]); 
        !           516:        }
        !           517:        db_printf("VCR: %08X %08X %08X %08X\n", dbvecs[32][0], dbvecs[32][1], dbvecs[32][2], dbvecs[32][3]);    /* Print VSCR */
        !           518: 
        !           519:        return;                                                                                                 /* Tell them we did it */
        !           520: 
        !           521: 
        !           522: }
        !           523: 
        !           524: 
        !           525: /*
        !           526:  *             Print out physical to vm system stuff
        !           527:  *
        !           528:  *             
        !           529:  *             dp 
        !           530:  */
        !           531: void db_display_phys(db_expr_t addr, int have_addr, db_expr_t count, char * modif) {
        !           532: 
        !           533: #if 0
        !           534:        int                             i, j, pents;
        !           535:        mapping         *mp;
        !           536:        vm_offset_t     pa;
        !           537:        struct phys_entry *pp;
        !           538:        
        !           539:        for (i = 0; i < pmap_mem_regions_count; i++) {                  /* Step through the phys tables */
        !           540:                for(j = 0; j < (pmap_mem_regions[i].end - pmap_mem_regions[i].start); j ++) {   /* Step through phys ents */
        !           541:                        pa = pmap_mem_regions[i].start + (j << 12);             /* Get paddr */
        !           542:                        pp = &pmap_mem_regions[i].phys_table[j];                /* Get phys_ent */
        !           543:                        db_printf(
        !           544:                
        !           545:                }
        !           546:        }
        !           547:                db_printf("pa=%08X\n", 
        !           548:                if (pa < pmap_mem_regions[i].start)
        !           549:                        continue;
        !           550:                if (pa >= pmap_mem_regions[i].end)
        !           551:                        return PHYS_NULL;
        !           552:                
        !           553:                entry = &pmap_mem_regions[i].phys_table[(pa - pmap_mem_regions[i].start) >> PPC_PGSHIFT];
        !           554:                return entry;
        !           555:        }
        !           556: 
        !           557: 
        !           558: 
        !           559:        mp = hw_lock_phys_vir(dvspace, addr);                                   /* Lock the physical entry for this mapping */
        !           560:        if(!mp) {                                                                                               /* Did we find one? */
        !           561:                db_printf("Not mapped\n");      
        !           562:                return;                                                                                         /* Didn't find any, return FALSE... */
        !           563:        }
        !           564:        if((unsigned int)mp&1) {                                                                /* Did we timeout? */
        !           565:                db_printf("Timeout locking physical entry for virtual address (%08X)\n", addr); /* Yeah, scream about it! */
        !           566:                return;                                                                                         /* Bad hair day, return FALSE... */
        !           567:        }
        !           568:        printf("dumpaddr: space=%08X; vaddr=%08X\n", dvspace, addr);    /* Say what address were dumping */
        !           569:        dumpmapping(mp);
        !           570:        if(mp->physent) {
        !           571:                db_dumppca(mp);
        !           572:                hw_unlock_bit(&mp->physent->pte1, PHYS_LOCK);           /* Unlock physical entry associated with mapping */
        !           573:        }
        !           574: 
        !           575: #endif
        !           576: 
        !           577:        return;                                                                                                 /* Tell them we did it */
        !           578: 
        !           579: 
        !           580: }
        !           581: 
        !           582: 
        !           583: 
        !           584: void Dumbo(void);
        !           585: void Dumbo(void){
        !           586: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.