#include <cpus.h>
#include <debug.h>
#include <mach_vm_debug.h>
#include <db_machine_commands.h>
#include <kern/thread.h>
#include <mach/vm_attributes.h>
#include <mach/vm_param.h>
#include <kern/spl.h>
#include <kern/misc_protos.h>
#include <ppc/misc_protos.h>
#include <ppc/proc_reg.h>
#include <ppc/mem.h>
#include <ppc/pmap.h>
#include <ppc/new_screen.h>
#include <ppc/Firmware.h>
#include <ppc/mappings.h>
#include <pexpert/pexpert.h>
#include <ddb/db_output.h>
extern Boot_Video boot_video_info;
Boot_Video dgVideo;
extern GDWorkArea GratefulDebWork[];
typedef struct RuptCtr {
struct GDpos {
unsigned short col;
unsigned short row;
} GDpos;
unsigned int count;
unsigned int timed;
unsigned int lasttime;
} RuptCtr;
RuptCtr RuptCtrs[96] = {
{ { 0, 0}, 0, 1 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ { 0, 1}, 0, 1 },
{ { 1, 1}, 0, 1 },
{ { 1, 2}, 0, 1 },
{ { 1, 4}, 0, 0 },
{ { 0, 4}, 0, 0 },
{ { 1, 3}, 0, 0 },
{ { 1, 0}, 0, 1 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ { 0, 2}, 0, 1 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ { 0, 3}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ { 0, 0}, 0, 1 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ { 0, 1}, 0, 1 },
{ { 1, 1}, 0, 1 },
{ { 1, 2}, 0, 1 },
{ { 1, 4}, 0, 0 },
{ { 0, 4}, 0, 0 },
{ { 1, 3}, 0, 0 },
{ { 1, 0}, 0, 1 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ { 0, 2}, 0, 1 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ { 0, 3}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 },
{ {-1, -1}, 0, 0 }
};
void GratefulDebInit(bootBumbleC *boot_video_info) {
unsigned int fillframe[256];
unsigned int startpos, startbyte, windowleft, newwidth, i, j, startword, oldwidth, nrmlgn;
unsigned int nwords, *byteleft, lstlgn, pixlgn, bytelgn;
if(!boot_video_info) {
return;
}
nrmlgn = (9 * GDfontsize) * (boot_video_info->v_depth / 8);
lstlgn = (((8 * GDfontsize) + (GDfontsize >> 1)) * boot_video_info->v_depth) / 8;
nrmlgn = (nrmlgn + 31) & -32;
bytelgn = (nrmlgn * (GDdispcols - 1)) + lstlgn;
pixlgn = bytelgn / (boot_video_info->v_depth / 8);
startbyte = (boot_video_info->v_width * (boot_video_info->v_depth / 8)) - bytelgn;
startpos = boot_video_info->v_width - pixlgn;
startbyte += (unsigned int)boot_video_info->v_baseAddr & 31;
startbyte &= -32;
startbyte += (unsigned int)boot_video_info->v_baseAddr & 31;
windowleft = startbyte - (((GDfontsize / 2) * boot_video_info->v_depth) / 8);
windowleft &= -4;
newwidth = windowleft / (boot_video_info->v_depth / 8);
oldwidth = boot_video_info->v_width;
nwords = oldwidth - newwidth;
nwords = nwords / (32 / boot_video_info->v_depth);
startword = (newwidth + 3) / 4;
byteleft = (unsigned int *)(boot_video_info->v_baseAddr + windowleft);
for (i=0; i < nwords; i++) byteleft[i] = 0;
byteleft = (unsigned int *)(boot_video_info->v_baseAddr + windowleft + (boot_video_info->v_rowBytes * 1));
for (i=0; i < nwords; i++) byteleft[i] = 0;
byteleft = (unsigned int *)(boot_video_info->v_baseAddr + windowleft +
(boot_video_info->v_rowBytes * (boot_video_info->v_height - 2)));
for (i=0; i < nwords; i++) byteleft[i] = 0;
byteleft = (unsigned int *)(boot_video_info->v_baseAddr + windowleft +
(boot_video_info->v_rowBytes * (boot_video_info->v_height - 1)));
for (i=0; i < nwords; i++) byteleft[i] = 0;
for (i=0; i < nwords; i++) fillframe[i] = 0xFFFFFFFF;
if(boot_video_info->v_depth == 8) {
fillframe[0] = 0x0000FFFF;
fillframe[nwords - 1] = 0xFFFF0000;
}
else if(boot_video_info->v_depth == 16) {
fillframe[0] = 0x00000000;
fillframe[nwords - 1] = 0x00000000;
}
else {
fillframe[0] = 0x00000000;
fillframe[1] = 0x00000000;
fillframe[nwords - 1] = 0x00000000;
fillframe[nwords - 2] = 0x00000000;
}
byteleft = (unsigned int *)(boot_video_info->v_baseAddr + windowleft + (boot_video_info->v_rowBytes * 2));
for(i=2; i < (boot_video_info->v_height - 2); i++) {
for(j=0; j<nwords; j++) byteleft[j] = fillframe[j];
byteleft = (unsigned int *)((unsigned int)byteleft + boot_video_info->v_rowBytes);
}
for(i=0; i<2; i++) {
GratefulDebWork[i].GDtop = 2 + (GDfontsize / 2) + (i * 18 * GDfontsize);
GratefulDebWork[i].GDleft = 2 + startpos + (GDfontsize / 2);
GratefulDebWork[i].GDtopleft = boot_video_info->v_baseAddr + startbyte +
(GratefulDebWork[i].GDtop * boot_video_info->v_rowBytes);
GratefulDebWork[i].GDrowbytes = boot_video_info->v_rowBytes;
GratefulDebWork[i].GDrowchar = boot_video_info->v_rowBytes * (GDfontsize + (GDfontsize / 4));
GratefulDebWork[i].GDdepth = boot_video_info->v_depth;
GratefulDebWork[i].GDcollgn = nrmlgn;
RuptCtrs[(48*i)+47].timed = gPEClockFrequencyInfo.timebase_frequency_hz >> 3;
sync();
GratefulDebWork[i].GDready = 1;
}
}
void debugNoop(void);
void debugNoop(void) {
return;
}