Ejemplo n.º 1
0
        public static unsafe void Main()
        {
            try
            {
                ManagedMemoy.InitializeGCMemory();
                StartUp.InitializeAssembly();
                KMath.Init();
                //Mosa.Runtime.StartUp.InitializeRuntimeMetadata();

                BootInfo.SetupStage1();

                Memory.InitialKernelProtect();

                ApiContext.Current = new ApiHost();
                Assert.Setup(AssertError);

                // Setup some pseudo devices
                DeviceManager.InitStage1();

                //Setup Output and Debug devices
                DeviceManager.InitStage2();

                // Write first output
                KernelMessage.WriteLine("<KERNEL:CONSOLE:BEGIN>");
                PerformanceCounter.Setup(BootInfo.Header->KernelBootStartCycles);
                KernelMessage.WriteLine("Starting Abanu Kernel...");

                KernelMessage.WriteLine("KConfig.UseKernelMemoryProtection: {0}", KConfig.UseKernelMemoryProtection);
                KernelMessage.WriteLine("KConfig.UsePAE: {0}", KConfig.UsePAE);
                KernelMessage.WriteLine("Apply PageTableType: {0}", (uint)BootInfo.Header->PageTableType);
                KernelMessage.WriteLine("GCInitialMemory: {0:X8}-{1:X8}", Address.GCInitialMemory, Address.GCInitialMemory + Address.GCInitialMemorySize - 1);

                Ulongtest1();
                Ulongtest2();
                InlineTest();

                // Detect environment (Memory Maps, Video Mode, etc.)
                BootInfo.SetupStage2();

                KernelMemoryMapManager.Setup();
                //KernelMemoryMapManager.Allocate(0x1000 * 1000, BootInfoMemoryType.PageDirectory);

                // Read own ELF-Headers and Sections
                KernelElf.Setup();

                // Initialize the embedded code (actually only a little proof of concept code)
                NativeCalls.Setup();

                //InitialKernelProtect();

                PhysicalPageManager.Setup();

                KernelMessage.WriteLine("Phys free: {0}", PhysicalPageManager.FreePages);
                PhysicalPageManager.AllocatePages(10);
                KernelMessage.WriteLine("Phys free: {0}", PhysicalPageManager.FreePages);
                VirtualPageManager.Setup();

                Memory.Setup();

                // Now Memory Sub System is working. At this point it's valid
                // to allocate memory dynamically

                DeviceManager.InitFrameBuffer();

                // Setup Programmable Interrupt Table
                PIC.Setup();

                // Setup Interrupt Descriptor Table
                // Important Note: IDT depends on GDT. Never setup IDT before GDT.
                IDTManager.Setup();

                InitializeUserMode();
                SysCallManager.Setup();

                KernelMessage.WriteLine("Initialize Runtime Metadata");
                StartUp.InitializeRuntimeMetadata();

                KernelMessage.WriteLine("Performing some Non-Thread Tests");
                Tests();
            }
            catch (Exception ex)
            {
                Panic.Error(ex.Message);
            }

            if (KConfig.SingleThread)
            {
                StartupStage2();
            }
            else
            {
                ProcessManager.Setup(StartupStage2);
            }
        }
Ejemplo n.º 2
0
 public static unsafe void TestPhysicalPageAllocation()
 {
     KernelMessage.WriteLine("Phys free: {0}", PhysicalPageManager.FreePages);
     PhysicalPageManager.AllocatePages(10);
     KernelMessage.WriteLine("Phys free: {0}", PhysicalPageManager.FreePages);
 }