//=========================================================================== //INTERRUPT SERVICE ROUTINE FOR TimerA/B static void TMRAB_ISR( void ) { //Your Code Here... //LED4_pin ^= 1; tm_init(TM_CH_NO_AB); tm_startAB(); //Clear & Restart Timer... }
//=========================================================================== //INTERRUPT SERVICE ROUTINE FOR TimerE/F static void TMREF_ISR( void ) { //Your Code Here... //LED7_pin ^= 1; tm_init(TM_CH_NO_EF); tm_startEF(); //Clear & Restart Timer... }
//=========================================================================== //INTERRUPT SERVICE ROUTINE FOR Timer8/9 static void TMR89_ISR( void ) { //Your Code Here... //LED1_pin ^= 1; tm_init(TM_CH_NO_89); tm_start89(); //Clear & Restart Timer... }
/** * API: Allocate a node. * * - Begin timing stats, * - Clear some stack words, * - Remember current stack pointer, * - Save the registers and stack pointers, * - Call "inner" routines, * - End timing stats. */ void *tm_alloc(size_t size) { void *ptr = 0; if ( size == 0 ) return 0; if ( ! tm.inited ) { tm_init(0, (char***) ptr, 0); } #if tm_TIME_STAT tm_time_stat_begin(&tm.ts_alloc); #endif _tm_clear_some_stack_words(); _tm_set_stack_ptr(&ptr); if ( tm.trigger_full_gc ) { tm.trigger_full_gc = 0; _tm_gc_full_inner(); } ptr = _tm_alloc_inner(size); #if tm_TIME_STAT tm_time_stat_end(&tm.ts_alloc); #endif return ptr; }
static int plm_tm_connect(void) { int ret; struct tm_roots tm_root; int count; struct timespec tp = {0, 100}; /* try a couple times to connect - might get busy signals every now and then */ for (count = 0 ; count < 10; ++count) { ret = tm_init(NULL, &tm_root); if (TM_SUCCESS == ret) { return ORTE_SUCCESS; } /* provide a very short quiet period so we * don't hammer the cpu while we wait */ nanosleep(&tp, NULL); #ifdef HAVE_SCHED_H sched_yield(); #endif } return ORTE_ERR_RESOURCE_BUSY; }
void turn_free_simple(void *ptr) { tm_init(); del_tm_ptr(ptr,__FUNCTION__); free(ptr); }
ut_setup() { int i; os_random_init(); unlink(test_tokens_file); data.file = test_tokens_file; /* We generate two random ports as when two instances of this UT are run at * the same time, one can block the other as they try to open the same port. * * The operation done below with the modulo and the addition is to ensure * the value is bound between 1025 and 65535, which is the default * non-privileged user accessible ports range. */ data.port = (os_process_id() % 64511) + 1025; data.priv_port = (data.port + 1) % 64511 + 1025; UT_ASSERT(data.port > 1024); UT_ASSERT(data.priv_port > 1024); UT_ASSERT(data.port != data.priv_port); #ifdef WIN32 data.logfile = "nul"; #else data.logfile = "/dev/null"; #endif os_thread_create(&server_thread, 0, token_manager_thread, &data); os_sleep(1); for (i = 0; i < NUM_TEST_CLUSTERS; i++) __setup_cluster(&clusters[i]); for (i = 0; i < NUM_TEST_CLUSTERS; i++) { UT_ASSERT_EQUAL(0, tm_init(&clusters[i].tms[0], "127.0.0.1", data.port)); UT_ASSERT_EQUAL(0, tm_connect(clusters[i].tms[0])); UT_ASSERT_EQUAL(0, tm_init(&clusters[i].tms[1], "127.0.0.1", data.port)); UT_ASSERT_EQUAL(0, tm_connect(clusters[i].tms[1])); } UT_ASSERT(tm_init(&user_tm, "127.0.0.1", data.priv_port) == 0); UT_ASSERT_EQUAL(0, tm_connect(user_tm)); }
void mom_reconnect(void) { int c, rc; struct tm_roots rootrot; for (;;) { tm_finalize(); sigprocmask(SIG_UNBLOCK, &allsigs, NULL); sleep(2); sigprocmask(SIG_BLOCK, &allsigs, NULL); /* attempt to reconnect */ rc = tm_init(0, &rootrot); if (rc == TM_SUCCESS) { fprintf(stderr, "%s: reconnected\n", id); /* resend obit requests */ for (c = 0; c < numnodes; ++c) { if (*(events_obit + c) != TM_NULL_EVENT) { rc = obit_submit(c); if (rc != TM_SUCCESS) { break; /* reconnect again */ } } else if (verbose) { fprintf(stderr, "%s: skipping obit resend for %u\n", id, *(tid + c)); } } break; } } return; } /* END mom_reconnect() */
void ledNightInit( void ) { P22C0 = 1; P22C1 = 1; // cmos P22MD = 0; P22MD1 = 0; // port tm_init( TM_CH_NO_89 ); // count stop, 16bit mode tm_set89Source( TM_CS_HTBCLK ); tm_set8Oneshot( TM_OST_ENA ); stepNight = STEP_NIGHT_DEFAULT; ledNightOff(); }
void clk_wait500us( void ) { int ret; ETM2 = 0; (void)tm_init( (unsigned char)CLKSYS_TM_CHNO, /* Timer channel */ (unsigned char)TM_M16_8BIT, /* 8bit or 16bit mode */ (unsigned char)TM_CS_LSCLK, /* Operation clock */ (unsigned short)CLKSYS_TIMER_CNT ); /* Timer count value */ CLKSYS_TM_IRQ = 0; (void)tm_start( (unsigned char)CLKSYS_TM_CHNO ); do { ret = tm_checkOvf( (unsigned char)CLKSYS_TM_CHNO ); } while( ret == TM_R_NOT_OVF ); (void)tm_stop( (unsigned char)CLKSYS_TM_CHNO ); CLKSYS_TM_IRQ = 0; }
/** * API: Explicitly free a node. * * - Begin timing stats, * - Clear some stack words, * - Remember current stack pointer, * - Save the registers and stack pointers, * - Call "inner" routines, * - End timing stats. */ void tm_free(void *ptr) { if ( ! tm.inited ) { tm_init(0, (char***) ptr, 0); } #if tm_TIME_STAT tm_time_stat_begin(&tm.ts_free); #endif _tm_clear_some_stack_words(); _tm_set_stack_ptr(&ptr); _tm_free_inner(ptr); #if tm_TIME_STAT tm_time_stat_end(&tm.ts_free); #endif }
/*-------------------------------------------------------------------------*\ * Creates a master udp object \*-------------------------------------------------------------------------*/ static int global_create(lua_State *L) { t_sock sock; const char *err = inet_trycreate(&sock, SOCK_DGRAM); /* try to allocate a system socket */ if (!err) { /* allocate tcp object */ p_udp udp = (p_udp) lua_newuserdata(L, sizeof(t_udp)); aux_setclass(L, "udp{unconnected}", -1); /* initialize remaining structure fields */ sock_setnonblocking(&sock); udp->sock = sock; tm_init(&udp->tm, -1, -1); return 1; } else { lua_pushnil(L); lua_pushstring(L, err); return 2; } }
int main() { int i = 10; unsigned long id = 0; #if LOG_MOD==LOG_MUL_THREAD thread_mgmt_t tm; logx_init("D:/abc.txt", LOG_MUL_THREAD); tm_init(&tm); tm_create_thread(tm,"t1",f_thread1); tm_create_thread(tm,"t2",f_thread2); tm_create_thread(tm,"t3",f_thread3); #else logx_init("D:/abc.txt", LOG_SIG_THREAD); #endif __assert(0); debugx(xinfo, "this is %s!\n", "xinfo"); debugx(xdata, "this is %s!\n", "xdata"); debugx(xentry, "this is %s!\n", "xentry"); debugx(xevent, "this is %s!\n", "xevent"); debugx(xmsg, "this is %s!\n", "xmsg"); debugx(xwarn, "this is %s!\n", "xwarn"); debugx(xerror, "this is %s!\n", "xerror"); debugx(xfatal, "this is %s!\n", "xfatal"); debugx(xerror, "this is %s!\n", "xerror"); id = gettidx(); while (i--) { debugx(xfatal, "thread id(%d): this is %s!\n", id, "xfatal"); sleep(val_time); } #if LOG_MOD==LOG_MUL_THREAD tm_exit(&tm); #endif logx_exit(); return 0; }
void setup(void) { int rc; rc = cr_init("../../../config/xml/core_config.xml"); fail_if(rc == 0, "config reader could not be initialized"); rc = logger_init(); fail_if(rc == 0, "logger could not be initialized"); //init thread management rc = tm_init(); if (rc == 0) { // ERROR LOG_ERROR(TEST_SIPSTACK_PREFIX "Thread management could not be initialized.\n"); }else { LOG_DEBUG(TEST_SIPSTACK_PREFIX "Thread management initialized.\n"); } //init event queue event_queue = queue_create_queue(30); LOG_DEBUG(TEST_SIPSTACK_PREFIX "Event queue created."); }
int main() { int x; tm_init(); ed_init(); void **params1; params1 = (void **) malloc(sizeof(int)); params1[0] = (void *) 27; void **params2; params2 = (void **) malloc(sizeof(int)); params2[0] = (void *) 99; event_dispatch(GUI_MAKE_CALL, params1, NULL); event_dispatch(GUI_MAKE_CALL, params2, NULL); scanf("%d", &x); ed_destroy(); tm_destroy(0); free(params1); free(params2); pthread_exit(NULL); }
/** * API: Force a full GC. * * - Begin timing stats, * - Clear some stack words, * - Remember current stack pointer, * - Save the registers and stack pointers, * - Call "inner" routines, * - End timing stats. */ void tm_gc_full() { void *ptr = 0; if ( ! tm.inited ) { tm_init(0, (char***) ptr, 0); } #if tm_TIME_STAT tm_time_stat_begin(&tm.ts_gc); #endif _tm_clear_some_stack_words(); _tm_set_stack_ptr(&ptr); _tm_gc_full_inner(); #if tm_TIME_STAT tm_time_stat_end(&tm.ts_gc); #endif }
static int plm_tm_connect(void) { int ret; struct tm_roots tm_root; int count; /* try a couple times to connect - might get busy signals every now and then */ for (count = 0 ; count < 10; ++count) { ret = tm_init(NULL, &tm_root); if (TM_SUCCESS == ret) { return ORTE_SUCCESS; } #if ORTE_ENABLE_PROGRESS_THREADS { /* provide a very short quiet period so we * don't hammer the cpu while we wait */ struct timespec tp = {0, 100}; nanosleep(&tp, NULL); #if HAVE_SCHED_YIELD sched_yield(); #endif } #else { int progress; for (progress = 0 ; progress < 10 ; ++progress) { opal_progress(); #if HAVE_SCHED_YIELD sched_yield(); #endif } } #endif } return ORTE_ERR_RESOURCE_BUSY; }
/******************************************************************************* Routine Name: _initPeri Form: static void _initPeri( void ) Parameters: void Return value: void Description: initialize peripheral. *******************************************************************************/ static void _initPeri( void ) { /*--- BLKCON ---*/ BLKCON2 = 0xC9; // UART0 BLKCON4 = 0x01; BLKCON6 = 0xC0; // BLKCON7 = 0x00; // PWMC/D/E/F /*--- Interrupt ---*/ irq_di(); irq_init(); (void)irq_setHdr( (unsigned char)IRQ_NO_PA0INT, _intPA0 ); (void)irq_setHdr( (unsigned char)IRQ_NO_TMBINT, _intTMB ); QPA0 = 0; QTMB = 0; EPA0 = 1; ETMB = 1; irq_ei(); /*---- WDT ---*/ WDTMOD = WDT_23MS; // main_clrWDT(); /*--- Clock ---*/ clk_setSysclk(); /*--- TBC ---*/ (void)tb_setHtbdiv( (unsigned char)TB_HTD_1_1 ); /*--- Timer ---*/ tm_init( TM_CH_NO_AB ); /* Timer channel */ tm_setABSource(TM_CS_LSCLK); /* Operation clock */ tm_setABData( (unsigned short)(MAIN_TIMER_CNT) ); /* Timer count value */ tm_startAB(); _swInit(); /*--- LED ---*/ led_Init(); }
int main (int argc, char *argv []) { void *ctx; int rc; int i; if (argc != 10) { printf ("usage: remote_thr <connect-to> <message-size> <message-count> <SND buffer> <RCV buffer> <flow (PUSH/PULL)> <records (ZMSG/DATA)> <zmq-threads> <workers>\n"); return 1; } connect_to = argv [1]; message_size = atoi (argv [2]); message_count = atoi (argv [3]); sndbuflen = atoi (argv [4]); rcvbuflen = atoi (argv [5]); if( !strcmp( argv [6], "PUSH")){ flow = ZMQ_PUSH; } if( !strcmp( argv [6], "PULL")){ flow = ZMQ_PULL; } if( !strcmp( argv [7], "ZMSG")){ rec = ZMSG; } if( !strcmp( argv [7], "DATA")){ rec = DATA; } threads = atoi (argv [8]); workers = atoi (argv [9]); ctx = zmq_ctx_new (); if (!ctx) { printf ("error in zmq_ctx_new: %s\n", zmq_strerror (errno)); return -1; } rc = zmq_ctx_set ( ctx, ZMQ_IO_THREADS, threads); if (rc) { printf ("error in zmq_ctx_set: %s\n", zmq_strerror (errno)); return -1; } printf("Threads: %d, workers %d\n", zmq_ctx_get( ctx, ZMQ_IO_THREADS), workers); #if defined ZMQ_HAVE_WINDOWS HANDLE worker[128]; #else pthread_t worker[128]; #endif US_TIMER timer; tm_init( &timer); for (i = 0; i < workers; i++) { #if defined ZMQ_HAVE_WINDOWS worker[i] = (HANDLE) _beginthreadex (NULL, 0, worker_routine, ctx, 0 , NULL); #else pthread_create (&worker[i], NULL, worker_routine, ctx); #endif printf("Worker %d spawned\n", i); } for (i = 0; i < workers; i++) { #if defined ZMQ_HAVE_WINDOWS WaitForSingleObject (worker[i], INFINITE); CloseHandle (worker[i]); #else pthread_join( worker[i], NULL); #endif printf("Worker %d joined\n", i); } float secs = tm_secs( &timer); float total = ( (float)workers)*(((float) message_count) * ((float) message_size)) / (1024.0*1024.0*1024.0); printf ("Message: size: %d KBytes, count: %d/workers(%d), time: %f secs\n", (int) message_size/1024, message_count, workers, secs); printf ("%sed %.3f GB @ %.3f GB/s\n", (flow == ZMQ_PULL) ? "Pull":"Push", total, total/secs); rc = zmq_term (ctx); if (rc != 0) { printf ("error in zmq_term: %s\n", zmq_strerror (errno)); return -1; } return 0; }
int main() { unsigned char tmp, i; WDTCTL = WDTPW | WDTHOLD; DCOCTL = 0; BCSCTL1 = CALBC1_16MHZ; DCOCTL = CALDCO_16MHZ; // ACLK and Timer1_A BCSCTL3 = XCAP_2; //10pf caps TACCR0 = 32768u; TACTL = TASSEL_1 | ID_0 | MC_1; TACCTL0 |= CCIE; t.h = t.m = t.s = 0; state = State_Normal; tm_init(0x08); _BIS_SR(GIE); while(1) { tmp = tm_getButtons(); switch (state) { case State_Normal: tm_data(0, 0); tm_data(0, 2); showTime(); if (tmp & BIT0) { state = State_SetTime; } break; case State_SetTime: tm_data(0b01101101, 0); //S tm_data(0b11111000, 2); //t. showTime(); if (tmp & BIT7) t.s = 0; if (tmp & BIT6) t.m = (t.m+1)%60; if (tmp & BIT5) t.h = (t.h+1)%24; if (tmp & BIT0) { TAR = 0; state = State_SetAlarm; } break; case State_SetAlarm: tm_data(0b01110111, 0); //A tm_data(0b10111000, 2); //L. if (tmp & BIT0) { state = State_Adjust; } break; case State_Adjust: tm_data(0b01110111, 0); //A tm_data(0b11011110, 2); //d. showTACCR0(); if (tmp & BIT7) ++TACCR0; if (tmp & BIT6) --TACCR0; if (tmp & BIT0) { state = State_Normal; } } for(i = 0; i < 8; i++) { if(tmp & (1<<i)) { tm_setLed(TM_RED, i); } else { tm_setLed(TM_GREEN, i); } } __delay_cycles(1000000); } while(1); return 0; }
int main( int argc, char *argv[]) { int c; int err = 0; int ncopies = -1; int onenode = -1; int rc; struct tm_roots rootrot; int nspawned = 0; tm_node_id *nodelist; int start; int stop; int sync = 0; int pernode = 0; char *targethost = NULL; char *allnodes; struct sigaction act; char **ioenv; extern int optind; extern char *optarg; int posixly_correct_set_by_caller = 0; char *envstr; id = malloc(60 * sizeof(char)); if (id == NULL) { fprintf(stderr, "%s: malloc failed, (%d)\n", id, errno); return(1); } sprintf(id, "pbsdsh%s", ((getenv("PBSDEBUG") != NULL) && (getenv("PBS_TASKNUM") != NULL)) ? getenv("PBS_TASKNUM") : ""); #ifdef __GNUC__ /* If it's already set, we won't unset it later */ if (getenv("POSIXLY_CORRECT") != NULL) posixly_correct_set_by_caller = 1; envstr = strdup("POSIXLY_CORRECT=1"); putenv(envstr); #endif while ((c = getopt(argc, argv, "c:n:h:osuv")) != EOF) { switch (c) { case 'c': ncopies = atoi(optarg); if (ncopies <= 0) { err = 1; } break; case 'h': targethost = strdup(optarg); /* run on this 1 hostname */ break; case 'n': onenode = atoi(optarg); if (onenode < 0) { err = 1; } break; case 'o': grabstdio = 1; break; case 's': sync = 1; /* force synchronous spawns */ break; case 'u': pernode = 1; /* run once per node (unique hostnames) */ break; case 'v': verbose = 1; /* turn on verbose output */ break; default: err = 1; break; } /* END switch (c) */ } /* END while ((c = getopt()) != EOF) */ if ((err != 0) || ((onenode >= 0) && (ncopies >= 1))) { fprintf(stderr, "Usage: %s [-c copies][-o][-s][-u][-v] program [args]...]\n", argv[0]); fprintf(stderr, " %s [-n nodenumber][-o][-s][-u][-v] program [args]...\n", argv[0]); fprintf(stderr, " %s [-h hostname][-o][-v] program [args]...\n", argv[0]); fprintf(stderr, "Where -c copies = run copy of \"args\" on the first \"copies\" nodes,\n"); fprintf(stderr, " -n nodenumber = run a copy of \"args\" on the \"nodenumber\"-th node,\n"); fprintf(stderr, " -o = capture stdout of processes,\n"); fprintf(stderr, " -s = forces synchronous execution,\n"); fprintf(stderr, " -u = run on unique hostnames,\n"); fprintf(stderr, " -h = run on this specific hostname,\n"); fprintf(stderr, " -v = forces verbose output.\n"); exit(1); } #ifdef __GNUC__ if (!posixly_correct_set_by_caller) { putenv("POSIXLY_CORRECT"); free(envstr); } #endif if (getenv("PBS_ENVIRONMENT") == NULL) { fprintf(stderr, "%s: not executing under PBS\n", id); return(1); } /* * Set up interface to the Task Manager */ if ((rc = tm_init(0, &rootrot)) != TM_SUCCESS) { fprintf(stderr, "%s: tm_init failed, rc = %s (%d)\n", id, get_ecname(rc), rc); return(1); } sigemptyset(&allsigs); sigaddset(&allsigs, SIGHUP); sigaddset(&allsigs, SIGINT); sigaddset(&allsigs, SIGTERM); act.sa_mask = allsigs; act.sa_flags = 0; /* We want to abort system calls and call a function. */ #ifdef SA_INTERRUPT act.sa_flags |= SA_INTERRUPT; #endif act.sa_handler = bailout; sigaction(SIGHUP, &act, NULL); sigaction(SIGINT, &act, NULL); sigaction(SIGTERM, &act, NULL); #ifdef DEBUG if (rootrot.tm_parent == TM_NULL_TASK) { fprintf(stderr, "%s: I am the mother of all tasks\n", id); } else { fprintf(stderr, "%s: I am but a child in the scheme of things\n", id); } #endif /* DEBUG */ if ((rc = tm_nodeinfo(&nodelist, &numnodes)) != TM_SUCCESS) { fprintf(stderr, "%s: tm_nodeinfo failed, rc = %s (%d)\n", id, get_ecname(rc), rc); return(1); } /* nifty unique/hostname code */ if (pernode || targethost) { allnodes = gethostnames(nodelist); if (targethost) { onenode = findtargethost(allnodes, targethost); } else { numnodes = uniquehostlist(nodelist, allnodes); } free(allnodes); if (targethost) free(targethost); } /* We already checked the lower bounds in the argument processing, now we check the upper bounds */ if ((onenode >= numnodes) || (ncopies > numnodes)) { fprintf(stderr, "%s: only %d nodes available\n", id, numnodes); return(1); } /* malloc space for various arrays based on number of nodes/tasks */ tid = (tm_task_id *)calloc(numnodes, sizeof(tm_task_id)); events_spawn = (tm_event_t *)calloc(numnodes, sizeof(tm_event_t)); events_obit = (tm_event_t *)calloc(numnodes, sizeof(tm_event_t)); ev = (int *)calloc(numnodes, sizeof(int)); if ((tid == NULL) || (events_spawn == NULL) || (events_obit == NULL) || (ev == NULL)) { /* FAILURE - cannot alloc memory */ fprintf(stderr, "%s: memory alloc of task ids failed\n", id); return(1); } for (c = 0; c < numnodes; c++) { *(tid + c) = TM_NULL_TASK; *(events_spawn + c) = TM_NULL_EVENT; *(events_obit + c) = TM_NULL_EVENT; *(ev + c) = 0; } /* END for (c) */ /* Now spawn the program to where it goes */ if (onenode >= 0) { /* Spawning one copy onto logical node "onenode" */ start = onenode; stop = onenode + 1; } else if (ncopies >= 0) { /* Spawn a copy of the program to the first "ncopies" nodes */ start = 0; stop = ncopies; } else { /* Spawn a copy on all nodes */ start = 0; stop = numnodes; } if ((ioenv = calloc(2, sizeof(char *)))==NULL) { /* FAILURE - cannot alloc memory */ fprintf(stderr,"%s: memory alloc of ioenv failed\n", id); return(1); } if (grabstdio != 0) { stdoutfd = build_listener(&stdoutport); if ((*ioenv = calloc(50,sizeof(char *))) == NULL) { /* FAILURE - cannot alloc memory */ fprintf(stderr,"%s: memory alloc of *ioenv failed\n", id); return(1); } snprintf(*ioenv,49,"TM_STDOUT_PORT=%d", stdoutport); FD_ZERO(&permrfsd); } sigprocmask(SIG_BLOCK, &allsigs, NULL); for (c = start; c < stop; ++c) { if ((rc = tm_spawn( argc - optind, argv + optind, ioenv, *(nodelist + c), tid + c, events_spawn + c)) != TM_SUCCESS) { fprintf(stderr, "%s: spawn failed on node %d err %s\n", id, c, get_ecname(rc)); } else { if (verbose) fprintf(stderr, "%s: spawned task %d\n", id, c); ++nspawned; if (sync) wait_for_task(&nspawned); /* one at a time */ } } /* END for (c) */ if (sync == 0) wait_for_task(&nspawned); /* wait for all to finish */ /* * Terminate interface with Task Manager */ tm_finalize(); return 0; } /* END main() */
//=========================================================================== // Initialize Micro to Desired State... //=========================================================================== static void Initialization(void){ //Initialize Peripherals //BLKCON2 Control Bits...Manually Set 4/12/2013 DSIO0 = 1; // 0=> Enables Synchronous Serial Port 0 DUA0 = 0; // 0=> Enables the operation of UART0 DUA1 = 1; // 0=> Enables Uart1 DI2C1 = 1; // 0=> Enables I2C bus Interface (Slave) DI2C0 = 0; // 0=> Enables I2C bus Interface (Master) BLKCON4 = 0x00; // SA-ADC: 0=> Enables ; 0xFF=> Disables BLKCON6 = 0x00; // Timers 8, 9, A, E, F : 0=> Enables ; 0xFF=> Disables BLKCON7 = 0x00; // PWM (PWMC, PWMD, PWME, PWMF : 0=> Enables ; 0xFF=> Disables // Port Initialize... PortA_Low(); //Initialize all 3 Ports of Q111 Port A to GPIO-Low PortB_Low(); //Initialize all 8 Ports of Q111 Port B to GPIO-Low PortC_Low(); //Initialize all 4 Ports of Q111 Port C to GPIO-Low // UART INIT... //uart_0_Init(); // ===== Set Oscillator Rate ===== SetOSC(); //8MHz // ===== PWM ================================================================ // // NOTE: Possible conflict of B.0 with RX pin from UART0 // // PinB0_PWM(); // Set up PWM peripheral (Pin on B.0) //=========================================================================== // ===== Comparator ===== //analog_comparator(); //Set up anaolg comparator peripheral /* // ===== SET SPECIFIC DESIRED PINS AS INPUTS ===== //Setup PIR Sensor Input on B.4 //Step 1: Set Pin Direction... PB4DIR = 1; // PortB Bit4 set Direction to INPUT... //Step 2: Set Pin I/O Type... PB4C1 = 0; // PortB Bit4 set Type to HIGH-IMPEDANCE INPUT... PB4C0 = 0; //Step 3: Set Pin Purpose... PB4MD1 = 0; // PortB Bit4 set Purpose to GENERAL PURPOSE Input/Output... PB4MD0 = 0; //Setup HALL Sensor Input on B.3 //Step 1: Set Pin Direction... PB3DIR = 1; // PortB Bit3 set Direction to INPUT... //Step 2: Set Pin I/O Type... PB3C1 = 0; // PortB Bit3 set Type to HIGH-IMPEDANCE INPUT... PB3C0 = 0; //Step 3: Set Pin Purpose... PB3MD1 = 0; // PortB Bit3 set Purpose to GENERAL PURPOSE Input/Output... PB3MD0 = 0; //Setup ACCELEROMETER X-SIGNAL Sensor Input on A.2 //Step 1: Set Pin Direction... PA2DIR = 1; // PortA Bit2 set Direction to INPUT... //Step 2: Set Pin I/O Type... PA2C1 = 0; // PortA Bit2 set Type to HIGH-IMPEDANCE INPUT... PA2C0 = 0; //Step 3: Set Pin Purpose... PA2MD1 = 0; // PortA Bit2 set Purpose to GENERAL PURPOSE Input/Output... PA2MD0 = 0; //Setup ACCELEROMETER Y-SIGNAL Sensor Input on A.1 //Step 1: Set Pin Direction... PA1DIR = 1; // PortA Bit1 set Direction to INPUT... //Step 2: Set Pin I/O Type... PA1C1 = 0; // PortA Bit1 set Type to HIGH-IMPEDANCE INPUT... PA1C0 = 0; //Step 3: Set Pin Purpose... PA1MD1 = 0; // PortA Bit1 set Purpose to GENERAL PURPOSE Input/Output... PA1MD0 = 0; //Setup ACCELEROMETER Temperature-SIGNAL Sensor Input on A.0 //Step 1: Set Pin Direction... PA0DIR = 1; // PortA Bit0 set Direction to INPUT... //Step 2: Set Pin I/O Type... PA0C1 = 0; // PortA Bit0 set Type to HIGH-IMPEDANCE INPUT... PA0C0 = 0; //Step 3: Set Pin Purpose... PA0MD1 = 0; // PortA Bit0 set Purpose to GENERAL PURPOSE Input/Output... PA0MD0 = 0; */ //================== STANDBY CONTROL REGISTER=================================== // // SBYCON is a 2-bit special function register to control operating mode of MCU // STP : HLT // BIT 1 : BIT 0 // 0 0 => Program RUN mode (initial value) // 0 1 => HALT mode // 1 0 => STOP mode // 1 1 => (Prohibited) // See ML610Q111/ML610Q112 User Manual - Section 4: MCU Control Function // SBYCON = 0; // Program RUN mode //============================================================================== //================== VOLTAGE LEVEL SUPERVISOR REGISTER ========================= // // The Q11x mcu's have two channels of VOLTAGE LEVEL SUPERVISORs // Accuracy is ±3% // // The threshold voltages of VLS0 (VDD fall) : 2.85V (Typ. ) // (VDD rise) : 2.92V (Typ. ) // // The threshold voltages of VLS1 (VDD fall) : 4 types selectable 3.3V/ 3.6V/ 3.9V/ 4.2V (Typ.) // The VLS0 can be used as the low voltage level detector reset. // // See ML610Q111/ML610Q112 User Manual - Section 22: Voltage Level Supervisor // //============================================================================== // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII // INTERRUPT SETUP... // The ML610Q1xx mcu's have 31 hardware interrupt sources // 7 External Interrupt Sources // 24 Internal Interrupt Sources // EXAMPLE: WDT; VLS; EXTERNAL INT Pins (6); SPI; ADC; I2C (Slave); I2C (Master); // TIMERS (6); UART; Comparators (2); PWM's ((4); TBC (4) irq_di(); // Disable Interrupts //irq_init(); // Initialize Interrupts (All Off and NO Requests) //==================================================================== //FOR NOTES ONLY...This is all taken care of in "irq_init()" // INTERRUPT ENABLE REGISTERS... // IE0 = VOLTAGE LEVEL SUPERVISOR Int. // IE1 = EXTERNAL Ints on B3, B2, B1, B0, A2, A1, & A0 // IE2 = SPI, A/D, I2C Slave & I2C Master Int. // IE3 = TIMERS 8 & 9 Ints. // IE4 = UART & COMPARATOR Ints. // IE5 = TIMERS A, B, E & F Ints. // IE6 = PWMC, PWMD, PWME, PWMF & 128Hz & 32Hz TBC Ints. // IE7 = 16Hz & 2Hz TBC Ints. //IE0 = IE1 = IE2 = IE3 = IE4 = IE5 = IE6 = IE7 = 0; //-------------------------------------------------------------- // INTERRUPT REQUEST FLAG REGISTERS... // IRQ0 = WDT & VLS Int Requests // IRQ1 = EXTERNAL Int Requests // IRQ2 = SPI, A/D, I2C Slave & I2C Master Int Requests // IRQ3 = TIMERS 8 & 9 Int Requests // IRQ4 = UART & COMPARATOR Int Requests // IRQ5 = TIMERS A, B, E & F Int Requests // IRQ6 = PWMC & 128Hz & 32Hz TBC Int Requests // IRQ7 = 16Hz & 2Hz TBC Int Requests //IRQ0 = IRQ1 = IRQ2 = IRQ3 = IRQ4 = IRQ5 = IRQ6 = IRQ7 = 0; //==================================================================== // INTERRUPT ENABLE REGISTERS... IE0 = IE1 = IE2 = IE3 = IE4 = IE5 = IE6 = IE7 = 0; // INTERRUPT REQUEST REGISTERS... IRQ0 = IRQ1 = IRQ2 = IRQ3 = IRQ4 = IRQ5 = IRQ6 = IRQ7 = 0; //------------- SET UP UART Interrupts Handler ------------------------------------------- (void)irq_setHdr( (unsigned char)IRQ_NO_UA0INT, _intUart ); EUA0 = 1; // EUA0 is the enable flag for the UART0 interrupt (1=ENABLED) QUA0 = 0; // Request Flag for the UART_0 INTERRUPT (1=REQUEST, 0-NO-REQUEST) //---------------------------------------------------------------------------------------- //------------- SET UP I2C MASTER Interrupts Handler ------------------------------------- (void)irq_setHdr( (unsigned char)IRQ_NO_I2CMINT, _intI2c ); EI2CM = 1; // EI2CM is the enable flag for the I2C MASTER interrupt (1=ENABLED) QI2CM = 0; //---------------------------------------------------------------------------------------- //------------- SET UP ADC Interrupts Handler -------------------------------------------- (void)irq_setHdr( (unsigned char)IRQ_NO_SADINT, _intADC ); ESAD = 1; // ESAD is the enable flag for the ADC interrupt (1=ENABLED) QSAD = 0; // Request Flag for the ADC INTERRUPT (1=REQUEST, 0-NO-REQUEST) //---------------------------------------------------------------------------------------- //------------- SET UP xHz TBC Interrupt (Options: 128Hz, 32Hz, 16Hz, 2Hz) -------------- (void)irq_setHdr( (unsigned char)IRQ_NO_T2HINT, TBC_ISR ); //Clear interrupt request flag E2H = 1; // Enable x Hz TBC Interrupt (1=ENABLED) Q2H = 0; // Request flag for the TIME BASE COUNTER 2Hz Interrupt // ----- //------------- TBC...Set Ratio: : 1:1 => 1_1 -------------------------------------------- (void)tb_setHtbdiv( (unsigned char)TB_HTD_1_1 ); //Set the ratio of dividing frequency of the time base counter //---------------------------------------------------------------------------------------- //------------- SET UP TIMER 8/9 Interrupt to increment timers every ~X ms --------------- (void)irq_setHdr( (unsigned char)IRQ_NO_TM9INT, TMR89_ISR ); //Clear interrupt request flag ETM8 = 1; // Enable timer 8 Interrupt (1=ENABLED ETM9 = 1; // Enable timer 9 Interrupt (1=ENABLED) QTM8 = 0; // Timer 8 IRQ request flag; 1=REQUEST QTM9 = 0; // Timer 9 IRQ request flag; 1=REQUEST T8CS0 = 1; // 111 => Select PLLCLK T8CS1 = 1; T8CS2 = 1; T9CS0 = 1; // 111 => Select PLLCLK T9CS1 = 1; T9CS2 = 1; tm_init(TM_CH_NO_89); tm_set89Data(8192); //A value of 1023 should yield 125us interrupts at 8.192 MHz tm_set89Source(TM_CS_HTBCLK); tm_start89(); T89M16 = 1; //1 => sets 16-bit timer mode HTD3 = 1; //High-Speed Time Base Counter Divide Register: 1111 = 9182kHz HTD2 = 1; HTD1 = 1; HTD0 = 1; //---------------------------------------------------------------------------------------- //------------- SET UP TIMER A/B Interrupt to increment timers every ~X ms --------------- (void)irq_setHdr( (unsigned char)IRQ_NO_TMBINT, TMRAB_ISR ); //Clear interrupt request flag ETMA = 1; // Enable timer 8 Interrupt (1=ENABLED ETMB = 1; // Enable timer 9 Interrupt (1=ENABLED) QTMA = 0; // timer 8 IRQ request flag; 1=REQUEST QTMB = 0; // timer 9 IRQ request flag; 1=REQUEST TACS0 = 1; // 111 => Select PLLCLK TACS1 = 1; TACS2 = 1; TBCS0 = 1; // 111 => Select PLLCLK TBCS1 = 1; TBCS2 = 1; tm_init(TM_CH_NO_AB); tm_setABData(8192); //A value of 1023 should yield 125us interrupts at 8.192 MHz tm_setABSource(TM_CS_HTBCLK); tm_startAB(); TABM16 = 1; //1 => sets 16-bit timer mode HTD3 = 1; //High-Speed Time Base Counter Divide Register: 1111 = 9182kHz HTD2 = 1; HTD1 = 1; HTD0 = 1; //---------------------------------------------------------------------------------------- //------------- SET UP TIMER E/F Interrupt to increment timers every ~X ms --------------- (void)irq_setHdr( (unsigned char)IRQ_NO_TMFINT, TMREF_ISR ); //Clear interrupt request flag ETME = 1; // Enable timer E Interrupt (1=ENABLED ETMF = 1; // Enable timer F Interrupt (1=ENABLED) QTME = 0; // Timer E IRQ request flag; 1=REQUEST QTMF = 0; // Timer F IRQ request flag; 1=REQUEST TECS0 = 1; // 111 => Select PLLCLK TECS1 = 1; TECS2 = 1; TFCS0 = 1; // 111 => Select PLLCLK TFCS1 = 1; TFCS2 = 1; tm_init(TM_CH_NO_EF); tm_setEFData(8192); //A value of 1023 should yield 125us interrupts at 8.192 MHz tm_setEFSource(TM_CS_HTBCLK); tm_startEF(); TEFM16 = 1; //1 => sets 16-bit timer mode HTD3 = 1; //High-Speed Time Base Counter Divide Register: 1111 = 9182kHz HTD2 = 1; HTD1 = 1; HTD0 = 1; //---------------------------------------------------------------------------------------- //------------- SET UP B.3 as an input, and prepare to use as an external interrupt ------ PB3DIR = 1; PB3C1 = 0; PB3C0 = 0; PB3MD1 = 0; PB3MD0 = 0; PB3E1 = 1; PB3E0 = 0; //PBnE0-1 are used to choose the Rising-Edge Mode for this interrupt PB3SM = 0; // ----- //------------- SET UP EXTERNAL INTERRUPT on B.3 ----------------------------------------- //Options include following pins: A.0; A.1; A.2. B.0; B.1; B.2 & B.3 (void)irq_setHdr( (unsigned char)IRQ_NO_PB3INT, ExtInt_ISR ); //Clear interrupt request flag EPB3 = 0; // 1=> Enables Interrupt QPB3 = 0; // EXT IRQ request flag; 1=REQUEST //---------------------------------------------------------------------------------------- irq_ei(); // Enable Interrupts // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII // ===== SET UP WATCH DOG TIMER ============================================= WDTMOD = 0x03; // 0x03=overflow 8sec... main_clrWDT(); // Clear WDT //=========================================================================== // ===== UART Initialization ================================================ // // Pin PB0 of mcu => RX // Pin PB1 of mcu => TX // (void)uart_init( (unsigned char)UART_CS_HSCLK, // Generator (unsigned short)HSCLK_KHZ, // HSCLK frequency &_uartSetParam ); // Parameters from Structure uart_PortSet(); // Set UART Port Pins _flgUartFin = 0; uart_stop(); // //=========================================================================== // ===== I2C Initialization ================================================= // (void)i2c_init(I2C_MOD_FST, (unsigned short)HSCLK_KHZ, I2C_SYN_ON); // I20SYN = 1; //Enable Clock Stretching //=========================================================================== }//End Initialization
sageContext * sage_open (int db_flag, int red_size, int green_size, int blue_size, int alpha_size, int depth_size, int stencil_size) { const char *str; sageContext *ctx; if (hardware < 0) { goto exit_error; } /* Create context */ ctx = malloc(sizeof(sageContext)); if (ctx == NULL) { goto exit_error; } ctx->gr_ctx = 0; /* Choose a visual */ ctx->fmt = findPixelFormat(&red_size, &green_size, &blue_size, &alpha_size, &depth_size, &stencil_size); fb_color = red_size + green_size + blue_size; fb_alpha = alpha_size; /* Initialize the core */ if (ctx_init(db_flag, red_size, green_size, blue_size, alpha_size, depth_size, stencil_size) != 0) { goto exit_error1; } /* Set driver capabilities */ allow_texuma = hwext_texuma && !YES("3dfx.disable.texuma"); allow_texmirror = hwext_texmirror && !YES("3dfx.disable.texmirror"); allow_fogcoord = hwext_fogcoord && !YES("3dfx.disable.fogcoord"); allow_32bpt = (fb_color == 24 && hwext_texfmt) && !YES("3dfx.disable.32bpt"); allow_blendsquare = (hardware >= GR_SSTTYPE_Voodoo4) && !YES("3dfx.disable.blendsquare"); allow_combine = GL_TRUE && !YES("3dfx.disable.combine"); allow_multitex = (getInteger(GR_NUM_TMU) > 1) && !YES("3dfx.disable.multitex"); allow_compressed = atoi(cfg_get("3dfx.texture.compression", "3")); if (hardware < GR_SSTTYPE_Voodoo4) { allow_compressed &= ~2; } if (!ctx_texcodec) { allow_compressed &= ~1; } if (hardware < GR_SSTTYPE_Voodoo4) { allow_combine = -allow_combine; } /* Update core with driver capabilities */ ctx_const_max_texture_size = getInteger(GR_MAX_TEXTURE_SIZE); ctx_const_max_texture_units = allow_multitex ? 2 : 1; max_texture_levels = 0; while ((GLuint)(1 << max_texture_levels) < ctx_const_max_texture_size) { max_texture_levels++; } ctx_const_max_lod_bias = max_texture_levels; str = cfg_get("3dfx.maxlod", NULL); if (str != NULL) { ctx_const_max_texture_size = 1 << atoi(str); } /* Finish driver setup */ tex_bound_mask = (hardware < GR_SSTTYPE_Banshee) ? 0x1fffff : -1U; if (tm_init() != 0) { goto exit_error2; } if (vb_init() != 0) { goto exit_error3; } fogtable = malloc(getInteger(GR_FOG_TABLE_ENTRIES) * sizeof(GrFog_t)); if (fogtable == NULL) { goto exit_error4; } /* XXX getInteger(GR_GLIDE_STATE_SIZE) */ drv_multipass = drv_multipass_none; init_tri_pointers(); /* Finish core setup */ ext_set("GL_EXT_texture_env_add", GL_TRUE); ext_set("GL_EXT_texture_edge_clamp", GL_TRUE); ext_set("GL_EXT_compiled_vertex_array", GL_TRUE); ext_set("GL_EXT_blend_func_separate", GL_TRUE); ext_set("GL_EXT_texture_lod_bias", GL_TRUE); if (allow_multitex) { ext_set("GL_ARB_multitexture", GL_TRUE); } if (allow_fogcoord) { ext_set("GL_EXT_fog_coord", GL_TRUE); } if (allow_texmirror) { ext_set("GL_ARB_texture_mirrored_repeat", GL_TRUE); } if (stencil_size) { ext_set("GL_EXT_stencil_wrap", GL_TRUE); } if (allow_blendsquare) { ext_set("GL_NV_blend_square", GL_TRUE); } if (allow_combine) { ext_set("GL_ARB_texture_env_combine", GL_TRUE); ext_set("GL_EXT_texture_env_combine", GL_TRUE); } if (allow_compressed) { ext_set("GL_ARB_texture_compression", GL_TRUE); ext_set("GL_EXT_texture_compression_s3tc", GL_TRUE); ext_set("GL_3DFX_texture_compression_FXT1", GL_TRUE); ext_set("GL_S3_s3tc", GL_TRUE); } /* XXX not really */ ext_set("GL_EXT_separate_specular_color", GL_TRUE); ext_set("GL_EXT_secondary_color", GL_TRUE); return ctx; exit_error4: free_a(vb); exit_error3: tm_fini(); exit_error2: ctx_fini(); exit_error1: free(ctx); exit_error: return NULL; }
int main(int argc, char *argv[]) { struct TM *tm; char *symbols; int n_states, n_syms; int *new_states; char *new_syms, *new_dirs; int n_tuples; char dir; FILE *program; char *tape_buffer; size_t tape_size = 1024; ssize_t tape_read; if (argc < 2) { fprintf(stderr, "usage: %s [program.tur]\n", argv[0]); return 1; } else if ((program = fopen(argv[1], "r")) == NULL) { const char *errstr = strerror(errno); fprintf(stderr, "%s: %s\n", argv[1], errstr); return 1; } fscanf(program, "%d %d", &n_states, &n_syms); n_tuples = n_states * n_syms; symbols = malloc(n_syms+1); symbols[n_syms] = 0; fscanf(program, "%s", symbols); if (debug) printf("states: %d, symbols(%d): %s\n", n_states, n_syms, symbols); new_states = malloc(sizeof(*new_states) * n_tuples); new_syms = malloc(n_tuples); new_dirs = malloc(n_tuples); for (int i=0; i<n_tuples; ++i) { fscanf(program, "%d %c %c", new_states+i, new_syms+i, &dir); new_dirs[i] = dir == '+' ? 1 : -1; if (debug) printf("(%d %c) -> (%d %c %c)\n", i/n_syms, symbols[i%n_syms], new_states[i], new_syms[i], dir); } tm = tm_new(symbols, new_states, new_syms, new_dirs, n_states, n_syms); // read tape from standard in tape_buffer = malloc(tape_size); tape_read = getline(&tape_buffer, &tape_size, stdin); if (tape_read < 1 || tape_buffer[0] == '\n') fprintf(stderr, "no tape given\n"); else { tape_buffer[tape_read-1] = 0; tm_init(tm, 0, 0, tape_buffer); tm_run(tm); } fclose(program); free(new_states); free(new_syms); free(new_dirs); return 0; }
void Kickoff_PBS(const Node_info *ddinodes,const Cmdline_info *info) { char ddiinfo[] = "-ddi"; char procid[8]; char portid[8]; char nodeid[8]; char snodes[8]; char sprocs[8]; char **rargs; char **argv = info->argv; int i,j,r,iarg,nargs = info->ddiarg + info->nnodes + 8; int inode,ncpus,np = info->nprocs; int ntests; if(info->nnodes == 1) return; int tm_errno; tm_task_id *tid; tm_event_t *spawn; tm_event_t polled; struct tm_roots roots; tm_node_id *nodelist; /* ---------------------------------- *\ Initialize PBS Task Management API \* ---------------------------------- */ if(tm_init(0, &roots) != TM_SUCCESS) { fprintf(stderr, " ddikick.x: tm_init failed\n"); Fatal_error(911); } if(tm_nodeinfo(&nodelist, &np) != TM_SUCCESS) { fprintf(stderr, " ddikick.x: tm_nodeinfo failed.\n"); Fatal_error(911); } tid = (tm_task_id *) Malloc(2*np*sizeof(tm_task_id)); spawn = (tm_event_t *) Malloc(2*np*sizeof(tm_event_t)); for(i=0; i<2*np; i++) { *(tid + i) = TM_NULL_TASK; *(spawn + i) = TM_NULL_EVENT; } /* ----------------------------------------- *\ Initialize arguments to kickoff DDI tasks \* ----------------------------------------- */ rargs = (char **) Malloc(nargs*sizeof(char*)); sprintf(portid, "%d", info->kickoffport); sprintf(snodes, "%d", info->nnodes); sprintf(sprocs, "%d", info->nprocs); for(i=1,r=0; i<info->ddiarg-1; i++) rargs[r++] = argv[i]; rargs[r++] = ddiinfo; rargs[r++] = info->kickoffhost; /* kickoff host name */ rargs[r++] = portid; /* kickoff port number */ rargs[r++] = nodeid; /* rank of this node */ rargs[r++] = procid; /* rank of this process */ rargs[r++] = snodes; /* number of nodes */ rargs[r++] = sprocs; /* number of processors */ for(i=0,iarg=info->nodearg; i<info->nnodes; i++,iarg++) { rargs[r++] = argv[iarg]; } rargs[r] = NULL; /* ------------------------ *\ Spawn DDI tasks to nodes \* ------------------------ */ ncpus=ddinodes[0].cpus+ddinodes[1].cpus; for(i=ddinodes[0].cpus,inode=1; i<np; i++) { if(i == ncpus) ncpus += ddinodes[++inode].cpus; sprintf(nodeid,"%d",inode); sprintf(procid,"%d",i); # if DDI_DEBUG DEBUG_START(DEBUG_MAX) fprintf(stdout,"DDI Process %i PBS tm_spawn arguments: ",i); for(iarg=0; iarg<r; iarg++) fprintf(stdout,"%s ",rargs[iarg]); fprintf(stdout,"\n"); DEBUG_END() # endif /* ------------------------- *\ Spawn DDI Compute Process \* ------------------------- */ if(tm_spawn(r,rargs,NULL,*(nodelist+i),(tid+i),spawn+i) != TM_SUCCESS) { fprintf(stderr," ddikick.x: tm_spawn failed.\n"); Fatal_error(911); } /* ---------------------------------- *\ No data server on single node runs \* ---------------------------------- */ if(info->nnodes == 1) continue; # if DDI_DEBUG DEBUG_START(DEBUG_MAX) fprintf(stdout,"DDI Process %i PBS tm_spawn arguments: ",j); for(iarg=0; iarg<r; iarg++) fprintf(stdout,"%s ",rargs[iarg]); fprintf(stdout,"\n"); DEBUG_END() # endif j = i+np; sprintf(procid,"%d",j); /* --------------------- *\ Spawn DDI Data Server \* --------------------- */ if(tm_spawn(r,rargs,NULL,*(nodelist+i),(tid+j),spawn+j) != TM_SUCCESS) { fprintf(stderr," ddikick.x: tm_spawn failed.\n"); Fatal_error(911); } } /* -------------------------------------------------------- *\ Poll PBS to ensure each DDI process started successfully \* -------------------------------------------------------- */ ntests = np-ddinodes[0].cpus; if(USING_DATA_SERVERS()) ntests *= 2; for(i=ntests; i--; ) { if(tm_poll(TM_NULL_EVENT,&polled,1,&tm_errno) != TM_SUCCESS) { fprintf(stderr," ddikick.x: tm_poll failed.\n"); Fatal_error(911); } for(j=0; j<np; j++) { if(polled == *(spawn+j)) { if(tm_errno) { fprintf(stderr," ddikick.x: error spawning DDI task %i.\n",j); Fatal_error(911); } else { # if DDI_DEBUG DEBUG_START(DEBUG_MAX) fprintf(stdout," ddikick.x: DDI task %i started.\n",j); DEBUG_END() # endif } } if(info->nnodes == 1) continue; if(polled == *(spawn+j+np)) { if(tm_errno) { fprintf(stderr," ddikick.x: error spawning DDI task %i.\n",j+np); Fatal_error(911); } else { # if DDI_DEBUG DEBUG_START(DEBUG_MAX) fprintf(stdout," ddikick.x: DDI task %i started.\n",j+np); DEBUG_END() # endif } } } } /* -------------------------------------- *\ Close the link to the PBS Task Manager \* -------------------------------------- */ tm_finalize(); /* ---------------- *\ Free used memory \* ---------------- */ free(tid); free(spawn); free(rargs); }
void kmain(void) { int reset_after_shutdown=0; #ifdef CONF_DKEY int c; #endif /* Install the text.hi segment in the correct place. The * firmware loader puts it in the bss segment, we copy it * to it's final location. */ memcpy(&__text_hi, &__bss, &__etext_hi - &__text_hi); reset_vector = rom_reset_vector; /* Turn off motor, since writing to hitext manipulates motors */ motor_controller = 0; memset(&__bss, 0, &__bss_end - &__bss); #ifdef CONF_MM mm_init(); #endif while (1) { power_init(); #ifdef CONF_AUTOSHUTOFF shutoff_init(); #endif lcd_init(); #ifdef CONF_DSOUND dsound_init(); #endif #ifdef CONF_TIME systime_init(); #endif #ifdef CONF_DSENSOR ds_init(); #endif #ifdef CONF_DMOTOR dm_init(); #endif #ifdef CONF_LNP lnp_init(); lnp_logical_init(); #endif #ifdef CONF_TM tm_init(); #endif #ifdef CONF_PROGRAM program_init(); #endif show_on(); // wait till power key released // #ifdef CONF_DKEY dkey_multi=KEY_ANY; while((c=dkey_multi) & KEY_ONOFF); #else while (PRESSED(dbutton(), BUTTON_ONOFF)); delay(100); #endif cls(); #ifndef CONF_PROGRAM lcd_show(man_run); #ifndef CONF_LCD_REFRESH lcd_refresh(); #endif #endif // run app // #ifdef CONF_TM #ifndef CONF_PROGRAM execi(&main,0,0,PRIO_NORMAL,DEFAULT_STACK_SIZE); #endif tm_start(); #else main(0,0); #endif show_off(); // ON/OFF + PROGRAM -> erase firmware #ifdef CONF_DKEY while((c=dkey_multi) & KEY_ONOFF) if(c&KEY_PRGM) reset_after_shutdown=1; #else while (PRESSED(dbutton(), BUTTON_ONOFF)) if (PRESSED(dbutton(), BUTTON_PROGRAM)) reset_after_shutdown=1; #endif #ifdef CONF_PROGRAM program_shutdown(); #endif #ifdef CONF_LNP lnp_logical_shutdown(); #endif #ifdef CONF_DMOTOR dm_shutdown(); #endif #ifdef CONF_DSENSOR ds_shutdown(); #endif #ifdef CONF_TIME systime_shutdown(); #endif if (reset_after_shutdown) rom_reset(); lcd_clear(); lcd_power_off(); power_off(); } }