Skip to content

Commit

Permalink
WIPP - BareMetal & Debugger (#1080)
Browse files Browse the repository at this point in the history
* - WIP

* - WIP

* - WIP

* - WIP

* - WIP

* - WIP

* - WIP
  • Loading branch information
tgiphil committed Jul 11, 2023
1 parent affa1c3 commit c7242d0
Show file tree
Hide file tree
Showing 51 changed files with 589 additions and 416 deletions.
2 changes: 1 addition & 1 deletion Source/Docs/command-line-arguments.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Below are the command line arguments available:
-memory,Emulator.Memory
-gdb,Emulator.GDB,true
-term,Emulator.MaxRuntime,{value}
-debug,Launcher.Serial.Console,true
-debug,Launcher.Serial.Connection,true

Launcher - Emulator - Qemu & VMWare:
-vmware-svga,Emulator.SVGA,vmware
Expand Down
2 changes: 1 addition & 1 deletion Source/Docs/settings-options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Launcher Settings
Launcher.Exit,"If true, exit immediately after launch"
Launcher.PlugKorlib,"If true, automatically include the plugs for CoreLib"
Launcher.GDB,"If true, launch the GNU GDB application after VM launch"
Launcher.Serial.Console,"If true, outout the serial to console"
Launcher.Serial.Connection,"If true, outout the serial to console"
Launcher.Serial.File,Filename to emit serial output (future)
Launcher.Debugger,"If true, launch the MOSA debugger application after VM launch"
Launcher.Test,"If true, monitors VM serial for success or failure messages"
Expand Down
3 changes: 3 additions & 0 deletions Source/Mosa.Demo.CoolWorld.x86/HAL/Hardware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public sealed class Hardware : BaseHardwareAbstraction
/// </summary>
public override uint PageSize => PageFrameAllocator.PageSize;

public override PlatformArchitecture PlatformArchitecture => PlatformArchitecture.X86;

/// <summary>
/// Gets a block of memory from the kernel
/// </summary>
Expand All @@ -33,6 +35,7 @@ public override ConstrainedPointer GetPhysicalMemory(Pointer address, uint size)

return new ConstrainedPointer(address, size);
}

/// Disables all interrupts.
/// </summary>
public override void DisableInterrupts()
Expand Down
2 changes: 2 additions & 0 deletions Source/Mosa.Demo.SVGAWorld.x86/HAL/Hardware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public sealed class Hardware : BaseHardwareAbstraction
/// </summary>
public override uint PageSize => PageFrameAllocator.PageSize;

public override PlatformArchitecture PlatformArchitecture => PlatformArchitecture.X86;

