This is the continuation of #1190, which aims to refactor parts of the code base with the primary goal of making them easier to understand. Here are the most notable changes in part 2 of refactoring Mosa.DeviceSystem:
Throughout all refactored files, pointless XML comments have been removed, and per-class comments have been added, giving more useful insight into what the class is, and does. This allow for better general understanding of the code
More minor code refactoring has been done:
Fold a function into one-line if allowed
Use pattern matching wherever possible
Braces were removed in blocks that only had one expression (which was put on a new line if not already)
The "this" reference has been removed in places where it wasn't needed
The "var" type inference for variables was used in more places were adequate (e.g. it didn't require casting)
Fields and functions were reordered when needed, so that private ones are always after public ones
In adequate places, fields were made public and/or into properties (to better indicate that there's an API)
Some function arguments were renamed if they were pointlessly too long
Ternary operators were used wherever possible
Introduced an empty BaseDeviceConfiguration class in Mosa.Utility.FileSystem to deal with the new dependency issues caused by this PR (as in, we'd have needed to import the Mosa.DeviceSystem.PCI namespace if we didn't do that)
In Mosa.Utility.FileSystem, the custom classes created from its Mosa.DeviceSystem counterparts (BaseDeviceDriver and Device) have received some cleanup
A more useful constructor has been introduced in the CHS class, which allows setting the cylinder, head and sector directly.
The MaximunDriveCount field in IDiskControllerDevice was renamed to MaximumDriveCount (fixes a typo)
In Mosa.Utility.BootImage.Generator, PartitionType.GPT was used instead of the magic number 0xEE (which is the same anyway)
In HardwareResources, the IOPointRegionCount and AddressRegionCount were removed as they were unused, and the GetIOPortRegion and GetMemoryRegion functions were removed in favor of making the IOPortRegions and AddressRegions fields (now properties) public (this would've also made the former fields useless anyway)
In HAL, the Assert() function was removed since it was unused and was pretty trivial
In MasterBootBlock:
The MaxMBRPartitions field was renamed to MaxPartitions
All protected fields were made private
The diskDevice field was made readonly
The Partitions field was made into a property
The Valid and DiskSignature properties were made into auto properties
The data field was made private, and the masterboot field was renamed to DataBlock (and made a property)
The PCIField enum was split from PCIDeviceDriverRegistryEntry
In ServiceManager, the Services and Events fields were made public (and properties), while the lockServices and lockEvents ones were made private
The following unused classes and interfaces have been removed:
BaseIOPort
ColorPalette
DataStream (only used by the CoolWorld demo, it uses DataBlock now)
DeviceDriverPhysicalMemory
DeviceDriverStartStatus
IPAddress and its corresponding unit tests as IPAddressTests (we don't have a network subsystem yet, so it was pointless to have, and if we really want one, we should focus on making it API compatible with the mscorlib implementation instead)
Setup (only used by the BareMetal kernel for initialization, it only contained 1 function that called 2 other functions anyway)
Mosa.DeviceSystem's restructuring has been finished. Here are the new folders introduced by this PR, along with an exhaustive list of the contents of each:
This is the continuation of #1190, which aims to refactor parts of the code base with the primary goal of making them easier to understand. Here are the most notable changes in part 2 of refactoring Mosa.DeviceSystem: