Exemplo n.º 1
0
 public static void FillLine()
 {
     for (uint c = 80 - Console.Column; c != 0; c--)
     {
         Console.Write(' ');
     }
 }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        public static void RunTests()
        {
            Console = Boot.Console;

            Console.Goto(2, 0);
            Console.Color = Color.Yellow;
            Console.Write("[");
            Console.Color = Color.White;
            Console.Write("Tests");
            Console.Color = Color.Yellow;
            Console.Write("]");
            Console.WriteLine();
            Console.WriteLine();
            Console.Color = Color.Yellow;

            var delegateTest   = new DelegateTest();
            var stringTest     = new StringTest();
            var interfaceTest  = new InterfaceTest();
            var genericsTest   = new GenericTest();
            var generics2Test  = new Generic2Test();
            var isInstanceTest = new IsInstanceTest();
            var exceptionTest  = new ExceptionTest();
            var plugTestTest   = new PlugTestTest();
            var compareTest    = new ComparisonTest();
            var simpleTest     = new OptimizationTest();
            var reflectionTest = new ReflectionTest();
            var arrayTest      = new ArrayTest();
            var int64Test      = new Int64Test();
            var otherTest      = new OtherTest();

            int64Test.Test();
            delegateTest.Test();
            stringTest.Test();
            interfaceTest.Test();
            genericsTest.Test();
            generics2Test.Test();
            isInstanceTest.Test();
            exceptionTest.Test();
            plugTestTest.Test();
            compareTest.Test();
            simpleTest.Test();

            reflectionTest.Test();
            arrayTest.Test();
            otherTest.Test();
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="flag"></param>
        public void PrintResult(bool flag)
        {
            byte color = Console.Color;

            if (flag)
            {
                Console.Color = Color.White;
                Console.Write("+");
            }
            else
            {
                Console.Color = Color.Red;
                Console.Write("X");
            }

            Console.Color = color;
        }
Exemplo n.º 4
0
        private static void UpdateThreadTicks(uint thread, uint ticks)
        {
            ++totalticks;

            if (totalticks % 10000 == 0)
            {
                lock (spinlock)
                {
                    Console.Goto(0, 14 + (thread * 13));
                    Console.Write("T" + thread.ToString() + ":" + ticks.ToString());
                }

                //Native.Hlt();
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Main
        /// </summary>
        unsafe public static void Main()
        {
            Kernel.x86.Kernel.Setup();

            Console = ConsoleManager.Controller.Boot;
            Debug   = ConsoleManager.Controller.Boot;

            Console.Clear();

            Console.ScrollRow = 23;

            IDT.SetInterruptHandler(ProcessInterrupt);

            Console.Color           = Colors.White;
            Console.BackgroundColor = Colors.Green;

            Console.Write(@"                   MOSA OS Version 1.4 - Compiler Version 1.4");
            FillLine();
            Console.Color           = Colors.White;
            Console.BackgroundColor = Colors.Black;

            Console.WriteLine("> Initializing hardware abstraction layer...");
            Setup.Initialize();

            Console.WriteLine("> Adding hardware devices...");
            Setup.Start();

            Console.Color = Colors.White;
            Console.WriteLine();

            Debug = ConsoleManager.Controller.Debug;

            // setup keymap
            var keymap = new US();

            // setup keyboard (state machine)
            var keyboard = new Mosa.DeviceSystem.Keyboard(Setup.StandardKeyboard, keymap);

            // setup app manager
            var manager = new AppManager(Console, keyboard);

            IDT.SetInterruptHandler(manager.ProcessInterrupt);

            manager.Start();
        }
Exemplo n.º 6
0
        public void ProcessInterrupt(uint interrupt, uint errorCode)
        {
            tick++;

            uint column     = debug.Column;
            uint row        = debug.Row;
            var  color      = debug.Color;
            var  background = debug.BackgroundColor;
            uint scrollrow  = debug.ScrollRow;

            debug.Color           = ScreenColor.Cyan;
            debug.BackgroundColor = ScreenColor.Black;
            debug.Row             = 24;
            debug.Column          = 0;
            debug.ScrollRow       = debug.Rows;

            debug.Write("Shell Mode - ");
            debug.Write("Tick: ");
            debug.Write(tick, 10, 7);
            debug.Write(" Free Memory: ");
            debug.Write((PageFrameAllocator.TotalPages - PageFrameAllocator.TotalPagesInUse) * PageFrameAllocator.PageSize / (1024 * 1024));
            debug.Write(" MB ");

            debug.Write("IRQ: ");
            debug.Write(interrupt, 16, 2);

            if (interrupt >= 0x20 && interrupt < 0x30)
            {
                HAL.ProcessInterrupt((byte)(interrupt - 0x20));
            }

            debug.BackgroundColor = background;
            debug.ScrollRow       = scrollrow;
            debug.Column          = column;
            debug.Color           = color;
            debug.Row             = row;

            if (interrupt == 0x21)
            {
                CheckForKeyPress();
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Main
        /// </summary>
        unsafe public static void Main()
        {
            Mosa.Kernel.x86.Kernel.Setup();

            Console = ConsoleManager.Controller.Boot;
            Console.Clear();

            IDT.SetInterruptHandler(ProcessInterrupt);

            Console.Color           = Colors.White;
            Console.BackgroundColor = Colors.Green;

            Console.Write(@"                   MOSA OS Version 1.4 - Compiler Version 1.4");
            FillLine();
            Console.Color           = Colors.White;
            Console.BackgroundColor = Colors.Black;

            if (SmbiosManager.IsAvailable)
            {
                BiosInformationStructure biosInfo = new BiosInformationStructure();
                CpuStructure             cpuInfo  = new CpuStructure();

                Console.WriteLine("> Checking BIOS...");
                BulletPoint(); Console.Write("Vendor  "); InBrackets(biosInfo.BiosVendor, Colors.White, Colors.LightBlue); Console.WriteLine();
                BulletPoint(); Console.Write("Version "); InBrackets(biosInfo.BiosVersion, Colors.White, Colors.LightBlue); Console.WriteLine();

                Console.WriteLine("> Checking CPU...");
                BulletPoint(); Console.Write("Vendor  "); InBrackets(cpuInfo.Vendor, Colors.White, Colors.LightBlue); Console.WriteLine();
                BulletPoint(); Console.Write("Version "); InBrackets(cpuInfo.Version, Colors.White, Colors.LightBlue); Console.WriteLine();
            }
            else
            {
                Console.WriteLine("> No SMBIOS available!");
            }

            Console.WriteLine("> Initializing hardware abstraction layer...");
            Setup.Initialize();

            Console.WriteLine("> Adding hardware devices...");
            Setup.Start();

            Console.WriteLine("> System ready");
            Console.WriteLine();
            Console.Goto(24, 0);
            Console.Color           = Colors.White;
            Console.BackgroundColor = Colors.Green;
            Console.Write("          Copyright (C) 2008-2015 [Managed Operating System Alliance]");
            FillLine();

            Process();
        }
Exemplo n.º 8
0
        public void ProcessInterrupt(uint interrupt, uint errorCode)
        {
            uint c    = debug.Column;
            uint r    = debug.Row;
            byte col  = debug.Color;
            byte back = debug.BackgroundColor;
            uint sr   = debug.ScrollRow;

            debug.Color           = Kernel.x86.Color.Cyan;
            debug.BackgroundColor = Kernel.x86.Color.Black;
            debug.Row             = 24;
            debug.Column          = 0;
            debug.ScrollRow       = debug.Rows;

            tick++;
            debug.Write("Shell Mode - ");
            debug.Write("Tick: ");
            debug.Write(tick, 10, 7);
            debug.Write(" Free Memory: ");
            debug.Write((PageFrameAllocator.TotalPages - PageFrameAllocator.TotalPagesInUse) * PageFrameAllocator.PageSize / (1024 * 1024));
            debug.Write(" MB    ");

            if (interrupt >= 0x20 && interrupt < 0x30)
            {
                Mosa.HardwareSystem.HAL.ProcessInterrupt((byte)(interrupt - 0x20));
            }

            debug.Column          = c;
            debug.Row             = r;
            debug.Color           = col;
            debug.BackgroundColor = back;
            debug.ScrollRow       = sr;

            if (interrupt == 0x20)
            {
                Poll();
            }
        }
Exemplo n.º 9
0
        public static void Start()
        {
            Screen.Color = 0x0;
            Screen.Clear();
            Screen.GotoTop();
            Screen.Color = 0x0E;
            Screen.Write('M');
            Screen.Write('O');
            Screen.Write('S');
            Screen.Write('A');
            Screen.Write(' ');
            Screen.Write('O');
            Screen.Write('S');
            Screen.Write("!");
            Screen.Write(" ");

            DebugClient.Setup(Serial.COM1);
            Screen.Write('0');
            IDT.SetInterruptHandler(null);
            Screen.Write('1');
            Multiboot.Setup();
            Screen.Write('2');
            PIC.Setup();
            Screen.Write('3');
            GDT.Setup();
            Screen.Write('4');
            IDT.Setup();
            Screen.Write('5');
            PageFrameAllocator.Setup();
            Screen.Write('6');
            PageTable.Setup();
            Screen.Write('7');
            VirtualPageAllocator.Setup();
            Screen.Write('8');
            ProcessManager.Setup();
            Screen.Write('9');
            GC.Setup();
            Screen.Write('0');

            //Runtime.Setup();
            Screen.Write('A');
            TaskManager.Setup();
            Screen.Write('B');
            IDT.SetInterruptHandler(ProcessInterrupt);
            Screen.Write('C');
            ConsoleManager.Setup();
            Screen.Write('D');
            Console = ConsoleManager.Controller.Boot;
            Screen.Write('E');
            Screen.Write('F');

            Console.Color           = 0x0E;
            Console.BackgroundColor = 1;
            Console.WriteLine();
            Console.WriteLine();
            Console.Write("!MOSA is alive!");

            Console.WriteLine();

            KernelTest.RunTests();

            Console.WriteLine();

            DumpStackTrace();

            //System.Threading.SpinLock splk = new System.Threading.SpinLock();

            //bool lockTaken = false;
            //splk.Enter(ref lockTaken);
            //if (splk.IsHeld)
            //	Console.Write("Entered...");

            //lockTaken = false;
            //splk.Enter(ref lockTaken);

            //Console.Write("Should have looped!!!");

            Console.Goto(22, 0);

            Process();
        }
Exemplo n.º 10
0
        public unsafe static void DumpStackTrace()
        {
            uint depth = 0;

            while (true)
            {
                var methodDef = Runtime.GetMethodDefinitionFromStackFrameDepth(depth);

                if (methodDef == null)
                {
                    return;
                }

                Debug.Assert(methodDef != null, "methodDef == null");

                string caller = Runtime.GetMethodDefinitionName(methodDef);

                if (caller == null)
                {
                    return;
                }

                Console.Write(depth, 10, 2);
                Console.Write(":");
                Console.WriteLine(caller);

                depth++;
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Displays the seconds.
        /// </summary>
        private static void DisplayCMOS()
        {
            Console.Row    = 2;
            Console.Column = 65;
            Console.Color  = 0x0A;
            Console.Write("CMOS:");
            Console.WriteLine();
            Console.Color = 0x0F;

            byte i = 0;

            for (byte x = 0; x < 5; x++)
            {
                Console.Column = 65;
                for (byte y = 0; y < 4; y++)
                {
                    Console.Write(CMOS.Get(i), 16, 2);
                    Console.Write(' ');
                    i++;
                }
                Console.WriteLine();
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Main
        /// </summary>
        public static void Main()
        {
            Mosa.Kernel.x86.Kernel.Setup();

            Console = ConsoleManager.Controller.Boot;

            Console.Clear();

            IDT.SetInterruptHandler(ProcessInterrupt);

            Console.Color = Colors.White;

            Console.Goto(0, 0);

            Console.Color           = Colors.Yellow;
            Console.BackgroundColor = Colors.Black;

            Console.Write("MOSA OS Version 1.4 '");
            Console.Color = Colors.Red;
            Console.Write("Neptune");
            Console.Color = Colors.Yellow;
            Console.Write("'                                Copyright 2008-2015");

            Console.Color = 0x0F;
            Console.Write(new String((char)205, 60));
            Console.Write((char)203);
            Console.Write(new String((char)205, 19));
            Console.WriteLine();

            Console.Goto(2, 0);
            Console.Color = Colors.Green;
            Console.Write("Multibootaddress: ");
            Console.Color = Colors.Gray;
            unsafe
            {
                Console.Write((uint)Multiboot.MultiBootInfo, 16, 8);
            }

            Console.WriteLine();
            Console.Color = Colors.Green;
            Console.Write("Multiboot-Flags:  ");
            Console.Color = Colors.Gray;
            Console.Write(Multiboot.Flags, 2, 32);
            Console.WriteLine();
            Console.WriteLine();

            Console.Color = Colors.Green;
            Console.Write("Size of Memory:   ");
            Console.Color = Colors.Gray;
            Console.Write((Multiboot.MemoryLower + Multiboot.MemoryUpper) / 1024, 10, -1);
            Console.Write(" MB (");
            Console.Write(Multiboot.MemoryLower + Multiboot.MemoryUpper, 10, -1);
            Console.Write(" KB)");
            Console.WriteLine();

            Console.Color = Colors.White;
            for (uint index = 0; index < 60; index++)
            {
                Console.Write((char)205);
            }

            Console.WriteLine();

            Console.Color = Colors.Green;
            Console.Write("Memory-Map:");
            Console.WriteLine();

            for (uint index = 0; index < Multiboot.MemoryMapCount; index++)
            {
                Console.Color = Colors.White;
                Console.Write(Multiboot.GetMemoryMapBase(index), 16, 10);
                Console.Write(" - ");
                Console.Write(Multiboot.GetMemoryMapBase(index) + Multiboot.GetMemoryMapLength(index) - 1, 16, 10);
                Console.Write(" (");
                Console.Color = Colors.Gray;
                Console.Write(Multiboot.GetMemoryMapLength(index), 16, 10);
                Console.Color = Colors.White;
                Console.Write(") ");
                Console.Color = Colors.Gray;
                Console.Write("Type: ");
                Console.Write(Multiboot.GetMemoryMapType(index), 16, 1);
                Console.WriteLine();
            }
            Console.WriteLine();
            Console.WriteLine();
            Console.Color = Colors.Green;
            Console.Write("Smbios Info: ");
            if (SmbiosManager.IsAvailable)
            {
                Console.Color = Colors.White;
                Console.Write("[");
                Console.Color = Colors.Gray;
                Console.Write("Version ");
                Console.Write(SmbiosManager.MajorVersion, 10, -1);
                Console.Write(".");
                Console.Write(SmbiosManager.MinorVersion, 10, -1);
                Console.Color = Colors.White;
                Console.Write("]");
                Console.WriteLine();

                Console.Color = Colors.Yellow;
                Console.Write("[Bios]");
                Console.Color = Colors.White;
                Console.WriteLine();

                BiosInformationStructure biosInformation = new BiosInformationStructure();
                Console.Color = Colors.White;
                Console.Write("Vendor: ");
                Console.Color = Colors.Gray;
                Console.Write(biosInformation.BiosVendor);
                Console.WriteLine();
                Console.Color = Colors.White;
                Console.Write("Version: ");
                Console.Color = Colors.Gray;
                Console.Write(biosInformation.BiosVersion);
                Console.WriteLine();
                Console.Color = Colors.White;
                Console.Write("Date: ");
                Console.Color = Colors.Gray;
                Console.Write(biosInformation.BiosDate);

                Console.Color  = Colors.Yellow;
                Console.Row    = 8;
                Console.Column = 35;
                Console.Write("[Cpu]");
                Console.Color = Colors.White;
                Console.WriteLine();
                Console.Column = 35;

                CpuStructure cpuStructure = new CpuStructure();
                Console.Color = Colors.White;
                Console.Write("Vendor: ");
                Console.Color = Colors.Gray;
                Console.Write(cpuStructure.Vendor);
                Console.WriteLine();
                Console.Column = 35;
                Console.Color  = Colors.White;
                Console.Write("Version: ");
                Console.Color = Colors.Gray;
                Console.Write(cpuStructure.Version);
                Console.WriteLine();
                Console.Column = 35;
                Console.Color  = Colors.White;
                Console.Write("Socket: ");
                Console.Color = Colors.Gray;
                Console.Write(cpuStructure.Socket);
                Console.Write(" MHz");
                Console.WriteLine();
                Console.Column = 35;
                Console.Color  = Colors.White;
                Console.Write("Cur. Speed: ");
                Console.Color = Colors.Gray;
                Console.Write(cpuStructure.MaxSpeed, 10, -1);
                Console.Write(" MHz");
                Console.WriteLine();
                Console.Column = 35;
            }
            else
            {
                Console.Color = Colors.Red;
                Console.Write("No SMBIOS available on this system!");
            }

            Console.Goto(14, 0);

            Console.Color = 0x0F;
            for (uint index = 0; index < 60; index++)
            {
                Console.Write((char)205);
            }

            Console.WriteLine();

            //CpuInfo cpuInfo = new CpuInfo();

            //#region Vendor

            //Console.Color = Colors.Green;
            //Console.Write("Vendor:   ");
            //Console.Color = Colors.White;

            //cpuInfo.PrintVendorString(Console);

            //Console.WriteLine();

            //#endregion Vendor

            //#region Brand

            //Console.Color = Colors.Green;
            //Console.Write("Brand:    ");
            //Console.Color = Colors.White;
            //cpuInfo.PrintBrandString(Console);
            //Console.WriteLine();

            //#endregion Brand

            //#region Stepping

            //Console.Color = Colors.Green;
            //Console.Write("Stepping: ");
            //Console.Color = Colors.White;
            //Console.Write(cpuInfo.Stepping, 16, 2);

            //#endregion Stepping

            //#region Model

            //Console.Color = Colors.Green;
            //Console.Write(" Model: ");
            //Console.Color = Colors.White;
            //Console.Write(cpuInfo.Model, 16, 2);

            //#endregion Model

            //#region Family

            //Console.Color = Colors.Green;
            //Console.Write(" Family: ");
            //Console.Color = Colors.White;
            //Console.Write(cpuInfo.Family, 16, 2);

            //#endregion Family

            //#region Type

            //Console.Color = Colors.Green;
            //Console.Write(" Type: ");
            //Console.Color = Colors.White;

            //Console.Write(cpuInfo.Type, 16, 2);
            //Console.WriteLine();
            //Console.Color = Colors.Green;
            //Console.Write("Cores:    ");
            //Console.Color = Colors.White;
            //Console.Write(cpuInfo.NumberOfCores, 16, 2);

            //#endregion Type

            Console.Row = 19;
            for (uint index = 0; index < 80; index++)
            {
                Console.Column = index;
                Console.Write((char)205);
            }

            Console.Row = 23;
            for (uint index = 0; index < 80; index++)
            {
                Console.Column = index;
                Console.Write((char)205);
            }

            for (uint index = 2; index < 20; index++)
            {
                Console.Column = 60;
                Console.Row    = index;

                Console.Color = Colors.White;
                if (index == 6)
                {
                    Console.Write((char)185);
                }
                else if (index == 14)
                {
                    Console.Write((char)185);
                }
                else if (index == 19)
                {
                    Console.Write((char)202);
                }
                else
                {
                    Console.Write((char)186);
                }
            }

            Console.Goto(24, 29);
            Console.Color = Colors.Yellow;

            Console.Write("www.mosa-project.org");

            Console.Goto(12, 0);

            byte last = 0;

            while (true)
            {
                DisplayCMOS();
                DisplayTime();

                byte second = CMOS.Second;

                if (second % 10 != 5 & last != second)
                {
                    last = CMOS.Second;
                    DebugClient.SendAlive();
                }

                Native.Hlt();
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Main
        /// </summary>
        public static void Main()
        {
            Kernel.x86.Kernel.Setup();

            Console = ConsoleManager.Controller.Boot;

            Console.Clear();
            Console.Goto(0, 0);

            IDT.SetInterruptHandler(ProcessInterrupt);

            Console.ScrollRow       = 25;
            Console.Color           = ScreenColor.Yellow;
            Console.BackgroundColor = ScreenColor.Black;

            Console.Write("MOSA OS Version 1.4 '");
            Console.Color = ScreenColor.Red;
            Console.Write("Neptune");
            Console.Color = ScreenColor.Yellow;
            Console.Write("'                                Copyright 2008-2018");

            Console.Color = ScreenColor.White;
            Console.Write(new String((char)205, 60));
            Console.Write((char)203);
            Console.Write(new String((char)205, 19));
            Console.WriteLine();

            Console.Goto(2, 0);
            Console.Color = ScreenColor.Green;
            Console.Write("Multibootaddress: ");
            Console.Color = ScreenColor.Gray;
            Console.Write(Multiboot.MultibootAddress, 16, 8);

            Console.WriteLine();
            Console.Color = ScreenColor.Green;
            Console.Write("Multiboot-Flags:  ");
            Console.Color = ScreenColor.Gray;
            Console.Write(Multiboot.Flags, 2, 32);
            Console.WriteLine();

            Console.Color = ScreenColor.Green;
            Console.Write("Size of Memory:   ");
            Console.Color = ScreenColor.Gray;
            Console.Write((Multiboot.MemoryLower + Multiboot.MemoryUpper) / 1024, 10, -1);
            Console.Write(" MB (");
            Console.Write(Multiboot.MemoryLower + Multiboot.MemoryUpper, 10, -1);
            Console.Write(" KB)");
            Console.WriteLine();
            Console.WriteLine();

            Console.WriteLine();
            Console.Color = ScreenColor.Green;
            Console.Write("Smbios Info: ");

            if (SmbiosManager.IsAvailable)
            {
                Console.Color = ScreenColor.White;
                Console.Write("[");
                Console.Color = ScreenColor.Gray;
                Console.Write("Version ");
                Console.Write(SmbiosManager.MajorVersion, 10, -1);
                Console.Write(".");
                Console.Write(SmbiosManager.MinorVersion, 10, -1);
                Console.Color = ScreenColor.White;
                Console.Write("]");
                Console.WriteLine();

                Console.Color = ScreenColor.Yellow;
                Console.Write("[Bios]");
                Console.Color = ScreenColor.White;
                Console.WriteLine();

                var biosInformation = new BiosInformationStructure();
                Console.Color = ScreenColor.White;
                Console.Write("Vendor: ");
                Console.Color = ScreenColor.Gray;
                Console.Write(biosInformation.BiosVendor);
                Console.WriteLine();
                Console.Color = ScreenColor.White;
                Console.Write("Version: ");
                Console.Color = ScreenColor.Gray;
                Console.Write(biosInformation.BiosVersion);
                Console.WriteLine();
                Console.Color = ScreenColor.White;
                Console.Write("Date: ");
                Console.Color = ScreenColor.Gray;
                Console.Write(biosInformation.BiosDate);

                Console.Color  = ScreenColor.Yellow;
                Console.Row    = 8;
                Console.Column = 35;
                Console.Write("[Cpu]");
                Console.Color = ScreenColor.White;
                Console.WriteLine();
                Console.Column = 35;

                var cpuStructure = new CpuStructure();
                Console.Color = ScreenColor.White;
                Console.Write("Vendor: ");
                Console.Color = ScreenColor.Gray;
                Console.Write(cpuStructure.Vendor);
                Console.WriteLine();
                Console.Column = 35;
                Console.Color  = ScreenColor.White;
                Console.Write("Version: ");
                Console.Color = ScreenColor.Gray;
                Console.Write(cpuStructure.Version);
                Console.WriteLine();
                Console.Column = 35;
                Console.Color  = ScreenColor.White;
                Console.Write("Socket: ");
                Console.Color = ScreenColor.Gray;
                Console.Write(cpuStructure.Socket);
                Console.Write(" MHz");
                Console.WriteLine();
                Console.Column = 35;
                Console.Color  = ScreenColor.White;
                Console.Write("Cur. Speed: ");
                Console.Color = ScreenColor.Gray;
                Console.Write(cpuStructure.MaxSpeed, 10, -1);
                Console.Write(" MHz");
                Console.WriteLine();
                Console.Column = 35;
            }
            else
            {
                Console.Color = ScreenColor.Red;
                Console.Write("No SMBIOS available on this system!");
            }

            Console.WriteLine();
            Console.WriteLine();

            Console.Color = ScreenColor.Green;
            Console.Write("Memory-Map:");
            Console.WriteLine();

            for (uint index = 0; index < Multiboot.MemoryMapCount; index++)
            {
                Console.Color = ScreenColor.White;
                Console.Write(Multiboot.GetMemoryMapBase(index), 16, 8);
                Console.Write(" - ");
                Console.Write(Multiboot.GetMemoryMapBase(index) + Multiboot.GetMemoryMapLength(index) - 1, 16, 8);
                Console.Write(" (");
                Console.Color = ScreenColor.Gray;
                Console.Write(Multiboot.GetMemoryMapLength(index), 16, 8);
                Console.Color = ScreenColor.White;
                Console.Write(") ");
                Console.Color = ScreenColor.Gray;
                Console.Write("Type: ");
                Console.Write(Multiboot.GetMemoryMapType(index), 16, 1);
                Console.WriteLine();
            }

            Console.Color = ScreenColor.Yellow;
            Console.Goto(24, 29);
            Console.Write("www.mosa-project.org");

            // Borders

            Console.Color = ScreenColor.White;

            for (uint index = 0; index < 60; index++)
            {
                Console.Goto(14, index);
                Console.Write((char)205);
            }

            for (uint index = 0; index < 60; index++)
            {
                Console.Goto(6, index);
                Console.Write((char)205);
            }

            for (uint index = 60; index < 80; index++)
            {
                Console.Goto(19, index);
                Console.Write((char)205);
            }

            for (uint index = 0; index < 80; index++)
            {
                Console.Goto(23, index);
                Console.Write((char)205);
            }

            for (uint index = 2; index < 20; index++)
            {
                Console.Goto(index, 60);
                if (index == 6)
                {
                    Console.Write((char)185);
                }
                else if (index == 14)
                {
                    Console.Write((char)185);
                }
                else if (index == 19)
                {
                    Console.Write((char)200);
                }
                else
                {
                    Console.Write((char)186);
                }
            }

            Console.Goto(12, 0);

            while (true)
            {
                DisplayCMOS();
                DisplayTime();

                Native.Hlt();
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Main
        /// </summary>
        public static void Main()
        {
            Kernel.x86.Kernel.Setup();

            Console = ConsoleManager.Controller.Boot;

            Console.Clear();
            Console.Goto(0, 0);

            //IDT.SetInterruptHandler(ProcessInterrupt);

            Console.ScrollRow       = 23;
            Console.Color           = ScreenColor.White;
            Console.BackgroundColor = ScreenColor.Green;

            Debug = ConsoleManager.Controller.Boot;

            Console.Write("                   MOSA OS Version 1.5 - Compiler Version 1.5");
            FillLine();
            Console.Color           = ScreenColor.White;
            Console.BackgroundColor = ScreenColor.Black;

            Console.WriteLine("> Initializing hardware abstraction layer...");
            var hardware = new HAL.Hardware();

            var DeviceManager = Setup.Initialize(PlatformArchitecture.X86, hardware);

            Console.WriteLine("> Registering device drivers...");
            DeviceDriver.Setup.Register(DeviceManager);

            Console.WriteLine("> Starting devices...");
            DeviceDriver.Setup.Start(DeviceManager);

            Console.Write("> Probing for ISA devices...");
            var isaDevices = DeviceManager.GetAllDevices();

            Console.WriteLine("[Completed: " + isaDevices.Count.ToString() + " found]");

            foreach (var device in isaDevices)
            {
                Console.Write("  ");
                Bullet(ScreenColor.Yellow);
                Console.Write(" ");
                InBrackets(device.Name, ScreenColor.White, ScreenColor.Green);
                Console.WriteLine();
            }

            Console.Write("> Probing for PCI devices...");

            //Setup.StartPCIDevices();
            var pciDevices = DeviceManager.GetDevices <DeviceSystem.PCI.IPCIDevice>(DeviceStatus.Available);

            Console.WriteLine("[Completed: " + pciDevices.Count.ToString() + " found]");

            foreach (var device in pciDevices)
            {
                var pciDevice = device.DeviceDriver as DeviceSystem.PCI.IPCIDevice;

                Console.Write("  ");
                Bullet(ScreenColor.Yellow);
                Console.Write(" ");
                InBrackets(device.Name + ": " + pciDevice.VendorID.ToString("x") + ":" + pciDevice.DeviceID.ToString("x") + " " + pciDevice.SubSystemID.ToString("x") + ":" + pciDevice.SubVendorID.ToString("x") + " (" + pciDevice.Function.ToString("x") + ":" + pciDevice.ClassCode.ToString("x") + ":" + pciDevice.SubClassCode.ToString("x") + ":" + pciDevice.ProgIF.ToString("x") + ":" + pciDevice.RevisionID.ToString("x") + ")", ScreenColor.White, ScreenColor.Green);
                Console.WriteLine();
            }

            Console.Write("> Probing for disk controllers...");
            var diskcontrollers = DeviceManager.GetDevices <IDiskControllerDevice>();

            Console.WriteLine("[Completed: " + diskcontrollers.Count.ToString() + " found]");

            foreach (var device in diskcontrollers)
            {
                Console.Write("  ");
                Bullet(ScreenColor.Yellow);
                Console.Write(" ");
                InBrackets(device.Name, ScreenColor.White, ScreenColor.Green);
                Console.WriteLine();
            }

            Console.Write("> Probing for disks...");
            var disks = DeviceManager.GetDevices <IDiskDevice>();

            Console.WriteLine("[Completed: " + disks.Count.ToString() + " found]");

            foreach (var disk in disks)
            {
                Console.Write("  ");
                Bullet(ScreenColor.Yellow);
                Console.Write(" ");
                InBrackets(disk.Name, ScreenColor.White, ScreenColor.Green);
                Console.Write(" " + (disk.DeviceDriver as IDiskDevice).TotalBlocks.ToString() + " blocks");
                Console.WriteLine();
            }

            var partitionManager = new PartitionManager(DeviceManager);

            partitionManager.CreatePartitionDevices();

            Console.Write("> Finding partitions...");
            var partitions = DeviceManager.GetDevices <IPartitionDevice>();

            Console.WriteLine("[Completed: " + partitions.Count.ToString() + " found]");

            foreach (var partition in partitions)
            {
                Console.Write("  ");
                Bullet(ScreenColor.Yellow);
                Console.Write(" ");
                InBrackets(partition.Name, ScreenColor.White, ScreenColor.Green);
                Console.Write(" " + (partition.DeviceDriver as IPartitionDevice).BlockCount.ToString() + " blocks");
                Console.WriteLine();
            }

            Console.Write("> Finding file systems...");

            foreach (var partition in partitions)
            {
                var fat = new FatFileSystem(partition.DeviceDriver as IPartitionDevice);

                if (fat.IsValid)
                {
                    Console.WriteLine("Found a FAT file system!");

                    const string filename = "TEST.TXT";

                    var location = fat.FindEntry(filename);

                    if (location.IsValid)
                    {
                        Console.Write("Found: " + filename);

                        var fatFileStream = new FatFileStream(fat, location);

                        uint len = (uint)fatFileStream.Length;

                        Console.WriteLine(" - Length: " + len.ToString());

                        Console.Write("Reading File: ");

                        for (; ;)
                        {
                            int i = fatFileStream.ReadByte();

                            if (i < 0)
                            {
                                break;
                            }

                            Console.Write((char)i);
                        }

                        Console.WriteLine();
                    }
                }
            }

            // Get StandardKeyboard
            var standardKeyboards = DeviceManager.GetDevices("StandardKeyboard");

            if (standardKeyboards.Count == 0)
            {
                Console.WriteLine("No Keyboard!");
                ForeverLoop();
            }

            var standardKeyboard = standardKeyboards[0].DeviceDriver as IKeyboardDevice;

            Debug = ConsoleManager.Controller.Debug;

            // setup keymap
            var keymap = new US();

            // setup keyboard (state machine)
            var keyboard = new DeviceSystem.Keyboard(standardKeyboard, keymap);

            // setup app manager
            var manager = new AppManager(Console, keyboard);

            IDT.SetInterruptHandler(manager.ProcessInterrupt);

            Logger.Log("<SELFTEST:PASSED>");

            manager.Start();
        }
Exemplo n.º 15
0
        public static void Process()
        {
            int lastSecond = -1;

            Console.BackgroundColor = Colors.Black;
            Console.Goto(21, 0);
            Console.Color = Colors.White;
            Console.Write("> ");

            Mosa.DeviceDriver.ScanCodeMap.US KBDMAP = new DeviceDriver.ScanCodeMap.US();

            while (true)
            {
                byte scancode = Setup.Keyboard.GetScanCode();

                if (scancode != 0)
                {
                    //	Debug.Trace("Main.Main Key Scan Code: " + scancode.ToString());

                    KeyEvent keyevent = KBDMAP.ConvertScanCode(scancode);

                    //	Debug.Trace("Main.Main Key Character: " + keyevent.Character.ToString());

                    if (keyevent.KeyPress == KeyEvent.Press.Make)
                    {
                        if (keyevent.Character != 0)
                        {
                            Console.Write(keyevent.Character);
                        }

                        if (keyevent.KeyType == KeyType.F1)
                        {
                            ConsoleManager.Controller.Active = ConsoleManager.Controller.Boot;
                        }
                        else if (keyevent.KeyType == KeyType.F2)
                        {
                            ConsoleManager.Controller.Active = ConsoleManager.Controller.Debug;
                        }
                    }

                    //	Debug.Trace("Main.Main Key Character: " + ((uint)keyevent.Character).ToString());
                }

                if (Setup.CMOS.Second != lastSecond)
                {
                    //DebugClient.SendAlive();
                    lastSecond = Setup.CMOS.Second;

                    //Debug.Trace("Main.Main Ping Alive");
                }

                //DebugClient.Process();
                Native.Hlt();
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Main
        /// </summary>
        public static void Main()
        {
            Kernel.x86.Kernel.Setup();

            Console = ConsoleManager.Controller.Boot;

            Console.Clear();
            Console.Goto(0, 0);
            Console.ScrollRow       = 23;
            Console.Color           = ScreenColor.White;
            Console.BackgroundColor = ScreenColor.Green;

            Debug = ConsoleManager.Controller.Debug;

            Console.Write("                   MOSA OS Version 2.2 - Compiler Version 2.2");
            FillLine();
            Console.Color           = ScreenColor.White;
            Console.BackgroundColor = ScreenColor.Black;

            Console.WriteLine("> Initializing services...");

            // Create Service manager and basic services
            var serviceManager = new ServiceManager();

            DeviceService = new DeviceService();

            var diskDeviceService    = new DiskDeviceService();
            var partitionService     = new PartitionService();
            var pciControllerService = new PCIControllerService();
            var pciDeviceService     = new PCIDeviceService();
            var pcService            = new PCService();

            serviceManager.AddService(DeviceService);
            serviceManager.AddService(diskDeviceService);
            serviceManager.AddService(partitionService);
            serviceManager.AddService(pciControllerService);
            serviceManager.AddService(pciDeviceService);
            serviceManager.AddService(pcService);

            Console.WriteLine("> Initializing hardware abstraction layer...");

            // Set device driver system with the hardware HAL
            var hardware = new HAL.Hardware();

            DeviceSystem.Setup.Initialize(hardware, DeviceService.ProcessInterrupt);

            Console.WriteLine("> Registering device drivers...");
            DeviceService.RegisterDeviceDriver(DeviceDriver.Setup.GetDeviceDriverRegistryEntries());

            Console.WriteLine("> Starting devices...");

            DeviceService.Initialize(new X86System(), null);

            var acpi = DeviceService.GetFirstDevice <IACPI>().DeviceDriver as IACPI;

            // Setup APIC
            var localApic = Mosa.DeviceSystem.HAL.GetPhysicalMemory((Pointer)acpi.LocalApicAddress, 0xFFFF).Address;
            var ioApic    = Mosa.DeviceSystem.HAL.GetPhysicalMemory((Pointer)acpi.IOApicAddress, 0xFFFF).Address;

            APIC.Setup(localApic, ioApic);

            Console.Write("> Probing for ISA devices...");
            var isaDevices = DeviceService.GetChildrenOf(DeviceService.GetFirstDevice <ISABus>());

            Console.WriteLine("[Completed: " + isaDevices.Count.ToString() + " found]");

            foreach (var device in isaDevices)
            {
                Console.Write("  ");
                Bullet(ScreenColor.Yellow);
                Console.Write(" ");
                InBrackets(device.Name, ScreenColor.White, ScreenColor.Green);
                Console.WriteLine();
            }

            Console.Write("> Probing for PCI devices...");
            var devices = DeviceService.GetDevices <PCIDevice>();

            Console.WriteLine("[Completed: " + devices.Count.ToString() + " found]");

            foreach (var device in devices)
            {
                Console.Write("  ");
                Bullet(ScreenColor.Yellow);
                Console.Write(" ");

                var pciDevice = device.DeviceDriver as PCIDevice;
                InBrackets(device.Name + ": " + pciDevice.VendorID.ToString("x") + ":" + pciDevice.DeviceID.ToString("x") + " " + pciDevice.SubSystemID.ToString("x") + ":" + pciDevice.SubSystemVendorID.ToString("x") + " (" + pciDevice.ClassCode.ToString("x") + ":" + pciDevice.SubClassCode.ToString("x") + ":" + pciDevice.ProgIF.ToString("x") + ":" + pciDevice.RevisionID.ToString("x") + ")", ScreenColor.White, ScreenColor.Green);

                var children = DeviceService.GetChildrenOf(device);

                if (children.Count != 0)
                {
                    var child = children[0];

                    Console.WriteLine();
                    Console.Write("    ");

                    var pciDevice2 = child.DeviceDriver as PCIDevice;
                    InBrackets(child.Name, ScreenColor.White, ScreenColor.Green);
                }

                Console.WriteLine();
            }

            Console.Write("> Probing for disk controllers...");
            var diskcontrollers = DeviceService.GetDevices <IDiskControllerDevice>();

            Console.WriteLine("[Completed: " + diskcontrollers.Count.ToString() + " found]");

            foreach (var device in diskcontrollers)
            {
                Console.Write("  ");
                Bullet(ScreenColor.Yellow);
                Console.Write(" ");
                InBrackets(device.Name, ScreenColor.White, ScreenColor.Green);
                Console.WriteLine();
            }

            Console.Write("> Probing for disks...");
            var disks = DeviceService.GetDevices <IDiskDevice>();

            Console.WriteLine("[Completed: " + disks.Count.ToString() + " found]");

            foreach (var disk in disks)
            {
                Console.Write("  ");
                Bullet(ScreenColor.Yellow);
                Console.Write(" ");
                InBrackets(disk.Name, ScreenColor.White, ScreenColor.Green);
                Console.Write(" " + (disk.DeviceDriver as IDiskDevice).TotalBlocks.ToString() + " blocks");
                Console.WriteLine();
            }

            partitionService.CreatePartitionDevices();

            Console.Write("> Finding partitions...");
            var partitions = DeviceService.GetDevices <IPartitionDevice>();

            Console.WriteLine("[Completed: " + partitions.Count.ToString() + " found]");

            //foreach (var partition in partitions)
            //{
            //	Console.Write("  ");
            //	Bullet(ScreenColor.Yellow);
            //	Console.Write(" ");
            //	InBrackets(partition.Name, ScreenColor.White, ScreenColor.Green);
            //	Console.Write(" " + (partition.DeviceDriver as IPartitionDevice).BlockCount.ToString() + " blocks");
            //	Console.WriteLine();
            //}

            Console.Write("> Finding file systems...");

            foreach (var partition in partitions)
            {
                var fat = new FatFileSystem(partition.DeviceDriver as IPartitionDevice);

                if (fat.IsValid)
                {
                    Console.WriteLine("Found a FAT file system!");

                    const string filename = "TEST.TXT";

                    var location = fat.FindEntry(filename);

                    if (location.IsValid)
                    {
                        Console.Write("Found: " + filename);

                        var fatFileStream = new FatFileStream(fat, location);

                        uint len = (uint)fatFileStream.Length;

                        Console.WriteLine(" - Length: " + len.ToString() + " bytes");

                        Console.Write("Reading File: ");

                        for (; ;)
                        {
                            int i = fatFileStream.ReadByte();

                            if (i < 0)
                            {
                                break;
                            }

                            Console.Write((char)i);
                        }

                        Console.WriteLine();
                    }

                    const string bmpname = "WALLP.BMP";

                    var bmploc = fat.FindEntry(bmpname);

                    if (bmploc.IsValid)
                    {
                        Console.Write("Found: " + bmpname);

                        var fatFileStream = new FatFileStream(fat, bmploc);

                        uint len = (uint)fatFileStream.Length;

                        Console.WriteLine(" - Length: " + len.ToString() + " bytes");
                        Console.WriteLine();
                    }
                }
            }

            // Get StandardKeyboard
            var keyboards = DeviceService.GetDevices("StandardKeyboard");

            if (keyboards.Count == 0)
            {
                Console.WriteLine("No Keyboard!");
                ForeverLoop();
            }

            var stdKeyboard = keyboards[0].DeviceDriver as IKeyboardDevice;

            // setup keymap
            var keymap = new US();

            // setup keyboard (state machine)
            var keyboard = new DeviceSystem.Keyboard(stdKeyboard, keymap);

            // setup app manager
            var manager = new AppManager(Console, keyboard, serviceManager);

            IDT.SetInterruptHandler(manager.ProcessInterrupt);

            Logger.Log("<SELFTEST:PASSED>");

            manager.Start();
        }
Exemplo n.º 17
0
        public unsafe static void DumpStackTrace()
        {
            uint depth = 0;

            while (true)
            {
                var methodDef = Mosa.Runtime.x86.Internal.GetMethodDefinitionFromStackFrameDepth(depth);

                if (methodDef == null)
                {
                    return;
                }

                string caller = methodDef->Name;

                if (caller == null)
                {
                    return;
                }

                Console.Write(depth, 10, 2);
                Console.Write(":");
                Console.WriteLine(caller);

                depth++;
            }
        }