void debug_prompt() { char s[81] = { 0 }; UINT8 done = 0; struct cpudef *cpu = get_cpu_struct(g_which_cpu); unsigned int addr = cpu->getpc_callback(); // this function relies on addr being initialized to PC g_break = 0; // once they get here, don't break anymore // they have to issue a proper command to get out of the prompt while (!done && !get_quitflag()) { newline(); print_cpu_context(); // show registers and stuff sprintf(s, "[#%u][%04x Command,'?']-> ", g_which_cpu, cpu->getpc_callback()); outstr(s); con_getline(s, 80); switch(toupper(s[0])) { case 'S': // this might help with debugging *shrug* g_ldp->pre_step_forward(); printline("Stepping forward one frame..."); break; case 'C': // continue execution g_cpu_trace = 0; done = 1; break; case 'D': // disassemble // if they entered in an address to disassemble at ... if (strlen(s) > 1) { addr = (unsigned int) strtol(&s[1], NULL, 16); // convert base 16 text to a number } // else if they entered no parameters, disassemble from PC debug_disassemble(addr); break; case 'F': // display current laserdisc frame g_ldp->print_frame_info(); print_ldv1000_info(); break; case 'I': // break at end of interrupt printline("This feature not implemented yet =]"); break; case '=': // set a new breakpoint // if they entered in an address to disassemble at ... if (strlen(s) > 1) { g_breakpoint = (UINT32) strtol(&s[1], NULL, 16); // convert base 16 text to a number g_break = 1; g_cpu_trace = 0; done = 1; } // else if they entered no parameters, disassemble from PC else { printline("You must specify an address to break at."); } break; case 'M': // memory dump if (strlen(s) > 1) { addr = (unsigned int) strtol(&s[1], NULL, 16); } print_memory_dump(addr); break; case 'N': // next CPU g_which_cpu++; // if we've run out of CPU's to debug, wrap back around to the first cpu if (get_cpu_struct(g_which_cpu) == NULL) g_which_cpu = 0; break; case 0: // carriage return g_cpu_trace = 1; done = 1; break; case 'Q': // quit emulator set_quitflag(); break; case 'W': // write byte at address if (strlen(s) > 1) { int i = 2; // skip the W and the first whitespace Uint32 addr = 0; Uint8 val = 0; // find next whitespace while (s[i] != ' ') { i++; } s[i] = 0; // terminate string so we can do a strtol addr = (Uint32) strtol(&s[1], NULL, 16); // convert base 16 text to a number val = (Uint8) strtol(&s[i+1], NULL, 16); // i+1 because we skip the NULL-terminator we added before g_game->cpu_mem_write((Uint16) addr, val); // assume 16-bit for now } break; case '?': // get menu debug_menu(); break; default: printline("Unknown command, press ? to get a menu"); break; } } // end while }
/****************************************************************************** * Name: main * Description: Program entry point * * Returns: int - returns 0 if no errors ******************************************************************************/ int main() { /* declare a network interface and network addresses */ struct netif *netif, server_netif; struct ip_addr ipaddr, netmask, gw; /* specify a unique MAC address for the board */ #ifdef XPAR_CPU_PPC440_CORE_CLOCK_FREQ_HZ /* set MAC on ML507 board */ unsigned char mac_ethernet_address[] = {0x00, 0x0a, 0x35, 0x01, 0xC9, 0x76}; #else /* set MAC on ML410 board */ unsigned char mac_ethernet_address[] = {0x00, 0x0a, 0x35, 0x01, 0x9A, 0xFE}; #endif /* set the network interface pointer */ netif = &server_netif; /* enable caches */ XCache_EnableICache( INSTR_CACHE ); XCache_EnableDCache( DATA_CACHE ); /* setup interrupts */ setup_interrupts(); /* initliaze network addresses to be used */ IP4_ADDR( &ipaddr, 192, 168, 1, 15 ); IP4_ADDR( &netmask, 255, 255, 255, 0 ); IP4_ADDR( &gw, 192, 168, 1, 1 ); /* print the application header and IP settings */ print_app_header(); print_ip_settings(&ipaddr, &netmask, &gw); /* initialize lwip */ lwip_init(); /* add network interface to the netif_list, and set it as default */ if( !xemac_add( netif, &ipaddr, &netmask, &gw, mac_ethernet_address, EMAC_BASEADDR ) ) { xil_printf( "Error adding N/W interface\n\r" ); return -1; } netif_set_default( netif ); /* now enable interrupts */ enable_interrupts(); /* specify that the network if is up */ netif_set_up( netif ); /* start the application */ start_application(); /* print debug header if debug mode set */ #ifdef QMFIR_DEBUG debug_menu(); while( 1) { qmfir_debug(); } #endif /* receive and process packets */ while( 1 ) { xemacif_input( netif ); } /* disable caches */ XCache_DisableDCache(); XCache_DisableICache(); return 0; } /* main */