void child_main(void) { setbuf(stdout, NULL); setbuf(stderr, NULL); printf("Child starts\n"); cache_param = heritage.param; AZ(pthread_key_create(&sp_key, NULL)); AZ(pthread_key_create(&name_key, NULL)); THR_SetName("cache-main"); VSM_Init(); /* First, LCK needs it. */ LCK_Init(); /* Second, locking */ WAIT_Init(); PAN_Init(); CLI_Init(); Fetch_Init(); CNT_Init(); VCL_Init(); HTTP_Init(); VDI_Init(); VBO_Init(); VBE_InitCfg(); VBP_Init(); WRK_Init(); Pool_Init(); EXP_Init(); HSH_Init(heritage.hash); BAN_Init(); VCA_Init(); SMS_Init(); SMP_Init(); STV_open(); VMOD_Init(); BAN_Compile(); /* Wait for persistent storage to load if asked to */ if (cache_param->diag_bitmap & 0x00020000) SMP_Ready(); CLI_Run(); STV_close(); printf("Child dies\n"); }
int DLLRegister(int Version) { if (Version != CONTEXT_VERSION) return ERR_NOT_COMPATIBLE; HTTP_Init(); return ERR_NONE; }
void TaskENC (uint32_t arg) { // FIXME: initialize the controls Controls_InitHandler(); // Initialize the webpages HTTP_Init(); // Get exclusive access to the SPI module SPI1_GetExclusiveAccess(FLASH_SPI_BAUDRATE); // Reset and configure the controller ENC_Reset(); ENC_EnableReceiver(); // Handle incoming packets while (1) { // Wait for a packet to be available ENC_TaskWaitForPacketAvailable(); // Read the packet, don't process if there was an error ETH_Size = ENC_ReceivePacket(ETH_Buffer, ETH_BUFFER_SIZE); // Analyze the packet uint32_t result = ETH_AnalyzePacket(); if (result == ETH_ANALYZE_TYPE_ARP) ETH_SendARPReply(); else if (result == ETH_ANALYZE_TYPE_ICMP_REQUEST) ETH_SendICMPReply(); else if (result == ETH_ANALYZE_TYPE_TCP_CLIENT) TCP_HandleClient(); else if (result == ETH_ANALYZE_TYPE_TCP_SERVER) TCP_HandleServer(); } // Clear access to the module SPI1_ClearExclusiveAccess(); }
void child_main(void) { setbuf(stdout, NULL); setbuf(stderr, NULL); printf("Child starts\n"); cache_param = heritage.param; AZ(pthread_key_create(&req_key, NULL)); AZ(pthread_key_create(&bo_key, NULL)); AZ(pthread_key_create(&name_key, NULL)); THR_SetName("cache-main"); VSM_Init(); /* First, LCK needs it. */ LCK_Init(); /* Second, locking */ Lck_New(&vxid_lock, lck_vxid); CLI_Init(); PAN_Init(); VFP_Init(); VCL_Init(); HTTP_Init(); VBO_Init(); VBP_Init(); VBE_InitCfg(); Pool_Init(); V1P_Init(); EXP_Init(); HSH_Init(heritage.hash); BAN_Init(); VCA_Init(); SMP_Init(); STV_open(); VMOD_Init(); BAN_Compile(); VRND_Seed(); srand48(random()); CLI_AddFuncs(debug_cmds); /* Wait for persistent storage to load if asked to */ if (FEATURE(FEATURE_WAIT_SILO)) SMP_Ready(); CLI_Run(); BAN_Shutdown(); STV_close(); printf("Child dies\n"); }
/* ================= Host_Main ================= */ int EXPORT Host_Main( int argc, const char **argv, const char *progname, int bChangeGame, pfnChangeGame func ) { static double oldtime, newtime; #ifdef XASH_SDL SDL_Event event; #endif pChangeGame = func; // may be NULL Host_InitCommon( argc, argv, progname, bChangeGame ); // init commands and vars if( host.developer >= 3 ) { Cmd_AddCommand ( "sys_error", Sys_Error_f, "just throw a fatal error to test shutdown procedures"); Cmd_AddCommand ( "host_error", Host_Error_f, "just throw a host error to test shutdown procedures"); Cmd_AddCommand ( "crash", Host_Crash_f, "a way to force a bus error for development reasons"); Cmd_AddCommand ( "net_error", Net_Error_f, "send network bad message from random place"); } host_cheats = Cvar_Get( "sv_cheats", "0", CVAR_LATCH, "allow usage of cheat commands and variables" ); host_maxfps = Cvar_Get( "fps_max", "72", CVAR_ARCHIVE, "host fps upper limit" ); host_sleeptime = Cvar_Get( "sleeptime", "1", CVAR_ARCHIVE, "higher value means lower accuracy" ); host_framerate = Cvar_Get( "host_framerate", "0", 0, "locks frame timing to this value in seconds" ); host_serverstate = Cvar_Get( "host_serverstate", "0", CVAR_INIT, "displays current server state" ); host_gameloaded = Cvar_Get( "host_gameloaded", "0", CVAR_INIT, "indicates a loaded game library" ); host_clientloaded = Cvar_Get( "host_clientloaded", "0", CVAR_INIT, "indicates a loaded client library" ); host_limitlocal = Cvar_Get( "host_limitlocal", "0", 0, "apply cl_cmdrate and rate to loopback connection" ); con_gamemaps = Cvar_Get( "con_mapfilter", "1", CVAR_ARCHIVE, "when enabled, show only maps in game folder (no maps from base folder when running mod)" ); download_types = Cvar_Get( "download_types", "msec", CVAR_ARCHIVE, "list of types to download: Model, Sounds, Events, Custom" ); build = Cvar_Get( "build", va( "%i", Q_buildnum()), CVAR_INIT, "returns a current build number" ); ver = Cvar_Get( "ver", va( "%i/%s.%i", PROTOCOL_VERSION, XASH_VERSION, Q_buildnum( ) ), CVAR_INIT, "shows an engine version" ); host_mapdesign_fatal = Cvar_Get( "host_mapdesign_fatal", "1", CVAR_ARCHIVE, "make map design errors fatal" ); host_xashds_hacks = Cvar_Get( "xashds_hacks", "0", 0, "hacks for xashds in singleplayer" ); // content control Cvar_Get( "violence_hgibs", "1", CVAR_ARCHIVE, "show human gib entities" ); Cvar_Get( "violence_agibs", "1", CVAR_ARCHIVE, "show alien gib entities" ); Cvar_Get( "violence_hblood", "1", CVAR_ARCHIVE, "draw human blood" ); Cvar_Get( "violence_ablood", "1", CVAR_ARCHIVE, "draw alien blood" ); if( host.type != HOST_DEDICATED ) { // when we're in developer-mode, automatically turn cheats on if( host.developer > 1 ) Cvar_SetFloat( "sv_cheats", 1.0f ); Cbuf_AddText( "exec video.cfg\n" ); } Mod_Init(); NET_Init(); Netchan_Init(); // allow to change game from the console if( pChangeGame != NULL ) { Cmd_AddCommand( "game", Host_ChangeGame_f, "change active game/mod" ); Cvar_Get( "host_allow_changegame", "1", CVAR_READ_ONLY, "whether changing game/mod is allowed" ); } else { Cvar_Get( "host_allow_changegame", "0", CVAR_READ_ONLY, "allows to change games" ); } SV_Init(); CL_Init(); HTTP_Init(); // post initializations switch( host.type ) { case HOST_NORMAL: Con_ShowConsole( false ); // hide console // execute startup config and cmdline Cbuf_AddText( va( "exec %s.rc\n", SI.ModuleName )); // intentional fallthrough case HOST_DEDICATED: // if stuffcmds wasn't run, then init.rc is probably missing, use default if( !host.stuffcmdsrun ) Cbuf_AddText( "stuffcmds\n" ); Cbuf_Execute(); break; case HOST_UNKNOWN: break; } if( host.type == HOST_DEDICATED ) { char *defaultmap; Con_InitConsoleCommands (); Cmd_AddCommand( "quit", Sys_Quit, "quit the game" ); Cmd_AddCommand( "exit", Sys_Quit, "quit the game" ); SV_InitGameProgs(); Cbuf_AddText( "exec config.cfg\n" ); // dedicated servers are using settings from server.cfg file Cbuf_AddText( va( "exec %s\n", Cvar_VariableString( "servercfgfile" ))); Cbuf_Execute(); defaultmap = Cvar_VariableString( "defaultmap" ); if( !defaultmap[0] ) Msg( "Please add \"defaultmap\" cvar with default map name to your server.cfg!\n" ); else Cbuf_AddText( va( "map %s\n", defaultmap )); Cvar_FullSet( "xashds_hacks", "0", CVAR_READ_ONLY ); NET_Config( true ); } else { Cmd_AddCommand( "minimize", Host_Minimize_f, "minimize main window to taskbar" ); Cbuf_AddText( "exec config.cfg\n" ); // listenserver/multiplayer config. // need load it to update menu options. Cbuf_AddText( "exec game.cfg\n" ); } host.errorframe = 0; Cbuf_Execute(); host.change_game = false; // done Cmd_RemoveCommand( "setr" ); // remove potential backdoor for changing renderer settings Cmd_RemoveCommand( "setgl" ); // we need to execute it again here if( host.type != HOST_DEDICATED ) Cmd_ExecuteString( "exec config.cfg\n", src_command ); // exec all files from userconfig.d Host_Userconfigd_f(); oldtime = Sys_DoubleTime(); IN_TouchInitConfig(); SCR_CheckStartupVids(); // must be last #ifdef XASH_SDL SDL_StopTextInput(); // disable text input event. Enable this in chat/console? #endif if( host.state == HOST_INIT ) host.state = HOST_FRAME; // initialization is finished // main window message loop while( !host.crashed && !host.shutdown_issued ) { #ifdef XASH_SDL while( !host.crashed && !host.shutdown_issued && SDL_PollEvent( &event ) ) SDLash_EventFilter( &event ); #endif newtime = Sys_DoubleTime (); Host_Frame( newtime - oldtime ); oldtime = newtime; } // never reached return 0; }