/// <summary>
/// Gets a block of memory from the kernel
/// </summary>
Expand Down
40 changes: 20 additions & 20 deletions Source/Mosa.DeviceDriver/Setup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static List<DeviceDriverRegistryEntry> GetDeviceDriverRegistryEntries()
new ISADeviceDriverRegistryEntry
{
Name = "StandardKeyboard",
Platforms = PlatformArchitecture.X86AndX64,
Platform = PlatformArchitecture.X86AndX64,
AutoLoad = true,
BasePort = 0x60,
PortRange = 1,
Expand All @@ -27,7 +27,7 @@ public static List<DeviceDriverRegistryEntry> GetDeviceDriverRegistryEntries()
new ISADeviceDriverRegistryEntry
{
Name = "StandardMouse",
Platforms = PlatformArchitecture.X86AndX64,
Platform = PlatformArchitecture.X86AndX64,
AutoLoad = true,
BasePort = 0x60,
PortRange = 1,
Expand All @@ -40,7 +40,7 @@ public static List<DeviceDriverRegistryEntry> GetDeviceDriverRegistryEntries()
new ISADeviceDriverRegistryEntry
{
Name = "PCIController",
Platforms = PlatformArchitecture.X86AndX64,
Platform = PlatformArchitecture.X86AndX64,
AutoLoad = true,
BasePort = 0x0CF8,
PortRange = 8,
Expand All @@ -50,7 +50,7 @@ public static List<DeviceDriverRegistryEntry> GetDeviceDriverRegistryEntries()
new PCIDeviceDriverRegistryEntry
{
Name = "PCIGenericHostBridge",
Platforms = PlatformArchitecture.X86AndX64,
Platform = PlatformArchitecture.X86AndX64,
BusType = DeviceBusType.PCI,
ClassCode = 0x06,
SubClassCode = 0x00,
Expand All @@ -61,7 +61,7 @@ public static List<DeviceDriverRegistryEntry> GetDeviceDriverRegistryEntries()
new ISADeviceDriverRegistryEntry
{
Name = "IDEController",
Platforms = PlatformArchitecture.X86AndX64,
Platform = PlatformArchitecture.X86AndX64,
AutoLoad = true,
BasePort = 0x1F0,
PortRange = 8,
Expand All @@ -73,7 +73,7 @@ public static List<DeviceDriverRegistryEntry> GetDeviceDriverRegistryEntries()
new ISADeviceDriverRegistryEntry
{
Name = "IDEController (Secondary)",
Platforms = PlatformArchitecture.X86AndX64,
Platform = PlatformArchitecture.X86AndX64,
AutoLoad = true,
BasePort = 0x170,
PortRange = 8,
Expand All @@ -86,7 +86,7 @@ public static List<DeviceDriverRegistryEntry> GetDeviceDriverRegistryEntries()
new PCIDeviceDriverRegistryEntry
{
Name = "Intel4SeriesChipsetDRAMController",
Platforms = PlatformArchitecture.X86AndX64,
Platform = PlatformArchitecture.X86AndX64,
BusType = DeviceBusType.PCI,
VendorID = 0x8086,
DeviceID = 0x2E10,
Expand All @@ -97,7 +97,7 @@ public static List<DeviceDriverRegistryEntry> GetDeviceDriverRegistryEntries()
new PCIDeviceDriverRegistryEntry
{
Name = "Intel4SeriesChipsetIntegratedGraphicsController",
Platforms = PlatformArchitecture.X86AndX64,
Platform = PlatformArchitecture.X86AndX64,
BusType = DeviceBusType.PCI,
VendorID = 0x8086,
DeviceID = 0x2E10,
Expand All @@ -108,7 +108,7 @@ public static List<DeviceDriverRegistryEntry> GetDeviceDriverRegistryEntries()
new PCIDeviceDriverRegistryEntry
{
Name = "Intel4SeriesChipsetIntegratedGraphicsController2E13",
Platforms = PlatformArchitecture.X86AndX64,
Platform = PlatformArchitecture.X86AndX64,
BusType = DeviceBusType.PCI,
VendorID = 0x8086,
DeviceID = 0x2E10,
Expand All @@ -119,7 +119,7 @@ public static List<DeviceDriverRegistryEntry> GetDeviceDriverRegistryEntries()
new PCIDeviceDriverRegistryEntry
{
Name = "Intel4SeriesChipsetPCIExpressRootPort",
Platforms = PlatformArchitecture.X86AndX64,
Platform = PlatformArchitecture.X86AndX64,
BusType = DeviceBusType.PCI,
VendorID = 0x8086,
DeviceID = 0x2E10,
Expand All @@ -130,7 +130,7 @@ public static List<DeviceDriverRegistryEntry> GetDeviceDriverRegistryEntries()
new PCIDeviceDriverRegistryEntry
{
Name = "Intel4SeriesChipsetPCIExpressRootPort",
Platforms = PlatformArchitecture.X86AndX64,
Platform = PlatformArchitecture.X86AndX64,
BusType = DeviceBusType.PCI,
VendorID = 0x8086,
DeviceID = 0x2E10,
Expand All @@ -141,7 +141,7 @@ public static List<DeviceDriverRegistryEntry> GetDeviceDriverRegistryEntries()
new PCIDeviceDriverRegistryEntry
{
Name = "Intel440FX",
Platforms = PlatformArchitecture.X86AndX64,
Platform = PlatformArchitecture.X86AndX64,
BusType = DeviceBusType.PCI,
VendorID = 0x8086,
DeviceID = 0x1237,
Expand All @@ -154,7 +154,7 @@ public static List<DeviceDriverRegistryEntry> GetDeviceDriverRegistryEntries()
new PCIDeviceDriverRegistryEntry
{
Name = "IntelPIIX3",
Platforms = PlatformArchitecture.X86AndX64,
Platform = PlatformArchitecture.X86AndX64,
BusType = DeviceBusType.PCI,
VendorID = 0x8086,
DeviceID = 0x7000,
Expand All @@ -165,7 +165,7 @@ public static List<DeviceDriverRegistryEntry> GetDeviceDriverRegistryEntries()
new PCIDeviceDriverRegistryEntry
{
Name = "IntelPIIX4",
Platforms = PlatformArchitecture.X86AndX64,
Platform = PlatformArchitecture.X86AndX64,
BusType = DeviceBusType.PCI,
VendorID = 0x8086,
DeviceID = 0x7113,
Expand All @@ -176,7 +176,7 @@ public static List<DeviceDriverRegistryEntry> GetDeviceDriverRegistryEntries()
new PCIDeviceDriverRegistryEntry
{
Name = "IntelGPIOController",
Platforms = PlatformArchitecture.X86AndX64,
Platform = PlatformArchitecture.X86AndX64,
BusType = DeviceBusType.PCI,
VendorID = 0x8086,
DeviceID = 0x0934,
Expand All @@ -191,7 +191,7 @@ public static List<DeviceDriverRegistryEntry> GetDeviceDriverRegistryEntries()
new PCIDeviceDriverRegistryEntry
{
Name = "IntelHSUART",
Platforms = PlatformArchitecture.X86AndX64,
Platform = PlatformArchitecture.X86AndX64,
BusType = DeviceBusType.PCI,
VendorID = 0x8086,
DeviceID = 0x0936,
Expand All @@ -206,7 +206,7 @@ public static List<DeviceDriverRegistryEntry> GetDeviceDriverRegistryEntries()
new PCIDeviceDriverRegistryEntry
{
Name = "PCIIDEInterface",
Platforms = PlatformArchitecture.X86AndX64,
Platform = PlatformArchitecture.X86AndX64,
BusType = DeviceBusType.PCI,
VendorID = 0x8086,
DeviceID = 0x7010,
Expand All @@ -220,7 +220,7 @@ public static List<DeviceDriverRegistryEntry> GetDeviceDriverRegistryEntries()
new PCIDeviceDriverRegistryEntry
{
Name = "VirtIOGPU",
Platforms = PlatformArchitecture.X86AndX64 | PlatformArchitecture.ARMv8A32,
Platform = PlatformArchitecture.X86AndX64 | PlatformArchitecture.ARMv8A32,
BusType = DeviceBusType.PCI,
VendorID = 0x1AF4,
DeviceID = 0x1050,
Expand All @@ -231,7 +231,7 @@ public static List<DeviceDriverRegistryEntry> GetDeviceDriverRegistryEntries()
new PCIDeviceDriverRegistryEntry
{
Name = "VMwareSVGA2",
Platforms = PlatformArchitecture.X86AndX64,
Platform = PlatformArchitecture.X86AndX64,
BusType = DeviceBusType.PCI,
VendorID = 0x15AD,
DeviceID = 0x0405,
Expand All @@ -242,7 +242,7 @@ public static List<DeviceDriverRegistryEntry> GetDeviceDriverRegistryEntries()
new ISADeviceDriverRegistryEntry
{
Name = "ACPI",
Platforms = PlatformArchitecture.X86,
Platform = PlatformArchitecture.X86,
AutoLoad = true,
Factory = () => new ISA.ACPI()
},
Expand Down
1 change: 1 addition & 0 deletions Source/Mosa.DeviceDriver/X86System.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public override void Probe()
public override void Start()
{
Debug.WriteLine("X86System:Start()");

CreateISABusDevices();

Device.Status = DeviceStatus.Online;
Expand Down
6 changes: 1 addition & 5 deletions Source/Mosa.DeviceSystem/BaseHardwareAbstraction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public abstract class BaseHardwareAbstraction
/// </summary>
public abstract uint PageSize { get; }

/// <summary>
public abstract PlatformArchitecture PlatformArchitecture { get; }

/// <summary>
/// Gets a block of memory from the kernel
Expand Down Expand Up @@ -76,8 +76,6 @@ public abstract class BaseHardwareAbstraction
/// </summary>
public abstract void Yield();

#region IO Port Operations

public abstract byte In8(ushort address);

public abstract ushort In16(ushort address);
Expand All @@ -89,6 +87,4 @@ public abstract class BaseHardwareAbstraction
public abstract void Out16(ushort address, ushort data);

public abstract void Out32(ushort address, uint data);

#endregion IO Port Operations
}
2 changes: 1 addition & 1 deletion Source/Mosa.DeviceSystem/DeviceDriverRegistryEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Mosa.DeviceSystem;

public abstract class DeviceDriverRegistryEntry
{
public virtual PlatformArchitecture Platforms { get; set; }
public virtual PlatformArchitecture Platform { get; set; }

public virtual DeviceBusType BusType { get; set; }

Expand Down
14 changes: 7 additions & 7 deletions Source/Mosa.DeviceSystem/FrameBuffer32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public sealed class FrameBuffer32
private const uint BytesPerPixel = 4;

/// <summary>The memory</summary>
public ConstrainedPointer Buffer { get; }
private ConstrainedPointer Buffer { get; }

/// <summary>Gets the width in pixels</summary>
/// <value>The width.</value>
Expand Down Expand Up @@ -118,8 +118,8 @@ public void DrawBuffer(FrameBuffer32 buffer, uint x, uint y, uint transparentCol
if (x >= Width || y >= Height)
return;

for (uint h = 0; h < he; h++)
for (uint w = 0; w < wi; w++)
for (var h = 0u; h < he; h++)
for (var w = 0u; w < wi; w++)
{
var color = buffer.GetPixel(w, h);

Expand All @@ -145,8 +145,8 @@ public void DrawBuffer(FrameBuffer32 buffer, uint x, uint y, bool alpha)
if (x >= Width || y >= Height)
return;

for (uint h = 0; h < he; h++)
for (uint w = 0; w < wi; w++)
for (var h = 0u; h < he; h++)
for (var w = 0u; w < wi; w++)
{
var xx = x + w;
var yy = y + h;
Expand Down Expand Up @@ -270,13 +270,13 @@ public void DrawLine(uint color, uint x1, uint y1, uint x2, uint y2)

private void DrawHorizontalLine(uint color, uint dx, uint x, uint y)
{
for (uint i = 0; i < dx; i++)
for (var i = 0u; i < dx; i++)
SetPixel(x + i, y, color);
}

private void DrawVerticalLine(uint color, uint dy, uint x, uint y)
{
for (uint i = 0; i < dy; i++)
for (var i = 0u; i < dy; i++)
SetPixel(color, x, y + i);
}

Expand Down

0 comments on commit c7242d0

Please sign in to comment.