📄 v850_ice.cxx
字号:
}static intcyg_hal_plf_diag_ice_isr(void *__ch_data, int* __ctrlc, CYG_ADDRWORD __vector, CYG_ADDRWORD __data){ CYGARC_HAL_SAVE_GP(); *__ctrlc = 0; CYGARC_HAL_RESTORE_GP(); return 0;}__externC voidcyg_hal_plf_ice_diag_init(){ hal_virtual_comm_table_t* comm; int cur = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT); // Init channels ICE_SYSCALL_INFO_DIAGOUTPC = (int)&hal_v850_ice_output_break; ICE_SYSCALL_INFO_DIAGOUTBUF = (int)&v850ice_output_buf[0]; ICE_SYSCALL_INFO_DIAGOUTBUFEND = (int)&v850ice_output_end; // Setup procs in the vector table // Set channel 1 CYGACC_CALL_IF_SET_CONSOLE_COMM(1); comm = CYGACC_CALL_IF_CONSOLE_PROCS(); CYGACC_COMM_IF_CH_DATA_SET(*comm, 0); CYGACC_COMM_IF_WRITE_SET(*comm, cyg_hal_plf_diag_ice_write); CYGACC_COMM_IF_READ_SET(*comm, cyg_hal_plf_diag_ice_read); CYGACC_COMM_IF_PUTC_SET(*comm, cyg_hal_plf_diag_ice_putc); CYGACC_COMM_IF_GETC_SET(*comm, cyg_hal_plf_diag_ice_getc); CYGACC_COMM_IF_CONTROL_SET(*comm, cyg_hal_plf_diag_ice_control); CYGACC_COMM_IF_DBG_ISR_SET(*comm, cyg_hal_plf_diag_ice_isr); CYGACC_COMM_IF_GETC_TIMEOUT_SET(*comm, cyg_hal_plf_diag_ice_getc_timeout); // Restore original console CYGACC_CALL_IF_SET_CONSOLE_COMM(cur);}#endif // ifdef CYGDBG_HAL_V85X_V850_ICE_DIAG/* ----------------------------------------------------------------------- *//* Support for debugging via ICE */#define ICE_STACK_SIZE 1024/sizeof(int)static int ice_stack[ICE_STACK_SIZE]; // ints so as to ensure alignmentstatic int ice_iobuf[128];static voidhal_v85x_ice_syscall_end(void){ for (;;);}static voidhal_v85x_ice_syscall(void){ int code, len; code = ice_iobuf[0]; len = ice_iobuf[1]; switch (code) { case V850ICE_SYSCALL_GET_THREADNEXT: { int ret; threadref currthread, nextthread; int thread_id; /* Unmarshall thread ref */ my_memcpy( &currthread, &ice_iobuf[2], 8 );#if ICEDEBUG diag_printf("*NEXTTHREAD* currthread=%08x,%08x\n", *(int *)&currthread[0], *(int *)(((char *)&currthread[0])+4));#endif // null threadref? if ((ice_iobuf[2] == 0) && (ice_iobuf[3] == 0)) {#if ICEDEBUG diag_printf("null threadref\n");#endif ret = dbg_threadlist( 1, NULL, &nextthread ); } else {#if ICEDEBUG diag_printf("non-null threadref\n");#endif ret = dbg_threadlist( 0, &currthread, &nextthread ); }#if ICEDEBUG diag_printf("*NEXTTHREAD* nextthread=%08x,%08x\n", *(int *)&nextthread[0], *(int *)(((char *)&nextthread[0])+4));#endif if (ret) { // if valid thread found thread_id = dbg_thread_id( &nextthread ); /* Returns 0 on error */ if (thread_id != 0) { ice_iobuf[1] = thread_id; my_memcpy( &ice_iobuf[2], nextthread, 8 ); // set return data size to 12 ice_iobuf[0] = 12;#if ICEDEBUG { int i; for (i=0; i<3; i++) diag_printf("%x, ", ice_iobuf[i]); diag_printf("\n"); }#endif } else { ret = 0; } } if (!ret) { // set to null my_memset( &ice_iobuf[1], 0, 12 ); } } break; case V850ICE_SYSCALL_GET_THREADREGS: { int ret; threadref thread; /* Unmarshall thread ref */ my_memcpy( &thread, &ice_iobuf[2], 8 );#if ICEDEBUG diag_printf("*GTHREADREGS* thread=%08x,%08x\n", *(int *)&thread[0], *(int *)(((char *)&thread[0])+4));#endif ret = dbg_getthreadreg( &thread, NUMREGS, &ice_iobuf[1]); if (ret) ice_iobuf[0] = NUMREGS * 4; else ice_iobuf[0] = 0; } break; case V850ICE_SYSCALL_SET_THREADREGS: { int ret; threadref thread; /* Unmarshall thread ref */ my_memcpy( &thread, &ice_iobuf[2], 8 );#if ICEDEBUG diag_printf("*STHREADREGS* thread=%08x,%08x\n", *(int *)&thread[0], *(int *)(((char *)&thread[0])+4));#endif ret = dbg_setthreadreg( &thread, NUMREGS, &ice_iobuf[4]); if (ret) ice_iobuf[0] = 1; else ice_iobuf[0] = 0; } break; case V850ICE_SYSCALL_GET_CURRTHREAD: { int ret, thread_id; threadref thread; ret = dbg_currthread( &thread );#if ICEDEBUG diag_printf("*CURRTHREAD* thread=%08x,%08x\n", *(int *)&thread[0], *(int *)(((char *)&thread[0])+4));#endif if (ret) { thread_id = dbg_thread_id( &thread ); /* Returns 0 on error */ if (thread_id != 0) { ice_iobuf[1] = thread_id; my_memcpy( &ice_iobuf[2], thread, 8 ); } else { ret = 0; } } if (ret) ice_iobuf[0] = 12; else ice_iobuf[0] = 0; } break; case V850ICE_SYSCALL_GET_THREADINFO: { int ret; threadref thread; struct cygmon_thread_debug_info info; char *s=(char *)&ice_iobuf[1], *p; /* Unmarshall thread ref */ my_memcpy( &thread, &ice_iobuf[2], 8 );#if ICEDEBUG diag_printf("*INFO* thread=%08x,%08x\n", *(int *)&thread[0], *(int *)(((char *)&thread[0])+4));#endif ret = dbg_threadinfo( &thread, &info ); if (ret) { if (info.thread_display) { my_memcpy (s, "State: ", 7); s += 7; p = info.thread_display; while (*p) { *s++ = *p++; } } if (info.unique_thread_name && info.unique_thread_name[0]) { my_memcpy (s, ", Name: ", 8); s += 8; p = info.unique_thread_name; while (*p) { *s++ = *p++; } } if (info.more_display) { my_memcpy (s, ", ", 2); s += 2; p = info.more_display; while (*p) { *s++ = *p++; } } } *s++ = '\0'; if (ret) ice_iobuf[0] = s - (char *)&ice_iobuf[1]; else ice_iobuf[0] = 0; } break; case V850ICE_SYSCALL_CONSOLE_INPUT: {#ifdef CYGDBG_HAL_V85X_V850_ICE_DIAG int len = ice_iobuf[0]; int i; for (i=1; i <= len; i++) { if (false == cyg_hal_plf_diag_ice_receive_char(ice_iobuf[i])) break; } ice_iobuf[0] = i-1;#else ice_iobuf[0] = 0;#endif } break; default: // set return data size to 0 ice_iobuf[0] = 0; break; } hal_v85x_ice_syscall_end();}class Cyg_dummy_ice_syscall_init_class {public: Cyg_dummy_ice_syscall_init_class() { const int valid_string = 0x45434956; // "VICE" ICE_SYSCALL_INFO_STARTPC = (int)&hal_v85x_ice_syscall; ICE_SYSCALL_INFO_ENDPC = (int)&hal_v85x_ice_syscall_end; // top of stack, less 4 ints for parameter flushback area as per ABI ICE_SYSCALL_INFO_STACK = (int)&ice_stack[ICE_STACK_SIZE-4]; ICE_SYSCALL_INFO_IOBUF = (int)&ice_iobuf[0]; HAL_REORDER_BARRIER(); // Leave validation string to last ICE_SYSCALL_INFO_VALIDATOR = valid_string; }};static Cyg_dummy_ice_syscall_init_class dummy_syscall_class;#endif // ifdef CYGDBG_HAL_V850_ICE// EOF v850_ice.cxx
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -