Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more options for global init #2727

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 44 additions & 11 deletions source/Cosmos.HAL2/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static class Global
/// </summary>
/// <param name="textScreen">Text screen.</param>
/// <exception cref="System.IO.IOException">Thrown on IO error.</exception>
static public void Init(TextScreenBase textScreen, bool InitScrollWheel, bool InitPS2, bool InitNetwork, bool IDEInit)
static public void Init(TextScreenBase textScreen, bool InitScrollWheel, bool InitPS2, bool InitNetwork, bool IDEInit, bool InitSerial, bool InitPCI, bool InitACPI, bool InitAHCI)
{
if (textScreen != null)
{
Expand All @@ -46,13 +46,28 @@ static public void Init(TextScreenBase textScreen, bool InitScrollWheel, bool In
// system level and not accessible from Core. Need to think about this
// for the future.
Console.Clear();
Console.WriteLine("Finding PCI Devices");
debugger.Send("PCI Devices");
PCI.Setup();

Console.WriteLine("Starting ACPI");
debugger.Send("ACPI Init");
ACPI.Start();
if (InitPCI)
{
Console.WriteLine("Finding PCI Devices");
debugger.Send("PCI Devices");
PCI.Setup();
}
else
{
debugger.Send("PCI Devices will not be set up");
}

if (InitACPI)
{
Console.WriteLine("Starting ACPI");
debugger.Send("ACPI Init");
ACPI.Start();
}
else
{
debugger.Send("ACPI will not be initialized");
}

// http://wiki.osdev.org/%228042%22_PS/2_Controller#Initialising_the_PS.2F2_Controller
// TODO: USB should be initialized before the PS/2 controller
Expand All @@ -74,8 +89,18 @@ static public void Init(TextScreenBase textScreen, bool InitScrollWheel, bool In
{
debugger.Send("IDE Driver disabled in User Kernel");
}
AHCI.InitDriver();

if (InitAHCI)
{
AHCI.InitDriver();
}
else
{
debugger.Send("AHCI Driver disabled in User Kernel");
}

//EHCI.InitDriver();

if (InitNetwork)
{
debugger.Send("Network Devices Init");
Expand All @@ -85,9 +110,17 @@ static public void Init(TextScreenBase textScreen, bool InitScrollWheel, bool In
{
debugger.Send("Network Driver disabled in User Kernel");
}
Console.WriteLine("Enabling Serial Output on COM1");
SerialPort.Enable(COMPort.COM1, BaudRate.BaudRate38400);
debugger.Send("Done initializing Cosmos.HAL.Global");

if (InitSerial)
{
Console.WriteLine("Enabling Serial Output on COM1");
SerialPort.Enable(COMPort.COM1, BaudRate.BaudRate38400);
debugger.Send("Done initializing Cosmos.HAL.Global");
}
else
{
debugger.Send("Serial will not be enabled");
}

}

Expand Down
4 changes: 2 additions & 2 deletions source/Cosmos.System2/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static bool ScrollLock
/// Initializes the console, screen and keyboard.
/// </summary>
/// <param name="textScreen">A screen device.</param>
public static void Init(TextScreenBase textScreen, bool initScrollWheel = true, bool initPS2 = true, bool initNetwork = true, bool ideInit = true)
public static void Init(TextScreenBase textScreen, bool initScrollWheel = true, bool initPS2 = true, bool initNetwork = true, bool ideInit = true, bool InitSerial = true, bool InitPCI = true, bool InitACPI = true, bool InitAHCI = true)
{

// We must init Console before calling Inits.
Expand All @@ -64,7 +64,7 @@ public static void Init(TextScreenBase textScreen, bool initScrollWheel = true,
Console = new Console(textScreen);

Debugger.Send("Initializing the Hardware Abstraction Layer (HAL)...");
HAL.Global.Init(textScreen, initScrollWheel, initPS2, initNetwork, ideInit);
HAL.Global.Init(textScreen, initScrollWheel, initPS2, initNetwork, ideInit, InitSerial, InitPCI, InitACPI, InitAHCI);

// TODO: @ascpixi: The end-user should have an option to exclude parts of
// Cosmos, such as the network stack, when they are not needed. As of
Expand Down
Loading