From faaffecc61d91f4d03efa8baf686584c7bb5b91b Mon Sep 17 00:00:00 2001 From: kudzu_cp <6d05c8c8ef5431987001abfdb2eadc9593ac9498> Date: Mon, 23 Aug 2010 02:57:27 +0000 Subject: [PATCH] --- .../Core/Cosmos.Core/Cosmos.Core.csproj | 1 + .../Hardware/Core/Cosmos.Core/IOGroup/ATA.cs | 34 ++++++++ .../Hardware/Core/Cosmos.Core/IOGroup/PIC.cs | 2 +- .../Hardware/Core/Cosmos.Core/IOGroup/PIT.cs | 2 +- .../Core/Cosmos.Core/IOGroup/PciBus.cs | 2 +- .../Core/Cosmos.Core/IOGroup/PciDevice.cs | 2 +- .../Hardware/Core/Cosmos.Core/PciBus.cs | 77 ++++++++++--------- .../System/Hardware/Cosmos.Hardware/ATA.html | 13 ++++ .../Cosmos.Hardware/Cosmos.Hardware.csproj | 1 + .../Breakpoints/BreakpointsKernel.csproj | 6 ++ .../Users/Kudzu/Breakpoints/BreakpointsOS.cs | 5 ++ source2/Users/Kudzu/Notes.html | 19 +++++ 12 files changed, 125 insertions(+), 39 deletions(-) create mode 100644 source2/Kernel/System/Hardware/Core/Cosmos.Core/IOGroup/ATA.cs create mode 100644 source2/Kernel/System/Hardware/Cosmos.Hardware/ATA.html diff --git a/source2/Kernel/System/Hardware/Core/Cosmos.Core/Cosmos.Core.csproj b/source2/Kernel/System/Hardware/Core/Cosmos.Core/Cosmos.Core.csproj index 1442c3bf9..a59548f5f 100644 --- a/source2/Kernel/System/Hardware/Core/Cosmos.Core/Cosmos.Core.csproj +++ b/source2/Kernel/System/Hardware/Core/Cosmos.Core/Cosmos.Core.csproj @@ -53,6 +53,7 @@ + diff --git a/source2/Kernel/System/Hardware/Core/Cosmos.Core/IOGroup/ATA.cs b/source2/Kernel/System/Hardware/Core/Cosmos.Core/IOGroup/ATA.cs new file mode 100644 index 000000000..e3bf99073 --- /dev/null +++ b/source2/Kernel/System/Hardware/Core/Cosmos.Core/IOGroup/ATA.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Cosmos.Core.IOGroup { + public class ATA : IOGroup { + + [FlagsAttribute] + enum Status : byte { + ATA_SR_BSY = 0x80 + , ATA_SR_DRD = 0x40 + , ATA_SR_DF = 0x20 + , ATA_SR_DSC = 0x10 + , ATA_SR_DRQ = 0x08 + , ATA_SR_COR = 0x04 + , ATA_SR_IDX = 0x02 + , ATA_SR_ERR = 0x01 + }; + + public readonly IOPort PortControl; + public readonly IOPort PortData; + + internal ATA(bool aSecondary) { + if (!aSecondary) { + PortControl = new IOPort(0x3F4); + PortData = new IOPort(0x1F0); + } else { + PortControl = new IOPort(0x374); + PortData = new IOPort(0x170); + } + } + } +} diff --git a/source2/Kernel/System/Hardware/Core/Cosmos.Core/IOGroup/PIC.cs b/source2/Kernel/System/Hardware/Core/Cosmos.Core/IOGroup/PIC.cs index 788657f5e..1c06cbb56 100644 --- a/source2/Kernel/System/Hardware/Core/Cosmos.Core/IOGroup/PIC.cs +++ b/source2/Kernel/System/Hardware/Core/Cosmos.Core/IOGroup/PIC.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; namespace Cosmos.Core.IOGroup { - public class PIC { + public class PIC : IOGroup { public readonly IOPort PortCmd1 = new IOPort(0x20); public readonly IOPort PortData1 = new IOPort(0x21); public readonly IOPort PortCmd2 = new IOPort(0xA0); diff --git a/source2/Kernel/System/Hardware/Core/Cosmos.Core/IOGroup/PIT.cs b/source2/Kernel/System/Hardware/Core/Cosmos.Core/IOGroup/PIT.cs index 1e8be08b9..74ae6425a 100644 --- a/source2/Kernel/System/Hardware/Core/Cosmos.Core/IOGroup/PIT.cs +++ b/source2/Kernel/System/Hardware/Core/Cosmos.Core/IOGroup/PIT.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; namespace Cosmos.Core.IOGroup { - public class PIT { + public class PIT : IOGroup { public readonly IOPort Port40 = new IOPort(0x40); public readonly IOPort Port43 = new IOPort(0x43); public readonly IOPort Port61 = new IOPort(0x61); diff --git a/source2/Kernel/System/Hardware/Core/Cosmos.Core/IOGroup/PciBus.cs b/source2/Kernel/System/Hardware/Core/Cosmos.Core/IOGroup/PciBus.cs index f89606626..4c3b08b36 100644 --- a/source2/Kernel/System/Hardware/Core/Cosmos.Core/IOGroup/PciBus.cs +++ b/source2/Kernel/System/Hardware/Core/Cosmos.Core/IOGroup/PciBus.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; namespace Cosmos.Core.IOGroup { - public class PciBus { + public class PciBus : IOGroup { public IOPort ConfigAddressPort = new IOPort(0xCF8); public IOPort ConfigDataPort = new IOPort(0xCFC); } diff --git a/source2/Kernel/System/Hardware/Core/Cosmos.Core/IOGroup/PciDevice.cs b/source2/Kernel/System/Hardware/Core/Cosmos.Core/IOGroup/PciDevice.cs index 040784162..3af6bbcfd 100644 --- a/source2/Kernel/System/Hardware/Core/Cosmos.Core/IOGroup/PciDevice.cs +++ b/source2/Kernel/System/Hardware/Core/Cosmos.Core/IOGroup/PciDevice.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; namespace Cosmos.Core.IOGroup { - public class PciDevice { + public class PciDevice : IOGroup { internal PciDevice() { } } diff --git a/source2/Kernel/System/Hardware/Core/Cosmos.Core/PciBus.cs b/source2/Kernel/System/Hardware/Core/Cosmos.Core/PciBus.cs index e435d8272..902edb7dd 100644 --- a/source2/Kernel/System/Hardware/Core/Cosmos.Core/PciBus.cs +++ b/source2/Kernel/System/Hardware/Core/Cosmos.Core/PciBus.cs @@ -43,6 +43,47 @@ namespace Cosmos.Core { return IO.ConfigDataPort.DWord; } + protected void DebugSendBAR(UInt32 aAddr, byte aBar) { + UInt32 x = ReadRegister(aAddr, (byte)(0x10 + aBar * 4)); + if ((x & 0x01) == 0x01) { + //TODO: Fix this 0 back to F when compmiler bug is fixed + x = x & 0x0FFFFFFC; + Global.Dbg.Send("BAR (IO) " + aBar + ": " + x.ToHex()); + } else { + Global.Dbg.Send("BAR " + aBar + ": " + x.ToHex()); + } + } + + protected void DebugSendDevice(UInt32 aAddr) { + UInt32 x; + + Global.Dbg.Send("--------------"); + Global.Dbg.Send("ATA Controller"); + + x = ReadRegister(aAddr, 0x04); + Global.Dbg.Send("Status: " + ((UInt16)(x >> 16)).ToHex()); + Global.Dbg.Send("Command: " + ((UInt16)(x & 0xFFFF)).ToHex()); + x = ReadRegister(aAddr, 0x08); + Global.Dbg.Send("Class Code: " + ((byte)(x >> 24)).ToHex()); + Global.Dbg.Send("Subclass: " + ((byte)((x >> 16) & 0xFF)).ToHex()); + Global.Dbg.Send("Prog IF: " + ((byte)((x >> 8) & 0xFF)).ToHex()); + Global.Dbg.Send("Revision ID: " + ((byte)(x & 0xFF)).ToHex()); + x = ReadRegister(aAddr, 0x0C); + Global.Dbg.Send("BIST: " + ((byte)(x >> 24)).ToHex()); + Global.Dbg.Send("Header Type: " + ((byte)((x >> 16) & 0xFF)).ToHex()); + Global.Dbg.Send("Latency Timer: " + ((byte)((x >> 8) & 0xFF)).ToHex()); + Global.Dbg.Send("Cache Line Size: " + ((byte)(x & 0xFF)).ToHex()); + for (byte i = 0; i <= 5; i++) { + DebugSendBAR(aAddr, i); + } + Global.Dbg.Send("Max Latency: " + ((byte)(x >> 24)).ToHex()); + Global.Dbg.Send("Min Grant: " + ((byte)((x >> 16) & 0xFF)).ToHex()); + Global.Dbg.Send("Interrupt PIN: " + ((byte)((x >> 8) & 0xFF)).ToHex()); + Global.Dbg.Send("Interrupt Line: " + ((byte)(x & 0xFF)).ToHex()); + + Global.Dbg.Send("--------------"); + } + protected void EnumerateBusses() { // We have to scan all busses. Normally only 0 and 1 are used. // During dev, just scan first 4...takes too long to scan rest till our @@ -62,41 +103,7 @@ namespace Cosmos.Core { UInt16 xDeviceID = (UInt16)(x >> 16); if ((xVendorID == 0x8086) && (xDeviceID == 0x7111)) { - Global.Dbg.Send("--------------"); - Global.Dbg.Send("ATA Controller"); - - x = ReadRegister(xAddr, 0x04); - Global.Dbg.Send("Status: " + ((UInt16)(x >> 16)).ToHex()); - Global.Dbg.Send("Command: " + ((UInt16)(x & 0xFFFF)).ToHex()); - x = ReadRegister(xAddr, 0x08); - Global.Dbg.Send("Class Code: " + ((byte)(x >> 24)).ToHex()); - Global.Dbg.Send("Subclass: " + ((byte)((x >> 16) & 0xFF)).ToHex()); - Global.Dbg.Send("Prog IF: " + ((byte)((x >> 8) & 0xFF)).ToHex()); - Global.Dbg.Send("Revision ID: " + ((byte)(x & 0xFF)).ToHex()); - x = ReadRegister(xAddr, 0x0C); - Global.Dbg.Send("BIST: " + ((byte)(x >> 24)).ToHex()); - Global.Dbg.Send("Header Type: " + ((byte)((x >> 16) & 0xFF)).ToHex()); - Global.Dbg.Send("Latency Timer: " + ((byte)((x >> 8) & 0xFF)).ToHex()); - Global.Dbg.Send("Cache Line Size: " + ((byte)(x & 0xFF)).ToHex()); - x = ReadRegister(xAddr, 0x10); - Global.Dbg.Send("BAR 0: " + x.ToHex()); - x = ReadRegister(xAddr, 0x14); - Global.Dbg.Send("BAR 1: " + x.ToHex()); - x = ReadRegister(xAddr, 0x18); - Global.Dbg.Send("BAR 2: " + x.ToHex()); - x = ReadRegister(xAddr, 0x1C); - Global.Dbg.Send("BAR 3: " + x.ToHex()); - x = ReadRegister(xAddr, 0x20); - Global.Dbg.Send("BAR 4: " + x.ToHex()); - x = ReadRegister(xAddr, 0x24); - Global.Dbg.Send("BAR 5: " + x.ToHex()); - x = ReadRegister(xAddr, 0x3C); - Global.Dbg.Send("Max Latency: " + ((byte)(x >> 24)).ToHex()); - Global.Dbg.Send("Min Grant: " + ((byte)((x >> 16) & 0xFF)).ToHex()); - Global.Dbg.Send("Interrupt PIN: " + ((byte)((x >> 8) & 0xFF)).ToHex()); - Global.Dbg.Send("Interrupt Line: " + ((byte)(x & 0xFF)).ToHex()); - - Global.Dbg.Send("--------------"); + DebugSendDevice(xAddr); } var xInfo = new PciInfo(xVendorID, xDeviceID); diff --git a/source2/Kernel/System/Hardware/Cosmos.Hardware/ATA.html b/source2/Kernel/System/Hardware/Cosmos.Hardware/ATA.html new file mode 100644 index 000000000..b3bd781f0 --- /dev/null +++ b/source2/Kernel/System/Hardware/Cosmos.Hardware/ATA.html @@ -0,0 +1,13 @@ + + + + + + + +

+ http://wiki.osdev.org/ATA
+

+ + + \ No newline at end of file diff --git a/source2/Kernel/System/Hardware/Cosmos.Hardware/Cosmos.Hardware.csproj b/source2/Kernel/System/Hardware/Cosmos.Hardware/Cosmos.Hardware.csproj index 251c690cf..84a107e29 100644 --- a/source2/Kernel/System/Hardware/Cosmos.Hardware/Cosmos.Hardware.csproj +++ b/source2/Kernel/System/Hardware/Cosmos.Hardware/Cosmos.Hardware.csproj @@ -74,6 +74,7 @@ + diff --git a/source2/Users/Kudzu/Breakpoints/BreakpointsKernel.csproj b/source2/Users/Kudzu/Breakpoints/BreakpointsKernel.csproj index cbd1db229..982f0255f 100644 --- a/source2/Users/Kudzu/Breakpoints/BreakpointsKernel.csproj +++ b/source2/Users/Kudzu/Breakpoints/BreakpointsKernel.csproj @@ -48,6 +48,12 @@ + + + {1FAC100C-D732-4EA4-B518-5AF4BAF64F2E} + Cosmos.Common.Extensions + +