Beispiel #1
0
void dump_thread_context_to_screen(PROCESSOR_DATA_BLOCK *processor,
        unsigned int exceptionCode, CONTEXT *context)
{
    console_set_colors(0x000080ff, 0xffffffff);
    console_clrscr();
    
    strcpy(exception_text, exception_strings[exceptionCode]);
    
    debug_flush_console();

    sprintf(exception_text,"\nIar=%016llx Msr=%016llx Lr=%016llx Dar=%08X Pir=%02X\n\n",
                    context->Iar, context->Msr, context->Lr,
                        processor->DAR, (unsigned int)mfspr(pir));
    
    debug_flush_console();

    int i;
    for(i=0;i<8;++i)
            sprintf(exception_text,"%s%02d=%016llx %02d=%016llx %02d=%016llx %02d=%016llx\n",
                            exception_text,
                    i,context->Gpr[i],
                    i+8,context->Gpr[i+8],
                    i+16,context->Gpr[i+16],
                    i+24,context->Gpr[i+24]);

    debug_flush_console();
    
    debug_cpu_print_stack((void*)context->Iar,(void*)context->Lr,(void*)context->Gpr[1]);

    strcat(exception_text,"\n\nOn uart: 'h'=Halt, 'r'=Reboot\n\n");

    debug_flush_console();

    for(;;){
            switch(getch()){
                    case 'h':
                            xenon_smc_power_shutdown();
                            for(;;);
                            break;
                    case 'r':
                            xenon_smc_power_reboot();
                            for(;;);
                            break;
            }
    }
}
Beispiel #2
0
void crashdump(u32 exception,u64 * context)
{
	console_set_colors(0x000080ff, 0xffffffff);
	console_init();
	console_clrscr();
        
        switch(exception)
        {
            case 0x200:
                strcpy(text,"\nMachine Check!\n\n");
                break;
            case 0x380:
                strcpy(text,"\nData SegFault!\n\n");
                break;
            case 0x480:
                strcpy(text,"\nInstruction SegFault!\n\n");
                break;
            case 0x500:
                strcpy(text,"\nExternal Interrupt!\n\n");
                break;
            case 0x600:
                strcpy(text,"\nAlignment!\n\n");
                break;
            case 0x700:
                strcpy(text,"\nProgram Interrupt!\n\n");
                break;
            case 0x800:
                strcpy(text,"\nFPU Unavailable!\n\n");
                break;
            case 0x900:
                strcpy(text,"\nDecrementer!\n\n");
                break;
            case 0x980:
                strcpy(text,"\nHV Decrementer!\n\n");
                break;
            case 0xC00:
                strcpy(text,"\nSystem Call!\n\n");
                break;
            case 0xD00:
                strcpy(text,"\nTrace!\n\n");
                break;
            case 0xE00:
                strcpy(text,"\nFPU Assist!\n\n");
                break;
            case 0xF20:
                strcpy(text,"\nVPU Unavailable!\n\n");
                break;
            case 0x1600:
                strcpy(text,"\nMaintenance!\n\n");
                break;
            case 0x1700:
                strcpy(text,"\nVMX Assist!\n\n");
                break;
            case 0x1800:
                strcpy(text,"\nThermal Managment!\n\n");
                break;
            case 0:
                strcpy(text,"\nSegmentation Fault!\n\n");
                break;
            default:
                sprintf(text,"\nException Vector! (%p)\n\n",exception);
                break;
        }
		
	flush_console();
	
	sprintf(text,"%spir=%016llx dar=%016llx\nIar=%016llx Msr=%016llx lr=%016llx\n\n",
			text,context[39],context[38],context[36],context[37],context[32]);
	
	flush_console();
	
	int i;
	for(i=0;i<8;++i)
		sprintf(text,"%s%02d=%016llx %02d=%016llx %02d=%016llx %02d=%016llx\n",
				text,i,context[i],i+8,context[i+8],i+16,context[i+16],i+24,context[i+24]);
	
	flush_console();
	
	_cpu_print_stack((void*)(u32)context[36],(void*)(u32)context[32],(void*)(u32)context[1]);
	
	strcat(text,"\n\nOn uart: 'x'=Xell, 'h'=Halt, 'r'=Reboot\n\n");

	flush_console();

	for(;;){
		switch(getch()){
			case 'x':
				exit(0);
				break;
			case 'h':
				xenon_smc_power_shutdown();
				for(;;);
				break;
			case 'r':
				xenon_smc_power_reboot();
				for(;;);
				break;
		}
	}
}
Beispiel #3
0
void ActionRestart(void * unused) {
    // restart
    xenon_smc_power_reboot();
}
Beispiel #4
0
int flash_from_file(const char *filename, int raw) {
    int i, logic_pos, status = 0x200;
    unsigned char *block, *block_flash, *bad_block;
    float pct = 0.f;

    FILE *f = fopen(filename, "rb");
    if (!f) {
        printf("\nError: Failed to open file: %s\n", filename);
        return -1;
    }

    printf("\nFlashing from %s...\n", filename);
    printf("0x%x block's to write...\n", sfc.size_blocks);

    if (!f)
        return -1;

    if (raw == -1) /* auto */ {
        fseek(f, 0, SEEK_END);
        raw = detect_read_write_modus(ftell(f));
        if (raw == -1)
            return -1;
        fseek(f, 0, SEEK_SET);
    }

    block = (unsigned char*) malloc(sfc.block_sz_phys);
    block_flash = (unsigned char*) malloc(sfc.block_sz_phys);
    bad_block = (unsigned char*) malloc(sfc.block_sz_phys);

    unsigned nand_size = sfc.size_bytes;

    // Dump only 64mb on big nand
    if ((nand_size == NAND_SIZE_512MB) | (nand_size == NAND_SIZE_256MB)) {
        nand_size = NAND_SIZE_64MB;
    }

    for (i = 0; i < nand_size; i += sfc.block_sz) {
        memset(block, 0xFF, sizeof (block));
        if (!fread(block, 1, sfc.page_sz_phys * sfc.pages_in_block, f)) {
            printf("Error reading ...\r\n");
            return i;
        }


        pct = ((float) i / (float) (nand_size));
        App.SetProgressValue(pct);

        // printf("Writing block: 0x%x of 0x%x (%iMB/%iMB)\r\n", sfcx_address_to_block(i) +1 , sfc.size_blocks , (i + sfc.block_sz) >> 20, nand_size >> 20);

        //Check for bad block
        sfcx_writereg(SFCX_STATUS, sfcx_readreg(SFCX_STATUS));
        sfcx_writereg(SFCX_ADDRESS, i);
        sfcx_writereg(SFCX_COMMAND, raw ? PHY_PAGE_TO_BUF : LOG_PAGE_TO_BUF);
        // Wait Busy
        while ((status = sfcx_readreg(SFCX_STATUS)) & 1);

        if ((!raw)) {
            logic_pos = sfcx_readreg(SFCX_PHYSICAL);

            if (!(logic_pos & 0x04000000)) /* shouldn't happen, unless the existing image is broken. just assume the block is okay. */ {
                printf("Error: Uh, oh, don't know. Reading @ block %08x failed. logic_pos: %i\r\n", i, sfcx_address_to_block(logic_pos));
                logic_pos = i;
            }
            logic_pos &= 0x3fffe00;

            if (logic_pos != i) {
                printf("Relocating/moving bad block from position 0x%x to 0x%x\r\n", sfcx_address_to_block(i), sfcx_address_to_block(logic_pos));
            }
        } else if (status & 0x40) //Bad Block Management
        {
            printf("Bad block ...\r\n");
#if 0
            logic_pos = sfc.last_bad_block_pos * sfc.block_sz;
            sfc.last_bad_block_pos--;

            sfcx_set_blocknumber(block, sfcx_address_to_block(i));
            sfcx_calcecc((int*) block);

            if (logic_pos != i) {
                printf("Relocating/moving bad block from position 0x%x to 0x%x\n", sfcx_address_to_block(i), sfcx_address_to_block(logic_pos));
            }
#endif
        } else {
            logic_pos = i;
        }
#if 0
        if (sfc.last_bad_block_pos == sfcx_address_to_block(i)) {
            //We reach the the last entry bad block in reserved area
            printf("\nWriting only to last entry bad block in the reserved area.");
            break;
        }
#endif

        //Erase block in Nand
        sfcx_erase_block(logic_pos);

        //Write block to Nand
        sfcx_write_block(block, logic_pos);

    }

    printf("\nWrite done\n");

    fclose(f);
    free(block);
    free(block_flash);
    free(bad_block);

    if (App.Warning("Flashing is complete, reboot the console?") == TRUE) {
        xenon_smc_power_reboot();
    }

    return 0;
}