/* Initialize IGD */ void igd_start(void) { char *value; /* * Stop igd_mainloop anyway, * if not enabled. */ value = nvram_get("upnp_enable"); if (value == 0 || atoi(value) == 0) { igd_stop_handler(); return; } if (igd_running == 0) { igd_down = 0; cyg_thread_create( IGD_PRIORITY, (cyg_thread_entry_t *)&igd_main, 0, "IGD", igd_main_stack, sizeof(igd_main_stack), &igd_main_tid, &igd_main_thread); cyg_thread_resume(igd_main_tid); /* Wait until thread scheduled */ while (!igd_running && !igd_down) cyg_thread_delay(1); } return; }
void nasd_start(void) { int wait_time = 1 * 100; /* 1 second */ if (!_nas_pid || !oslib_waitpid(_nas_pid, NULL)) { cyg_thread_create(7, (cyg_thread_entry_t *)nas_main, (cyg_addrword_t)NULL, "NAS", (void *)nas_main_stack, sizeof(nas_main_stack), &nas_main_hdl, &nas_thread); cyg_thread_resume(nas_main_hdl); /* Make sure nas stared and initial completed. Otherwise, * it may lost some wireless driver events. */ while (_nas_ready == 0 && wait_time > 0) { cyg_thread_delay(10); wait_time -= 10; } NASMSG("NAS task started\n"); } }
void kbd_init(void) { // Initialize environment, setup interrupt handler cyg_drv_interrupt_create(CYGNUM_HAL_INTERRUPT_KBDINT, 99, // Priority - what goes here? 0, // Data item passed to interrupt handler (cyg_ISR_t *)keyboard_isr, (cyg_DSR_t *)keyboard_dsr, &kbd_interrupt_handle, &kbd_interrupt); cyg_drv_interrupt_attach(kbd_interrupt_handle); cyg_drv_interrupt_acknowledge(CYGNUM_HAL_INTERRUPT_KBDINT); cyg_drv_interrupt_unmask(CYGNUM_HAL_INTERRUPT_KBDINT); // Set up the mbox for keyboard data cyg_mbox_create(&kbd_events_mbox_handle, &kbd_events_mbox); // This semaphore is set when there is a keypress cyg_semaphore_init(&kbd_sem, 0); // Create a thread whose job it is to de-bounce the keyboard and // actually process the input, turning it into a series of events cyg_thread_create(10, // Priority - just a number kbd_server, // entry 0, // initial parameter "KBD_server", // Name &kbd_server_stack[0], // Stack STACK_SIZE, // Size &kbd_server_thread_handle, // Handle &kbd_server_thread_data // Thread data structure ); cyg_thread_resume(kbd_server_thread_handle); // Start it }
void cyg_start(void) { CYG_TEST_INIT(); // // open CAN device driver // if (ENOERR != cyg_io_lookup("/dev/can0", &hCAN0)) { CYG_TEST_FAIL_FINISH("Error opening /dev/can0"); } // // create the thread that accesses the CAN device driver // cyg_thread_create(4, can0_thread, (cyg_addrword_t) 0, "can0_thread", (void *) can0_thread_data.stack, 1024 * sizeof(long), &can0_thread_data.hdl, &can0_thread_data.obj); cyg_thread_resume(can0_thread_data.hdl); cyg_scheduler_start(); }
bool cyg_sc_lpe_init(struct cyg_netdevtab_entry *tab) { struct eth_drv_sc *sc = (struct eth_drv_sc *)tab->device_instance; dp83902a_priv_data_t *dp = (dp83902a_priv_data_t *)sc->driver_private; struct cf_slot* slot; cf_init(); // Make sure Compact Flash subsystem is initialized slot = dp->plf_priv = (void*)cf_get_slot(0); dp->tab = tab; #ifdef CYGPKG_KERNEL // Create card handling [background] thread cyg_thread_create(CYGPKG_NET_THREAD_PRIORITY-1, // Priority sc_lpe_card_handler, // entry (cyg_addrword_t)sc, // entry parameter "SC LP-E card support", // Name &sc_lpe_card_handler_stack[0], // Stack STACK_SIZE, // Size &sc_lpe_card_handler_thread_handle, // Handle &sc_lpe_card_handler_thread_data // Thread data structure ); cyg_thread_resume(sc_lpe_card_handler_thread_handle); // Start it // Initialize environment, setup interrupt handler // eth_drv_dsr is used to tell the fast net thread to run the deliver funcion. cf_register_handler(slot, eth_drv_dsr, sc); return false; // Device is not ready until inserted, powered up, etc. #else // Initialize card return sc_lpe_card_handler((cyg_addrword_t)sc); #endif }
void cyg_start(void) { CYG_TEST_INIT(); // // open CAN device driver // if (ENOERR != cyg_io_lookup("/dev/can0", &hCAN0)) { CYG_TEST_FAIL_FINISH("Error opening /dev/can0"); } // // create the two threads which access the CAN device driver // a reader thread with a higher priority and a writer thread // with a lower priority // cyg_thread_create(4, can0_thread, (cyg_addrword_t) 0, "can0_thread", (void *) can0_thread_data.stack, 1024 * sizeof(long), &can0_thread_data.hdl, &can0_thread_data.obj); cyg_thread_resume(can0_thread_data.hdl); cyg_scheduler_start(); }
// // This function is used to create a new server [thread] which supports // the TFTP protocol on the given port. A server 'id' will be returned // which can later be used to destroy the server. // // Note: all [memory] resources for the server thread will be allocated // dynamically. If there are insufficient resources, an error will be // returned. // int tftpd_start(int port, struct tftpd_fileops *ops) { struct tftp_server *server; #ifdef CYGSEM_TFTP_SERVER_MULTITHREADED static char init = 0; if ( 0 == init ) { init++; cyg_semaphore_init( &tftp_server_sem, 0 ); } #endif if ((server = malloc(sizeof(struct tftp_server)))) { server->tag = TFTP_tag; server->port = port; server->ops = ops; cyg_thread_create(CYGPKG_NET_TFTPD_THREAD_PRIORITY, // Priority tftpd_server, // entry (cyg_addrword_t)server, // entry parameter "TFTP server", // Name &server->stack[0], // Stack STACK_SIZE, // Size &server->thread_handle, // Handle &server->thread_data // Thread data structure ); cyg_thread_resume(server->thread_handle); // Start it } return (int)server; }
static BOOL TestNet_ThreadInit(unsigned short usPort) { if (g_pWirelessTest != NULL) goto error_alread_inited; g_pWirelessTest = (WIRELESS_TEST_T *) malloc(sizeof(WIRELESS_TEST_T)); if (g_pWirelessTest == NULL) goto error_malloc; /* Create listening socket. */ g_pWirelessTest->fd_listen = create_listen_socket( usPort ); if ( g_pWirelessTest->fd_listen == -1 ) goto error_listen; cyg_thread_create(PTD_PRIORITY-3, WirelessTest_Test_Entry, (cyg_addrword_t)g_pWirelessTest, "test_net", g_pWirelessTest->datathread_stack, sizeof(g_pWirelessTest->datathread_stack), &g_pWirelessTest->datathread_handle, &g_pWirelessTest->datathread_thread); cyg_thread_resume(g_pWirelessTest->datathread_handle); return TRUE; error_listen: free(g_pWirelessTest); error_malloc: error_alread_inited: return FALSE; }
/** creates preResampling sw thread. */ void create_preResampling_thread(){ // create sw threads variables sw_thread_preResampling = (cyg_thread *) malloc (sizeof(cyg_thread)); // create sw thread stacks sw_thread_preResampling_stack = (char **) malloc (sizeof (char *)); sw_thread_preResampling_stack[0] = (char *) malloc (STACK_SIZE * sizeof(char)); // create sw handles sw_thread_preResampling_handle = (cyg_handle_t *) malloc (sizeof(cyg_handle_t)); // create and resume sw resampling switch thread in eCos // create sw resampling threads cyg_thread_create(PRIO, // scheduling info (eg pri) preResampling_thread, // entry point function 0, // entry data "PRERESAMPLING", // optional thread name sw_thread_preResampling_stack[0], // stack base STACK_SIZE, // stack size, sw_thread_preResampling_handle, // returned thread handle sw_thread_preResampling // put thread here ); // resume threads cyg_thread_resume(sw_thread_preResampling_handle[0]); }
/**************************************************************************** Function: cyg_user_start Description: This routine is the entry point of the application task. Inputs: none Returns: none ****************************************************************************/ void cyg_user_start(void) { /* Turn all led's on */ P4205_LED_ON(P4205_BOARD_CNTL_STATUS, P4205_FP_LED_ALL); #ifdef CYGPKG_KERNEL /* Using eCos kernel */ /* Create a ssbMode Thread */ cyg_thread_create(10, /* Thread priority */ (cyg_thread_entry_t *)TskFunc_ssbMode, /* Entry function */ 0, /* Thread function arg */ "ssbMode", /* Thread name */ stThread_ssbMode, /* Thread Stack Base */ CYGNUM_HAL_STACK_SIZE_TYPICAL, /* Thread Stack Size */ &hThread_ssbMode, /* Thread Handle */ &oThread_ssbMode); /* Thread Housekeeping Info */ /* Take thread out of suspended state */ cyg_thread_resume(hThread_ssbMode); #else /* No eCos kernel */ /* Enable Processor Interrupts - not required but enables gdb/insight * for stopping an executing program using the stop button or Ctrl-C. */ HAL_ENABLE_INTERRUPTS(); /* Invoke application directly */ TskFunc_ssbMode(); #endif } /* end cyg_user_start() */
void cyg_start(void) { CYG_TEST_INIT(); cyg_thread_create(MAIN_THREAD_PRIORITY, // Priority tcp_server, // entry 0, // entry parameter "TCP loopback server", // Name &stack_server[0], // Stack STACK_SIZE, // Size &server_thread_handle, // Handle &server_thread_data // Thread data structure ); cyg_thread_resume(server_thread_handle); // Start it cyg_thread_create(MAIN_THREAD_PRIORITY, // Priority tcp_client, // entry 0, // entry parameter "TCP loopback client", // Name &stack_client[0], // Stack STACK_SIZE, // Size &client_thread_handle, // Handle &client_thread_data // Thread data structure ); cyg_scheduler_start(); }
void nc_slave_main(void) { int i; CYG_TEST_INIT(); // Create the idle thread environment cyg_semaphore_init(&idle_thread_sem, 0); cyg_thread_create(IDLE_THREAD_PRIORITY, // Priority net_idle, // entry 0, // entry parameter "Network idle", // Name &idle_thread_stack[0], // Stack STACK_SIZE, // Size &idle_thread_handle, // Handle &idle_thread_data // Thread data structure ); cyg_thread_resume(idle_thread_handle); // Start it // Create the load threads and their environment(s) for (i = 0; i < NUM_LOAD_THREADS; i++) { cyg_semaphore_init(&load_thread_sem[i], 0); cyg_thread_create(LOAD_THREAD_PRIORITY, // Priority net_load, // entry i, // entry parameter "Background load", // Name &load_thread_stack[i][0], // Stack STACK_SIZE, // Size &load_thread_handle[i], // Handle &load_thread_data[i] // Thread data structure ); cyg_thread_resume(load_thread_handle[i]); // Start it } // Create a main thread, so we can run the scheduler and have time 'pass' cyg_thread_create(10, // Priority - just a number tmain, // entry 0, // entry parameter "socket echo test", // Name &stack[0], // Stack STACK_SIZE, // Size &thread_handle, // Handle &thread_data // Thread data structure ); cyg_thread_resume(thread_handle); // Start it cyg_scheduler_start(); CYG_TEST_FAIL_FINISH("Not reached"); }
static void cyg_httpd_init(cyg_addrword_t arg) { int i; int err = 0; /* Delay for a configurable length of time to give the application * a chance to get going, or even complete, without interference * from the HTTPD. */ if( CYGNUM_HTTPD_SERVER_DELAY > 0 ) { cyg_thread_delay( CYGNUM_HTTPD_SERVER_DELAY ); } server_address.sin_family = AF_INET; server_address.sin_len = sizeof(server_address); server_address.sin_addr.s_addr = INADDR_ANY; server_address.sin_port = htons(CYGNUM_HTTPD_SERVER_PORT); /* Get the network going. This is benign if the application has * already done this. */ init_all_network_interfaces(); /* Create and bind the server socket. */ server_socket = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ); CYG_ASSERT( server_socket > 0, "Socket create failed"); err = bind( server_socket, (struct sockaddr *)&server_address, sizeof(server_address) ); CYG_ASSERT( err == 0, "bind() returned error"); err = listen( server_socket, SOMAXCONN ); CYG_ASSERT( err == 0, "listen() returned error" ); /* If we are configured to have more than one server thread, * create them now. */ for( i = 1; i < CYGNUM_HTTPD_THREAD_COUNT; i++ ) { cyg_thread_create( CYGNUM_HTTPD_THREAD_PRIORITY, cyg_httpd_server, 0, "HTTPD", &httpd_stacks[i][0], sizeof(httpd_stacks[i]), &httpd_thread[i], &httpd_thread_object[i] ); cyg_thread_resume( httpd_thread[i] ); } /* Now go be a server ourself. */ cyg_httpd_server(arg); }
void cyg_start(void *n) { int i; // Create processing threads for (i = 0; i < CYGHWR_NET_DRIVERS; i++) { cyg_thread_create(MAIN_THREAD_PRIORITY, // Priority net_test, // entry i, // entry parameter "Network test", // Name &main_thread_stack[i][0], // Stack STACK_SIZE, // Size &main_thread_handle[i], // Handle &main_thread_data[i] // Thread data structure ); } cyg_thread_resume(main_thread_handle[0]); // Start first one // Create the idle thread environment cyg_semaphore_init(&idle_thread_sem, 0); cyg_thread_create(IDLE_THREAD_PRIORITY, // Priority net_idle, // entry 0, // entry parameter "Network idle", // Name &idle_thread_stack[0], // Stack STACK_SIZE, // Size &idle_thread_handle, // Handle &idle_thread_data // Thread data structure ); cyg_thread_resume(idle_thread_handle); // Start it // Create the load threads and their environment(s) for (i = 0; i < NUM_LOAD_THREADS; i++) { cyg_semaphore_init(&load_thread_sem[i], 0); cyg_thread_create(LOAD_THREAD_PRIORITY, // Priority net_load, // entry i, // entry parameter "Background load", // Name &load_thread_stack[i][0], // Stack STACK_SIZE, // Size &load_thread_handle[i], // Handle &load_thread_data[i] // Thread data structure ); cyg_thread_resume(load_thread_handle[i]); // Start it } cyg_scheduler_start(); }
void cyg_user_start(void) { cyg_thread_create(4, thread_prog, (cyg_addrword_t) 0, "Thread 1", (void *) stack, STACKSIZE, &thread_h, &thread_s); cyg_thread_resume(thread_h); }
/** creates observation SW threads (an delete old 'SW' threads) @param number_of_threads: number of threads for observation step */ void set_observe_sw (unsigned int number_of_threads){ int i; // terminate old sw threads if needed if (sw_number_of_threads_o > 0){ observation_sw_delete(); // free all variables for (i=0; i<sw_number_of_threads_o;i++){ free(sw_thread_o_stack[i]); } free(sw_thread_o); free(sw_thread_o_stack); free(sw_thread_o_handle); } // set number of sw threads sw_number_of_threads_o = number_of_threads; // create sw threads variables sw_thread_o = (cyg_thread *) malloc (number_of_threads * sizeof(cyg_thread)); // create sw thread stacks sw_thread_o_stack = (char **) malloc (number_of_threads * sizeof (char *)); for (i=0; i<number_of_threads; i++){ sw_thread_o_stack[i] = (char *) malloc (STACK_SIZE * sizeof(char)); } // create sw handles sw_thread_o_handle = (cyg_handle_t *) malloc (number_of_threads * sizeof(cyg_handle_t)); // create and resume sw importance threads in eCos for (i = 0; i < number_of_threads; i++){ // create sw sampling threads cyg_thread_create(PRIO, // scheduling info (eg pri) observation_sw_thread, // entry point function ( cyg_addrword_t ) i, // entry data "OBSERVATION_SW", // optional thread name sw_thread_o_stack[i], // stack base STACK_SIZE, // stack size, &sw_thread_o_handle[i], // returned thread handle &sw_thread_o[i] // put thread here ); // resume threads cyg_thread_resume(sw_thread_o_handle[i]); } }
/* we install our own startup routine which sets up threads */ void test_ecos_simple_program(void) { printf("Entering twothreads' cyg_user_start() function\n"); #if 1 cyg_mutex_init(&cliblock); #endif cyg_thread_create(4, simple_program, (cyg_addrword_t) 0, "Thread A", (void *) stack[0], 4096, &simple_threadA, &thread_s[0]); cyg_thread_create(4, simple_program, (cyg_addrword_t) 1, "Thread B", (void *) stack[1], 4096, &simple_threadB, &thread_s[1]); cyg_thread_resume(simple_threadA); cyg_thread_resume(simple_threadB); }
void cyg_start(void) { int i; // Create a main thread which actually runs the test cyg_thread_create(MAIN_THREAD_PRIORITY, // Priority net_test, // entry 0, // entry parameter "Network test", // Name &stack[0], // Stack STACK_SIZE, // Size &thread_handle, // Handle &thread_data // Thread data structure ); cyg_thread_resume(thread_handle); // Start it // Create the idle thread environment cyg_semaphore_init(&idle_thread_sem, 0); cyg_thread_create(IDLE_THREAD_PRIORITY, // Priority net_idle, // entry 0, // entry parameter "Network idle", // Name &idle_thread_stack[0], // Stack STACK_SIZE, // Size &idle_thread_handle, // Handle &idle_thread_data // Thread data structure ); cyg_thread_resume(idle_thread_handle); // Start it // Create the load threads and their environment(s) for (i = 0; i < NUM_LOAD_THREADS; i++) { cyg_semaphore_init(&load_thread_sem[i], 0); cyg_thread_create(LOAD_THREAD_PRIORITY, // Priority net_load, // entry i, // entry parameter "Background load", // Name &load_thread_stack[i][0], // Stack STACK_SIZE, // Size &load_thread_handle[i], // Handle &load_thread_data[i] // Thread data structure ); cyg_thread_resume(load_thread_handle[i]); // Start it } cyg_scheduler_start(); }
void kcache2_main( void ) { CYG_TEST_INIT(); cyg_thread_create(4, entry0 , (cyg_addrword_t)0, "kcache1", (void *)stack[0], STACKSIZE, &thread[0], &thread_obj[0]); cyg_thread_resume(thread[0]); cyg_scheduler_start(); }
void cyg_user_start(void){ ezs_dac_init(); /* Thread erzeugen ... */ diag_printf("Entering cyg_user_start() function\n"); cyg_thread_create(PRIORITY, &test_thread, 0, "thread 1", my_stack, STACKSIZE, &handle, &threaddata); /* Thread starten ... */ cyg_thread_resume(&handle); }
externC void cyg_start( void ) { CYG_TEST_INIT(); cyg_thread_create(4, entry0 , (cyg_addrword_t)0, "intr", (void *)stack[0], STACKSIZE, &thread[0], &thread_obj[0]); cyg_thread_resume(thread[0]); cyg_scheduler_start(); }
/* we install our own startup routine which sets up threads */ void cyg_user_start(void) { // FILE *f = fopen("/dev/ser1", "w"); // stdout = f; // Redirect stdout printf("\r\nEntering twothreads' cyg_user_start() function\r\n"); cyg_mutex_init(&cliblock); cyg_thread_create(4, simple_program, (cyg_addrword_t) 0, "Thread A", (void *) stack[0], 4096, &simple_threadA, &thread_s[0]); cyg_thread_create(4, simple_program, (cyg_addrword_t) 1, "Thread B", (void *) stack[1], 4096, &simple_threadB, &thread_s[1]); cyg_thread_resume(simple_threadA); cyg_thread_resume(simple_threadB); }
void ksem1_main( void ) { CYG_TEST_INIT(); cyg_semaphore_init( &s0, 0); cyg_semaphore_init( &s1, 2); cyg_semaphore_init( &s2, 0); cyg_thread_create(4, entry0 , (cyg_addrword_t)0, "ksem1-0", (void *)stack[0], STACKSIZE,&thread[0], &thread_obj[0]); cyg_thread_resume(thread[0]); cyg_thread_create(4, entry1 , (cyg_addrword_t)1, "ksem1-1", (void *)stack[1], STACKSIZE, &thread[1], &thread_obj[1]); cyg_thread_resume(thread[1]); cyg_scheduler_start(); CYG_TEST_FAIL_FINISH("Not reached"); }
void tcp_server(cyg_addrword_t param) { init_all_network_interfaces(); diag_printf("Start TCP server - test\n"); cyg_thread_resume(client_thread_handle); // Start it #if NLOOP > 0 server(); CYG_TEST_PASS_FINISH( "server returned OK" ); #endif CYG_TEST_NA( "No loopback devs" ); }
void CLI_start(int cmd) { if (cmd) { if (CLI_cmd_init() == 0) { cyg_thread_create(8, (cyg_thread_entry_t *)CLI_cmd_proc, (cyg_addrword_t) &sys_cmds[0], "CLI_thread", (void *)&cli_stack[0], sizeof(cli_stack), &cli_thread_h, &cli_thread); cyg_thread_resume(cli_thread_h); } } }
void zlib2_main( void ) { CYG_TEST_INIT(); cyg_thread_create(4, entry0 , (cyg_addrword_t)0, "zlib1", (void *)stack[0], STACKSIZE,&thread[0], &thread_obj[0]); cyg_thread_resume(thread[0]); cyg_scheduler_start(); CYG_TEST_FAIL_FINISH("Not reached"); }
void start_WinMain_thread(int priority, int argc, char** argv) { static struct ecos_winmain_data winmain_data; winmain_data.argc=argc; winmain_data.argv=argv; cyg_thread_create(priority, winmain_mainloop, (cyg_addrword_t) &winmain_data, "winmain", (void *) winmain_data.stack, STACK_SIZE, &winmain_data.handle, &winmain_data.thread); cyg_thread_resume(winmain_data.handle); }
void cyg_user_start(void) { // Create the initial thread and start it up cyg_thread_create(ECOS_MW_STARTUP_PRIORITY, startup, (cyg_addrword_t) 0, "System startup", (void *)startup_stack, STACKSIZE, &startup_thread, &startup_thread_obj); cyg_thread_resume(startup_thread); }
void test_sus() { if (bs_handle != NULL) { cyg_thread_info info; thread_join(&bs_handle, &bs_thread, &info); } cyg_thread_create(PTD_PRIORITY, &test_break_system, (cyg_addrword_t)NULL, "breaking", bs_thread_stack, sizeof(bs_thread_stack), &bs_handle, &bs_thread); cyg_thread_resume(bs_handle); }
/* we install our own startup routine which sets up threads */ void cyg_user_start(void) { targetBoardInit(); TCInterruptInstallHandler (CYGNUM_HAL_INTERRUPT_WATCHDOG, &watchdogIsrHandler, NULL); #ifdef _PRMGR_INT TCInterruptInstallHandler (CYGNUM_HAL_INTERRUPT_PRMGR, &pmIsrHandler, NULL); #endif //_PRGGR_INT cyg_thread_create(20, init_thread_main, (cyg_addrword_t)0, "INIT Thread", (void *)init_thread_stack, 4096, &init_thread_handle, &init_thread); cyg_thread_resume(init_thread_handle); }