// ************************************************************************************************* // @fn main // @brief Main routine // @param none // @return none // ************************************************************************************************* int main(void) { #ifdef EMU emu_init(); #endif // Init MCU init_application(); // Assign initial value to global variables init_global_variables(); #ifdef CONFIG_TEST // Branch to welcome screen test_mode(); #else display_all_off(); #endif // Main control loop: wait in low power mode until some event needs to be processed while(1) { // When idle go to LPM3 idle_loop(); // Process wake-up events if (button.all_flags || sys.all_flags) wakeup_event(); // Process actions requested by logic modules if (request.all_flags) process_requests(); // Before going to LPM3, update display if (display.all_flags) display_update(); } }
int kernelStart(struct multiboot_info *mboot_ptr){ kprintf("\n\n\n\n\n\n HW init ...\n"); init_descriptor_tables(); kprintf("\t\t IDT/GDT initialised...\n"); init_sysClock(100); kprintf("\t\t CMOS timer initialised to 100hz...\n"); u32int memsize = (mboot_ptr->mem_lower + mboot_ptr->mem_upper) * 1024; init_heap(end_address + 0x1000, memsize - end_address - 0x1000); //kprintf("\t\t end_address: %d \n", end_address); kprintf("\t\t Heap initialised...\n"); init_keyboard(); kprintf("\t\t PS/2 keyboard initialised...\n"); init_system_timer(); kprintf("\t\t timer initialised...\n"); init_application(); kprintf("\t\t application initialised...\n"); enableInterrupt(); while(1){} return 0; }
int main( int argc, char *argv[] ) { /* Initialize application. */ init_application( &argc, &argv ); surface->Clear( surface, 0xff, 0xff, 0xff, 0x30 ); window->SetOpacity( window, 0xff ); /* Main loop. */ while (1) { DFBWindowEvent event; update(); events->WaitForEventWithTimeout( events, 0, 100 ); /* Check for new events. */ while (events->GetEvent( events, DFB_EVENT(&event) ) == DFB_OK) { switch (event.type) { default: break; } } } /* Shouldn't reach this. */ return 0; }
// ************************************************************************************************* // @fn main // @brief Main routine // @param none // @return none // ************************************************************************************************* int main(void) { LED_On(); // Init MCU init_application(); // Assign initial value to global variables init_global_variables(); //timestampInit(1396556875); // Main control loop: wait in low power mode until some event needs to be processed while (1) { // Do the SHM specific stuff here. shmApp(); // Now for the predetermined time we should sleep here... P1OUT ^= 0x01; uint8_t i = 3; while (i--) { Timer0_A4_Delay(CONV_MS_TO_TICKS(1000)); } } }
/*************************************************************************** ************************ ENTRYPOINT AND MAIN LOOP ************************* **************************************************************************/ int main(void) { // Init MCU init_application(); #ifdef CONFIG_TEST // Branch to welcome screen test_mode(); #else /* clear whole scren */ display_clear(0, 0); #endif /* Init modules */ mod_init(); /* main loop */ while (1) { /* Go to LPM3, wait for interrupts */ _BIS_SR(LPM3_bits + GIE); __no_operation(); /* service watchdog on wakeup */ #ifdef USE_WATCHDOG // Service watchdog (reset counter) WDTCTL = (WDTCTL & 0xff) | WDTPW | WDTCNTCL; #endif /* check if any driver has events pending */ check_events(); /* check for button presses, drive the menu */ check_buttons(); } }
int main(void) { init_application(); for(;;) { } }
/****************************************************************************** * MAIN function ******************************************************************************/ int main ( int argc, char **argv ) { Widget appShell = init_application(&argc, argv ); catch_sigterm(); trace_main = TRACE_MAIN; signal(SIGPIPE, SIG_IGN); /* ignore broken pipe on write */ /* -- Register all application specific callbacks and widget classes */ RegisterApplication ( appShell ); add_winmove_translations(appShell); /* -- Create widget tree below toplevel shell using Xrm database register callbacks,actions, widget classe before */ WcWidgetCreation ( appShell ); /* get application resources and widget ptr */ XtGetApplicationResources( appShell, (XtPointer)&SETTINGS, basicSettingRes, XtNumber(basicSettingRes), (ArgList)0, 0 ); SETTINGS.app = XtWidgetToApplicationContext(appShell); SETTINGS.vset = v_init(); /* init widgets */ trace_level = SETTINGS.traceLevel; TRACE(1,"Thermal1 %s\nThermal2 %s", SETTINGS.p[0], SETTINGS.p[1] ); /* init application functions All widgets are created, but not visible. functions can now communicate with widgets */ update_cb(0,0); /* start timer */ /* -- Realize the widget tree and enter the main application loop */ XtRealizeWidget ( appShell ); grab_window_quit( appShell ); make_borderless_window(appShell); make_stay_above(appShell); int x0,y0; if( load_window_position(&x0,&y0) == 0 ) XMoveWindow(XtDisplay(appShell),XtWindow(appShell), x0, y0 ); XtAppMainLoop(XtWidgetToApplicationContext(appShell)); /* use XtAppSetExitFlag */ Dimension x,y; XtVaGetValues( appShell, "x", &x, "y", &y, NULL ); save_window_position(x,y); XtDestroyWidget(appShell); v_free( SETTINGS.vset ); m_destruct(); return EXIT_SUCCESS; }
// Handle setup request extern byte_t usb_setup ( byte_t data[8] ) { byte_t len = 0; // Load the application if (data[1] == USBTINYBL_FUNC_APP_INIT) { init_application(); } // Write a page else if (data[1] == USBTINYBL_FUNC_WRITE) { status = STATUS_WRITE; page_address = (data[3] << 8) | data[2]; // Set the page address // ignore a page write over the bootloader section if (page_address >= BOOTLOADER_ADDRESS) { status = STATUS_IDLE; return 0xff; } page_counter = 0; eeprom_busy_wait(); cli(); boot_page_erase(page_address); // Erase the page sei(); boot_spm_busy_wait(); // Wait until page is erased len = 0xff; // Request the data though usb_out } // Read a page else if (data[1] == USBTINYBL_FUNC_READ) { status = STATUS_READ; page_address = (data[3] << 8) | data[2]; // Set the page address page_counter = 0; boot_rww_enable(); len = 0xff; // Request the data though usb_out } else if (data[1] == USBTINYBL_FUNC_GET_VER) { data[0] = VERSION_MAJOR; data[1] = VERSION_MINOR; len = 2; } // Load page size else if (data[1] == USBTINYBL_FUNC_GET_PAGE) { data[0] = SPM_PAGESIZE >> 8; data[1] = SPM_PAGESIZE & 0xff; len = 2; }
int main() { init_application(); for(;;) { if(mouse_sensor.new_motion_data_available()) { int16_t delta_x = 0, delta_y = 0; mouse_sensor.get_delta_x_y(delta_x, delta_y); usb_uart.printf("dx = %d, dy = %d\n", delta_x, delta_y); } } }
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); // TODO: Place code here. MSG msg; HACCEL hAccelTable; memset(&__theApp, 0x0, sizeof(__theApp)); if(!init_application(hInstance)){ return FALSE; } // Perform application initialization: if (!InitInstance (hInstance, nCmdShow)){ return FALSE; } hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_SEGDVIEWER)); // Main message loop: while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } return (int) msg.wParam; }
gint main (int argc, char **argv) { int c; char *profile = NULL; init_signal_handlers(argv[0]); opterr = 0; while ((c = getopt (argc, argv, "c:p:u:")) != -1) switch (c) { case 'c': ctx = iio_create_network_context(optarg); if (!ctx) { printf("Failed connecting to remote device: %s\n", optarg); exit(-1); } break; case 'u': ctx = iio_create_context_from_uri(optarg); if (!ctx) { printf("Failed connecting to remote device: %s\n", optarg); exit(-1); } break; case 'p': profile = strdup(optarg); break; case '?': usage(argv[0]); break; default: printf("Unknown command line option\n"); usage(argv[0]); break; } #ifndef __MINGW32__ /* XXX: Enabling threading when compiling for Windows will lock the UI * as soon as the main window is moved. */ gdk_threads_init(); #endif gtk_init(&argc, &argv); signal(SIGTERM, sigterm); signal(SIGINT, sigterm); #ifndef __MINGW32__ signal(SIGHUP, sigterm); #endif gdk_threads_enter(); init_application(); c = load_default_profile(profile, true); if (!ctx_destroyed_by_do_quit) { if (!ctx) connect_dialog(false); create_default_plot(); if (c == 0) { if (gtk_check_menu_item_get_active( GTK_CHECK_MENU_ITEM(versioncheck_en))) version_check_start(NULL); gtk_main(); } else application_quit(); } gdk_threads_leave(); if (profile) free(profile); if (c == 0 || c == -ENOTTY) return 0; else return -1; }
/* * Function: Main routine called on program invocation. * * Parameters: * hinstance - the current instance * * hprevinstance - previous instance if one exists or NULL. * * cmdline - the command line string passed by Windows. * * ncmdshow - show flag to indicate wheather to come up minimized * or not. * * Returns: TRUE if initialized sucessfully, false otherwise. */ int PASCAL WinMain(HINSTANCE hinst, HINSTANCE hprevinstance, LPSTR cmdline, int ncmdshow) { DLGPROC dlgproc; HWND hwnd; HACCEL haccel; MSG msg; char *p; char buf[MAX_K_NAME_SZ + 9]; char name[MAX_K_NAME_SZ]; strcpy(buf, cmdline); action = LOGIN_AND_RUN; name[0] = 0; p = strtok(buf, " ,"); while (p != NULL) { if (_stricmp(p, "/exit") == 0) action = LOGIN_AND_EXIT; else if (_stricmp(p, "/minimize") == 0) action = LOGIN_AND_MINIMIZE; else strcpy(name, p); p = strtok(NULL, " ,"); } dlgncmdshow = ncmdshow; hinstance = hinst; #ifndef _WIN32 /* * If a previous instance of this application exits, bring it * to the front and exit. * * This code is not compiled for WIN32, since hprevinstance will always * be NULL. */ if (hprevinstance != NULL) { hwnd = FindWindow(KWIN_DIALOG_CLASS, NULL); if (IsWindow(hwnd) && IsWindowVisible(hwnd)) { if (GetWindowWord(hwnd, GWW_HINSTANCE) == hprevinstance) { if (name[0]) SendMessage(hwnd, WM_KWIN_SETNAME, 0, (LONG)name); ShowWindow(hwnd, ncmdshow); SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE); return FALSE; } } } if (hprevinstance == NULL) #endif /* _WIN32 */ if (!init_application(hinstance)) return FALSE; if (!init_instance(hinstance, ncmdshow)) return FALSE; #ifdef _WIN32 dlgproc = kwin_dlg_proc; #else dlgproc = (FARPROC)MakeProcInstance(kwin_dlg_proc, hinstance); assert(dlgproc != NULL); if (dlgproc == NULL) return 1; #endif hwnd = CreateDialogParam(hinstance, MAKEINTRESOURCE(ID_KWIN), HWND_DESKTOP, dlgproc, (LONG)name); assert(hwnd != NULL); if (hwnd == NULL) return 1; haccel = LoadAccelerators(hinstance, MAKEINTRESOURCE(IDA_KWIN)); assert(hwnd != NULL); while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(hwnd, haccel, &msg) && !IsDialogMessage(hwnd, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } DestroyWindow(hwnd); #ifndef _WIN32 FreeProcInstance((FARPROC)dlgproc); #endif cns_save_registry(); return 0; }
int main( int argc, char *argv[] ) { int i = 0; int width, height; cairo_matrix_t matrix; /* Initialize application. */ init_application( &argc, &argv ); /* Query size of output surface. */ primary->GetSize( primary, &width, &height ); /* Transform coordinates to have 0,0 in the center. */ cairo_matrix_init_translate( &matrix, width/2, height/2 ); /* Enable coordinate transformation and anti-aliasing for all drawing/blitting, but not Clear(). */ primary->SetRenderOptions( primary, DSRO_MATRIX | DSRO_ANTIALIAS ); /* Main loop. */ while (1) { DFBInputEvent event; /* Convert doubles to DirectFB's fixed point 16.16 and call IDirectFBSurface::SetMatrix(). */ set_cairo_matrix( &matrix ); /* Clear the frame. */ primary->SetDrawingFlags( primary, DSDRAW_NOFX ); primary->Clear( primary, 0x00, 0x00, 0x00, 0x00 ); /* Enable alphablend. */ primary->SetDrawingFlags( primary, DSDRAW_BLEND ); /* Set the blend functions to (SRCALPHASAT, ONE) to * prevent antialiased edges within complex shapes * (e.g. transformed rectangles). */ primary->SetSrcBlendFunction( primary, DSBF_SRCALPHASAT ); primary->SetDstBlendFunction( primary, DSBF_ONE ); /* Fill a small white rectangle in the middle. */ primary->SetColor( primary, 0xff, 0xff, 0xff, 0xff ); primary->FillRectangle( primary, -20, -20, 40, 40 ); /* Fill a small green rectangle on the left. */ primary->SetColor( primary, 0x00, 0xff, 0x00, 0xff ); primary->FillRectangle( primary, -120, -20, 40, 40 ); /* Fill a small blue rectangle at the top. */ primary->SetColor( primary, 0x00, 0x00, 0xff, 0xff ); primary->FillRectangle( primary, -20, -120, 40, 40 ); /* Fill a red rectangle down-right without AA. */ primary->SetColor( primary, 0xff, 0, 0, 0xff ); primary->SetDrawingFlags( primary, DSDRAW_NOFX ); primary->SetRenderOptions( primary, DSRO_MATRIX ); primary->FillRectangle( primary, 100, 100, 100, 100 ); primary->SetRenderOptions( primary, DSRO_MATRIX | DSRO_ANTIALIAS ); primary->SetDrawingFlags( primary, DSDRAW_BLEND ); /* For simpe shapes (lines & triangles) SRCALPHA is good. */ primary->SetSrcBlendFunction( primary, DSBF_SRCALPHA ); /* Draw a white outline around the red rectangle. */ primary->SetColor( primary, 0xcc, 0xcc, 0xcc, 0xff ); primary->DrawRectangle( primary, 100, 100, 100, 100 ); /* Draw a line across the objects. */ primary->SetColor( primary, 0x12, 0x34, 0x56, 0xff ); primary->DrawLine( primary, 0, 0, 300, 300 ); primary->SetColor( primary, 0xff, 0xff, 0xff, 0xff ); primary->DrawLine( primary, -20, -20, -300, -300 ); /* Fill a triangle. */ primary->SetColor( primary, 0x80, 0x90, 0x70, 0xff ); primary->FillTriangle( primary, 0, 0, 200, -210, -200, 190 ); /* Flip the output surface. */ primary->Flip( primary, NULL, DSFLIP_WAITFORSYNC ); // primary->Dump( primary, "/", "df_matrix" ); /* Rotate scene slightly. */ cairo_matrix_rotate( &matrix, 0.1 ); cairo_matrix_scale( &matrix, 0.99, 0.99 ); //cairo_matrix_scale( &matrix, 1.001, 1.001 ); if (++i == 500) { i = 0; cairo_matrix_init_translate( &matrix, width/2, height/2 ); } /* Check for new events. */ while (events->GetEvent( events, DFB_EVENT(&event) ) == DFB_OK) { /* Handle key press events. */ if (event.type == DIET_KEYPRESS) { switch (event.key_symbol) { case DIKS_ESCAPE: case DIKS_POWER: case DIKS_BACK: case DIKS_SMALL_Q: case DIKS_CAPITAL_Q: exit_application( 0 ); break; default: break; } } } } /* Shouldn't reach this. */ return 0; }
int request_vcores_datacenter(provider *pv, int ndatacenter, event *ev){ int pattern=1; int res, size; float hv = 0.0; long f1 = 0; long f2 = 0; long ptotal = 0; long pmin = 0; application *app = NULL; app_frontend *app_fe; size = ev->sizel1 + ev->sizel2 + ev->sizel3; int *assigned_vcores = malloc(sizeof(int)*size); init_application(pv, &app, ev); switch(pv->datacenters[ndatacenter].allocation_policy){ case FF: res = request_vcores_network_ff(pv,ndatacenter,size,assigned_vcores, app->str.maxbw); break; case RR: res = request_vcores_network_rr(pv,ndatacenter,size,assigned_vcores, app->str.maxbw); break; default: panic("No policy selected"); } if(res == 1){ switch(pv->datacenters[ndatacenter].optimization_alg){ case NONE: allocate_vcores_network(pv, ndatacenter, size, assigned_vcores, app->id, app->str.maxbw); break; case NSGA2: case SPEA2: case HYPE: case SHV: hv = optimize(pv->datacenters[ndatacenter].optimization_alg, alpha, mu, lambda, dim, tournament, ngen, mtype, cotype, pmut, pmuttopo, pco, pcotopo, size, assigned_vcores, pv, ndatacenter, app); allocate_vcores_network(pv, ndatacenter, size, assigned_vcores, app->id, app->str.maxbw); break; default: panic("datacenter: no optimization algorithm"); } f1 = eval_cores_f1(assigned_vcores, size, pv->datacenters[ndatacenter].nw, app->str.bw); f2 = eval_cores_f2(assigned_vcores, size, pv->datacenters[ndatacenter].nw); ptotal = on_servers_total(pv->datacenters[ndatacenter].nw, assigned_vcores, size); pmin = eval_pmin_constrained(size, app->str.maxbw); f1_metric(pv, ndatacenter, f1); f2_metric(pv, ndatacenter, f2); ptotal_metric(pv, ndatacenter, ptotal); pmin_metric(pv, ndatacenter, pmin); hv_metric(pv, ndatacenter, hv); //write_opt(f1,f2,ptotal); change_assigned_cores(app, assigned_vcores); //printApplication(app); app_fe = add_app_lb(pv, app); change_app_fe(app, app_fe); allocate_application(pv, ndatacenter, app); if(ev->requests){ gen_requests(pv, app->id, app->type, app->etime, app_fe, app->rtime, pattern, app->maxreq, app->req_chunk,0,0); } num_applications_metric(pv, ndatacenter); } else{ free(assigned_vcores); rem_application(app); } return(res); }