Skip to content

Commit

Permalink
Mosa.DeviceDriver: clean up pointless types + other minor changes (#1201
Browse files Browse the repository at this point in the history
)

Signed-off-by: AnErrupTion <[email protected]>
  • Loading branch information
AnErrupTion authored Mar 9, 2024
1 parent 88ae20f commit f73cdf1
Show file tree
Hide file tree
Showing 20 changed files with 94 additions and 148 deletions.
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2023, MOSA-Project
Copyright (c) 2024, MOSA-Project
All rights reserved.

Redistribution and use in source and binary forms,
Expand Down
4 changes: 2 additions & 2 deletions Source/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<CodeAnalysisRuleSet>../Common.ruleset</CodeAnalysisRuleSet>
<Company>MOSA Project</Company>
<Copyright>Copyright © MOSA Project 2023</Copyright>
<AssemblyVersion>2.5.0.0</AssemblyVersion>
<Copyright>Copyright © MOSA Project 2024</Copyright>
<AssemblyVersion>2.6.0.0</AssemblyVersion>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion Source/Docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# -- Project information -----------------------------------------------------
project = 'MOSA Project'
copyright = '2008-{}, Mosa Project & contributors'.format(2023)
copyright = '2008-{}, Mosa Project & contributors'.format(2024)
author = 'Phil Garcia'

# -- General configuration ---------------------------------------------------
Expand Down
45 changes: 0 additions & 45 deletions Source/Mosa.DeviceDriver/PCI/GenericHostBridgeController.cs

This file was deleted.

4 changes: 3 additions & 1 deletion Source/Mosa.DeviceDriver/PCI/Intel/Intel440FX.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) MOSA Project. Licensed under the New BSD License.

using Mosa.DeviceSystem.Framework;

namespace Mosa.DeviceDriver.PCI.Intel;

// Intel® 440FX PCIset 82441FX (PMC) and 82442FX (DBX)
Expand All @@ -8,7 +10,7 @@ namespace Mosa.DeviceDriver.PCI.Intel;
/// <summary>
/// </summary>
//[PCIDeviceDriver(VendorID = 0x8086, DeviceID = 0x1237, Platforms = PlatformArchitecture.X86AndX64)]
public class Intel440FX : GenericHostBridgeController
public class Intel440FX : BaseDeviceDriver
{
public override void Initialize() => Device.Name = "Intel440FX";
}
14 changes: 2 additions & 12 deletions Source/Mosa.DeviceDriver/Setup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,6 @@ public static class Setup
Factory = () => new ISA.PCIController()
},

new PCIDeviceDriverRegistryEntry
{
Name = "PCIGenericHostBridge",
Platform = PlatformArchitecture.X86AndX64,
BusType = DeviceBusType.PCI,
ClassCode = 0x06,
SubClassCode = 0x00,
PCIFields = PCIField.ClassCode | PCIField.SubClassCode,
Factory = () => new PCI.GenericHostBridgeController()
},

new ISADeviceDriverRegistryEntry
{
Name = "IDEController",
Expand All @@ -92,6 +81,7 @@ public static class Setup
Factory = () => new ISA.IDEController()
},

// Future: Clarify how these 4-series controllers are differentiated in PCI (right now most are pointing to the same device?)
new PCIDeviceDriverRegistryEntry
{
Name = "Intel4SeriesChipsetDRAMController",
Expand Down Expand Up @@ -120,7 +110,7 @@ public static class Setup
Platform = PlatformArchitecture.X86AndX64,
BusType = DeviceBusType.PCI,
VendorID = 0x8086,
DeviceID = 0x2E10,
DeviceID = 0x2E13,
PCIFields = PCIField.VendorID | PCIField.DeviceID,
Factory = () => new PCI.Intel.Intel4SeriesChipsetIntegratedGraphicsController2E13()
},
Expand Down
38 changes: 0 additions & 38 deletions Source/Mosa.DeviceDriver/X86System.cs

This file was deleted.

6 changes: 0 additions & 6 deletions Source/Mosa.DeviceSystem/Misc/DataBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ public class DataBlock

public DataBlock(uint length) => Data = new byte[length];

public byte this[int index]
{
get => Data[index];
set => Data[index] = value;
}

public char GetChar(uint offset) => (char)Data[offset];

public void SetChar(uint offset, char value) => Data[offset] = (byte)value;
Expand Down
13 changes: 0 additions & 13 deletions Source/Mosa.DeviceSystem/PCI/IHostBridgeController.cs

This file was deleted.

5 changes: 3 additions & 2 deletions Source/Mosa.Kernel.BareMetal/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,10 @@ public static void EntryPoint()
Console.ForegroundColor = ConsoleColor.DarkGray;
Console.WriteLine(" [Completed]");

// Future: We shouldn't be directly initializing ISA devices on non-x86 platforms (even if it doesn't do anything on those)
Console.ForegroundColor = ConsoleColor.LightGreen;
Console.Write("> X86System...");
deviceService.Initialize(new X86System(), null);
Console.Write("> ISABus...");
deviceService.Initialize(new ISABus(), null);
Console.ForegroundColor = ConsoleColor.DarkGray;
Console.WriteLine(" [Completed]");

Expand Down
63 changes: 44 additions & 19 deletions Source/Mosa.Korlib/System.Text/StringBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,72 @@ namespace System.Text;

