From 945a1cce720a2a4c484ae5684fb25575cd130df8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pedro?= Date: Sat, 1 Dec 2018 22:55:14 +0000 Subject: [PATCH] Code cleanup. --- source/Cosmos.HAL2/.editorconfig | 8 --- source/Cosmos.HAL2/BlockDevice/Ata.cs | 58 +++++++++---------- source/Cosmos.HAL2/BlockDevice/BlockDevice.cs | 23 +++----- source/Cosmos.HAL2/BlockDevice/Partition.cs | 7 +-- 4 files changed, 35 insertions(+), 61 deletions(-) delete mode 100644 source/Cosmos.HAL2/.editorconfig diff --git a/source/Cosmos.HAL2/.editorconfig b/source/Cosmos.HAL2/.editorconfig deleted file mode 100644 index 3e188034f..000000000 --- a/source/Cosmos.HAL2/.editorconfig +++ /dev/null @@ -1,8 +0,0 @@ -[*.cs] -indent_size=4 - -[Global.cs] -indent_size = 2 - -[BlockDevice/Ata.cs] -indent_size = 2 diff --git a/source/Cosmos.HAL2/BlockDevice/Ata.cs b/source/Cosmos.HAL2/BlockDevice/Ata.cs index 89578a989..e052af801 100644 --- a/source/Cosmos.HAL2/BlockDevice/Ata.cs +++ b/source/Cosmos.HAL2/BlockDevice/Ata.cs @@ -1,36 +1,30 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Cosmos.Debug.Kernel; +using Cosmos.Debug.Kernel; -namespace Cosmos.HAL.BlockDevice { - public abstract class Ata : BlockDevice - { - - internal static Debugger AtaDebugger = new Debugger("HAL", "Ata"); - - protected Ata() { - mBlockSize = 512; - } - - // In future may need to add a None for PCI ATA controllers. - // Or maybe they all have Primary and Secondary on them as well. - public enum ControllerIdEnum { Primary, Secondary } - protected ControllerIdEnum mControllerID; - public ControllerIdEnum ControllerID { - get { return mControllerID; } - } - - public enum BusPositionEnum { Master, Slave } - protected BusPositionEnum mBusPosition; - public BusPositionEnum BusPosition { - get { return mBusPosition; } - } - - public override string ToString() +namespace Cosmos.HAL.BlockDevice +{ + public abstract class Ata : BlockDevice { - return "Ata (Abstract)"; + + internal static Debugger AtaDebugger = new Debugger("HAL", "Ata"); + + protected Ata() + { + mBlockSize = 512; + } + + // In future may need to add a None for PCI ATA controllers. + // Or maybe they all have Primary and Secondary on them as well. + public enum ControllerIdEnum { Primary, Secondary } + protected ControllerIdEnum mControllerID; + public ControllerIdEnum ControllerID => mControllerID; + + public enum BusPositionEnum { Master, Slave } + protected BusPositionEnum mBusPosition; + public BusPositionEnum BusPosition => mBusPosition; + + public override string ToString() + { + return "Ata (Abstract)"; + } } - } } diff --git a/source/Cosmos.HAL2/BlockDevice/BlockDevice.cs b/source/Cosmos.HAL2/BlockDevice/BlockDevice.cs index 63ad54312..e34acc41e 100644 --- a/source/Cosmos.HAL2/BlockDevice/BlockDevice.cs +++ b/source/Cosmos.HAL2/BlockDevice/BlockDevice.cs @@ -1,8 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using Cosmos.Debug.Kernel; namespace Cosmos.HAL.BlockDevice { @@ -23,21 +20,15 @@ namespace Cosmos.HAL.BlockDevice } protected UInt64 mBlockCount = 0; - public UInt64 BlockCount - { - get { return mBlockCount; } - } + public UInt64 BlockCount => mBlockCount; - protected UInt64 mBlockSize = 0; - public UInt64 BlockSize - { - get { return mBlockSize; } - } + protected UInt64 mBlockSize = 0; + public UInt64 BlockSize => mBlockSize; - // Only allow reading and writing whole blocks because many of the hardware - // command work that way and we dont want to add complexity at the BlockDevice level. - // public abstract void ReadBlock(UInt64 aBlockNo, UInt32 aBlockCount, byte[] aData); - public abstract void ReadBlock(UInt64 aBlockNo, UInt64 aBlockCount, byte[] aData); + // Only allow reading and writing whole blocks because many of the hardware + // command work that way and we dont want to add complexity at the BlockDevice level. + // public abstract void ReadBlock(UInt64 aBlockNo, UInt32 aBlockCount, byte[] aData); + public abstract void ReadBlock(UInt64 aBlockNo, UInt64 aBlockCount, byte[] aData); public abstract void WriteBlock(UInt64 aBlockNo, UInt64 aBlockCount, byte[] aData); protected void CheckDataSize(byte[] aData, UInt64 aBlockCount) diff --git a/source/Cosmos.HAL2/BlockDevice/Partition.cs b/source/Cosmos.HAL2/BlockDevice/Partition.cs index 16c9f699f..979eb576c 100644 --- a/source/Cosmos.HAL2/BlockDevice/Partition.cs +++ b/source/Cosmos.HAL2/BlockDevice/Partition.cs @@ -1,14 +1,11 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; namespace Cosmos.HAL.BlockDevice { public class Partition : BlockDevice { - BlockDevice mHost; - UInt64 mStartingSector; + private readonly BlockDevice mHost; + private readonly UInt64 mStartingSector; public Partition(BlockDevice aHost, UInt64 aStartingSector, UInt64 aSectorCount) {