Esempio n. 1
0
/**
 * @brief Setup fixture.
 */
void setup(void) {

	Mem_Init();

	Fs_Init(FS_NONE);

	Cmd_Init();
}
Esempio n. 2
0
/**
 * @brief Setup fixture.
 */
void setup(void) {

	Mem_Init();

	Fs_Init(false);
}
Esempio n. 3
0
/*
 * @brief Initializes the master server.
 */
static void Init(void) {

	Z_Init();

	Fs_Init(false);
}
Esempio n. 4
0
void
main()
{
    Proc_PID	pid;
    int		i;

    /*
     * Initialize variables specific to a given kernel.  
     * IMPORTANT: Only variable assignments and nothing else can be
     *		  done in this routine.
     */
    Main_InitVars();

    /*
     * Initialize machine dependent info.  MUST BE CALLED HERE!!!.
     */
    Mach_Init();
    Sync_Init();

    /*
     * Initialize the debugger.
     */
    Dbg_Init();

    /*
     * Initialize the system module, particularly the fact that there is an
     * implicit DISABLE_INTR on every processor.
     */
    if (main_PrintInitRoutines) {
	Mach_MonPrintf("Calling Sys_Init().\n");
    }
    Sys_Init();

    /*
     * Now allow memory to be allocated by the "Vm_BootAlloc" call.  Memory
     * can be allocated by this method until "Vm_Init" is called.  After this
     * then the normal memory allocator must be used.
     */
    if (main_PrintInitRoutines) {
	Mach_MonPrintf("Calling Vm_BootInit().\n");
    }
    Vm_BootInit();

    /*
     * Initialize all devices.
     */
    if (main_PrintInitRoutines) {
	Mach_MonPrintf("Calling Dev_Init().\n");
    }
    Dev_Init();

    /*
     *  Initialize the mappings of keys to call dump routines.
     *  Must be after Dev_Init. 
     */
    if (main_DoDumpInit) {
	if (main_PrintInitRoutines) {
	    Mach_MonPrintf("Calling Dump_Init().\n");
	}
	Dump_Init();
    }

    /*
     * Initialize the timer, signal, process, scheduling and synchronization
     * modules' data structures.
     */
    if (main_PrintInitRoutines) {
	Mach_MonPrintf("Calling Proc_Init().\n");
    }
    Proc_Init();
    if (main_PrintInitRoutines) {
	Mach_MonPrintf("Calling Sync_LockStatInit().\n");
    }
    Sync_LockStatInit();
    if (main_PrintInitRoutines) {
	Mach_MonPrintf("Calling Timer_Init().\n");
    }
    Timer_Init();
    if (main_PrintInitRoutines) {
	Mach_MonPrintf("Calling Sig_Init().\n");
    }
    Sig_Init();
    if (main_PrintInitRoutines) {
	Mach_MonPrintf("Calling Sched_Init().\n");
    }
    Sched_Init();

    /*
     * Sys_Printfs are not allowed before this point.
     */  
    main_PanicOK++;
    printf("Sprite kernel: %s\n", SpriteVersion());

    /*
     * Set up bins for the memory allocator.
     */
    if (main_PrintInitRoutines) {
	Mach_MonPrintf("Calling Fs_Bin\n");
    }
    Fs_Bin();
    if (main_PrintInitRoutines) {
	Mach_MonPrintf("Calling Net_Bin\n");
    }
    Net_Bin();

    /*
     * Initialize virtual memory.  After this point must use the normal
     * memory allocator to allocate memory.  If you use Vm_BootAlloc then
     * will get a panic into the debugger.
     */
    if (main_PrintInitRoutines) {
	Mach_MonPrintf("Calling Vm_Init\n");
    }
    Vm_Init();

    /*
     * malloc can be called from this point on.
     */

    /*
     * Initialize the main process. Must be called before any new 
     * processes are created.
     * Dependencies: Proc_InitTable, Sched_Init, Vm_Init, Mem_Init
     */
    if (main_PrintInitRoutines) {
	Mach_MonPrintf("Calling Proc_InitMainProc\n");
    }
    Proc_InitMainProc();

    /*
     * Initialize the network and the routes.  It would be nice if we
     * could call Net_Init earlier so that we can use the debugger earlier
     * but we must call Vm_Init first.  VM could be changed so that we
     * could move the call earlier however.
     */
    if (main_PrintInitRoutines) {
	Mach_MonPrintf("Calling Net_Init\n");
    }
    Net_Init();
    if (main_PrintInitRoutines) {
	Mach_MonPrintf("Calling Net_RouteInit\n");
    }
    Net_RouteInit();

    /*
     * Enable server process manager.
     */
    if (main_PrintInitRoutines) {
	Mach_MonPrintf("Calling Proc_ServerInit\n");
    }
    Proc_ServerInit();

    /*
     * Initialize the recovery module.  Do before Rpc and after Vm_Init.
     */
    if (main_PrintInitRoutines) {
	Mach_MonPrintf("Calling Recov_Init\n");
    }
    Recov_Init();

    /*
     * Initialize the data structures for the Rpc system.  This uses
     * Vm_RawAlloc to so it must be called after Vm_Init.
     * Dependencies: Timer_Init, Vm_Init, Net_Init, Recov_Init
     */
    if (main_PrintInitRoutines) {
	Mach_MonPrintf("Calling Rpc_Init\n");
    }
    Rpc_Init();

    /*
     * Configure devices that may or may not exist.  This needs to be
     * done after Proc_InitMainProc because the initialization routines
     * use SetJump which uses the proc table entry for the main process.
     */
    if (main_PrintInitRoutines) {
	Mach_MonPrintf("Calling Dev_Config\n");
    }
    Dev_Config();

    /*
     * Initialize profiling after the timer and vm stuff is set up.
     * Dependencies: Timer_Init, Vm_Init
     */
    if (main_DoProf) {
	Prof_Init();
    }
    /*
     *  Allow interrupts from now on.
     */
    if (main_PrintInitRoutines) {
	Mach_MonPrintf("Enabling interrupts\n");
    }
    ENABLE_INTR();

    if (main_Debug) {
	DBG_CALL;
    }

    /*
     * Sleep for a few seconds to calibrate the idle time ticks.
     */
    Sched_TimeTicks();

    /*
     * Start profiling, if desired.
     */
    if (main_DoProf) {
        (void) Prof_Start();
    }

    /*
     * Do an initial RPC to get a boot timestamp.  This allows
     * servers to detect when we crash and reboot.  This will set the
     * system clock too, although rdate is usually done from user level later.
     */
    if (main_PrintInitRoutines) {
	Mach_MonPrintf("Call Rpc_Start\n");
    }
    Rpc_Start();

    /*
     * Initialize the file system. 
     */
    if (main_PrintInitRoutines) {
	Mach_MonPrintf("Call Fs_Init\n");
    }
    Fs_Init();

    /*
     * Before starting up any more processes get a current directory
     * for the main process.  Subsequent new procs will inherit it.
     */
    if (main_PrintInitRoutines) {
	Mach_MonPrintf("Call Fs_ProcInit\n");
    }
    Fs_ProcInit();
    if (main_PrintInitRoutines) {
	Mach_MonPrintf("Bunch of call funcs\n");
    }
    /*
     * Start the clock daemon and the routine that opens up the swap directory.
     */
    Proc_CallFunc(Vm_Clock, (ClientData) NIL, 0);
    Proc_CallFunc(Vm_OpenSwapDirectory, (ClientData) NIL, 0);

    /*
     * Start the process that synchronizes the filesystem caches
     * with the data kept on disk.
     */
    Proc_CallFunc(Fsutil_SyncProc, (ClientData) NIL, 0);

    /*
     * Create a few RPC server processes and the Rpc_Daemon process which
     * will create more server processes if needed.
     */
    if (main_NumRpcServers > 0) {
	for (i=0 ; i<main_NumRpcServers ; i++) {
	    (void) Rpc_CreateServer((int *) &pid);
	}
    }
    (void) Proc_NewProc((Address) Rpc_Daemon, PROC_KERNEL, FALSE, &pid,
	"Rpc_Daemon", FALSE);
    if (main_PrintInitRoutines) {
	Mach_MonPrintf("Creating Proc server procs\n");
    }

    /*
     * Create processes  to execute functions.
     */
    (void) Proc_ServerProcCreate(FSCACHE_MAX_CLEANER_PROCS + 
					VM_MAX_PAGE_OUT_PROCS);

    /*
     * Create a recovery process to monitor other hosts.  Can't use
     * Proc_CallFunc's to do this because they can be used up waiting
     * for page faults against down servers.  (Alternatively the VM
     * code could be fixed up to retry page faults later instead of
     * letting the Proc_ServerProc wait for recovery.)
     */
    (void) Proc_NewProc((Address) Recov_Proc, PROC_KERNEL, FALSE, &pid,
			"Recov_Proc", FALSE);

    /*
     * Set up process migration recovery management.
     */
    if (main_PrintInitRoutines) {
	Mach_MonPrintf("Calling Proc_MigInit\n");
    }
    Proc_MigInit();

    /*
     * Call the routine to start test kernel processes.
     */

    if (main_PrintInitRoutines) {
	Mach_MonPrintf("Calling Main_HookRoutine\n");
    }
    Main_HookRoutine();

    /*
     * Print out the amount of memory used.
     */
    printf("MEMORY %d bytes allocated for kernel\n", 
		vmMemEnd - mach_KernStart);

    /*
     * Start up the first user process.
     */
    if (main_PrintInitRoutines) {
	Mach_MonPrintf("Creating Init\n");
    }
    (void) Proc_NewProc((Address) Init, PROC_KERNEL, FALSE, &pid,
	                "Init", FALSE);

    (void) Sync_WaitTime(time_OneYear);
    printf("Main exiting\n");
    Proc_Exit(0);
}
Esempio n. 5
0
/*
 * @brief Setup fixture.
 */