public class StringBuilder
{
private char[] Characters = new char[int.MaxValue];
private char[] characters;
private int length;

private int Length = 0;
public StringBuilder() => characters = new char[byte.MaxValue];

public StringBuilder(int capacity) => characters = new char[capacity];

public StringBuilder Clear()
{
Length = 0;
length = 0;
return this;
}

public StringBuilder Append(char c)
{
if (Length >= Characters.Length)
{
var chars = new char[Length + 100];
for (var i = 0; i < Length; i++)
chars[i] = Characters[i];
Characters = chars;
}
EnsureCapacity();

characters[length++] = c;
return this;
}

public StringBuilder Append(char c, int count)
{
EnsureCapacity(count);

Characters[Length] = c;
Length++;
for (var i = 0; i < count; i++)
characters[length++] = c;

return this;
}

public StringBuilder AppendLine(string s)
public StringBuilder Append(string s)
{
for (var i = 0; i < s.length; i++)
Append(s[i]);
EnsureCapacity(s.length);

foreach (var c in s)
characters[length++] = c;

return this;
}

public char[] ToCharArray()
public StringBuilder AppendLine(string s)
{
return Characters;
EnsureCapacity(s.length);

foreach (var c in s)
characters[length++] = c;

characters[length++] = '\n';
return this;
}

public override string ToString()
public char[] ToCharArray() => characters;

public override string ToString() => new string(characters, 0, length);

private void EnsureCapacity(int capacity = 0)
{
return new string(Characters, 0, Length);
var newLength = length + capacity;
if (newLength < characters.Length)
return;

var chars = new char[newLength + 100];
for (var i = 0; i < length; i++)
chars[i] = characters[i];

characters = chars;
}
}
2 changes: 2 additions & 0 deletions Source/Mosa.Korlib/System/Char.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ public static bool IsDigit(char c)
return c >= '0' && c <= '9';
}

public static bool IsAsciiDigit(char c) => IsDigit(c);

public static bool IsLetterOrDigit(char c)
{
return (IsLetter(c) || IsDigit(c));
Expand Down
30 changes: 29 additions & 1 deletion Source/Mosa.Korlib/System/String.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,35 @@ public string Remove(int startIndex, int count)

public static string Format(string format, params object[] args)
{
return format;
var sb = new StringBuilder(format.length + args.Length * 8);
var index = 0;

while (index < format.length)
{
var c = format[index++];

if (c != '{')
{
sb.Append(c);
continue;
}

var argIndexStr = Empty;
var current = format[index++];

while (current != '}')
{
argIndexStr += current;
current = format[index++];
}

var argIndex = int.Parse(argIndexStr);
var arg = args[argIndex];

sb.Append(arg.ToString());
}

return sb.ToString();
}

public bool Equals(string s)
Expand Down
2 changes: 1 addition & 1 deletion Source/Mosa.Packages/Mosa.DeviceSystem.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<summary>MOSA device drivers framework and file system</summary>
<description>This package contains the MOSA device drivers framework along with the VFS (Virtual File System) and the file systems implementations.</description>
<copyright>Copyright © MOSA Project 2023</copyright>
<copyright>Copyright © MOSA Project 2024</copyright>
<tags>MOSA Compiler</tags>
<dependencies>
<dependency id="Mosa.Platform" version="$version$" />
Expand Down
2 changes: 1 addition & 1 deletion Source/Mosa.Packages/Mosa.Platform.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<summary>MOSA BareMetal kernel and runtime libraries</summary>
<description>This package contains the platform-agnostic BareMetal kernel and runtime libraries (including the core library).</description>
<copyright>Copyright © MOSA Project 2023</copyright>
<copyright>Copyright © MOSA Project 2024</copyright>
<tags>MOSA Compiler</tags>
</metadata>
<files>
Expand Down
2 changes: 1 addition & 1 deletion Source/Mosa.Packages/Mosa.Platform.x86.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<summary>MOSA x86 platform libraries</summary>
<description>This package contains the x86 implementations of the BareMetal kernel and runtime libraries (including the core library).</description>
<copyright>Copyright © MOSA Project 2023</copyright>
<copyright>Copyright © MOSA Project 2024</copyright>
<tags>MOSA Compiler</tags>
<dependencies>
<dependency id="Mosa.Platform" version="$version$" />
Expand Down
2 changes: 1 addition & 1 deletion Source/Mosa.Packages/Mosa.Tools.Package.Qemu.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<summary>MOSA tools with QEMU for Windows</summary>
<description>This package contains all the tools for MOSA along with QEMU binaries for Windows.</description>
<copyright>Copyright © MOSA Project 2023</copyright>
<copyright>Copyright © MOSA Project 2024</copyright>
<tags>MOSA Compiler</tags>
<contentFiles>
<files include="**/*.*" buildAction="None" copyToOutput="true" />
Expand Down
2 changes: 1 addition & 1 deletion Source/Mosa.Packages/Mosa.Tools.Package.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<summary>MOSA Tools without QEMU</summary>
<description>This package contains all the tools for MOSA without QEMU binaries.</description>
<copyright>Copyright © MOSA Project 2023</copyright>
<copyright>Copyright © MOSA Project 2024</copyright>
<tags>MOSA Compiler</tags>
<contentFiles>
<files include="**/*.*" buildAction="None" copyToOutput="true" />
Expand Down
2 changes: 1 addition & 1 deletion Source/Mosa.Tool.Compiler/Compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public int Run(string[] args)

// always print header with version information
Console.WriteLine("MOSA Compiler, Version {0}.", CompilerVersion.VersionString);
Console.WriteLine("Copyright 2023 by the MOSA Project. Licensed under the New BSD License.");
Console.WriteLine("Copyright 2024 by the MOSA Project. Licensed under the New BSD License.");

//OutputStatus($"Current Directory: {Environment.CurrentDirectory}");

Expand Down
Loading

0 comments on commit f73cdf1

Please sign in to comment.