コード例 #1
0
ファイル: Diagnostics.cs プロジェクト: willvin313/SharpOS
        public unsafe static void Warning(string msg)
        {
            TextMode.SaveAttributes();
            PString8 *buf = PString8.Wrap(intermediateStringBuffer, MaxMessageLength);

            SetWarningTextAttributes();

            buf->Concat("Warning: ");
            buf->Concat(msg);
            TextMode.WriteLine(buf);

            TextMode.RestoreAttributes();
        }
コード例 #2
0
        public static void Execute(CommandExecutionContext *context)
        {
            byte *rawbuf = stackalloc byte [EntryModule.MaxKeyMapNameLength];

            if (context->parameters->Compare("--list") == 0)
            {
                ListKeyMaps();
            }
            else if (context->parameters->Compare(0, "--set ", 0, 6) == 0 &&
                     context->parameters->Length > 6)
            {
                PString8 *buf = PString8.Wrap(rawbuf,
                                              EntryModule.MaxKeyMapNameLength);
                buf->Clear();
                TextMode.Write(context->parameters->Length);
                TextMode.WriteLine();
                buf->Concat(context->parameters, 6, context->parameters->Length - 6);

                if (KeyMap.GetBuiltinKeyMap(buf) == null)
                {
                    TextMode.SaveAttributes();
                    TextMode.Foreground = TextColor.Red;
                    TextMode.Write("Unknown keymap `");
                    TextMode.Write(buf);
                    TextMode.Write("'");
                    TextMode.RestoreAttributes();
                }
                else
                {
                    TextMode.Write("Setting key map to `");
                    TextMode.Write(buf);
                    TextMode.Write("'");
                    KeyMap.SetKeyMap(buf);
                }
            }
            else if (context->parameters->Length == 0)
            {
                TextMode.Write("Current key map: ");
                TextMode.WriteLine(KeyMap.GetCurrentKeyMapName());
            }
            else
            {
                TextMode.WriteLine("Usage: keymap [--list|--set NAME]");
            }
        }
コード例 #3
0
ファイル: Time.cs プロジェクト: willvin313/SharpOS
        public static void Execute(CommandExecutionContext *context)
        {
            SharpOS.Kernel.Foundation.Time time = new SharpOS.Kernel.Foundation.Time();
            byte *    rawbuf = stackalloc byte [50];
            PString8 *pstr   = PString8.Wrap(rawbuf, 50);

            if (context->parameters->Compare("--hw") == 0)
            {
                Clock.GetHardwareTime(time);
            }
            else
            {
                Clock.GetCurrentTime(time);
            }

            time.ToString(pstr);
            TextMode.WriteLine(pstr);
        }
コード例 #4
0
ファイル: Diagnostics.cs プロジェクト: willvin313/SharpOS
        /// <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();
        }
コード例 #5
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();
                }
            }
        }