/** \internal * \brief Associate a thread id with and interrupt id - FSMLang Special PIC. */ Hint _syscall_intr_assoc( Huint iid ) { Huint res; volatile Huint *cmd; // Print out a trace message about this system call TRACE_PRINTF( TRACE_FINE, TRACE_SYSCALL, "SYSCALL: (OP=INTR) (IID=0x%8.8x)\n", (Huint)iid ); // Get currently running thread ID Huint cur; cur = _current_thread(); // Associate thread with interrupt // 1) Form command address cmd = (Huint *)cbis_encode_cmd(CBIS_WRITE, cur, iid); // 2) Invoke command (read from address) and grab result res = *cmd; //printf("PIC CMD = 0x%08x --> 0x%08x\n",(unsigned int)cmd, res); // 3) Check for success, if successful put to sleep, else return with error if (res == 0) { _run_sched( Htrue ); } // Print out a trace message about this system call TRACE_PRINTF( TRACE_FINE, TRACE_SYSCALL, "SYSCALL DONE: (OP=INTR) (IID=0x%8.8x)\n", (Huint)iid ); return res; }
int main( int argc, char *argv[] ) { unsigned int base; unsigned int cmd; unsigned int id; unsigned int mx; if( argc < 3 ) { printf( "Usage: %s <thread id> <mutex id> [base addr]\n", argv[0] ); return 1; } base = BASE; id = atoi( argv[1] ); mx = atoi( argv[2] ); if( argc >= 4 ) { base = strtol( argv[3], NULL, 16 ); } printf( "\n\n" ); printf( "HWTI Base Address: 0x%04x\n", base ); printf( "Thread ID: %u\n", id ); printf( "Mutex ID: %u\n", mx ); printf( "-----------------------------------------------\n" ); cmd = encode_cmd(id, HT_CMD_CLEAR_THREAD ); printf( "Clear Thread: mrd 0x%04x\n", cmd ); cmd = encode_cmd(id, HT_CMD_JOIN_THREAD ); printf( "Join Thread: mrd 0x%04x\n", cmd ); cmd = encode_cmd(id, HT_CMD_DETACH_THREAD ); printf( "Detach Thread: mrd 0x%04x\n", cmd ); cmd = encode_cmd(id, HT_CMD_READ_THREAD ); printf( "Read Thread: mrd 0x%04x\n", cmd ); cmd = encode_cmd(id, HT_CMD_ADD_THREAD ); printf( "Add Thread: mrd 0x%04x\n", cmd ); cmd = encode_cmd(id, HT_CMD_EXIT_THREAD ); printf( "Exit Thread: mrd 0x%04x\n", cmd ); cmd = encode_cmd(0, HT_CMD_CREATE_THREAD_J ); printf( "Create Joinable Thread: mrd 0x%04x\n", cmd ); cmd = encode_cmd(0, HT_CMD_CREATE_THREAD_D ); printf( "Create Detached Thread: mrd 0x%04x\n", cmd ); cmd = encode_cmd(0, HT_CMD_NEXT_THREAD ); printf( "Next Thread: mrd 0x%04x\n", cmd ); cmd = encode_cmd(0, HT_CMD_CURRENT_THREAD ); printf( "Current Thread: mrd 0x%04x\n", cmd ); cmd = encode_cmd(0, HT_CMD_EXCEPTION_REG); printf( "Exception Cause: mrd 0x%04x\n", cmd ); cmd = sched_cmd(0, id, HT_CMD_SCHED_SET_IDLE_THREAD ); printf( "Idle Thread: mrd 0x%04x\n", cmd ); cmd = sched_cmd(0, id, HT_CMD_SCHED_HIGHPRI ); printf( "High/DBG Thread: mrd 0x%04x\n", cmd ); cmd = encode_cmd(0, HT_CMD_QUE_LENGTH ); printf( "Queue Length: mrd 0x%04x\n", cmd ); cmd = encode_cmd(0, HT_CMD_SOFT_STOP ); printf( "Soft Stop: mrd 0x%04x\n", cmd ); cmd = encode_cmd(0, HT_CMD_SOFT_START ); printf( "Soft Start: mrd 0x%04x\n", cmd ); cmd = encode_cmd(0, HT_CMD_SOFT_RESET ); printf( "Soft Reset: mrd 0x%04x\n", cmd ); cmd = mutex_cmd( HT_MUTEX_LOCK, id, mx ); //cmd = blk_sema_cmd( HT_CMD_REQUEST, id, mx ); printf( "Mutex Lock: mrd 0x%04x\n", cmd ); cmd = mutex_cmd( HT_MUTEX_UNLOCK, id, mx ); //cmd = blk_sema_cmd( HT_CMD_RELEASE, id, mx ); printf( "Mutex Unlock: mrd 0x%04x\n", cmd ); cmd = mutex_cmd( HT_MUTEX_TRY, id, mx ); //cmd = blk_sema_cmd( HT_CMD_TRYLOCK, id, mx ); printf( "Mutex Try Lock: mrd 0x%04x\n", cmd ); cmd = mutex_cmd( HT_MUTEX_OWNER, 0, mx ); printf( "Mutex Owner: mrd 0x%04x\n", cmd ); cmd = mutex_cmd( HT_MUTEX_KIND, 0, mx ); printf( "Mutex Kind: mrd 0x%04x\n", cmd ); cmd = mutex_cmd( HT_MUTEX_COUNT, 0, mx ); printf( "Mutex Count: mrd 0x%04x\n", cmd ); cmd = cvr_sema_cmd(HT_CMD_SIGNAL, id, mx); printf( "Cond Signal: mrd 0x%04x\n", cmd ); cmd = cvr_sema_cmd(HT_CMD_CWAIT, id, mx); printf( "Cond Wait: mrd 0x%04x\n", cmd ); cmd = cvr_sema_cmd(HT_CMD_BROADCAST, id, mx); printf( "Cond Broad: mrd 0x%04x\n", cmd ); cmd = sched_cmd(0, id, HT_CMD_SCHED_ENTRY); printf( "Sched Entry: mrd 0x%04x\n", cmd ); cmd = sched_cmd( 0, id, HT_CMD_SCHED_SETSCHEDPARAM ); printf( "Set Sched Param: mrd 0x%04x\n", cmd ); cmd = sched_cmd( 0, id, HT_CMD_SCHED_GETSCHEDPARAM ); printf( "Get Sched Param: mrd 0x%04x\n", cmd ); cmd = sched_cmd( 0, id, HT_CMD_SCHED_SYSCALL_LOCK ); cmd |= 0x00040000; printf( "Syscall lock: mrd 0x%04x\n", cmd ); cmd = sched_cmd( 0, id, HT_CMD_SCHED_SYSCALL_LOCK ); printf( "Syscall unlock: mrd 0x%04x\n", cmd ); cmd = sched_cmd( 0, id, HT_CMD_SCHED_MALLOC_LOCK ); cmd |= 0x00040000; printf( "Malloc lock: mrd 0x%04x\n", cmd ); cmd = sched_cmd( 0, id, HT_CMD_SCHED_MALLOC_LOCK ); printf( "Malloc unlock: mrd 0x%04x\n", cmd ); cmd = hwti_cmd( base, HT_CMD_HWTI_COMMAND ); printf( "HWTI Reset: mrd 0x%04x\n", cmd ); cmd = hwti_cmd( base, HT_CMD_HWTI_SETID ); printf( "HWTI Set ID: mrd 0x%04x\n", cmd ); cmd = hwti_cmd( base, HT_CMD_HWTI_SETARG ); printf( "HWTI Set Arg: mrd 0x%04x\n", cmd ); cmd = hwti_cmd( base, HT_CMD_HWTI_RESULTS ); printf( "HWTI Results: mrd 0x%04x\n", cmd ); cmd = cbis_encode_cmd( CBIS_WRITE, id, mx ); printf( "CBIS Associate (TID = %d, IID = %d) mrd 0x%04x\n", id, mx, cmd ); printf( "\n\n" ); return 0; }