public override void MainMethod() { Ensure.Init(); CPU.DisableInts(); GDT.Init(); IDT.Init(); ISR.Init(); Console.Clear(); ACPI.Init(); ACPI.Enable(); PageManager.Init(); Heap.Init(); GC.Init(); Paging.Init(); PIT.Init(); RTC.Init(); Scheduler.Init(); CPU.EnableInts(); DiskDrive.Init(); //FatFileSystem.Init(); PCI.Init(); Driver.Init(); AudioMixer.Init(); new Thread(Event.Init, "Events").Start(); new Thread(new SCI().Main, "Shell").Start(); Scheduler.Idle(); }
static public void Init(TextScreenBase textScreen) { Console.WriteLine("[Aura Operating System v" + Aura_OS.Kernel.version + " - Made by valentinbreiz and geomtech]"); Aura_OS.System.CustomConsole.WriteLineInfo("Starting Cosmos kernel..."); PCI.Setup(); Aura_OS.System.CustomConsole.WriteLineOK("PCI Devices Scan"); ACPI.Start(); Aura_OS.System.CustomConsole.WriteLineOK("ACPI Initialization"); /*Cosmos.HAL.BlockDevice.IDE.InitDriver(); * Aura_OS.System.CustomConsole.WriteLineOK("IDE Driver Initialization"); * * Cosmos.HAL.BlockDevice.AHCI.InitDriver(); * Aura_OS.System.CustomConsole.WriteLineOK("AHCI Driver Initialization");*/ Cosmos.HAL.Global.PS2Controller.Initialize(); Aura_OS.System.CustomConsole.WriteLineOK("PS/2 Controller Initialization"); //Cosmos.Core.Processing.ProcessorScheduler.Initialize(); //Aura_OS.System.CustomConsole.WriteLineOK("Processor Scheduler Initialization"); Aura_OS.System.CustomConsole.WriteLineOK("Kernel successfully initialized!"); }
static public void Init(TextScreenBase textScreen) { if (textScreen != null) { TextScreen = textScreen; } mDebugger.Send("Before Core.Global.Init"); Core.Global.Init(); //TODO Redo this - Global init should be other. // Move PCI detection to hardware? Or leave it in core? Is Core PC specific, or deeper? // If we let hardware do it, we need to protect it from being used by System. // Probably belongs in hardware, and core is more specific stuff like CPU, memory, etc. //Core.PCI.OnPCIDeviceFound = PCIDeviceFound; //TODO: Since this is FCL, its "common". Otherwise it should be // system level and not accessible from Core. Need to think about this // for the future. Console.WriteLine("Finding PCI Devices"); mDebugger.Send("PCI Devices"); PCI.Setup(); Console.WriteLine("Starting ACPI"); mDebugger.Send("ACPI Init"); ACPI.Start(); IDE.InitDriver(); AHCI.InitDriver(); //EHCI.InitDriver(); mDebugger.Send("Done initializing Cosmos.HAL.Global"); }
public void Update() { Width = (uint)(Kernel.apps.Count * Kernel.programlogo.Width + Kernel.apps.Count * Devide); Kernel.vMWareSVGAII.DoubleBuffer_DrawFillRectangle(0, 0, Kernel.screenWidth, 20, (uint)Kernel.avgCol.ToArgb()); string text = "PowerOFF"; uint strX = 2; uint strY = (20 - 16) / 2; Kernel.vMWareSVGAII._DrawACSIIString("PowerOFF", (uint)Color.White.ToArgb(), strX, strY); if (Kernel.Pressed) { if (MouseManager.X > strX && MouseManager.X < strX + (text.Length * 8) && MouseManager.Y > strY && MouseManager.Y < strY + 16) { ACPI.Shutdown(); } } Kernel.vMWareSVGAII.DoubleBuffer_DrawFillRectangle((Kernel.screenWidth - Width) / 2, Kernel.screenHeight - Height, Width, Height, (uint)Kernel.avgCol.ToArgb()); for (int i = 0; i < Kernel.apps.Count; i++) { Kernel.apps[i].dockX = (uint)(Devide / 2 + ((Kernel.screenWidth - Width) / 2) + (Kernel.programlogo.Width * i) + (Devide * i)); Kernel.apps[i].dockY = Kernel.screenHeight - Kernel.programlogo.Height - Devide / 2; Kernel.vMWareSVGAII.DoubleBuffer_DrawImage(Kernel.programlogo, Kernel.apps[i].dockX, Kernel.apps[i].dockY); } }
/// <summary> /// Initiates a Bluescreen. /// </summary> /// <param name="error">Error title or exception name</param> /// <param name="description">Error description</param> /// <param name="critical">Critical error?</param> public static void Init( string error = "Something went wrong!", string description = "Unknown exception", bool critical = false) { DrawOOPS(); if (description.Length + 33 < System.Console.WindowHeight) { System.Console.CursorTop = 2; System.Console.CursorLeft = 33; ConsoleColor errcolor = ConsoleColor.White; if (critical) { errcolor = ConsoleColor.Red; } AConsole.WriteLineEx(error, errcolor, ConsoleColor.Blue); AConsole.CursorTop = 4; AConsole.CursorLeft = 70; AConsole.WriteLineEx(description, ConsoleColor.White, ConsoleColor.Blue); } else { AConsole.CursorTop = 12; AConsole.CursorLeft = 2; ConsoleColor errcolor = ConsoleColor.White; if (critical) { errcolor = ConsoleColor.Red; } AConsole.WriteLineEx(error, errcolor, ConsoleColor.Blue); AConsole.CursorTop = 14; AConsole.CursorLeft = 2; AConsole.WriteLineEx(description, ConsoleColor.White, ConsoleColor.Blue); } if (!critical) { AConsole.CursorTop = AConsole.WindowHeight - 1; AConsole.WriteEx("Press the [Enter]-key to resume", ConsoleColor.White, ConsoleColor.Blue); AConsole.CursorTop++; AConsole.ReadLine(); AConsole.Clear(); } else { AConsole.CursorTop = AConsole.WindowHeight - 4; AConsole.WriteLineEx("Press the [Enter]-key to shutdown", ConsoleColor.White, ConsoleColor.Blue); AConsole.CursorTop++; AConsole.WriteLineEx("If it doesn't work, press the RESET-button on your computer.", ConsoleColor.White, ConsoleColor.Blue); AConsole.CursorTop++; AConsole.ReadLine(); ACPI.Shutdown(); } }
public static void Init(Exception ex, bool critical = false) { DrawOOPS(); if (ex.Message.Length + 33 < AConsole.WindowHeight) { AConsole.CursorTop = 2; AConsole.CursorLeft = 33; ConsoleColor errcolor = ConsoleColor.White; if (critical) { errcolor = ConsoleColor.Red; } //AConsole.WriteLineEx(ex.Source, errcolor, ConsoleColor.Blue); AConsole.CursorTop = 3; AConsole.CursorLeft = 70; AConsole.WriteLineEx(ex.Message, ConsoleColor.White, ConsoleColor.Blue); } else { AConsole.CursorTop = 12; AConsole.CursorLeft = 2; ConsoleColor errcolor = ConsoleColor.White; if (critical) { errcolor = ConsoleColor.Red; } //AConsole.WriteLineEx(ex.Source, errcolor, ConsoleColor.Blue); AConsole.CursorTop = 13; AConsole.CursorLeft = 2; AConsole.WriteLineEx(ex.Message, ConsoleColor.White, ConsoleColor.Blue); } if (!critical) { AConsole.CursorTop = AConsole.WindowHeight - 3; AConsole.WriteEx("Press the [Enter]-key to resume", ConsoleColor.White, ConsoleColor.Blue); AConsole.CursorTop++; AConsole.ReadLine(); AConsole.Clear(); } else { AConsole.CursorTop = AConsole.WindowHeight - 4; AConsole.WriteEx("Press the [Enter]-key to shutdown", ConsoleColor.White, ConsoleColor.Blue); AConsole.CursorTop++; AConsole.WriteEx("If it doesn't work, press the RESET-button on your computer.", ConsoleColor.White, ConsoleColor.Blue); AConsole.CursorTop++; AConsole.ReadLine(); ACPI.Shutdown(); } }
// TODO: continue adding exceptions to the list, as HAL and Core would be documented. /// <summary> /// Init <see cref="Global"/> instance. /// </summary> /// <param name="textScreen">Text screen.</param> /// <exception cref="System.IO.IOException">Thrown on IO error.</exception> static public void Init(TextScreenBase textScreen) { if (textScreen != null) { TextScreen = textScreen; } mDebugger.Send("Before Core.Global.Init"); Core.Global.Init(); //TODO Redo this - Global init should be other. // Move PCI detection to hardware? Or leave it in core? Is Core PC specific, or deeper? // If we let hardware do it, we need to protect it from being used by System. // Probably belongs in hardware, and core is more specific stuff like CPU, memory, etc. //Core.PCI.OnPCIDeviceFound = PCIDeviceFound; //TODO: Since this is FCL, its "common". Otherwise it should be // system level and not accessible from Core. Need to think about this // for the future. Console.Clear(); Console.WriteLine("Finding PCI Devices"); mDebugger.Send("PCI Devices"); PCI.Setup(); Console.WriteLine("Starting ACPI"); mDebugger.Send("ACPI Init"); ACPI.Start(); // http://wiki.osdev.org/%228042%22_PS/2_Controller#Initialising_the_PS.2F2_Controller // TODO: USB should be initialized before the PS/2 controller // TODO: ACPI should be used to check if a PS/2 controller exists mDebugger.Send("PS/2 Controller Init"); PS2Controller.Initialize(); IDE.InitDriver(); AHCI.InitDriver(); //EHCI.InitDriver(); mDebugger.Send("Network Devices Init"); NetworkInit.Init(); mDebugger.Send("Done initializing Cosmos.HAL.Global"); }
static public void Init(TextScreenBase textScreen) { if (textScreen != null) { TextScreen = textScreen; } mDebugger.Send("Before Core.Global.Init"); Core.Global.Init(); //TODO Redo this - Global init should be other. // Move PCI detection to hardware? Or leave it in core? Is Core PC specific, or deeper? // If we let hardware do it, we need to protect it from being used by System. // Probably belongs in hardware, and core is more specific stuff like CPU, memory, etc. //Core.PCI.OnPCIDeviceFound = PCIDeviceFound; //TODO: Since this is FCL, its "common". Otherwise it should be // system level and not accessible from Core. Need to think about this // for the future. Console.WriteLine("Finding PCI Devices"); mDebugger.Send("PCI Devices"); PCI.Setup(); Console.WriteLine("Starting ACPI"); mDebugger.Send("ACPI Init"); ACPI.Start(); mDebugger.Send("Done initializing Cosmos.HAL.Global"); mDebugger.Send("ATA Primary Master"); InitAta(Ata.ControllerIdEnum.Primary, Ata.BusPositionEnum.Master); //TODO Need to change code to detect if ATA controllers are present or not. How to do this? via PCI enum? // They do show up in PCI space as well as the fixed space. // Or is it always here, and was our compiler stack corruption issue? mDebugger.Send("ATA Secondary Master"); InitAta(Ata.ControllerIdEnum.Secondary, Ata.BusPositionEnum.Master); //InitAta(BlockDevice.Ata.ControllerIdEnum.Secondary, BlockDevice.Ata.BusPositionEnum.Slave); }
//Shutdown with ACPI /// <summary> /// Shutdown the ACPI. /// </summary> /// <exception cref="System.IO.IOException">Thrown on IO error.</exception> public static void ACPIShutdown() { ACPI.Shutdown(); }
//Reboot with ACPI /// <summary> /// Reboot using ACPI. /// </summary> /// <exception cref="NotImplementedException">Thrown always.</exception> public static void ACPIReboot() { ACPI.Reboot(); //TODO }
public static void ShutDown() { ACPI.Shutdown(); ACPI.Disable(); Cosmos.Core.Global.CPU.Halt(); }
public void shutdownButtonPressed() { ACPI.Shutdown(); }
public void Update() { //Top bar Width = (uint)(Kernel.WindowManager.apps.Count * Kernel.programLogo.Width + Kernel.WindowManager.apps.Count * Devide); Kernel.canvas.DrawFilledRectangle(Kernel.avgColPen, 0, 0, (int)Kernel.screenWidth, 24); uint strX = 0; uint strY = 0; Kernel.canvas.DrawImage(Kernel.powerIco, (int)strX, (int)strY); if (!NetworkStack.ConfigEmpty()) { Kernel.canvas.DrawImage(Kernel.connectedIco, (int)(Kernel.screenWidth - 24), (int)strY); } string time = Time.TimeString(true, true, true); Kernel.canvas.DrawString(time, Kernel.font, Kernel.BlackPen, (int)((Kernel.screenWidth / 2) - ((time.Length * Kernel.font.Width) / 2)), (int)(strY + 4)); if (Kernel.Pressed) { if (MouseManager.X > strX && MouseManager.X < strX + Kernel.powerIco.Width && MouseManager.Y > strY && MouseManager.Y < strY + 24) { ACPI.Shutdown(); } } //Dock Kernel.canvas.DrawFilledRectangle(Kernel.avgColPen, (int)(Kernel.screenWidth - Width) / 2, (int)(Kernel.screenHeight - Height), (int)Width, (int)Height); int i = 0; foreach (var process in Kernel.ProcessManager.Processes) { if (process.Type == ProcessType.Program) { var app = process as App; app.dockX = (uint)(Devide / 2 + ((Kernel.screenWidth - Width) / 2) + (Kernel.programLogo.Width * i) + (Devide * i)); app.dockY = Kernel.screenHeight - Kernel.programLogo.Height - Devide / 2; Kernel.canvas.DrawImage(Kernel.programLogo, (int)app.dockX, (int)app.dockY); i++; if (MouseManager.X > app.dockX && MouseManager.X < app.dockX + app.dockWidth && MouseManager.Y > app.dockY && MouseManager.Y < app.dockY + app.dockHeight) { Kernel.canvas.DrawString(app.name, Kernel.font, Kernel.WhitePen, (int)(app.dockX - ((app.name.Length * 8) / 2) + app.dockWidth / 2), (int)(app.dockY - 20)); } if (MouseManager.MouseState == MouseState.Left) { if (!Clicked && MouseManager.X > app.dockX && MouseManager.X < app.dockX + app.dockWidth && MouseManager.Y > app.dockY && MouseManager.Y < app.dockY + app.dockHeight) { Clicked = true; app.visible = !app.visible; if (app.visible) { Kernel.ProcessManager.Start(app); } else { app.Stop(); } } } else { Clicked = false; } } } }
protected override void Run() { Console.Write("Input: "); var input = Console.ReadLine(); switch (input) { case "about": { Console.WriteLine("Welcome to the OS(TBD)"); Console.WriteLine("Made by Jatin and Ishaan"); break; } case "help": { Console.WriteLine("about: Tells about the OS"); Console.WriteLine("help: list all the available commands"); Console.WriteLine("calc: Basic calculator"); Console.WriteLine("echo: Repeats the given input"); break; } case "echo": { var echo = Console.ReadLine(); Console.Write("Text typed: "); Console.WriteLine(echo); break; } case "shutdown": { ACPI.Shutdown(); break; } case "mkdir": { string dirpath = @"D:\Testdir4"; try { if (Directory.Exists(dirpath)) { Console.WriteLine("That path exists already."); return; } System.IO.Directory.CreateDirectory(dirpath); Console.WriteLine("The directory was created successfully at {0}.", Directory.GetCreationTime(dirpath)); } catch (Exception e) { Console.WriteLine("The process failed: {0}", e.ToString()); } break; } case "calc": { double a, b; char c; Console.Write("Enter First Number: "); a = Double.Parse(Console.ReadLine()); Console.Write("Enter Second Number: "); b = Double.Parse(Console.ReadLine()); Console.Write("Enter Sign (+ - * /): "); c = Char.Parse(Console.ReadLine()); switch (c) { case '+': Console.WriteLine("{0}+{1}={2}", a, b, a + b); break; case '-': Console.WriteLine("{0}-{1}={2}", a, b, a - b); break; case '*': Console.WriteLine("{0}*{1}={2}", a, b, a * b); break; case '/': Console.WriteLine("{0}/{1}={2}", a, b, a / b); break; default: Console.WriteLine("Unknown sign!"); break; } break; } default: Console.WriteLine("Unknown command"); break; } }
public static void StartACPI() { Console.WriteLine("Starting ACPI"); ACPI.Start(); }
public static void CMD_Reboot()//byte* param) { ACPI.Reboot(); }
public static void CMD_Shutdown()//byte* param) { ACPI.Shutdown(); }
private static uint internalAllocation(uint size, bool allign) { totalAllocations++; tryAgain :; uint returnable = 0; if (Settings.HeapUseBasic || entryCount == 0) { if (heapPointer == 0) { heapPointer = Utils.allign4K(Multiboot.GetEndOfKernel()) + 4096; } if (allign) { heapPointer = Utils.allign4K(heapPointer) + 4096; } uint tmp = heapPointer; heapPointer += size; returnable = tmp; goto allocationEnd; } mutex.Lock(); if (currentEntry >= entryCount) { currentEntry = 0; } var entry = directory->GetEntry(currentEntry); if (entry->used) { currentEntry++; goto tryAgain; } if (!allign && size < 4096) { if (entry->size <= size && entry->location != 0) { entry->used = true; returnable = entry->location; goto allocationEnd; } if (size > pageSpace) { pageSpace = 4096; heapPointer = PageManager.GetFreePage(); if (heapPointer == 0) { // need to to a GC scan and free some pages Console.WriteLine("RAN OUT OF RAM"); ACPI.Shutdown(); while (true) { } } } pageSpace -= size; entry->size = size; entry->location = heapPointer; heapPointer += size; entry->used = true; returnable = entry->location; goto allocationEnd; } else { int num = (int)(size / 4096); int remainder = (int)(size % 4096); if (remainder > 0) { num++; } entry->used = true; entry->location = PageManager.GetFreePage(num); entry->size = (uint)num * 4096; returnable = entry->location; goto allocationEnd; } allocationEnd :; Utils.memset((byte *)returnable, 0, size); mutex.Unlock(); return(returnable); }
public static void Reboot() { ACPI.Reboot(); }