📄 hal_if.c
字号:
default: __comm_id++; // skip mangler entry update = 1; break; } if (update) { __selected_id = __comm_id; CYGACC_CALL_IF_CONSOLE_PROCS_SET(comm_channels[__comm_id]); } CYGARC_HAL_RESTORE_GP(); return res;}//----------------------------------// Cache functionsstatic voidflush_icache(void *__p, int __nbytes){ CYGARC_HAL_SAVE_GP();#ifdef HAL_ICACHE_FLUSH HAL_ICACHE_FLUSH( __p , __nbytes );#elif defined(HAL_ICACHE_INVALIDATE) HAL_ICACHE_INVALIDATE();#endif CYGARC_HAL_RESTORE_GP();}static voidflush_dcache(void *__p, int __nbytes){ CYGARC_HAL_SAVE_GP();#ifdef HAL_DCACHE_FLUSH HAL_DCACHE_FLUSH( __p , __nbytes );#elif defined(HAL_DCACHE_INVALIDATE) HAL_DCACHE_INVALIDATE();#endif CYGARC_HAL_RESTORE_GP();}#endif#if defined(CYGSEM_HAL_VIRTUAL_VECTOR_DIAG)//-----------------------------------------------------------------------------// Console IO functions that adhere to the virtual vector table semantics in// order to ensure proper debug agent mangling when required.//// The platform HAL must specify the channel used, and provide raw IO// routines for that channel. The platform HAL also has the necessary// information to determine if the channel is already initialized by// a debug agent (either builtin or in ROM).externC void cyg_hal_plf_comms_init(void);voidhal_if_diag_init(void){#ifdef CYGPRI_HAL_IMPLEMENTS_IF_SERVICES cyg_hal_plf_comms_init();#endif#ifdef CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_DEFAULT#define _DEFAULT CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_DEFAULT#else#define _DEFAULT (CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL+1)#endif#if CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL != _DEFAULT // Set console channel. This should only be done when the console channel // differs from the debug channel to prevent removing the debug agent's // mangler procs. if (CYGACC_CALL_IF_SET_DEBUG_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT) != CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL) CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL);#endif#undef _DEFAULT}void hal_if_diag_write_char(char c){ hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_CONSOLE_PROCS(); if (__chan) CYGACC_COMM_IF_PUTC(*__chan, c); else { __chan = CYGACC_CALL_IF_DEBUG_PROCS(); CYGACC_COMM_IF_PUTC(*__chan, c); } // Check interrupt flag if (CYGACC_CALL_IF_CONSOLE_INTERRUPT_FLAG()) { CYGACC_CALL_IF_CONSOLE_INTERRUPT_FLAG_SET(0); cyg_hal_user_break(0); }}void hal_if_diag_read_char(char *c){ hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_CONSOLE_PROCS(); if (__chan) *c = CYGACC_COMM_IF_GETC(*__chan); else { __chan = CYGACC_CALL_IF_DEBUG_PROCS(); *c = CYGACC_COMM_IF_GETC(*__chan); }}#endif // CYGSEM_HAL_VIRTUAL_VECTOR_DIAG//=============================================================================// CtrlC support//=============================================================================#if defined(CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT) \ || defined(CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT)struct Hal_SavedRegisters *hal_saved_interrupt_state;voidhal_ctrlc_isr_init(void){ // A ROM monitor never enables the interrupt itself. This is left // to the (RAM) application.#ifndef CYGSEM_HAL_ROM_MONITOR hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_DEBUG_PROCS();#if 1 // Prevents crash on older stubs if (CYGNUM_CALL_IF_TABLE_VERSION != CYGACC_CALL_IF_VERSION()) return; // Now trash that value - otherwise downloading an image with // builtin stubs on a board with older stubs may cause all // subsequent runs to (wrongly) fall through to the below code. // If there is a new stub on the board, it will reinitialize the // version field on reset. // Yes, this is a gross hack! CYGACC_CALL_IF_VERSION_SET(CYGNUM_CALL_IF_TABLE_VERSION+1);#endif CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_IRQ_ENABLE);#endif}cyg_uint32hal_ctrlc_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data){ hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_DEBUG_PROCS(); int isr_ret, ctrlc = 0; isr_ret = CYGACC_COMM_IF_DBG_ISR(*__chan, &ctrlc, vector, data); if (ctrlc) cyg_hal_user_break( (CYG_ADDRWORD *)hal_saved_interrupt_state ); return isr_ret;}cyg_boolhal_ctrlc_check(CYG_ADDRWORD vector, CYG_ADDRWORD data){ hal_virtual_comm_table_t* chan = CYGACC_CALL_IF_DEBUG_PROCS(); int gdb_vector = -1; int isr_ret, ctrlc = 0; // This check only to avoid crash on older stubs in case of unhandled // interrupts. It is a bit messy, but required in a transition period. if (CYGNUM_CALL_IF_TABLE_VERSION+1 == CYGACC_CALL_IF_VERSION()) { gdb_vector = CYGACC_COMM_IF_CONTROL(*chan, __COMMCTL_DBG_ISR_VECTOR); } if( vector == gdb_vector ) { isr_ret = CYGACC_COMM_IF_DBG_ISR(*chan, &ctrlc, vector, data); if (ctrlc) cyg_hal_user_break( (CYG_ADDRWORD *)hal_saved_interrupt_state ); return true; } return false;}#endif // CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT || CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT//--------------------------------------------------------------------------// Init function. It should be called from the platform initialization code.// For monitor configurations it will initialize the calling interface table,// for client configurations it will patch the existing table as per// configuration.voidhal_if_init(void){ // Set up services provided by monitors#ifdef CYGPRI_HAL_IMPLEMENTS_IF_SERVICES { int i, j; // Initialize tables with the NOP service. // This should only be done for service routine entries - data // pointers should be NULLed. for (i = 0; i < CYGNUM_CALL_IF_TABLE_SIZE; i++) hal_virtual_vector_table[i] = (CYG_ADDRWORD) &nop_service; for (j = 0; j < CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS+1; j++) for (i = 0; i < CYGNUM_COMM_IF_TABLE_SIZE; i++) comm_channels[j][i] = (CYG_ADDRWORD) &nop_service; // Fill in supported services. // Version number CYGACC_CALL_IF_VERSION_SET(CYGNUM_CALL_IF_TABLE_VERSION); // ICTRL and EXC tables - I assume these to be the equivalents of // ISR and VSR tables. CYGACC_CALL_IF_ICTRL_TABLE_SET(hal_interrupt_handlers); CYGACC_CALL_IF_EXC_TABLE_SET(hal_vsr_table); // Miscellaneous services with wrappers in this file. CYGACC_CALL_IF_RESET_SET(reset); CYGACC_CALL_IF_KILL_VECTOR_SET(kill_by_reset); CYGACC_CALL_IF_DELAY_US_SET(delay_us); // Comm controls CYGACC_CALL_IF_SET_DEBUG_COMM_SET(set_debug_comm); CYGACC_CALL_IF_SET_CONSOLE_COMM_SET(set_console_comm); // Cache functions CYGACC_CALL_IF_FLUSH_ICACHE_SET(flush_icache); CYGACC_CALL_IF_FLUSH_DCACHE_SET(flush_dcache); // Clear debug and console procs entries. If platform has been // configured to use a separate console port, it will be set // up later (hal_diag_init). Alternatively (if this is a stub) // it will be initialized with the output mangler // (O-packetizer for GDB) which uses the debug comms. set_debug_comm(CYGNUM_CALL_IF_SET_COMM_ID_EMPTY); set_console_comm(CYGNUM_CALL_IF_SET_COMM_ID_EMPTY); // Data entries not currently supported in eCos CYGACC_CALL_IF_CPU_DATA_SET(0); CYGACC_CALL_IF_BOARD_DATA_SET(0); CYGACC_CALL_IF_DBG_DATA_SET(0); }#endif // Reset console interrupt flag. CYGACC_CALL_IF_CONSOLE_INTERRUPT_FLAG_SET(0); // Set up services provided by clients#if defined(CYGFUN_HAL_COMMON_KERNEL_SUPPORT) && \ ( defined(CYGSEM_HAL_USE_ROM_MONITOR_GDB_stubs) \ || defined(CYGSEM_HAL_USE_ROM_MONITOR_CygMon)) patch_dbg_syscalls( (void *)(hal_virtual_vector_table) );#endif // Init client services#if !defined(CYGPKG_KERNEL) && defined(CYGDBG_HAL_DEBUG_GDB_THREAD_SUPPORT) // Only include this code if we do not have a kernel. Otherwise // the kernel supplies the functionality for the app we are linked // with. // Prepare for application installation of thread info function in // vector table. init_thread_syscall( (void *)&hal_virtual_vector_table[CYGNUM_CALL_IF_DBG_SYSCALL] );#endif // Finally, install async breakpoint handler if it is configured in. // FIXME: this should probably check for STUBS instead (but code is // conditional on BREAK for now)#if defined(CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT) // Install async breakpoint handler into vector table. CYGACC_CALL_IF_INSTALL_BPT_FN_SET(&cyg_hal_gdb_interrupt);#endif}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -