Annotation of XNU/osfmk/ppc/FirmwareC.c, revision 1.1.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:  *     This file contains firmware code.
                     24:  *
                     25:  */
                     26: 
                     27: #include <cpus.h>
                     28: #include <debug.h>
                     29: #include <mach_vm_debug.h>
                     30: #include <db_machine_commands.h>
                     31: 
                     32: #include <kern/thread.h>
                     33: #include <mach/vm_attributes.h>
                     34: #include <mach/vm_param.h>
                     35: #include <kern/spl.h>
                     36: 
                     37: #include <kern/misc_protos.h>
                     38: #include <ppc/misc_protos.h>
                     39: #include <ppc/proc_reg.h>
                     40: #include <ppc/mem.h>
                     41: #include <ppc/pmap.h>
                     42: #include <ppc/pmap_internals.h>
                     43: #include <ppc/new_screen.h>
                     44: #include <ppc/Firmware.h>
                     45: #include <ppc/mappings.h>
                     46: #include <pexpert/ppc/powermac.h>
                     47: #include <ddb/db_output.h>
                     48: 
                     49: extern Boot_Video      boot_video_info;
                     50: Boot_Video dgVideo;
                     51: extern GDWorkArea      GratefulDebWork[];
                     52: 
                     53: typedef struct RuptCtr {                                                               /* Counts hardware interrupts */
                     54:        struct GDpos {                                                                          /* Screen position for Grateful Deb display */
                     55:                unsigned short col;                                                             /* Column  (-1 means no display) */
                     56:                unsigned short row;                                                             /* Row */
                     57:        } GDpos;
                     58:        unsigned int count;                                                                     /* Count of interrupt */
                     59:        unsigned int timed;                                                                     /* If set, count updates at timed rate  */
                     60:        unsigned int lasttime;                                                          /* Low of timebase when last updated */
                     61: } RuptCtr;
                     62: 
                     63: /*                                                     Window layout for Grateful Deb:
                     64:  *                                                     
                     65:  *                                                     0                               9
                     66:  *
                     67:  *                                             0       Total                   Decrimenter
                     68:  *                                             1       DSI                             ISI
                     69:  *                                             2       System call             External
                     70:  *                                             3       SIGP                    Floating point
                     71:  *                                             4       Program                 Alignment
                     72:  */
                     73: 
                     74: 
                     75: 
                     76: 
                     77: 
                     78: RuptCtr RuptCtrs[96] = {
                     79:                                                        { { 0,  0}, 0, 1 },             /* Total interruptions */
                     80:                                                        { {-1, -1}, 0, 0 },             /* Reset */
                     81:                                                        { {-1, -1}, 0, 0 },             /* Machine check */
                     82:                                                        { { 0,  1}, 0, 1 },             /* DSIs */
                     83:                                                        { { 1,  1}, 0, 1 },             /* ISIs */
                     84:                                                        { { 1,  2}, 0, 1 },             /* Externals */
                     85:                                                        { { 1,  4}, 0, 0 },             /* Alignment */
                     86:                                                        { { 0,  4}, 0, 0 },             /* Program */
                     87:                                                        { { 1,  3}, 0, 0 },             /* Floating point */
                     88:                                                        { { 1,  0}, 0, 1 },             /* Decrementer */
                     89:                                                        { {-1, -1}, 0, 0 },             /* I/O error */
                     90:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                     91:                                                        { { 0,  2}, 0, 1 },             /* System call */
                     92:                                                        { {-1, -1}, 0, 0 },             /* Trace */
                     93:                                                        { {-1, -1}, 0, 0 },             /* Floating point assist */
                     94:                                                        { {-1, -1}, 0, 0 },             /* Performance monitor */
                     95:                                                        { {-1, -1}, 0, 0 },             /* VMX */
                     96:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                     97:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                     98:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                     99:                                                        { {-1, -1}, 0, 0 },             /* Instruction breakpoint */
                    100:                                                        { {-1, -1}, 0, 0 },             /* System management */
                    101:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    102:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    103:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    104:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    105:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    106:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    107:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    108:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    109:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    110:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    111:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    112:                                                        { {-1, -1}, 0, 0 },             /* Trace */
                    113:                                                        { { 0,  3}, 0, 0 },             /* SIGP */
                    114:                                                        { {-1, -1}, 0, 0 },             /* Preemption */
                    115:                                                        { {-1, -1}, 0, 0 },             /* Context switch */
                    116:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    117:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    118:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    119:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    120:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    121:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    122:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    123:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    124:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    125:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    126:                                                        { {-1, -1}, 0, 0 },             /* Special, update frequency controls */
                    127: 
                    128: /*                                                     Start of second processor counts */
                    129:                                                        
                    130:                                                        { { 0,  0}, 0, 1 },             /* Total interruptions */
                    131:                                                        { {-1, -1}, 0, 0 },             /* Reset */
                    132:                                                        { {-1, -1}, 0, 0 },             /* Machine check */
                    133:                                                        { { 0,  1}, 0, 1 },             /* DSIs */
                    134:                                                        { { 1,  1}, 0, 1 },             /* ISIs */
                    135:                                                        { { 1,  2}, 0, 1 },             /* Externals */
                    136:                                                        { { 1,  4}, 0, 0 },             /* Alignment */
                    137:                                                        { { 0,  4}, 0, 0 },             /* Program */
                    138:                                                        { { 1,  3}, 0, 0 },             /* Floating point */
                    139:                                                        { { 1,  0}, 0, 1 },             /* Decrementer */
                    140:                                                        { {-1, -1}, 0, 0 },             /* I/O error */
                    141:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    142:                                                        { { 0,  2}, 0, 1 },             /* System call */
                    143:                                                        { {-1, -1}, 0, 0 },             /* Trace */
                    144:                                                        { {-1, -1}, 0, 0 },             /* Floating point assist */
                    145:                                                        { {-1, -1}, 0, 0 },             /* Performance monitor */
                    146:                                                        { {-1, -1}, 0, 0 },             /* VMX */
                    147:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    148:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    149:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    150:                                                        { {-1, -1}, 0, 0 },             /* Instruction breakpoint */
                    151:                                                        { {-1, -1}, 0, 0 },             /* System management */
                    152:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    153:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    154:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    155:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    156:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    157:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    158:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    159:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    160:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    161:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    162:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    163:                                                        { {-1, -1}, 0, 0 },             /* Trace */
                    164:                                                        { { 0,  3}, 0, 0 },             /* SIGP */
                    165:                                                        { {-1, -1}, 0, 0 },             /* Preemption */
                    166:                                                        { {-1, -1}, 0, 0 },             /* Context switch */
                    167:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    168:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    169:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    170:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    171:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    172:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    173:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    174:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    175:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    176:                                                        { {-1, -1}, 0, 0 },             /* Reserved */
                    177:                                                        { {-1, -1}, 0, 0 }                      /* Special, update frequency controls */
                    178:                                                };
                    179: 
                    180: void GratefulDebInit(bootBumbleC *boot_video_info) {   /* Initialize the video debugger */
                    181: 
                    182:        unsigned int fillframe[256];
                    183:        unsigned int startpos, startbyte, windowleft, newwidth, i, j, startword, oldwidth, nrmlgn;
                    184:        unsigned int nwords, *byteleft, lstlgn, pixlgn, bytelgn;
                    185:        
                    186:        if(!boot_video_info) {                                                          /* Are we disabling it?
                    187:                GratefulDebWork[0].GDready = 0;                                 /* Disable output */
                    188:                return;
                    189:        }
                    190:        
                    191:        nrmlgn = (9 * GDfontsize) * (boot_video_info->v_depth / 8);     /* Get the normal column size in bytes */
                    192:        lstlgn = (((8 * GDfontsize) + (GDfontsize >> 1)) * boot_video_info->v_depth) / 8;       /* Same as normal, but with 1/2 character space */
                    193:        nrmlgn = (nrmlgn + 31) & -32;                                           /* Round to a line */
                    194:        
                    195:        bytelgn = (nrmlgn * (GDdispcols - 1)) + lstlgn;         /* Length in bytes */
                    196:        pixlgn = bytelgn / (boot_video_info->v_depth / 8);      /* Number of pixels wide */
                    197:        
                    198:        startbyte = (boot_video_info->v_width * (boot_video_info->v_depth / 8)) - bytelgn;      /* Get the starting byte unaligned */
                    199:        startpos = boot_video_info->v_width - pixlgn;           /* Starting pixel position */
                    200:        
                    201:        startbyte += (unsigned int)boot_video_info->v_baseAddr & 31;    /* Add the extra to cache boundary in frame buffer */
                    202:        startbyte &= -32;                                                                       /* Make sure it's on a cache line for speed */
                    203:        startbyte += (unsigned int)boot_video_info->v_baseAddr & 31;    /* Subtract the extra to cache boundary in frame buffer */
                    204: 
                    205:        windowleft = startbyte - (((GDfontsize / 2) * boot_video_info->v_depth) / 8);   /* Back up a half character */
                    206:        windowleft &= -4;                                                                       /* Make sure it is on a word boundary */
                    207:        newwidth = windowleft / (boot_video_info->v_depth / 8); /* Get the new pixel width of screen */
                    208:        
                    209:        oldwidth = boot_video_info->v_width;                                    /* Save the old width */
                    210: //     boot_video_info->v_width = newwidth;                                    /* Set the new width */
                    211:        
                    212:        nwords = oldwidth - newwidth;                                           /* See how much to fill in pixels */
                    213:        nwords = nwords / (32 / boot_video_info->v_depth);      /* Get that in bytes */
                    214:        
                    215:        startword = (newwidth + 3) / 4;                                         /* Where does it start? */
                    216:        
                    217:        
                    218:        byteleft = (unsigned int *)(boot_video_info->v_baseAddr + windowleft);  /* Starting place */
                    219:        for (i=0; i < nwords; i++) byteleft[i] = 0;             /* Set the row to all black */
                    220:        
                    221:        byteleft = (unsigned int *)(boot_video_info->v_baseAddr + windowleft + (boot_video_info->v_rowBytes * 1));      /* Starting place */
                    222:        for (i=0; i < nwords; i++) byteleft[i] = 0;             /* Set the row to all black */
                    223:        
                    224:        byteleft = (unsigned int *)(boot_video_info->v_baseAddr + windowleft + 
                    225:                (boot_video_info->v_rowBytes * (boot_video_info->v_height - 2)));       /* Starting place */
                    226:        for (i=0; i < nwords; i++) byteleft[i] = 0;             /* Set the row to all black */
                    227:        
                    228:        byteleft = (unsigned int *)(boot_video_info->v_baseAddr + windowleft + 
                    229:                (boot_video_info->v_rowBytes * (boot_video_info->v_height - 1)));       /* Starting place */
                    230:        for (i=0; i < nwords; i++) byteleft[i] = 0;             /* Set the row to all black */
                    231:        
                    232:        for (i=0; i < nwords; i++) fillframe[i] = 0xFFFFFFFF;   /* Set the row to all white */
                    233:        
                    234:        if(boot_video_info->v_depth == 8) {                             /* See if 8 bits a pixel */
                    235:                fillframe[0] = 0x0000FFFF;                                      /* Make left border */
                    236:                fillframe[nwords - 1] = 0xFFFF0000;                     /* Make right border */
                    237:        }
                    238:        else if(boot_video_info->v_depth == 16) {               /* See if 16 bits a pixel */
                    239:                fillframe[0] = 0x00000000;                                      /* Make left border */
                    240:                fillframe[nwords - 1] = 0x00000000;                     /* Make right border */
                    241:        }
                    242:        else {
                    243:                fillframe[0] = 0x00000000;                                      /* Make left border */
                    244:                fillframe[1] = 0x00000000;                                      /* Make left border */
                    245:                fillframe[nwords - 1] = 0x00000000;                     /* Make right border */
                    246:                fillframe[nwords - 2] = 0x00000000;                     /* Make right border */
                    247:        }
                    248:        
                    249:        byteleft = (unsigned int *)(boot_video_info->v_baseAddr + windowleft + (boot_video_info->v_rowBytes * 2));      /* Place to start filling */
                    250:                
                    251:        for(i=2; i < (boot_video_info->v_height - 2); i++) {    /* Fill the rest */
                    252:                for(j=0; j<nwords; j++) byteleft[j] = fillframe[j];     /* Fill the row */
                    253:                byteleft = (unsigned int *)((unsigned int)byteleft + boot_video_info->v_rowBytes);      /* Next row */
                    254:        }
                    255: 
                    256:        for(i=0; i<2; i++) {                                                    /* Initialize both (for now) processor areas */
                    257:                
                    258:                GratefulDebWork[i].GDtop = 2 + (GDfontsize / 2) + (i * 18 * GDfontsize);
                    259:                GratefulDebWork[i].GDleft = 2 + startpos + (GDfontsize / 2);
                    260:                GratefulDebWork[i].GDtopleft = boot_video_info->v_baseAddr + startbyte + 
                    261:                        (GratefulDebWork[i].GDtop * boot_video_info->v_rowBytes);
                    262:                GratefulDebWork[i].GDrowbytes = boot_video_info->v_rowBytes;
                    263:                GratefulDebWork[i].GDrowchar = boot_video_info->v_rowBytes * (GDfontsize + (GDfontsize / 4));
                    264:                GratefulDebWork[i].GDdepth = boot_video_info->v_depth;
                    265:                GratefulDebWork[i].GDcollgn = nrmlgn;
                    266:        
                    267: //             RuptCtrs[(48*i)+47].timed = powermac_info.bus_clock_rate_hz >> 6;       /* (Update every 16th of a second (16 fps) */
                    268:                RuptCtrs[(48*i)+47].timed = powermac_info.bus_clock_rate_hz >> 5;       /* (Update every 8th of a second (8 fps) */
                    269: //             RuptCtrs[(48*i)+47].timed = powermac_info.bus_clock_rate_hz >> 4;       /* (Update every 4th of a second (4 fps) */
                    270: //             RuptCtrs[(48*i)+47].timed = powermac_info.bus_clock_rate_hz >> 3;       /* (Update every 2th of a second (2 fps) */
                    271: //             RuptCtrs[(48*i)+47].timed = powermac_info.bus_clock_rate_hz >> 2;       /* (Update every 1 second (1 fps) */
                    272:                
                    273:                sync();
                    274:                
                    275:                GratefulDebWork[i].GDready = 1;                         /* This one's all ready */
                    276:        }
                    277: 
                    278: }
                    279: 
                    280: 

unix.superglobalmegacorp.com

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