internal static int Main() { bootReturnCode = Platform.EXIT_AND_RESTART; InitPreMonitoring(); try { InitServices(); // Consider boot successful at this stage. bootReturnCode = Platform.EXIT_AND_SHUTDOWN; ARM_SPIN_FOREVER("kernel.arm Spinning forever"); bootReturnCode = SpawnAndWaitForShell(); // The shell has exited when we get here FinalizeServices(); } catch (Exception e) { System.Console.WriteLine("EXCEPTION:: " + e.Message); Tracing.Log(Tracing.Fatal, "Caught exception {0}", e.Message); DebugStub.WriteLine("Caught {0}", __arglist(e.Message)); bootReturnCode = -1; DebugStub.Break(); } DebugStub.WriteLine("Kernel exiting with 0x{0:x4}", __arglist(bootReturnCode)); FinalizePreMonitoring(); if (bootReturnCode != Platform.EXIT_AND_WARMBOOT) { Kill(bootReturnCode); } return(bootReturnCode); }
public static void RestoreInterrupts(bool enabled) { int i = 0; try { #if CHECK_DISABLE_INTERRUPTS if (!InterruptsDisabled()) { DebugStub.Break(); } #endif i = 1; if (enabled) { i = 2; // Processor flag should be turned off before this call if (GetCurrentProcessor().InInterruptContext) { DebugStub.Break(); } i = 3; Isa.EnableInterrupts(); } i = 5; #if CHECK_DISABLE_INTERRUPTS if (enabled && InterruptsDisabled()) { DebugStub.Break(); } #endif } catch (Exception e) { DebugStub.Break(); } }
internal static void Shutdown(int exitCode) { unchecked { Tracing.Log(Tracing.Audit, "Kernel.Shutdown({0})", (UIntPtr)(uint)exitCode); } DebugStub.WriteLine("Kernel.Shutdown(0x{0:x4})", __arglist(exitCode)); DebugStub.Break(); VTable.Shutdown(exitCode); }
private static IoMemory GetSystemManifest() { IoMemory res = Binder.GetSystemManifest(); if (res == null) { DebugStub.WriteLine("Failed to load system manifest."); DebugStub.Break(); throw new Exception("The system manifest could not be loaded."); } return(res); }
internal static int MpMain(int cpu) { Tracing.Log(Tracing.Audit, "processor"); Processor processor = Processor.EnableProcessor(cpu); // Initialize dispatcher Processor.InitializeDispatcher(cpu); // Initialize the HAL processor services // Note that this must occur after EnableProcessor, as the kernel // thread does not get bound until then. (It gets bound much // earlier in the boot processor case -- need to decide if this difference is // really appropriate.) Platform.Cpu(cpu).InitializeServices(); Platform.InitializeHal(processor); Thread.CurrentThread.Affinity = cpu; Processor.ActivateTimer(cpu); #if DEBUG_SYSTEM_LOCKUP // Spin one CPU on debugger. For instance with a quad-proc // box, spin CPU 3. while (cpu == 3) { if (DebugStub.PollForBreak() == true) { DebugStub.Break(); } } #endif // DEBUG_SYSTEM_LOCKUP Processor.RestoreInterrupts(true); Tracing.Log(Tracing.Audit, "Looping in processor's kernel thread."); //while (cpu > 0) { // Thread.Yield(); //} // This probably won't be the // ultimate way of dissociating kernel entry threads // from the kernel. DebugStub.Print("AP Processor started, about to wait\n"); mpEndEvent.WaitOne(); return(0); }
public static bool DisableInterrupts() { #if CHECK_DISABLE_INTERRUPTS bool wasDisabled = InterruptsDisabled(); #endif bool result = Isa.DisableInterrupts(); #if CHECK_DISABLE_INTERRUPTS if (result && wasDisabled) { DebugStub.Break(); } #endif return(result); }
private static int DetermineShutdown(int exit) { switch (exit) { case -10000: Tracing.Log(Tracing.Audit, "Failed to start shell process."); return(Platform.EXIT_AND_RESTART); case Platform.EXIT_AND_WARMBOOT: case Platform.EXIT_AND_RESTART: case Platform.EXIT_AND_SHUTDOWN: return(exit); default: DebugStub.WriteLine("Shell process terminated improperly (0x{0:x4})", __arglist(exit)); Tracing.Log(Tracing.Audit, "Shell process terminated improperly"); DebugStub.Break(); return(Platform.EXIT_AND_SHUTDOWN); } }
public void Uninitialize(int processorId) { Tracing.Log(Tracing.Debug, "UnInitializing Processor {0}", (UIntPtr)processorId); Interlocked.Decrement(ref runningCpus); // #if DEBUG // Interrupts should be off now if (!InterruptsDisabled()) { DebugStub.WriteLine("Processor::Uninitialize AP Processor does not have interrupts disabled\n"); DebugStub.Break(); } // #endif // DBG // Processor is out of commission HaltUntilInterrupt(); // #if DEBUG DebugStub.WriteLine("Processor::Uninitialize: AP processor woke up on shutdown!\n"); DebugStub.Break(); // #endif // DBG }