void sparc_ex_main( void ) { int i; CYG_TEST_INIT(); for ( i = CYGNUM_HAL_EXCEPTION_MIN; i <= CYGNUM_HAL_EXCEPTION_MAX; i++ ){ int j; HAL_TRANSLATE_VECTOR( i, j ); HAL_INTERRUPT_ATTACH( j, &fail_exception_handler, j, 0 ); // we must also ensure that eCos handles the exception; // do not drop into CygMon or equivalent. // Leave USER_TRAP undisturbed so that breakpoints work. if ( CYGNUM_HAL_VECTOR_USER_TRAP != i ) { extern void hal_default_exception_vsr( void ); HAL_VSR_SET( i, (CYG_ADDRESS)hal_default_exception_vsr, NULL ); } } HAL_TRANSLATE_VECTOR( CYGNUM_HAL_VECTOR_UNALIGNED, i ); HAL_INTERRUPT_DETACH( i, &fail_exception_handler ); HAL_INTERRUPT_ATTACH( i, &skip_exception_handler, i, 0 ); CYG_TEST_INFO( "Vectors attached OK; calling do_test" ); do_test(); CYG_TEST_EXIT( "Done" ); }
void hal_plf_stub_init(void) { // extern CYG_ADDRESS hal_virtual_vector_table[64]; extern void init_thread_syscall( void *); extern void install_async_breakpoint(void *epc); void (*oldvsr)(void); extern void __default_exception_vsr(void); // Ensure that the breakpoint VSR points to the default VSR. This will pass // it on to the stubs. HAL_VSR_SET( CYGNUM_HAL_VECTOR_BREAKPOINT, __default_exception_vsr, &oldvsr ); // Install async breakpoint handler into vector table. hal_virtual_vector_table[35] = (CYG_ADDRESS)install_async_breakpoint; #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. hal_virtual_vector_table[15] = 0; init_thread_syscall( (void *)&hal_virtual_vector_table[15] ); #endif }
static void audio_exercise(cyg_addrword_t p) { int sample, len; bool started; diag_printf("AUDIO test here!\n"); // Enable my special FIQ handler HAL_VSR_SET(CYGNUM_HAL_VECTOR_FIQ, i2s_FIQ, NULL); while (TRUE) { diag_printf("... Starting over\n"); // Set up pointers cur_buf.length = 0; next_buf.length = 0; sample = 0; started = false; // Send out the data while (sample != NUM_PCM_SAMPLES) { if (next_buf.length == 0) { // Move some data into the "next" buffer next_buf.left_chan_ptr = &left_channel[sample]; next_buf.right_chan_ptr = &right_channel[sample]; len = NUM_PCM_SAMPLES - sample; if (len > CHUNK_LENGTH) len = CHUNK_LENGTH; next_buf.length = len; idle(); if (!started) { started = true; // Initialize audio interface I2Sreset(); } sample += len; } } // Wait for all data to be sent while (cur_buf.length != 0) { } // Shut off audio interface I2Sdisable(); } diag_printf("All done!\n"); cyg_test_exit(); }
int hal_enable_profile_timer(int resolution) { cyg_uint16 ticks; // Make sure the clock is not running but is otherwise initialized. HAL_WRITE_UINT16(HAL_MCFxxxx_PROFILE_TIMER_BASE + HAL_MCFxxxx_PITx_PCSR, HAL_MCFxxxx_PITx_PCSR_PRE_64 | HAL_MCFxxxx_PITx_PCSR_OVW | HAL_MCFxxxx_PITx_PCSR_PIE | HAL_MCFxxxx_PITx_PCSR_PIF | HAL_MCFxxxx_PITx_PCSR_RLD); // The resolution is a time interval in microseconds. The actual // cpu clock frequency is determined by the platform. This is divided // by 64, which means it may not be possible to get the exact resolution. ticks = ((resolution * CYGHWR_HAL_SYSTEM_CLOCK_MHZ) / 64) - 1; HAL_WRITE_UINT16(HAL_MCFxxxx_PROFILE_TIMER_BASE + HAL_MCFxxxx_PITx_PMR, ticks); // Convert back to microseconds. This may actually increase rounding // errors for some arguments and platforms, but the result should // still be accurate enough for practical purposes. resolution = ((ticks + 1) * 64) / CYGHWR_HAL_SYSTEM_CLOCK_MHZ; // Set up the interrupt handler. This is usually a high-priority // interrupt so that we can get profiling information for other // interrupt sources. #ifdef HAL_VSR_SET HAL_VSR_SET(HAL_MCFxxxx_PROFILE_TIMER_VECTOR, &hal_mcfxxxx_profile_vsr, (cyg_uint32)0); #endif HAL_INTERRUPT_SET_LEVEL(HAL_MCFxxxx_PROFILE_TIMER_ISR, CYGNUM_HAL_M68K_MCFxxxx_SOFTWARE_PROFILE_TIMER_ISR_PRIORITY); HAL_INTERRUPT_UNMASK(HAL_MCFxxxx_PROFILE_TIMER_ISR); // Now start the timer running. HAL_WRITE_UINT16(HAL_MCFxxxx_PROFILE_TIMER_BASE + HAL_MCFxxxx_PITx_PCSR, HAL_MCFxxxx_PITx_PCSR_PRE_64 | HAL_MCFxxxx_PITx_PCSR_OVW | HAL_MCFxxxx_PITx_PCSR_PIE | HAL_MCFxxxx_PITx_PCSR_PIF | HAL_MCFxxxx_PITx_PCSR_RLD | HAL_MCFxxxx_PITx_PCSR_EN); // Return the actual resolution. return resolution; }