/** * Initialize the on-chip timer controller. We snag TMU channel 2 in its * highest resolution mode, and start it counting down from max_int. */ void timer_init() { unsigned int val = byte_read(TSTR); byte_write( TSTR, val & (~(1<<TMU_CHANNEL)) ); /* Stop counter */ long_write( TCOR(TMU_CHANNEL), 0xFFFFFFFF ); long_write( TCNT(TMU_CHANNEL), 0xFFFFFFFF ); word_write( TCR(TMU_CHANNEL), 0x00000000 ); }
int main( int argc, char *argv[] ) { int i; int failures = 0; int tests = 0; ide_init(); for( i=0; test_cases[i].reg != 0; i++ ) { unsigned int oldval = long_read( test_cases[i].reg ); unsigned int newval; long_write( test_cases[i].reg, test_cases[i].write ); newval = long_read( test_cases[i].reg ); if( test_cases[i].expect == UNCHANGED ) { if( newval != oldval ) { fprintf( stderr, "Test %d (%08X) failed. Expected %08X but was %08X\n", i+1, test_cases[i].reg, oldval, newval ); failures++; } } else { if( newval != test_cases[i].expect ) { fprintf( stderr, "Test %d (%08X) failed. Expected %08X but was %08X\n", i+1, test_cases[i].reg, test_cases[i].expect, newval ); failures++; } } long_write( test_cases[i].reg, oldval ); tests++; } fprintf( stdout, "%d/%d test cases passed successfully\n", (tests-failures), tests ); return failures; }
void pvr2_render_loaded_scene() { asic_clear(); long_write( (PVR2_BASE+0x14), 0xFFFFFFFF ); asic_wait( EVENT_PVR_RENDER_DONE ); asic_clear(); asic_wait( EVENT_RETRACE ); uint32_t addr = long_read( (PVR2_BASE+0x060) ); uint32_t mod = long_read( (PVR2_BASE+0x04C) ); long_write( (PVR2_BASE+0x050), addr); long_write( (PVR2_BASE+0x054), addr + (mod<<3) ); }
int main( int argc, char *argv[] ) { char buf[65536] __attribute__((aligned(32))); uint32_t aica_addr = AICA_RAM_BASE; int len; int totallen = 0; aica_disable(); /* Load ARM program from stdin and copy to ARM memory */ while( (len = read(0, buf, sizeof(buf))) > 0 ) { if(memcpy_to_aica( aica_addr, buf, len ) != 0 ) { printf( "Failed to load program!\n" ); return 1; } aica_addr += len; totallen += len; } printf( "Program loaded (%d bytes)\n", totallen); /* Main loop waiting for IO commands */ aica_enable(); do { g2_fifo_wait(); irq_disable(); int syscall = long_read(AICA_SYSCALL); irq_enable(); if( syscall != -1 ) { if( syscall == -2 ) { fprintf( stderr, "ARM aborted with general exception\n" ); return -2; } else if( syscall == SYS_EXIT ) { printf( "Exiting at ARM request\n" ); aica_disable(); return long_read(AICA_SYSCALL_ARG1); } else { uint32_t result = do_syscall( syscall, long_read(AICA_SYSCALL_ARG1), long_read(AICA_SYSCALL_ARG2), long_read(AICA_SYSCALL_ARG3) ); g2_fifo_wait(); irq_disable(); long_write( AICA_SYSCALL_RETURN, result ); long_write( AICA_SYSCALL, -1 ); irq_enable(); } } } while( 1 ); }
int main_with_exceptions() { libusbp::device device = libusbp::find_device_with_vid_pid( vendor_id, product_id); if (!device) { std::cerr << "Device not found." << std::endl; return 1; } libusbp::generic_interface gi(device, interface_number, composite); libusbp::generic_handle handle(gi); long_write(handle); return 0; }
/** * Stop TMU2 and report the current value. */ unsigned int timer_stop() { long_write( TSTR, long_read(TSTR) & (~(1<<TMU_CHANNEL)) ); return long_read( TCNT(TMU_CHANNEL) ); }