diff --git a/Launcher.bat b/Launcher.bat index cf4c5bdf5..380af107b 100644 --- a/Launcher.bat +++ b/Launcher.bat @@ -1 +1 @@ -start bin\Mosa.Tool.Launcher.exe -qemu bin\Mosa.HelloWorld.x86.exe +start bin\Mosa.Tool.Launcher.exe --qemu bin\Mosa.HelloWorld.x86.exe diff --git a/Source/Mosa.DeviceDriver/ISA/CMOSX.cs b/Source/Mosa.DeviceDriver/ISA/CMOSX.cs index 62b7723b9..73f2f0ca4 100644 --- a/Source/Mosa.DeviceDriver/ISA/CMOSX.cs +++ b/Source/Mosa.DeviceDriver/ISA/CMOSX.cs @@ -8,7 +8,7 @@ namespace Mosa.DeviceDriver.ISA /// CMOS Device Driver /// //[ISADeviceDriver(AutoLoad = true, BasePort = 0x0070, PortRange = 2, Platforms = PlatformArchitecture.X86)] - public class CMOSX : HardwareDeviceX + public class CMOSX : DeviceDriverX { /// /// The command port @@ -25,6 +25,9 @@ public class CMOSX : HardwareDeviceX /// protected SpinLock spinLock; + /// + /// Initializes this device. + /// protected override void Initialize() { Device.Name = "CMOS"; @@ -37,10 +40,10 @@ protected override void Initialize() public override void Start() { - if (Device.Status == DeviceStatus.Available) - { - Device.Status = DeviceStatus.Online; - } + if (Device.Status != DeviceStatus.Available) + return; + + Device.Status = DeviceStatus.Online; } /// diff --git a/Source/Mosa.DeviceDriver/ISA/DMA8Bit.cs b/Source/Mosa.DeviceDriver/ISA/DMA8Bit.cs deleted file mode 100644 index 31736361e..000000000 --- a/Source/Mosa.DeviceDriver/ISA/DMA8Bit.cs +++ /dev/null @@ -1,369 +0,0 @@ -// Copyright (c) MOSA Project. Licensed under the New BSD License. - -using Mosa.DeviceSystem; - -namespace Mosa.DeviceDriver.ISA -{ - /// - /// Direct Memory Access (DMA) Device Driver - /// - //[ISADeviceDriver(AutoLoad = false, BasePort = 0x0000, PortRange = 32, AltBasePort = 0x0080, AltPortRange = 8, Platforms = PlatformArchitecture.X86AndX64)] - //[DeviceDriverPhysicalMemory(MemorySize = 64 * 1024, MemoryAlignment = 64 * 1024, RestrictUnder16M = true)] - //[DeviceDriverPhysicalMemory(MemorySize = 64 * 1024, MemoryAlignment = 64 * 1024, RestrictUnder16M = true)] - //[DeviceDriverPhysicalMemory(MemorySize = 64 * 1024, MemoryAlignment = 64 * 1024, RestrictUnder16M = true)] - public class DMA8Bit : HardwareDevice - { - #region Definitions - - internal struct DMAModeValue - { - internal const byte ReadFromMemory = 0x08; // TRN=10 - internal const byte WriteToMemory = 0x04; // TRN=01 - } - - internal struct DMATransferTypeValue - { - internal const byte OnDemand = 0x00; // MOD=00 - internal const byte Single = 0x40; // MOD=01 - internal const byte Block = 0x80; // MOD=10 - internal const byte CascadeMode = 0xC0; // MOD=11 - } - - internal struct DMAAutoValue - { - internal const byte Auto = 0x10; - internal const byte NoAuto = 0x00; - } - - #endregion Definitions - - /// - /// - /// - protected IOPortRead statusRegister; - - /// - /// - /// - protected IOPortWrite commandRegister; - - /// - /// - /// - protected IOPortWrite requestRegister; - - /// - /// - /// - protected IOPortWrite channelMaskRegister; - - /// - /// - /// - protected IOPortWrite modeRegister; - - /// - /// - /// - protected IOPortWrite byteWordRegister; - - /// - /// - /// - protected IOPortRead intermediateRegister; - - /// - /// - /// - protected IOPortWrite maskRegister; - - /// - /// - /// - protected IOPortReadWrite channel0Address; - - /// - /// - /// - protected IOPortReadWrite channel0Count; - - /// - /// - /// - protected IOPortReadWrite channel0Page; - - /// - /// - /// - protected IOPortReadWrite channel1Address; - - /// - /// - /// - protected IOPortReadWrite channel1Count; - - /// - /// - /// - protected IOPortReadWrite channel1Page; - - /// - /// - /// - protected IOPortReadWrite channel2Address; - - /// - /// - /// - protected IOPortReadWrite channel2Count; - - /// - /// - /// - protected IOPortReadWrite channel2Page; - - /// - /// - /// - protected IOPortReadWrite channel3Address; - - /// - /// - /// - protected IOPortReadWrite channel3Count; - - /// - /// - /// - protected IOPortReadWrite channel3Page; - - /// - /// - /// - protected BaseMemory memory0; - - /// - /// - /// - protected BaseMemory memory1; - - /// - /// - /// - protected BaseMemory memory2; - - /// - /// - /// - protected BaseMemory memory3; - - /// - /// Initializes a new instance of the class. - /// - public DMA8Bit() - { - } - - /// - /// Setups this hardware device driver - /// - /// - /// - public override bool Setup(HardwareResources hardwareResources) - { - this.HardwareResources = hardwareResources; - base.Name = "DMA_0x" + base.HardwareResources.GetIOPortRegion(0).BaseIOPort.ToString("X"); - - statusRegister = base.HardwareResources.GetIOPortRead(0, 0x08); - commandRegister = base.HardwareResources.GetIOPortWrite(0, 0x08); - requestRegister = base.HardwareResources.GetIOPortWrite(0, 0x09); - channelMaskRegister = base.HardwareResources.GetIOPortWrite(0, 0x0A); - modeRegister = base.HardwareResources.GetIOPortWrite(0, 0x0B); - byteWordRegister = base.HardwareResources.GetIOPortWrite(0, 0x0C); - intermediateRegister = base.HardwareResources.GetIOPortReadWrite(0, 0x0D); - maskRegister = base.HardwareResources.GetIOPortWrite(0, 0x0F); - - channel0Address = base.HardwareResources.GetIOPortReadWrite(0, 0x00); - channel0Count = base.HardwareResources.GetIOPortReadWrite(0, 0x01); - channel0Page = base.HardwareResources.GetIOPortReadWrite(0, 0x87); - - channel1Address = base.HardwareResources.GetIOPortReadWrite(0, 0x02); - channel1Count = base.HardwareResources.GetIOPortReadWrite(0, 0x03); - channel1Page = base.HardwareResources.GetIOPortReadWrite(0, 0x83); - - channel2Address = base.HardwareResources.GetIOPortReadWrite(0, 0x04); - channel2Count = base.HardwareResources.GetIOPortReadWrite(0, 0x05); - channel2Page = base.HardwareResources.GetIOPortReadWrite(0, 0x81); - - channel3Address = base.HardwareResources.GetIOPortReadWrite(0, 0x06); - channel3Count = base.HardwareResources.GetIOPortReadWrite(0, 0x07); - channel3Page = base.HardwareResources.GetIOPortReadWrite(0, 0x82); - - memory0 = base.HardwareResources.GetMemory(0); - memory1 = base.HardwareResources.GetMemory(1); - memory2 = base.HardwareResources.GetMemory(2); - memory3 = base.HardwareResources.GetMemory(3); - - return true; - } - - /// - /// Starts this hardware device. - /// - /// - public override DeviceDriverStartStatus Start() => DeviceDriverStartStatus.Started; - - /// - /// Called when an interrupt is received. - /// - /// - public override bool OnInterrupt() => false; - - /// - /// Setups the channel. - /// - /// The channel. - /// The count. - /// The mode. - /// The type. - /// if set to true [auto]. - /// - public bool SetupChannel(byte channel, uint count, DMAMode mode, DMATransferType type, bool auto) - { - IOPortReadWrite dmaAddress; - IOPortReadWrite dmaCount; - IOPortReadWrite dmaPage; - BaseMemory memory; - - switch (channel) - { - case 0: dmaAddress = channel0Address; dmaCount = channel0Count; dmaPage = channel0Page; memory = memory0; break; - case 1: dmaAddress = channel1Address; dmaCount = channel1Count; dmaPage = channel1Page; memory = memory1; break; - case 2: dmaAddress = channel2Address; dmaCount = channel2Count; dmaPage = channel2Page; memory = memory2; break; - case 3: dmaAddress = channel3Address; dmaCount = channel3Count; dmaPage = channel3Page; memory = memory3; break; - default: return false; - } - - var address = memory.Address; - - // Disable DMA Controller - channelMaskRegister.Write8((byte)(channel | 4)); - - // Clear any current transfers - byteWordRegister.Write8(0xFF); // reset flip-flop - - // Set Address - dmaAddress.Write8((byte)(address & 0xFF)); // low byte - dmaAddress.Write8((byte)((address >> 8) & 0xFF)); // high byte - dmaPage.Write8((byte)((address >> 16) & 0xFF)); // page - - // Clear any current transfers - byteWordRegister.Write8(0xFF); // reset flip-flop - - // Set Count - dmaCount.Write8((byte)((count - 1) & 0xFF)); // low - dmaCount.Write8((byte)(((count - 1) >> 8) & 0xFF)); // high - - var value = channel; - - if (auto) - value = (byte)(value | DMAAutoValue.Auto); - else - value = (byte)(value | DMAAutoValue.NoAuto); - - if (mode == DMAMode.ReadFromMemory) - value = (byte)(value | DMAModeValue.ReadFromMemory); - else - value = (byte)(value | DMAModeValue.WriteToMemory); - - switch (type) - { - case DMATransferType.Block: value = (byte)(value | DMATransferTypeValue.Block); break; - case DMATransferType.CascadeMode: value = (byte)(value | DMATransferTypeValue.CascadeMode); break; - case DMATransferType.OnDemand: value = (byte)(value | DMATransferTypeValue.OnDemand); break; - case DMATransferType.Single: value = (byte)(value | DMATransferTypeValue.Single); break; - default: break; - } - - // Set DMA Channel to write - modeRegister.Write8(value); - - // Enable DMA Controller - channelMaskRegister.Write8(channel); - - return true; - } - - /// - /// Gets the DMA transer address. - /// - /// The channel. - /// - protected BaseMemory GetTranserAddress(byte channel) - { - switch (channel) - { - case 0: return memory0; - case 1: return memory1; - case 2: return memory2; - case 3: return memory3; - default: - return null; - } - } - - /// - /// Transfers the out. - /// - /// The channel. - /// The count. - /// The destination. - /// The offset. - /// - public bool TransferOut(byte channel, uint count, byte[] destination, uint offset) - { - if (count > (1024 * 64)) - return false; - - if (destination.Length + offset > count) - return false; - - var address = GetTranserAddress(channel); - - if (address.Address == 0x00) - return false; - - for (uint i = 0; i < count; i++) - destination[offset + i] = address[i]; - - return true; - } - - /// - /// Transfers the in. - /// - /// The channel. - /// The count. - /// The source. - /// The offset. - /// - public bool TransferIn(byte channel, uint count, byte[] source, uint offset) - { - if (count > (1024 * 64)) - return false; - - if (source.Length + offset > count) - return false; - - var address = GetTranserAddress(channel); - - if (address.Address == 0x00) - return false; - - for (uint i = 0; i < count; i++) - address[i] = source[offset + i]; - - return true; - } - } -} diff --git a/Source/Mosa.DeviceDriver/ISA/FloppyDiskController.cs b/Source/Mosa.DeviceDriver/ISA/FloppyDiskController.cs deleted file mode 100644 index 8ec5ea90c..000000000 --- a/Source/Mosa.DeviceDriver/ISA/FloppyDiskController.cs +++ /dev/null @@ -1,1087 +0,0 @@ -// Copyright (c) MOSA Project. Licensed under the New BSD License. - -// References: -// http://en.wikipedia.org/wiki/Floppy_disk_controller -// http://www.osdev.org/wiki/Floppy_Disk_Controller -// ftp://download.intel.com/design/archives/periphrl/docs/29047403.pdf -// http://www.osdever.net/documents/82077AA_FloppyControllerDatasheet.pdf?the_id=41 -// http://www.isdaman.com/alsos/hardware/fdc/floppy.htm -// http://www.osdev.org/phpBB2/viewtopic.php?t=13538 - -using Mosa.DeviceSystem; - -namespace Mosa.DeviceDriver.ISA -{ - /// - /// Floppy Disk Controller (FDC) Device Driver - /// - //[ISADeviceDriver(AutoLoad = false, BasePort = 0x03F0, PortRange = 8, IRQ = 6, Platforms = PlatformArchitecture.X86AndX64)] - //[ISADeviceDriver(AutoLoad = false, BasePort = 0x0370, PortRange = 8, IRQ = 5, ForceOption = "fdc2", Platforms = PlatformArchitecture.X86AndX64)] - public class FloppyDiskController : HardwareDevice, IDiskControllerDevice - { - #region Definitions - - internal struct FIFOCommand - { - internal const byte ReadTrack = 0x02; - internal const byte Specify = 0x03; - internal const byte SenseDriveStatus = 0x04; - internal const byte WriteSector = 0x05; - internal const byte ReadSector = 0x06; - internal const byte Recalibrate = 0x07; - internal const byte SenseInterrupt = 0x08; - internal const byte WriteDeletedSector = 0x09; - internal const byte ReadID = 0x0A; - internal const byte ReadDeletedSector = 0x0C; - internal const byte FormatTrack = 0x0D; - internal const byte Seek = 0x0F; - internal const byte Version = 0x10; - internal const byte ScanEqual = 0x11; - internal const byte PerpendicularMode = 0x12; - internal const byte Configure = 0x13; - internal const byte Verify = 0x16; - internal const byte ScanLowOrEqual = 0x19; - internal const byte ScanHighOrEqual = 0x1D; - internal const byte MFMModeMask = 0x40; - }; - - internal struct DORFlags - { - internal const byte MotorEnableShift = 0x04; - internal const byte MotorEnableMask = 0x0F; - internal const byte ResetController = 0x00; - internal const byte EnableDMA = 0x08; - internal const byte EnableController = 0x04; - internal const byte MotorShift = 0x10; - internal const byte DisableAll = 0x00; - internal const uint driveSelectMask = 0x03; - }; - - internal struct FDC - { - internal const uint BytesPerSector = 512; - internal const uint MaxSectorsPerTracks = 36; // 2.88 = 36, DMF formatted disks can have up to 21 sectors - internal const uint MaxBytesPerTrack = MaxSectorsPerTracks * BytesPerSector; - }; - - #endregion Definitions - - /// - /// - /// - public enum FloppyDriveType - { - /// - /// - /// - None, - - /// - /// - /// - Floppy_5_25, - - /// - /// - /// - Floppy_3_5, - - /// - /// - /// - Unknown - } - - /// - /// - /// - public struct FloppyDriveInfo - { - /// - /// - /// - public FloppyDriveType Type; - - /// - /// - /// - public uint KiloByteSize; - } - - /// - /// - /// - public struct FloppyMediaInfo - { - /// - /// - /// - public uint SectorsPerTrack; - - /// - /// - /// - public uint TotalTracks; - - /// - /// - /// - public byte Gap1Length; - - /// - /// - /// - public byte Gap2Length; - } - - /// - /// - /// - protected struct LastSeek - { - /// - /// - /// - public bool calibrated; - - /// - /// - /// - public uint drive; - - /// - /// - /// - public byte track; - - /// - /// - /// - public byte head; - } - - /// - /// - /// - protected struct TrackCache - { - /// - /// - /// - public byte[] buffer; - - /// - /// - /// - public bool valid; - - /// - /// - /// - public byte track; - - /// - /// - /// - public byte head; - } - - /// - /// - /// - protected SpinLock spinLock; - - /// - /// - /// - protected bool enchancedController = false; - - /// - /// - /// - public const uint DrivesPerController = 2; // the maximum supported - - /// - /// - /// - protected FloppyDriveInfo[] floppyDrives; - - /// - /// - /// - protected FloppyMediaInfo[] floppyMedia; - - /// - /// - /// - protected TrackCache[] trackCache; - - /// - /// - /// - protected LastSeek[] lastSeek; - - /// - /// - /// - protected IOPortReadWrite commandPort; - - /// - /// - /// - protected IOPortReadWrite dataPort; - - /// - /// - /// - protected IOPortReadWrite configPort; - - /// - /// - /// - protected IOPortReadWrite statusPort; - - /// - /// - /// - protected IDMAChannel floppyDMA; - - /// - /// - /// - protected bool interruptSet = false; - - //protected enum OperationPending - //{ - // None, - // Read, - // Write, - // Seek, - // Recalibrate, - // Reset, - //} - - //protected OperationPending pendingOperation; - - /// - /// Initializes a new instance of the class. - /// - public FloppyDiskController() - { - floppyDrives = new FloppyDriveInfo[DrivesPerController]; - floppyMedia = new FloppyMediaInfo[DrivesPerController]; - - trackCache = new TrackCache[DrivesPerController]; - lastSeek = new LastSeek[DrivesPerController]; - - for (int drive = 0; drive < DrivesPerController; drive++) - trackCache[drive].buffer = new byte[FDC.MaxBytesPerTrack]; - } - - /// - /// Setups this hardware device driver - /// - /// - public override bool Setup(HardwareResources hardwareResources) - { - this.HardwareResources = hardwareResources; - base.Name = "FDC_0x" + base.HardwareResources.GetIOPortRegion(0).BaseIOPort.ToString("X"); - base.Parent = null; // no parent - - commandPort = base.HardwareResources.GetIOPortReadWrite(0, 2); - statusPort = base.HardwareResources.GetIOPortReadWrite(0, 4); - dataPort = base.HardwareResources.GetIOPortReadWrite(0, 5); - configPort = base.HardwareResources.GetIOPortReadWrite(0, 7); - - // floppyDMA = base.CreateDMAChannel(2); - // floppyIRQ = base.CreateIRQHandler(6); - - return true; - } - - /// - /// Starts this hardware device. - /// - /// - public override DeviceDriverStartStatus Start() - { - for (int drive = 0; drive < DrivesPerController; drive++) - { - trackCache[drive].valid = false; - lastSeek[drive].calibrated = false; - - // default - floppyMedia[drive].SectorsPerTrack = 18; - floppyMedia[drive].TotalTracks = 80; - - //TODO: for 5.25, Gap1 = 0x2A and Gap2 = 0x50 - floppyMedia[drive].Gap1Length = 0x1B; // 27 - floppyMedia[drive].Gap2Length = 0x54; - } - - ResetController(); - - commandPort.Write8(DORFlags.EnableController | DORFlags.EnableDMA); - - SendByte(FIFOCommand.SenseInterrupt); - GetByte(); - GetByte(); - - configPort.Write8(0x00); // 500 Kb/s (MFM) - - // Set step rate to 3ms & head unload time to 240ms - SendByte(FIFOCommand.Specify); - SendByte((((16 - (3)) << 4) | ((240 / 16)))); - - // Set head load time to 2ms - SendByte(0x02); - - SendByte(FIFOCommand.Version); - - if (GetByte() == 0x80) - enchancedController = false; - else - enchancedController = true; - - DetectDrives(); - - return DeviceDriverStartStatus.Started; - } - - /// - /// Called when an interrupt is received. - /// - /// - public override bool OnInterrupt() - { - interruptSet = true; - return true; - } - - /// - /// Opens the specified drive. - /// - /// The drive NBR. - /// - public bool Open(uint drive) - { - if (drive > MaximunDriveCount) - return false; - - if (floppyDrives[drive].Type != FloppyDriveType.None) - return false; - - // clear it - floppyMedia[drive].TotalTracks = 0; - floppyMedia[drive].SectorsPerTrack = 0; - - byte[] temp = new byte[FDC.BytesPerSector]; - spinLock.Enter(); - - try - { - //TODO: check drive type first - - // attempt to read 2.88MB/2880KB - floppyMedia[drive].SectorsPerTrack = 36; - floppyMedia[drive].TotalTracks = 80; - floppyMedia[drive].Gap1Length = 0x1B; - floppyMedia[drive].Gap2Length = 0x54; - - if (ReadBlock(drive, CHSToLBA(drive, floppyMedia[drive].TotalTracks - 1, 0, floppyMedia[drive].SectorsPerTrack - 1), 1, temp)) - return true; - - // attempt to read 1.64MB/1680KB (DMF) - floppyMedia[drive].SectorsPerTrack = 21; - floppyMedia[drive].TotalTracks = 80; - floppyMedia[drive].Gap1Length = 0x0C; - floppyMedia[drive].Gap2Length = 0x1C; - - if (ReadBlock(drive, CHSToLBA(drive, floppyMedia[drive].TotalTracks - 1, 0, floppyMedia[drive].SectorsPerTrack - 1), 1, temp)) - return true; - - // attempt to read 1.44MB - floppyMedia[drive].TotalTracks = 80; - floppyMedia[drive].SectorsPerTrack = 18; - floppyMedia[drive].Gap1Length = 0x1B; - floppyMedia[drive].Gap2Length = 0x54; - - if (ReadBlock(drive, CHSToLBA(drive, floppyMedia[drive].TotalTracks - 1, 0, floppyMedia[drive].SectorsPerTrack - 1), 1, temp)) - return true; - - // attempt to read 720Kb - floppyMedia[drive].TotalTracks = 80; - floppyMedia[drive].SectorsPerTrack = 9; - floppyMedia[drive].Gap1Length = 0x1B; - floppyMedia[drive].Gap2Length = 0x54; - - if (ReadBlock(drive, CHSToLBA(drive, floppyMedia[drive].TotalTracks - 1, 0, floppyMedia[drive].SectorsPerTrack - 1), 1, temp)) - return true; - - // unable to read floppy media - floppyMedia[drive].TotalTracks = 0; - floppyMedia[drive].SectorsPerTrack = 0; - - return false; - } - finally - { - spinLock.Exit(); - } - } - - /// - /// Releases the specified drive. - /// - /// The drive. - /// - public bool Release(uint drive) - { - return true; - } - - /// - /// Gets the maximun drive count. - /// - /// The drive count. - public uint MaximunDriveCount { get { return 2; } } - - /// - /// Gets the size of the sector. - /// - /// The drive. - /// - public uint GetSectorSize(uint drive) - { - return 512; - } - - /// - /// Gets the total sectors. - /// - /// The drive NBR. - /// - public uint GetTotalSectors(uint drive) - { - if (drive > MaximunDriveCount) - return 0; - - return floppyMedia[drive].SectorsPerTrack * floppyMedia[drive].TotalTracks * 2; - } - - /// - /// Determines whether this instance can write the specified drive NBR. - /// - /// The drive NBR. - /// - /// true if this instance can write the specified drive NBR; otherwise, false. - /// - public bool CanWrite(uint drive) - { - if (drive > MaximunDriveCount) - return false; - - if (floppyMedia[drive].SectorsPerTrack == 0) - return false; - - return true; - } - - /// - /// Waits for register ready. - /// - /// - protected bool WaitForReqisterReady() - { - // wait for RQM data register to be ready - while (true) - { - uint status = statusPort.Read8(); - - if ((status & 0x80) == 0x80) - return true; - - //TODO: add timeout check - } - - //return false; - } - - /// - /// Sends the byte. - /// - /// The command. - protected void SendByte(byte command) - { - WaitForReqisterReady(); - dataPort.Write8(command); - } - - /// - /// Gets the byte. - /// - /// - protected byte GetByte() - { - WaitForReqisterReady(); - return dataPort.Read8(); - } - - /// - /// Clears the interrupt. - /// - protected void ClearInterrupt() - { - interruptSet = false; - } - - /// - /// Waits for interrupt. - /// - /// The milliseconds. - /// - protected bool WaitForInterrupt(uint milliseconds) - { - while (!interruptSet) ; - - return true; - } - - /// - /// Resets the controller. - /// - protected void ResetController() - { - ClearInterrupt(); - - commandPort.Write8(DORFlags.ResetController); - - HAL.Sleep(200); - - commandPort.Write8(DORFlags.EnableController); - - WaitForInterrupt(3000); - } - - /// - /// Determines the type of the by. - /// - /// The type. - /// - protected static FloppyDriveInfo DetermineByType(byte type) - { - FloppyDriveInfo floppy = new FloppyDriveInfo(); - - switch (type) - { - case 0: { floppy.Type = FloppyDriveType.None; floppy.KiloByteSize = 0; break; } - case 1: { floppy.Type = FloppyDriveType.Floppy_5_25; floppy.KiloByteSize = 360; break; } - case 2: { floppy.Type = FloppyDriveType.Floppy_5_25; floppy.KiloByteSize = 1200; break; } - case 3: { floppy.Type = FloppyDriveType.Floppy_3_5; floppy.KiloByteSize = 720; break; } - case 4: { floppy.Type = FloppyDriveType.Floppy_3_5; floppy.KiloByteSize = 1440; break; } - case 5: { floppy.Type = FloppyDriveType.Floppy_3_5; floppy.KiloByteSize = 2880; break; } - default: { floppy.Type = FloppyDriveType.Unknown; floppy.KiloByteSize = 0; break; } - } - - return floppy; - } - - /// - /// Detects the drives. - /// - protected void DetectDrives() - { - // TODO - connect to CMOS driver and request this information - // for now, just assume one 3.5in 1.44Mb drive - - //CMOSComand = base.CreateIOPort(0x70); - //CMOSResponse = base.CreateIOPort(0x71); - - //CMOSComand.Write8(0x10); - //byte types = CMOSResponse.Read8(); - - //floppyDrives[0] = DetermineByType((byte)(types >> 4)); - //floppyDrives[1] = DetermineByType((byte)(types & 0xF)); - - floppyDrives[0].Type = FloppyDriveType.Floppy_3_5; - floppyDrives[0].KiloByteSize = 14400; - - floppyDrives[1].Type = FloppyDriveType.None; - floppyDrives[1].KiloByteSize = 0; - } - - /// - /// Turns the off motor. - /// - /// The drive. - protected void TurnOffMotor(uint drive) - { - commandPort.Write8((byte)(DORFlags.EnableDMA | DORFlags.EnableController | drive)); - } - - /// - /// Turns the on motor. - /// - /// The drive. - protected void TurnOnMotor(uint drive) - { - byte reg = commandPort.Read8(); - byte bits = (byte)(DORFlags.MotorShift << (byte)drive | DORFlags.EnableDMA | DORFlags.EnableController | (byte)drive); - - if (reg != bits) - { - commandPort.Write8(bits); - HAL.Sleep(500); // 500 msec - } - } - - /// - /// Re-calibrates the specified drive. - /// - /// The drive. - /// - protected bool Recalibrate(uint drive) - { - lastSeek[drive].calibrated = false; - - for (int i = 0; i < 5; i++) - { - TurnOnMotor(drive); - - ClearInterrupt(); - - SendByte(FIFOCommand.Recalibrate); - SendByte((byte)drive); - - WaitForInterrupt(3000); - - SendByte(FIFOCommand.SenseInterrupt); - byte sr0 = GetByte(); - byte fdc_track = GetByte(); - - if (((sr0 & 0xC0) == 0x00) && (fdc_track == 0)) - { - lastSeek[drive].calibrated = true; - lastSeek[drive].track = 0; - lastSeek[drive].head = 2; // invalid head (required) - return true; // Note: motor is left on - } - } - - TurnOffMotor(drive); - - return false; - } - - /// - /// Seeks the specified drive. - /// - /// The drive. - /// The track. - /// The head. - /// - protected bool Seek(uint drive, byte track, byte head) - { - TurnOnMotor(drive); - - if (!lastSeek[drive].calibrated) - if (!Recalibrate(drive)) - return false; - - if ((lastSeek[drive].calibrated) && (lastSeek[drive].track == track) && (lastSeek[drive].head == head)) - return true; - - for (int i = 0; i < 5; i++) - { - ClearInterrupt(); - - lastSeek[drive].calibrated = false; - - SendByte(FIFOCommand.Seek); - SendByte((byte)(((byte)drive | (head << 2)))); - SendByte(track); - - if (!WaitForInterrupt(3000)) - return false; - - HAL.Sleep(20); - - SendByte(FIFOCommand.SenseInterrupt); - byte sr0 = GetByte(); - byte trk = GetByte(); - - if ((sr0 == (0x20 + ((byte)drive | (head << 2)))) && (trk == track)) - { - lastSeek[drive].calibrated = true; - lastSeek[drive].track = track; - lastSeek[drive].head = head; - return true; - } - } - - return false; - } - - /// - /// LBAs to track. - /// - /// The drive. - /// The lba. - /// - protected byte LBAToTrack(uint drive, uint lba) - { - return (byte)(lba / (floppyMedia[drive].SectorsPerTrack * 2)); - } - - /// - /// LBAs to head. - /// - /// The drive. - /// The lba. - /// - protected byte LBAToHead(uint drive, uint lba) - { - return (byte)((lba % (floppyMedia[drive].SectorsPerTrack * 2)) / floppyMedia[drive].SectorsPerTrack); - } - - /// - /// LBAs to sector. - /// - /// The drive. - /// The lba. - /// - protected byte LBAToSector(uint drive, uint lba) - { - return (byte)((lba % (floppyMedia[drive].SectorsPerTrack * 2)) % floppyMedia[drive].SectorsPerTrack); - } - - /// - /// CHSs to LBA. - /// - /// The drive. - /// The cylinder. - /// The head. - /// The sector. - /// - protected uint CHSToLBA(uint drive, uint cylinder, uint head, uint sector) - { - return ((cylinder * 2 + head) * floppyMedia[drive].SectorsPerTrack) + sector - 1; - } - - /// - /// Reads the block. - /// - /// The drive NBR. - /// The block. - /// The count. - /// The data. - /// - public bool ReadBlock(uint drive, uint block, uint count, byte[] data) - { - if (data.Length < count * 512) - return false; - - try - { - spinLock.Enter(); - for (uint index = 0; index < count; index++) - { - if (!ReadBlock2(drive, block + index, data, index * FDC.BytesPerSector)) - return false; - } - return true; - } - finally - { - TurnOffMotor(drive); //TODO: create timer to turn off drive motors after 1 sec. - spinLock.Exit(); - } - } - - /// - /// Writes the block. - /// - /// The drive NBR. - /// The block. - /// The count. - /// The data. - /// - public bool WriteBlock(uint drive, uint block, uint count, byte[] data) - { - if (data.Length < count * 512) - return false; - - try - { - spinLock.Enter(); - for (uint index = 0; index < count; index++) - { - if (!WriteBlock2(drive, block + index, 1, data, index * FDC.BytesPerSector)) - return false; - } - return true; - } - finally - { - TurnOffMotor(drive); //TODO: create timer to turn off drive motors after 1 sec. - spinLock.Exit(); - } - } - - /// - /// Reads the block2. - /// - /// The drive. - /// The lba. - /// The data. - /// The offset. - /// - protected bool ReadBlock2(uint drive, uint lba, byte[] data, uint offset) - { - if (drive > MaximunDriveCount) - return false; - - byte track = LBAToTrack(drive, lba); - byte head = LBAToHead(drive, lba); - byte sector = LBAToSector(drive, lba); - - if (!((trackCache[drive].valid) && (trackCache[drive].track == track) && (trackCache[drive].head == head))) - { - trackCache[drive].valid = false; - - if (!PerformIO(SectorOperation.Read, drive, 0, track, head, floppyMedia[drive].SectorsPerTrack, trackCache[drive].buffer, 0)) - return false; - - trackCache[drive].valid = true; - trackCache[drive].head = head; - trackCache[drive].track = track; - } - - for (uint i = 0; i < FDC.BytesPerSector; i++) - data[offset + i] = trackCache[drive].buffer[(sector * FDC.BytesPerSector) + i]; - - return true; - } - - /// - /// Writes the block. - /// - /// The drive. - /// The lba. - /// The count. - /// The data. - /// The offset. - /// - protected bool WriteBlock2(uint drive, uint lba, uint count, byte[] data, uint offset) - { - if (drive > MaximunDriveCount) - return false; - - byte track = LBAToTrack(drive, lba); - byte head = LBAToHead(drive, lba); - byte sector = LBAToSector(drive, lba); - - if (sector + count > floppyMedia[drive].SectorsPerTrack) - return false; - - if ((trackCache[drive].track == track) && (trackCache[drive].head == head)) - { - // updated track cache - for (uint i = 0; i < count * FDC.BytesPerSector; i++) - trackCache[drive].buffer[(sector * FDC.BytesPerSector) + i] = data[offset + i]; - } - - if (!PerformIO(SectorOperation.Write, drive, sector, track, head, count, data, offset)) - return false; - - return true; - } - - /// - /// - /// - protected enum SectorOperation - { - /// - /// - /// - Read, - - /// - /// - /// - Write - } - - /// - /// Performs the IO. - /// - /// The operation. - /// The drive. - /// The sector. - /// The track. - /// The head. - /// The count. - /// The data. - /// The offset. - /// - protected bool PerformIO(SectorOperation operation, uint drive, byte sector, byte track, byte head, uint count, byte[] data, uint offset) - { - for (int i = 0; i < 5; i++) - { - int error = 0; - - TurnOnMotor(drive); - - //TODO: Check for disk change - - if (Seek(drive, track, head)) - { - if (operation == SectorOperation.Write) - { - floppyDMA.TransferIn(count * FDC.BytesPerSector, data, offset); - floppyDMA.SetupChannel(DMAMode.ReadFromMemory, DMATransferType.Single, false, count * FDC.BytesPerSector); - } - else - floppyDMA.SetupChannel(DMAMode.WriteToMemory, DMATransferType.Single, false, count * FDC.BytesPerSector); - - ClearInterrupt(); - - if (operation == SectorOperation.Write) - SendByte(FIFOCommand.WriteSector | FIFOCommand.MFMModeMask); - else - SendByte(FIFOCommand.ReadSector | FIFOCommand.MFMModeMask); - - SendByte((byte)((byte)drive | (head << 2))); // 0:0:0:0:0:HD:US1:US0 = head and drive - SendByte(track);// C: - SendByte(head); // H: first head (should match with above) - SendByte((byte)(sector + 1)); // R: first sector, strangely counts from 1 - SendByte(2); // N: bytes/sector, 128*2^x (x=2 -> 512) - SendByte((byte)(sector + count)); // EOT - SendByte(floppyMedia[drive].Gap1Length); // GPL: GAP3 length, 27 is default for 3.5" - SendByte(0xFF); // DTL: (bytes to transfer) = unused - - if (!WaitForInterrupt(3000)) - error = 3; - - byte st0 = GetByte(); - byte st1 = GetByte(); - byte st2 = GetByte(); - - byte trk = GetByte(); // track (cylinder) - byte rhe = GetByte(); // head - - //byte sec = GetByte(); // sector number - GetByte(); // sector number - byte bps = GetByte(); // bytes per sector - - if ((st0 & 0xC0) != 0x0) - { - //if (verbose) TextMode.WriteLine ("FloppyDiskController: error"); - error = 1; - } - if (trk != track + 1) - { - //if (verbose) TextMode.WriteLine ("FloppyDiskController: wrong track: ", trk - 1); - error = 1; - } - if (rhe != head) - { - //if (verbose) TextMode.WriteLine ("FloppyDiskController: wrong track: ", trk - 1); - error = 1; - } - if ((st1 & 0x80) != 0x0) - { - //if (verbose) TextMode.WriteLine ("FloppyDiskController: end of cylinder"); - error = 1; - } - if ((st0 & 0x08) != 0x0) - { - //if (verbose) TextMode.WriteLine ("FloppyDiskController: drive not ready"); - error = 1; - } - if ((st1 & 0x20) != 0x0) - { - //if (verbose) TextMode.WriteLine ("FloppyDiskController: CRC error"); - error = 1; - } - if ((st1 & 0x10) != 0x0) - { - //if (verbose) TextMode.WriteLine ("FloppyDiskController: controller timeout"); - error = 1; - } - if ((st1 & 0x04) != 0x0) - { - //if (verbose) TextMode.WriteLine ("FloppyDiskController: no data found"); - error = 1; - } - if (((st1 | st2) & 0x01) != 0x0) - { - //if (verbose) TextMode.WriteLine ("FloppyDiskController: no address mark found"); - error = 1; - } - if ((st2 & 0x40) != 0x0) - { - //if (verbose) TextMode.WriteLine ("FloppyDiskController: deleted address mark"); - error = 1; - } - if ((st2 & 0x20) != 0x0) - { - //if (verbose) TextMode.WriteLine ("FloppyDiskController: CRC error in data"); - error = 1; - } - if ((st2 & 0x10) != 0x0) - { - //if (verbose) TextMode.WriteLine ("FloppyDiskController: wrong cylinder"); - error = 1; - } - if ((st2 & 0x04) != 0x0) - { - //if (verbose) TextMode.WriteLine ("FloppyDiskController: sector not found"); - error = 1; - } - if ((st2 & 0x02) != 0x0) - { - //if (verbose) TextMode.WriteLine ("FloppyDiskController: bad cylinder"); - error = 1; - } - if (bps != 0x02) - { - //if (verbose) TextMode.WriteLine ("FloppyDiskController: wanted 512B/sector, got something else: ", (int)bps); - error = 1; - } - if ((st1 & 0x02) != 0x0) - { - //if (verbose) TextMode.WriteLine ("FloppyDiskController: not writable"); - error = 2; - } - } - else - { - error = 1; // seek failed - } - - if (error == 0) - { - if (operation == SectorOperation.Write) - return true; - else - if (floppyDMA.TransferOut(count * FDC.BytesPerSector, data, offset)) - return true; - - return false; - } - - lastSeek[drive].calibrated = false; // will force recalibration - - if (error > 1) - { - TurnOffMotor(drive); - break; - } - } - - return false; - } - } -} diff --git a/Source/Mosa.DeviceDriver/ISA/IDEControllerX.cs b/Source/Mosa.DeviceDriver/ISA/IDEControllerX.cs index 71336e6fa..02fd3c3a1 100644 --- a/Source/Mosa.DeviceDriver/ISA/IDEControllerX.cs +++ b/Source/Mosa.DeviceDriver/ISA/IDEControllerX.cs @@ -13,7 +13,7 @@ namespace Mosa.DeviceDriver.ISA /// //[ISADeviceDriver(AutoLoad = true, BasePort = 0x1F0, PortRange = 8, Platforms = PlatformArchitecture.X86AndX64)] //[ISADeviceDriver(AutoLoad = false, BasePort = 0x170, PortRange = 8, ForceOption = "ide2", Platforms = PlatformArchitecture.X86AndX64)] - public class IDEControllerX : HardwareDeviceX, IDiskControllerDevice + public class IDEControllerX : DeviceDriverX, IDiskControllerDevice { #region Definitions diff --git a/Source/Mosa.DeviceDriver/ISA/PCIControllerX.cs b/Source/Mosa.DeviceDriver/ISA/PCIControllerX.cs index 7bd8c1b87..48a87a713 100644 --- a/Source/Mosa.DeviceDriver/ISA/PCIControllerX.cs +++ b/Source/Mosa.DeviceDriver/ISA/PCIControllerX.cs @@ -8,7 +8,7 @@ namespace Mosa.DeviceDriver.ISA /// PCIControllerX /// //[ISADeviceDriver(AutoLoad = true, BasePort = 0x0CF8, PortRange = 8, Platforms = PlatformArchitecture.X86AndX64)] - public class PCIControllerX : HardwareDeviceX, IPCIController + public class PCIControllerX : DeviceDriverX, IPCIController { #region Definitions diff --git a/Source/Mosa.DeviceDriver/ISA/PIC.cs b/Source/Mosa.DeviceDriver/ISA/PIC.cs index 629245e38..0f965285e 100644 --- a/Source/Mosa.DeviceDriver/ISA/PIC.cs +++ b/Source/Mosa.DeviceDriver/ISA/PIC.cs @@ -14,7 +14,7 @@ namespace Mosa.DeviceDriver.ISA /// Programmable Interrupt Controller (PIC) Device Driver /// //[ISADeviceDriver(AutoLoad = true, BasePort = 0x20, PortRange = 2, AltBasePort = 0xA0, AltPortRange = 2, Platforms = PlatformArchitecture.X86AndX64)] - public class PIC : HardwareDevice + public class PIC : DeviceDriverX { #region Definitions @@ -71,38 +71,26 @@ public class PIC : HardwareDevice /// protected byte slaveInterruptMask; - /// - /// Initializes a new instance of the class. - /// - public PIC() - { - } - - /// - /// Setups this hardware device driver - /// - /// - /// - public override bool Setup(HardwareResources hardwareResources) + protected override void Initialize() { - this.HardwareResources = hardwareResources; - base.Name = "PIC_0x" + base.HardwareResources.GetIOPortRegion(0).BaseIOPort.ToString("X"); + Device.Name = "PIC_0x" + Device.Resources.GetIOPortRegion(0).BaseIOPort.ToString("X"); - masterCommandPort = base.HardwareResources.GetIOPortReadWrite(0, 0); - masterDataPort = base.HardwareResources.GetIOPortReadWrite(0, 1); + masterCommandPort = Device.Resources.GetIOPortReadWrite(0, 0); + masterDataPort = Device.Resources.GetIOPortReadWrite(0, 1); - slaveCommandPort = base.HardwareResources.GetIOPortReadWrite(1, 0); - slaveDataPort = base.HardwareResources.GetIOPortReadWrite(1, 1); - - return true; + slaveCommandPort = Device.Resources.GetIOPortReadWrite(1, 0); + slaveDataPort = Device.Resources.GetIOPortReadWrite(1, 1); } - /// - /// Starts this hardware device. - /// - /// - public override DeviceDriverStartStatus Start() + public override void Probe() => Device.Status = DeviceStatus.Available; + + public override void Start() { + if (Device.Status != DeviceStatus.Available) + return; + + Device.Status = DeviceStatus.Online; + byte masterMask; byte slaveMask; @@ -139,9 +127,6 @@ public override DeviceDriverStartStatus Start() slaveDataPort.Write8(slaveMask); DisableIRQs(); - - base.DeviceStatus = DeviceStatus.Online; - return DeviceDriverStartStatus.Started; } /// @@ -160,7 +145,9 @@ public override bool OnInterrupt() public void SendEndOfInterrupt(byte irq) { if (irq >= 8) + { slaveCommandPort.Write8(EOI); + } masterCommandPort.Write8(EOI); } diff --git a/Source/Mosa.DeviceDriver/ISA/PIT.cs b/Source/Mosa.DeviceDriver/ISA/PIT.cs index 9c06e8637..2ca2741f9 100644 --- a/Source/Mosa.DeviceDriver/ISA/PIT.cs +++ b/Source/Mosa.DeviceDriver/ISA/PIT.cs @@ -11,7 +11,7 @@ namespace Mosa.DeviceDriver.ISA /// Programmable Interval Timer (PIT) Device Driver /// //[ISADeviceDriver(AutoLoad = true, BasePort = 0x40, PortRange = 4, IRQ = 0, Platforms = PlatformArchitecture.X86AndX64)] - public class PIT : HardwareDevice, IDevice, IHardwareDevice + public class PIT : DeviceDriverX { #region Definitions @@ -48,33 +48,32 @@ public class PIT : HardwareDevice, IDevice, IHardwareDevice protected uint tickCount; /// - /// Initializes a new instance of the class. + /// Initializes this device. /// - public PIT() + protected override void Initialize() { + Device.Name = "PIT_0x" + Device.Resources.GetIOPortRegion(0).BaseIOPort.ToString("X"); + + modeControlPort = Device.Resources.GetIOPortReadWrite(0, 3); + counter0Divisor = Device.Resources.GetIOPortReadWrite(0, 0); } /// - /// Setups this hardware device driver + /// Probes this instance. /// - /// - public override bool Setup(HardwareResources hardwareResources) - { - this.HardwareResources = hardwareResources; - base.Name = "PIT_0x" + base.HardwareResources.GetIOPortRegion(0).BaseIOPort.ToString("X"); - - modeControlPort = base.HardwareResources.GetIOPortReadWrite(0, 3); - counter0Divisor = base.HardwareResources.GetIOPortReadWrite(0, 0); - - return true; - } + /// + /// Overide for ISA devices, if example + /// + public override void Probe() => Device.Status = DeviceStatus.Available; /// /// Starts this hardware device. /// - /// - public override DeviceDriverStartStatus Start() + public override void Start() { + if (Device.Status != DeviceStatus.Available) + return; + ushort timerCount = (ushort)(Frequency / Hz); // Set to Mode 3 - Square Wave Generator @@ -84,8 +83,7 @@ public override DeviceDriverStartStatus Start() tickCount = 0; - base.DeviceStatus = DeviceStatus.Online; - return DeviceDriverStartStatus.Started; + Device.Status = DeviceStatus.Online; } /// diff --git a/Source/Mosa.DeviceDriver/ISA/Serial.cs b/Source/Mosa.DeviceDriver/ISA/Serial.cs index 4818ba9de..c1a96c6e0 100644 --- a/Source/Mosa.DeviceDriver/ISA/Serial.cs +++ b/Source/Mosa.DeviceDriver/ISA/Serial.cs @@ -11,7 +11,7 @@ namespace Mosa.DeviceDriver.ISA //[ISADeviceDriver(AutoLoad = false, BasePort = 0x02F8, PortRange = 8, IRQ = 3, Platforms = PlatformArchitecture.X86AndX64)] //[ISADeviceDriver(AutoLoad = false, BasePort = 0x03E8, PortRange = 8, IRQ = 4, Platforms = PlatformArchitecture.X86AndX64)] //[ISADeviceDriver(AutoLoad = false, BasePort = 0x02E8, PortRange = 8, IRQ = 3, Platforms = PlatformArchitecture.X86AndX64)] - public class Serial : HardwareDevice, ISerialDevice + public class Serial : DeviceDriverX, ISerialDevice { /// /// Receive Buffer Register (read only) @@ -374,51 +374,51 @@ private enum MSR : byte #endregion Flags /// - /// Initializes a new instance of the class. + /// Initializes this device. /// - public Serial() + protected override void Initialize() { + Device.Name = "COM_0x" + Device.Resources.GetIOPortRegion(0).BaseIOPort.ToString("X"); + + rbrBase = Device.Resources.GetIOPortReadWrite(0, 0); // Receive Buffer Register (read only) + thrBase = Device.Resources.GetIOPortWrite(0, 0); // Transmitter Holding Register (write only) + ierBase = Device.Resources.GetIOPortReadWrite(0, 1); // Interrupt Enable Register + dllBase = Device.Resources.GetIOPortReadWrite(0, 0); // Divisor Latch (LSB and MSB) + dlmBase = Device.Resources.GetIOPortReadWrite(0, 1); + iirBase = Device.Resources.GetIOPortReadWrite(0, 2); // Interrupt Identification Register (read only) + fcrBase = Device.Resources.GetIOPortWrite(0, 2); // FIFO Control Register (write only, 16550+ only) + lcrBase = Device.Resources.GetIOPortReadWrite(0, 3); // Line Control Register + mcrBase = Device.Resources.GetIOPortReadWrite(0, 4); // Modem Control Register + lsrBase = Device.Resources.GetIOPortReadWrite(0, 5); // Line Status Register + msrBase = Device.Resources.GetIOPortReadWrite(0, 6); // Modem Status Register + scrBase = Device.Resources.GetIOPortReadWrite(0, 7); // Scratch Register (16450+ and some 8250s, special use with some boards) + + fifoBuffer = new byte[fifoSize]; + fifoStart = 0; + fifoEnd = 0; } /// - /// Setups this hardware device driver + /// Probes this instance. /// - /// - /// - public override bool Setup(HardwareResources hardwareResources) + /// + /// Overide for ISA devices, if example + /// + public override void Probe() { - this.HardwareResources = hardwareResources; - base.Name = "COM_0x" + base.HardwareResources.GetIOPortRegion(0).BaseIOPort.ToString("X"); - - rbrBase = base.HardwareResources.GetIOPortReadWrite(0, 0); // Receive Buffer Register (read only) - thrBase = base.HardwareResources.GetIOPortWrite(0, 0); // Transmitter Holding Register (write only) - ierBase = base.HardwareResources.GetIOPortReadWrite(0, 1); // Interrupt Enable Register - dllBase = base.HardwareResources.GetIOPortReadWrite(0, 0); // Divisor Latch (LSB and MSB) - dlmBase = base.HardwareResources.GetIOPortReadWrite(0, 1); - iirBase = base.HardwareResources.GetIOPortReadWrite(0, 2); // Interrupt Identification Register (read only) - fcrBase = base.HardwareResources.GetIOPortWrite(0, 2); // FIFO Control Register (write only, 16550+ only) - lcrBase = base.HardwareResources.GetIOPortReadWrite(0, 3); // Line Control Register - mcrBase = base.HardwareResources.GetIOPortReadWrite(0, 4); // Modem Control Register - lsrBase = base.HardwareResources.GetIOPortReadWrite(0, 5); // Line Status Register - msrBase = base.HardwareResources.GetIOPortReadWrite(0, 6); // Modem Status Register - scrBase = base.HardwareResources.GetIOPortReadWrite(0, 7); // Scratch Register (16450+ and some 8250s, special use with some boards) - - fifoBuffer = new byte[fifoSize]; - fifoStart = 0; - fifoEnd = 0; + //TODO: auto detect - otherwise just assume one is there + //TODO: could use BIOS to help w/ detection; 0x0400-x0403 supply base address for COM1-4 - base.DeviceStatus = DeviceStatus.Online; - return true; + Device.Status = DeviceStatus.Available; } /// /// Starts this hardware device. /// - /// - public override DeviceDriverStartStatus Start() + public override void Start() { - //TODO: auto detect - otherwise just assume one is there - //TODO: could use BIOS to help w/ detection; 0x0400-x0403 supply base address for COM1-4 + if (Device.Status != DeviceStatus.Available) + return; // Disable all UART interrupts ierBase.Write8(0x00); @@ -444,7 +444,7 @@ public override DeviceDriverStartStatus Start() // Interrupt when data received ierBase.Write8((byte)IER.DR); - return DeviceDriverStartStatus.Started; + Device.Status = DeviceStatus.Online; } /// @@ -572,8 +572,12 @@ protected void ReadSerial() spinLock.Enter(); if (!IsFIFOFull()) + { while (CanRead()) + { AddToFIFO(rbrBase.Read8()); + } + } } finally { diff --git a/Source/Mosa.DeviceDriver/ISA/StandardKeyboardX.cs b/Source/Mosa.DeviceDriver/ISA/StandardKeyboardX.cs new file mode 100644 index 000000000..8212f094b --- /dev/null +++ b/Source/Mosa.DeviceDriver/ISA/StandardKeyboardX.cs @@ -0,0 +1,184 @@ +// Copyright (c) MOSA Project. Licensed under the New BSD License. + +using Mosa.DeviceSystem; + +namespace Mosa.DeviceDriver.ISA +{ + /// + /// Standard Keyboard Device Driver + /// + //[ISADeviceDriver(AutoLoad = true, BasePort = 0x60, PortRange = 1, AltBasePort = 0x64, AltPortRange = 1, IRQ = 1, Platforms = PlatformArchitecture.X86AndX64)] + public class StandardKeyboardX : DeviceDriverX, IKeyboardDevice + { + /// + /// + /// + protected IOPortReadWrite commandPort; + + /// + /// + /// + protected IOPortReadWrite dataPort; + + /// + /// + /// + protected const ushort fifoSize = 256; + + /// + /// + /// + protected byte[] fifoBuffer; + + /// + /// + /// + protected uint fifoStart; + + /// + /// + /// + protected uint fifoEnd; + + /// + /// + /// + protected SpinLock spinLock; + + /// + /// Initializes this device. + /// + protected override void Initialize() + { + Device.Name = "StandardKeyboard"; + + commandPort = Device.Resources.GetIOPortReadWrite(0, 0); + dataPort = Device.Resources.GetIOPortReadWrite(1, 0); + + fifoBuffer = new byte[fifoSize]; + fifoStart = 0; + fifoEnd = 0; + } + + /// + /// Probes this instance. + /// + /// + /// Overide for ISA devices, if example + /// + public override void Probe() => Device.Status = DeviceStatus.Available; + + /// + /// Starts this hardware device. + /// + public override void Start() + { + if (Device.Status != DeviceStatus.Available) + return; + + Device.Status = DeviceStatus.Online; + } + + /// + /// Called when interrupt is received. + /// + /// + public override bool OnInterrupt() + { + ReadScanCode(); + return true; + } + + /// + /// Adds scan code to FIFO. + /// + /// The value. + protected void AddToFIFO(byte value) + { + uint next = fifoEnd + 1; + + if (next == fifoSize) + next = 0; + + if (next == fifoStart) + return; // out of room + + fifoBuffer[next] = value; + fifoEnd = next; + } + + /// + /// Gets scan code from FIFO. + /// + /// + protected byte GetFromFIFO() + { + if (fifoEnd == fifoStart) + return 0; // should not happen + + byte value = fifoBuffer[fifoStart]; + + fifoStart++; + + if (fifoStart == fifoSize) + fifoStart = 0; + + return value; + } + + /// + /// Determines whether FIFO data is available + /// + /// + /// true if [FIFO data is available]; otherwise, false. + /// + protected bool IsFIFODataAvailable() + { + return (fifoEnd != fifoStart); + } + + /// + /// Determines whether the FIFO is full + /// + /// + /// true if the FIFO is full; otherwise, false. + /// + protected bool IsFIFOFull() + { + if ((((fifoEnd + 1) == fifoSize) ? 0 : fifoEnd + 1) == fifoStart) + return true; + else + return false; + } + + /// + /// Reads the scan code from the device + /// + protected void ReadScanCode() + { + spinLock.Enter(); + + byte v = commandPort.Read8(); + + AddToFIFO(v); + + HAL.DebugWrite(" scancode: " + v.ToString() + " "); + + spinLock.Exit(); + } + + /// + /// Gets the scan code from the fifo + /// + /// + public byte GetScanCode() + { + if (!IsFIFODataAvailable()) + { + return 0; + } + + return GetFromFIFO(); + } + } +} diff --git a/Source/Mosa.DeviceDriver/ISA/VGAText.cs b/Source/Mosa.DeviceDriver/ISA/VGAText.cs index a3cfffda1..b9d633baf 100644 --- a/Source/Mosa.DeviceDriver/ISA/VGAText.cs +++ b/Source/Mosa.DeviceDriver/ISA/VGAText.cs @@ -8,7 +8,7 @@ namespace Mosa.DeviceDriver.ISA /// VGA Text Device Driver /// //[ISADeviceDriver(AutoLoad = true, BasePort = 0x03B0, PortRange = 0x1F, BaseAddress = 0xB0000, AddressRange = 0x10000, Platforms = PlatformArchitecture.X86AndX64)] - public class VGAText : HardwareDevice, IDevice, ITextDevice + public class VGAText : DeviceDriverX, ITextDevice { #region Definitions @@ -135,48 +135,35 @@ internal struct CRTCommands /// protected TextColor defaultBackground = TextColor.White; - /// - /// Initializes a new instance of the class. - /// - public VGAText() + protected override void Initialize() { + Device.Name = "VGAText"; + + miscellaneousOutput = Device.Resources.GetIOPortReadWrite(0, 0x1C); + crtControllerIndex = Device.Resources.GetIOPortReadWrite(0, 0x04); + crtControllerData = Device.Resources.GetIOPortReadWrite(0, 0x05); + crtControllerIndexColor = Device.Resources.GetIOPortReadWrite(0, 0x24); + crtControllerDataColor = Device.Resources.GetIOPortReadWrite(0, 0x25); + + miscellaneousOutputWrite = Device.Resources.GetIOPortWrite(0, 0x12); + sequencerAddress = Device.Resources.GetIOPortReadWrite(0, 0x14); + sequencerData = Device.Resources.GetIOPortReadWrite(0, 0x15); + graphicsControllerAddress = Device.Resources.GetIOPortReadWrite(0, 0x1E); + graphicsControllerData = Device.Resources.GetIOPortReadWrite(0, 0x1F); + inputStatus1ReadB = Device.Resources.GetIOPortReadWrite(0, 0x2A); + attributeAddress = Device.Resources.GetIOPortReadWrite(0, 0x10); + attributeData = Device.Resources.GetIOPortReadWrite(0, 0x11); + + memory = Device.Resources.GetMemory(0); } - /// - /// Setups this hardware device driver - /// - /// - public override bool Setup(HardwareResources hardwareResources) - { - this.HardwareResources = hardwareResources; - base.Name = "VGAText"; - - miscellaneousOutput = base.HardwareResources.GetIOPortReadWrite(0, 0x1C); - crtControllerIndex = base.HardwareResources.GetIOPortReadWrite(0, 0x04); - crtControllerData = base.HardwareResources.GetIOPortReadWrite(0, 0x05); - crtControllerIndexColor = base.HardwareResources.GetIOPortReadWrite(0, 0x24); - crtControllerDataColor = base.HardwareResources.GetIOPortReadWrite(0, 0x25); - - miscellaneousOutputWrite = base.HardwareResources.GetIOPortWrite(0, 0x12); - sequencerAddress = base.HardwareResources.GetIOPortReadWrite(0, 0x14); - sequencerData = base.HardwareResources.GetIOPortReadWrite(0, 0x15); - graphicsControllerAddress = base.HardwareResources.GetIOPortReadWrite(0, 0x1E); - graphicsControllerData = base.HardwareResources.GetIOPortReadWrite(0, 0x1F); - inputStatus1ReadB = base.HardwareResources.GetIOPortReadWrite(0, 0x2A); - attributeAddress = base.HardwareResources.GetIOPortReadWrite(0, 0x10); - attributeData = base.HardwareResources.GetIOPortReadWrite(0, 0x11); - - memory = base.HardwareResources.GetMemory(0); - - return true; - } + public override void Probe() => Device.Status = DeviceStatus.Available; - /// - /// Starts this hardware device. - /// - /// - public override DeviceDriverStartStatus Start() + public override void Start() { + if (Device.Status != DeviceStatus.Available) + return; + WriteSettings(VGAText80x25); colorMode = ((miscellaneousOutput.Read8() & 1) == 1); @@ -202,18 +189,14 @@ public override DeviceDriverStartStatus Start() width++; height = 25; - base.DeviceStatus = DeviceStatus.Online; - return DeviceDriverStartStatus.Started; + Device.Status = DeviceStatus.Online; } /// /// Called when an interrupt is received. /// /// - public override bool OnInterrupt() - { - return true; - } + public override bool OnInterrupt() => true; /// /// Sends the command. @@ -253,14 +236,14 @@ protected void SetCursorSize(byte start, byte end) /// /// /// - public byte Width { get { return width; } } + public byte Width => width; /// /// Gets the height. /// /// /// - public byte Height { get { return height; } } + public byte Height => height; /// /// Writes the char at the position indicated. @@ -307,16 +290,20 @@ public void ClearScreen() uint size = (uint)(height * width); if (bytePerChar == 2) + { for (int i = 0; i < size; i++) { memory[(uint)(index + (i * 2))] = 0; memory[(uint)(index + (i * 2) + 1)] = (byte)((byte)defaultBackground << 4); } + } else + { for (int i = 0; i < size; i = i + bytePerChar) { memory[(uint)(index + i)] = 0; } + } } /// @@ -328,12 +315,16 @@ public void ScrollUp() uint size = (uint)(((height * width) - width) * bytePerChar); for (uint i = index; i < (index + size); i++) + { memory[i] = memory[(uint)(i + (width * bytePerChar))]; + } index = (uint)(index + ((height - 1) * width * bytePerChar)); for (int i = 0; i < width * 2; i++) + { memory[(uint)(index + i)] = 0; + } } /// diff --git a/Source/Mosa.DeviceDriver/Mosa.DeviceDriver.csproj b/Source/Mosa.DeviceDriver/Mosa.DeviceDriver.csproj index 186ac7d44..c2193d8f1 100644 --- a/Source/Mosa.DeviceDriver/Mosa.DeviceDriver.csproj +++ b/Source/Mosa.DeviceDriver/Mosa.DeviceDriver.csproj @@ -84,17 +84,12 @@ + Code - - Code - - - Code - Code diff --git a/Source/Mosa.DeviceDriver/Setup.cs b/Source/Mosa.DeviceDriver/Setup.cs index c791d11a5..f3b7eb530 100644 --- a/Source/Mosa.DeviceDriver/Setup.cs +++ b/Source/Mosa.DeviceDriver/Setup.cs @@ -8,7 +8,7 @@ public static class Setup { public static void Register(DeviceDriverRegistry registery) { - registery.AddDeviceDriver(new ISADeviceDriver() + registery.AddDeviceDriver(new ISADeviceDriverRegistryEntry() { Name = "CMOS", Platforms = PlatformArchitecture.X86, @@ -18,7 +18,7 @@ public static void Register(DeviceDriverRegistry registery) Factory = delegate { return new ISA.CMOS(); } }); - registery.AddDeviceDriver(new ISADeviceDriver() + registery.AddDeviceDriver(new ISADeviceDriverRegistryEntry() { Name = "StandardKeyboard", Platforms = PlatformArchitecture.X86AndX64, @@ -31,7 +31,7 @@ public static void Register(DeviceDriverRegistry registery) Factory = delegate { return new ISA.StandardKeyboard(); } }); - registery.AddDeviceDriver(new ISADeviceDriver() + registery.AddDeviceDriver(new ISADeviceDriverRegistryEntry() { Name = "PCIController", Platforms = PlatformArchitecture.X86AndX64, @@ -41,7 +41,7 @@ public static void Register(DeviceDriverRegistry registery) Factory = delegate { return new ISA.PCIController(); } }); - registery.AddDeviceDriver(new ISADeviceDriver() + registery.AddDeviceDriver(new ISADeviceDriverRegistryEntry() { Name = "IDEController", Platforms = PlatformArchitecture.X86AndX64, diff --git a/Source/Mosa.DeviceSystem/DeviceDriverRegistry.cs b/Source/Mosa.DeviceSystem/DeviceDriverRegistry.cs index 0411941ec..fbe0e789c 100644 --- a/Source/Mosa.DeviceSystem/DeviceDriverRegistry.cs +++ b/Source/Mosa.DeviceSystem/DeviceDriverRegistry.cs @@ -7,22 +7,21 @@ namespace Mosa.DeviceSystem public class DeviceDriverRegistry { protected PlatformArchitecture PlatformArchitecture; - protected List DeviceDrivers; + protected readonly List DeviceDrivers = new List(); public DeviceDriverRegistry(PlatformArchitecture platformArchitecture) { - this.PlatformArchitecture = platformArchitecture; - DeviceDrivers = new List(); + PlatformArchitecture = platformArchitecture; } - public void AddDeviceDriver(IDeviceDriver deviceDriver) + public void AddDeviceDriver(DeviceDriverRegistryEntry deviceDriver) { DeviceDrivers.Add(deviceDriver); } - public List GetDeviceDrivers(DeviceBusType busType) + public List GetDeviceDrivers(DeviceBusType busType) { - var drivers = new List(); + var drivers = new List(); foreach (var deviceDriver in DeviceDrivers) { diff --git a/Source/Mosa.DeviceSystem/DeviceDriverRegistryEntry.cs b/Source/Mosa.DeviceSystem/DeviceDriverRegistryEntry.cs new file mode 100644 index 000000000..aae532eee --- /dev/null +++ b/Source/Mosa.DeviceSystem/DeviceDriverRegistryEntry.cs @@ -0,0 +1,21 @@ +// Copyright (c) MOSA Project. Licensed under the New BSD License. + +namespace Mosa.DeviceSystem +{ + public delegate IDevice InstantiateDevice(); // legacy + + public delegate DeviceDriverX InstantiateDeviceDriver(); + + public abstract class DeviceDriverRegistryEntry + { + public virtual PlatformArchitecture Platforms { get; set; } + + public virtual DeviceBusType BusType { get; set; } + + public string Name { get; set; } + + public InstantiateDevice Factory { get; set; } // legacy + + public InstantiateDeviceDriver FactoryX { get; set; } + } +} diff --git a/Source/Mosa.DeviceSystem/HardwareDeviceX.cs b/Source/Mosa.DeviceSystem/DeviceDriverX.cs similarity index 97% rename from Source/Mosa.DeviceSystem/HardwareDeviceX.cs rename to Source/Mosa.DeviceSystem/DeviceDriverX.cs index e0eaace54..9259bcb9a 100644 --- a/Source/Mosa.DeviceSystem/HardwareDeviceX.cs +++ b/Source/Mosa.DeviceSystem/DeviceDriverX.cs @@ -7,7 +7,7 @@ namespace Mosa.DeviceSystem /// /// Abstract class for hardware devices /// - public abstract class HardwareDeviceX + public abstract class DeviceDriverX { protected DeviceX Device; diff --git a/Source/Mosa.DeviceSystem/DeviceX.cs b/Source/Mosa.DeviceSystem/DeviceX.cs index caa49f1fb..7766bf78d 100644 --- a/Source/Mosa.DeviceSystem/DeviceX.cs +++ b/Source/Mosa.DeviceSystem/DeviceX.cs @@ -10,7 +10,7 @@ namespace Mosa.DeviceSystem public class DeviceX { public string Name { get; set; } - public IDeviceDriver Driver { get; set; } + public DeviceDriverRegistryEntry Driver { get; set; } public DeviceStatus Status { get; set; } public IService Service { get; set; } public DeviceX Parent { get; set; } diff --git a/Source/Mosa.DeviceSystem/IDeviceDriver.cs b/Source/Mosa.DeviceSystem/IDeviceDriver.cs deleted file mode 100644 index ab05b95bd..000000000 --- a/Source/Mosa.DeviceSystem/IDeviceDriver.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) MOSA Project. Licensed under the New BSD License. - -namespace Mosa.DeviceSystem -{ - public delegate IDevice InstantiateDevice(); - - public interface IDeviceDriver - { - PlatformArchitecture Platforms { get; } - - DeviceBusType BusType { get; } - - string Name { get; } - - InstantiateDevice Factory { get; } - } -} diff --git a/Source/Mosa.DeviceSystem/IPCIDeviceDriver.cs b/Source/Mosa.DeviceSystem/IPCIDeviceDriver.cs deleted file mode 100644 index d9da8863e..000000000 --- a/Source/Mosa.DeviceSystem/IPCIDeviceDriver.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) MOSA Project. Licensed under the New BSD License. - -namespace Mosa.DeviceSystem -{ - public interface IPCIDeviceDriver : IDeviceDriver - { - ushort DeviceID { get; } - - ushort VendorID { get; } - - ushort SubSystemVendorID { get; } - - ushort SubSystemID { get; } - - byte RevisionID { get; } - - byte ProgIF { get; } - - ushort ClassCode { get; } - - byte SubClassCode { get; } - - PCIFields PCIFields { get; } - } - - [System.Flags] - public enum PCIFields : byte - { - DeviceID = 1, - VendorID = 2, - SubSystemVendorID = 4, - SubSystemID = 8, - RevisionID = 16, - ProgIF = 32, - ClassCode = 64, - SubClassCode = 128 - }; -} diff --git a/Source/Mosa.DeviceSystem/ISADeviceDriver.cs b/Source/Mosa.DeviceSystem/ISADeviceDriverRegistryEntry.cs similarity index 64% rename from Source/Mosa.DeviceSystem/ISADeviceDriver.cs rename to Source/Mosa.DeviceSystem/ISADeviceDriverRegistryEntry.cs index e416d9eb3..ebe9c6b8f 100644 --- a/Source/Mosa.DeviceSystem/ISADeviceDriver.cs +++ b/Source/Mosa.DeviceSystem/ISADeviceDriverRegistryEntry.cs @@ -2,15 +2,9 @@ namespace Mosa.DeviceSystem { - public class ISADeviceDriver : IDeviceDriver + public class ISADeviceDriverRegistryEntry : DeviceDriverRegistryEntry { - public PlatformArchitecture Platforms { get; set; } - - public DeviceBusType BusType { get { return DeviceBusType.ISA; } } - - public string Name { get; set; } - - public InstantiateDevice Factory { get; set; } + public override DeviceBusType BusType { get { return DeviceBusType.ISA; } } public ushort BasePort { get; set; } diff --git a/Source/Mosa.DeviceSystem/Mosa.DeviceSystem.csproj b/Source/Mosa.DeviceSystem/Mosa.DeviceSystem.csproj index cca65c07c..491c35315 100644 --- a/Source/Mosa.DeviceSystem/Mosa.DeviceSystem.csproj +++ b/Source/Mosa.DeviceSystem/Mosa.DeviceSystem.csproj @@ -87,11 +87,11 @@ - + - + @@ -102,8 +102,8 @@ - - + + diff --git a/Source/Mosa.DeviceSystem/PCIDeviceDriverRegistryEntry.cs b/Source/Mosa.DeviceSystem/PCIDeviceDriverRegistryEntry.cs new file mode 100644 index 000000000..2a862a2ff --- /dev/null +++ b/Source/Mosa.DeviceSystem/PCIDeviceDriverRegistryEntry.cs @@ -0,0 +1,40 @@ +// Copyright (c) MOSA Project. Licensed under the New BSD License. + +namespace Mosa.DeviceSystem +{ + public class PCIDeviceDriverRegistryEntry : DeviceDriverRegistryEntry + { + public override DeviceBusType BusType { get { return DeviceBusType.PCI; } } + + public ushort DeviceID { get; set; } + + public ushort VendorID { get; set; } + + public ushort SubSystemVendorID { get; set; } + + public ushort SubSystemID { get; set; } + + public byte RevisionID { get; set; } + + public byte ProgIF { get; set; } + + public ushort ClassCode { get; set; } + + public byte SubClassCode { get; set; } + + public PCIFields PCIFields { get; set; } + } + + [System.Flags] + public enum PCIFields : byte + { + DeviceID = 1, + VendorID = 2, + SubSystemVendorID = 4, + SubSystemID = 8, + RevisionID = 16, + ProgIF = 32, + ClassCode = 64, + SubClassCode = 128 + }; +} diff --git a/Source/Mosa.DeviceSystem/Setup.cs b/Source/Mosa.DeviceSystem/Setup.cs index 6aea93f3a..d87cd9a11 100644 --- a/Source/Mosa.DeviceSystem/Setup.cs +++ b/Source/Mosa.DeviceSystem/Setup.cs @@ -46,9 +46,9 @@ public static void StartISADevices() foreach (var driver in drivers) { - if (driver is ISADeviceDriver) + if (driver is ISADeviceDriverRegistryEntry) { - StartISADevice(driver as ISADeviceDriver); + StartISADevice(driver as ISADeviceDriverRegistryEntry); } } } @@ -66,7 +66,7 @@ static public void StartPCIDevices() //} } - public static void StartISADevice(ISADeviceDriver driver) + public static void StartISADevice(ISADeviceDriverRegistryEntry driver) { var hardwareDevice = driver.Factory() as IHardwareDevice; diff --git a/Source/Mosa.HelloWorld.x86/Boot.cs b/Source/Mosa.HelloWorld.x86/Boot.cs index 1e1770dcd..7b4264fb9 100644 --- a/Source/Mosa.HelloWorld.x86/Boot.cs +++ b/Source/Mosa.HelloWorld.x86/Boot.cs @@ -25,7 +25,7 @@ public static void Main() Console.Clear(); - Console.ScrollRow = 23; + Console.ScrollRow = 25; IDT.SetInterruptHandler(ProcessInterrupt); @@ -40,7 +40,7 @@ public static void Main() Console.Color = Color.Red; Console.Write("Neptune"); Console.Color = Color.Yellow; - Console.Write("' Copyright 2008-2015"); + Console.Write("' Copyright 2008-2017"); Console.Color = 0x0F; Console.Write(new String((char)205, 60)); @@ -60,7 +60,6 @@ public static void Main() Console.Color = Color.Gray; Console.Write(Multiboot.Flags, 2, 32); Console.WriteLine(); - Console.WriteLine(); Console.Color = Color.Green; Console.Write("Size of Memory: "); @@ -70,14 +69,12 @@ public static void Main() Console.Write(Multiboot.MemoryLower + Multiboot.MemoryUpper, 10, -1); Console.Write(" KB)"); Console.WriteLine(); - - Console.Color = Color.White; - for (uint index = 0; index < 60; index++) - Console.Write((char)205); + Console.WriteLine(); Console.WriteLine(); Console.Color = Color.Green; Console.Write("Smbios Info: "); + if (SmbiosManager.IsAvailable) { Console.Color = Color.White; @@ -96,7 +93,7 @@ public static void Main() Console.Color = Color.White; Console.WriteLine(); - BiosInformationStructure biosInformation = new BiosInformationStructure(); + var biosInformation = new BiosInformationStructure(); Console.Color = Color.White; Console.Write("Vendor: "); Console.Color = Color.Gray; @@ -120,7 +117,7 @@ public static void Main() Console.WriteLine(); Console.Column = 35; - CpuStructure cpuStructure = new CpuStructure(); + var cpuStructure = new CpuStructure(); Console.Color = Color.White; Console.Write("Vendor: "); Console.Color = Color.Gray; @@ -154,12 +151,7 @@ public static void Main() Console.Write("No SMBIOS available on this system!"); } - Console.Goto(14, 0); - - Console.Color = 0x0F; - for (uint index = 0; index < 60; index++) - Console.Write((char)205); - + Console.WriteLine(); Console.WriteLine(); Console.Color = Color.Green; @@ -182,112 +174,52 @@ public static void Main() Console.Write(Multiboot.GetMemoryMapType(index), 16, 1); Console.WriteLine(); } - Console.WriteLine(); - Console.WriteLine(); - - //CpuInfo cpuInfo = new CpuInfo(); - - //#region Vendor - - //Console.Color = Colors.Green; - //Console.Write("Vendor: "); - //Console.Color = Colors.White; - - //cpuInfo.PrintVendorString(Console); - - //Console.WriteLine(); - - //#endregion Vendor - - //#region Brand - - //Console.Color = Colors.Green; - //Console.Write("Brand: "); - //Console.Color = Colors.White; - //cpuInfo.PrintBrandString(Console); - //Console.WriteLine(); - - //#endregion Brand - - //#region Stepping - - //Console.Color = Colors.Green; - //Console.Write("Stepping: "); - //Console.Color = Colors.White; - //Console.Write(cpuInfo.Stepping, 16, 2); - - //#endregion Stepping - //#region Model - - //Console.Color = Colors.Green; - //Console.Write(" Model: "); - //Console.Color = Colors.White; - //Console.Write(cpuInfo.Model, 16, 2); - - //#endregion Model - - //#region Family - - //Console.Color = Colors.Green; - //Console.Write(" Family: "); - //Console.Color = Colors.White; - //Console.Write(cpuInfo.Family, 16, 2); - - //#endregion Family + Console.Color = Color.Yellow; + Console.Goto(24, 29); + Console.Write("www.mosa-project.org"); - //#region Type + // Borders - //Console.Color = Colors.Green; - //Console.Write(" Type: "); - //Console.Color = Colors.White; + Console.Color = Color.White; - //Console.Write(cpuInfo.Type, 16, 2); - //Console.WriteLine(); - //Console.Color = Colors.Green; - //Console.Write("Cores: "); - //Console.Color = Colors.White; - //Console.Write(cpuInfo.NumberOfCores, 16, 2); + for (uint index = 0; index < 60; index++) + { + Console.Goto(14, index); + Console.Write((char)205); + } - //#endregion Type + for (uint index = 0; index < 60; index++) + { + Console.Goto(6, index); + Console.Write((char)205); + } - Console.Row = 19; for (uint index = 60; index < 80; index++) { - Console.Color = Color.White; - Console.Column = index; + Console.Goto(19, index); Console.Write((char)205); } - Console.Row = 23; for (uint index = 0; index < 80; index++) { - Console.Color = Color.White; - Console.Column = index; + Console.Goto(23, index); Console.Write((char)205); } for (uint index = 2; index < 20; index++) { - Console.Column = 60; - Console.Row = index; - - Console.Color = Color.White; + Console.Goto(index, 60); if (index == 6) Console.Write((char)185); else if (index == 14) Console.Write((char)185); else if (index == 19) - Console.Write((char)202); + Console.Write((char)200); else Console.Write((char)186); } - Console.Goto(24, 29); - Console.Color = Color.Yellow; - - Console.Write("www.mosa-project.org"); - Console.Goto(12, 0); while (true) @@ -330,7 +262,7 @@ private static void DisplayCMOS() /// private static void DisplayTime() { - Console.Goto(24, 52); + Console.Goto(24, 50); Console.Color = Color.Green; Console.Write("Time: "); diff --git a/Source/Mosa.HelloWorld.x86/Mosa.HelloWorld.x86.csproj b/Source/Mosa.HelloWorld.x86/Mosa.HelloWorld.x86.csproj index 4d6f46217..b4709b8ae 100644 --- a/Source/Mosa.HelloWorld.x86/Mosa.HelloWorld.x86.csproj +++ b/Source/Mosa.HelloWorld.x86/Mosa.HelloWorld.x86.csproj @@ -25,6 +25,21 @@ 3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true true @@ -88,5 +103,17 @@ + + + False + Microsoft .NET Framework 4.6.1 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + \ No newline at end of file diff --git a/Source/Mosa.Kernel.x86/ConsoleSession.cs b/Source/Mosa.Kernel.x86/ConsoleSession.cs index 0415ecf53..045d00876 100644 --- a/Source/Mosa.Kernel.x86/ConsoleSession.cs +++ b/Source/Mosa.Kernel.x86/ConsoleSession.cs @@ -5,7 +5,7 @@ namespace Mosa.Kernel.x86 { /// - /// + /// Console Session /// public class ConsoleSession { @@ -19,18 +19,21 @@ public class ConsoleSession protected uint scrollRow = 0; /// - /// + /// The columns /// public readonly uint Columns; /// - /// + /// The rows /// public readonly uint Rows; /// - /// + /// Gets or sets the column. /// + /// + /// The column. + /// public uint Column { get { return column; } @@ -38,8 +41,11 @@ public uint Column } /// - /// + /// Gets or sets the row. /// + /// + /// The row. + /// public uint Row { get { return row; }