📄 sparc_ex.c
字号:
TRAPPROC( i, cyg_uint32, 1, get_iplus ); TRAPPROC( i, cyg_uint32, 2, get_iplus ); TRAPPROC( i, cyg_uint32, 3, get_iplus ); TRAPPROC( i, cyg_uint32, 5, get_i ); TRAPPROC( i, cyg_uint32, 6, get_i ); TRAPPROC( i, cyg_uint32, 7, get_i ); TRAPPROC( s, cyg_uint16, 1, get_splus ); TRAPPROC( s, cyg_uint16, 3, get_splus ); TRAPPROC( s, cyg_uint16, 5, get_s ); TRAPPROC( s, cyg_uint16, 7, get_s ); } CYG_TEST_PASS( "Unaligned accesses OK" ); // Now test some legal and illegal accesses intermingled. for ( repeats = (cyg_test_is_simulator ? SIM_REPEATS : HW_REPEATS) ; repeats > 0 ; repeats-- ) { SAFEPROC( l, cyg_uint64, 0, get_llplus ); TRAPPROC( l, cyg_uint64, 5, get_llplus ); TRAPPROC( l, cyg_uint64, 6, get_llplus ); SAFEPROC( l, cyg_uint64, 8, get_llplus ); TRAPPROC( i, cyg_uint32, 1, get_iplus ); SAFEPROC( i, cyg_uint32, 4, get_iplus ); TRAPPROC( i, cyg_uint32, 2, get_iplus ); SAFEPROC( i, cyg_uint32, 8, get_iplus ); SAFEPROC( i, cyg_uint32, 12, get_iplus ); SAFEPROC( i, cyg_uint32, 16, get_iplus ); TRAPPROC( i, cyg_uint32, 3, get_iplus ); TRAPPROC( s, cyg_uint16, 5, get_s ); SAFEPROC( s, cyg_uint16, 6, get_s ); TRAPPROC( s, cyg_uint16, 7, get_s ); SAFEPROC( s, cyg_uint16, 8, get_s ); TRAPPROC( i, cyg_uint32, 5, get_i ); SAFEPROC( i, cyg_uint32, 4, get_i ); TRAPPROC( i, cyg_uint32, 6, get_i ); TRAPPROC( i, cyg_uint32, 7, get_i ); SAFEPROC( i, cyg_uint32, 0, get_i ); TRAPPROC( l, cyg_uint64, 4, get_ll ); SAFEPROC( l, cyg_uint64, 0, get_ll ); TRAPPROC( l, cyg_uint64, 1, get_ll ); SAFEPROC( l, cyg_uint64, 8, get_ll ); TRAPPROC( s, cyg_uint16, 1, get_splus ); SAFEPROC( s, cyg_uint16, 2, get_splus ); TRAPPROC( s, cyg_uint16, 3, get_splus ); SAFEPROC( s, cyg_uint16, 4, get_splus ); } CYG_TEST_PASS( "Mixture of accesses OK" ); }}// -------------------------------------------------------------------------externC voidskip_exception_handler(CYG_ADDRWORD vector, CYG_ADDRWORD data, CYG_ADDRWORD stackpointer);externC voidfail_exception_handler(CYG_ADDRWORD vector, CYG_ADDRWORD data, CYG_ADDRWORD stackpointer);// -------------------------------------------------------------------------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" );}// -------------------------------------------------------------------------externC voidskip_exception_handler(CYG_ADDRWORD vector, CYG_ADDRWORD data, CYG_ADDRWORD stackpointer){ HAL_SavedRegisters *save; HAL_FrameStructure *frame; HAL_FLUSH_REGISTERS_TO_STACK(); save = (HAL_SavedRegisters *) stackpointer; frame = (HAL_FrameStructure *) (save + 1); // immediately after // now, this is the invokation environment when this saved regset // was created (copied from hal_xvsr.S): // ! here,locals have been set up as follows: // ! %l0 = psr (with this CWP/window-level in it) // ! %l1 = pc // ! %l2 = npc // ! %l3 = vector number (16-25 for traps) // ! and we are in our own register window, though it is likely that // ! the next one will need to be saved before we can use it: // ! ie. this one is the invalid register window. // and the intention is that we can mess therewith: // Check we're not in a trap loop if ( trap == save->li.l[1] ) { same++; if ( 10 < same ) CYG_TEST_FAIL_EXIT( "Repeated trap" ); } else // restart the count same = 0; // and record it trap = save->li.l[1]; tcount++; // now step on so that we return to the instruction after: save->li.l[1] = save->li.l[2]; // PC := NPC save->li.l[2] += 4; // NPC += 4 // that's all.}externC voidfail_exception_handler(CYG_ADDRWORD vector, CYG_ADDRWORD data, CYG_ADDRWORD stackpointer){ HAL_FLUSH_REGISTERS_TO_STACK(); CYG_TEST_FAIL_EXIT( "Other exception handler called" );}// -------------------------------------------------------------------------externC void#ifdef CYGPKG_KERNELcyg_user_start( void )#elsecyg_start( void )#endif{ sparc_ex_main();}// -------------------------------------------------------------------------cyg_uint64 get_ll( cyg_uint64 *p ){ return *p;}cyg_uint64 get_llplus( cyg_uint64 *p ){ cyg_uint64 ll = 0l, v; ll = (cyg_uint32)p; ll++; v = *p; v^= ll; return v;}cyg_uint32 get_i( cyg_uint32 *p ){ return *p;}cyg_uint32 get_iplus( cyg_uint32 *p ){ cyg_uint32 i = 0, v; i = (cyg_uint32)p; i++; v = *p; v^= i; return v;}cyg_uint16 get_s( cyg_uint16 *p ){ return *p;}cyg_uint16 get_splus( cyg_uint16 *p ){ cyg_uint16 s = 0, v; s = (cyg_uint16)(0xffff & (cyg_uint32)p); s++; v = *p; v^= s; return v;}// -------------------------------------------------------------------------/* EOF sparc_ex.c */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -