Exemple #1
0
        /// <summary>
        /// Induce a kernel panic. Prints the meessage, stage, and error code
        /// then halts the computer.
        /// <summary>
        public unsafe static void Panic(string msg, KernelStage stage, KernelError code)
        {
            TextMode.Write("Panic: ");
            TextMode.WriteLine(msg);
#if false
            PString8 *buf = PString8.Wrap(intermediateStringBuffer, MaxMessageLength);

            buf->Concat("Stage: ");
            buf->Concat((int)stage, false);
            buf->ConcatLine();

            buf->Concat("  Error: ");
            buf->Concat((int)code, false);
            buf->ConcatLine();

            TextMode.SaveAttributes();
            SetErrorTextAttributes();
            TextMode.ClearScreen();
            TextMode.WriteLine("SharpOS");
            TextMode.WriteLine("Kernel Panic. Your system was halted to ensure your security.");
            TextMode.Write("  Stage: ");
            TextMode.Write((int)stage, false);
            TextMode.WriteLine();
            TextMode.Write("  Error: ");
            TextMode.Write((int)code, false);
            TextMode.WriteLine();

            TextMode.WriteLine();
            TextMode.WriteLine("              ,  ");
            TextMode.WriteLine("      |\\   /\\/ \\/|   ,_");
            TextMode.WriteLine("      ; \\/`     '; , \\_',");
            TextMode.WriteLine("       \\        / ");
            TextMode.WriteLine("        '.    .'    /`.");
            TextMode.WriteLine("    jgs   `~~` , /\\ `\"`");
            TextMode.WriteLine("              .  `\"");

            TextMode.WriteLine();
            TextMode.WriteLine("The SharpOS Project would appreciate your feedback on this bug.");

            TextMode.RestoreAttributes();
#endif
            EntryModule.Halt();
        }
Exemple #2
0
        public unsafe static void BootEntry(uint magic, uint pointer, uint kernelStart, uint kernelEnd)
        {
            // Initialize architecture-specific portion of the kernel
            Architecture.Setup();

            // Set up text mode display
            TextMode.Setup();

            TextMode.SetAttributes(TextColor.Yellow, TextColor.Black);
            TextMode.ClearScreen();
            TextMode.SetCursor(0, 0);

            // Write the banner
            DisplayBanner();

            StageMessage("Multiboot setup...");
            if (!Multiboot.Setup(magic, pointer, kernelStart, kernelEnd))
            {
                StageError("Error: multiboot loader required!");
                return;
            }

            kernelStartLoc = (void *)kernelStart;
            kernelEndLoc   = (void *)kernelEnd;

            StageMessage("Commandline setup...");
            CommandLine.Setup();

            StageMessage("PageAllocator setup...");
            PageAllocator.Setup(
                Multiboot.KernelAddress,
                Multiboot.KernelSize,
                Multiboot.UpperMemorySize + 1000);

            StageMessage("MemoryManager setup...");
            ADC.MemoryManager.Setup();

            StageMessage("Debug setup...");
            Debug.Setup();

            // Must be done after MemoryManager setup.
            StageMessage("Runtime setup...");
            ExceptionHandling.Setup();

            StageMessage("Event Dispatch setup...");
            SimpleEventDispatch.Setup();

            StageMessage("Device setup...");
            DeviceSystem.Boot.Start();
            Debug.Setup2();

            StageMessage("Diagnostic Tool setup...");
            DiagnosticTool.Server.Setup();

            StageMessage("Scheduler setup...");
            ThreadManager.Setup();

            StageMessage("File System setup...");
            FileSystem.Boot.Start();

            //StageMessage ("Clock setup...");
            Clock.Setup();

            StageMessage("Keymap setup...");
            KeyMap.Setup();

            StageMessage("Keyboard setup...");
            Keyboard.Setup();

            StageMessage("Console setup...");
            SharpOS.Kernel.Console.Setup();

            TextMode.SaveAttributes();
            TextMode.SetAttributes(TextColor.LightGreen, TextColor.Black);
            TextMode.WriteLine("");
            TextMode.WriteLine("Pinky: What are we gonna do tonight, Brain?");
            TextMode.WriteLine("The Brain: The same thing we do every night, Pinky - Try to take over the world!");
            TextMode.RestoreAttributes();

            //SharpOS.Kernel.Memory.PageAllocator.DumpInfo ();

#if KERNEL_TESTS
            // Testcases
            MemoryManager.__RunTests();
            ByteString.__RunTests();
            StringBuilder.__RunTests();
            CString8.__RunTests();
            PString8.__RunTests();
            InternalSystem.String.__RunTests();
            Runtime.__RunTests();
            Debug.COM1.WriteLine("Failed AOT Tests:");
            //SharpOS.Kernel.Tests.Wrapper.Run ();
            Debug.COM1.WriteLine();
            Debug.COM1.WriteLine("Kernel Tests:");
#endif

            /*
             * void* thread = ThreadManager.CreateThread(Stubs.GetFunctionPointer ("TEST"));
             * void* thread2 = ThreadManager.CreateThread(Stubs.GetFunctionPointer ("TEST2"));
             *
             * ThreadManager.ScheduleThread(thread);
             * ThreadManager.ScheduleThread(thread2);
             * ThreadManager.Enabled = true;
             */

            //Multiboot.WriteMultibootInfo();

            StageMessage("Shell setup...");
            SharpOS.Kernel.Shell.Prompter.Setup();
            SharpOS.Kernel.Shell.Prompter.Start();

            SetKernelStage(KernelStage.Diagnostics);

            // Infinite loop used to halt the processors
            //FIXME We must know on each processor the current thread runs on.
            //      Halt all other procs, then halt the current one.
            IProcessor[] procs     = Architecture.GetProcessors();
            int          procCount = Architecture.GetProcessorCount();
            while (stayInLoop)
            {
                for (int i = 0; i < procCount; i++)
                {
                    procs[i].Halt();
                }
            }
        }