void setup(void) {

	Mem_Init();

	Fs_Init(true);
}
Esempio n. 6
0
/**
 * @brief
 */
static void Init(void) {

	SDL_Init(SDL_INIT_TIMER);

	Mem_Init();

	Cmd_Init();

	Cvar_Init();

	verbose = Cvar_Add("verbose", "0", 0, "Print verbose debugging information");

	dedicated = Cvar_Add("dedicated", "0", CVAR_NO_SET, "Run a dedicated server");
	if (strstr(Sys_ExecutablePath(), "-dedicated")) {
		Cvar_ForceSet("dedicated", "1");
	}

	if (dedicated->value) {
		Cvar_ForceSet("threads", "0");
	}

	game = Cvar_Add("game", DEFAULT_GAME, CVAR_LATCH | CVAR_SERVER_INFO, "The game module name");
	game->modified = g_strcmp0(game->string, DEFAULT_GAME);

	threads = Cvar_Add("threads", "0", CVAR_ARCHIVE, "Specifies the number of threads to create");
	threads->modified = false;

	time_demo = Cvar_Add("time_demo", "0", CVAR_LO_ONLY, "Benchmark and stress test");
	time_scale = Cvar_Add("time_scale", "1.0", CVAR_LO_ONLY, "Controls time lapse");

	const char *s = va("Quetoo %s %s %s", VERSION, __DATE__, BUILD_HOST);
	Cvar_Add("version", s, CVAR_SERVER_INFO | CVAR_NO_SET, NULL);

	quetoo.Debug = Debug;
	quetoo.Error = Error;
	quetoo.Print = Print;
	quetoo.Verbose = Verbose;
	quetoo.Warn = Warn;

	Fs_Init(true);

	Thread_Init(threads->integer);

	Con_Init();

	Cmd_Add("mem_stats", MemStats_f, CMD_SYSTEM, "Print memory stats");
	Cmd_Add("debug", Debug_f, CMD_SYSTEM, "Control debugging output");
	Cmd_Add("quit", Quit_f, CMD_SYSTEM, "Quit Quetoo");

	Netchan_Init();

	Sv_Init();

	Cl_Init();

	Com_Print("Quetoo %s %s %s initialized\n", VERSION, __DATE__, BUILD_HOST);

	// reset debug value since Cbuf may change it from Com's "all" init
	Com_SetDebug("0");

	// execute any +commands specified on the command line
	Cbuf_InsertFromDefer();
	Cbuf_Execute();

	// dedicated server, nothing specified, use Edge
	if (dedicated->value && !Com_WasInit(QUETOO_SERVER)) {
		Cbuf_AddText("map edge\n");
		Cbuf_Execute();
	}
}
Esempio n. 7
0
/*
 * @brief Setup fixture.
 */
void setup(void) {

	Z_Init();

	Fs_Init(true);
}