mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-24 12:35:31 +00:00
This commit is contained in:
parent
d2a860698e
commit
faaffecc61
12 changed files with 125 additions and 39 deletions
|
|
@ -53,6 +53,7 @@
|
||||||
<Compile Include="DeviceIDAttribute.cs" />
|
<Compile Include="DeviceIDAttribute.cs" />
|
||||||
<Compile Include="Global.cs" />
|
<Compile Include="Global.cs" />
|
||||||
<Compile Include="Heap.cs" />
|
<Compile Include="Heap.cs" />
|
||||||
|
<Compile Include="IOGroup\ATA.cs" />
|
||||||
<Compile Include="IOGroup\Keyboard.cs" />
|
<Compile Include="IOGroup\Keyboard.cs" />
|
||||||
<Compile Include="IOGroup\PciBus.cs" />
|
<Compile Include="IOGroup\PciBus.cs" />
|
||||||
<Compile Include="IOGroup\PciDevice.cs" />
|
<Compile Include="IOGroup\PciDevice.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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Cosmos.Core.IOGroup {
|
namespace Cosmos.Core.IOGroup {
|
||||||
public class PIC {
|
public class PIC : IOGroup {
|
||||||
public readonly IOPort PortCmd1 = new IOPort(0x20);
|
public readonly IOPort PortCmd1 = new IOPort(0x20);
|
||||||
public readonly IOPort PortData1 = new IOPort(0x21);
|
public readonly IOPort PortData1 = new IOPort(0x21);
|
||||||
public readonly IOPort PortCmd2 = new IOPort(0xA0);
|
public readonly IOPort PortCmd2 = new IOPort(0xA0);
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Cosmos.Core.IOGroup {
|
namespace Cosmos.Core.IOGroup {
|
||||||
public class PIT {
|
public class PIT : IOGroup {
|
||||||
public readonly IOPort Port40 = new IOPort(0x40);
|
public readonly IOPort Port40 = new IOPort(0x40);
|
||||||
public readonly IOPort Port43 = new IOPort(0x43);
|
public readonly IOPort Port43 = new IOPort(0x43);
|
||||||
public readonly IOPort Port61 = new IOPort(0x61);
|
public readonly IOPort Port61 = new IOPort(0x61);
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Cosmos.Core.IOGroup {
|
namespace Cosmos.Core.IOGroup {
|
||||||
public class PciBus {
|
public class PciBus : IOGroup {
|
||||||
public IOPort ConfigAddressPort = new IOPort(0xCF8);
|
public IOPort ConfigAddressPort = new IOPort(0xCF8);
|
||||||
public IOPort ConfigDataPort = new IOPort(0xCFC);
|
public IOPort ConfigDataPort = new IOPort(0xCFC);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Cosmos.Core.IOGroup {
|
namespace Cosmos.Core.IOGroup {
|
||||||
public class PciDevice {
|
public class PciDevice : IOGroup {
|
||||||
internal PciDevice() {
|
internal PciDevice() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,47 @@ namespace Cosmos.Core {
|
||||||
return IO.ConfigDataPort.DWord;
|
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() {
|
protected void EnumerateBusses() {
|
||||||
// We have to scan all busses. Normally only 0 and 1 are used.
|
// 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
|
// 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);
|
UInt16 xDeviceID = (UInt16)(x >> 16);
|
||||||
|
|
||||||
if ((xVendorID == 0x8086) && (xDeviceID == 0x7111)) {
|
if ((xVendorID == 0x8086) && (xDeviceID == 0x7111)) {
|
||||||
Global.Dbg.Send("--------------");
|
DebugSendDevice(xAddr);
|
||||||
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("--------------");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var xInfo = new PciInfo(xVendorID, xDeviceID);
|
var xInfo = new PciInfo(xVendorID, xDeviceID);
|
||||||
|
|
|
||||||
13
source2/Kernel/System/Hardware/Cosmos.Hardware/ATA.html
Normal file
13
source2/Kernel/System/Hardware/Cosmos.Hardware/ATA.html
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title></title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<a href="http://wiki.osdev.org/ATA">http://wiki.osdev.org/ATA</a><br />
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -74,6 +74,7 @@
|
||||||
<None Include="Cosmos.snk" />
|
<None Include="Cosmos.snk" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Content Include="ATA.html" />
|
||||||
<Content Include="Drivers\ReadMe.html" />
|
<Content Include="Drivers\ReadMe.html" />
|
||||||
<Content Include="Keyboard.html" />
|
<Content Include="Keyboard.html" />
|
||||||
<Content Include="TextScreen.html" />
|
<Content Include="TextScreen.html" />
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,12 @@
|
||||||
<Compile Include="BreakpointsOS.cs" />
|
<Compile Include="BreakpointsOS.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\..\Kernel\Common\Cosmos.Common.Extensions\Cosmos.Common.Extensions.csproj">
|
||||||
|
<Project>{1FAC100C-D732-4EA4-B518-5AF4BAF64F2E}</Project>
|
||||||
|
<Name>Cosmos.Common.Extensions</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Sys = Cosmos.System;
|
using Sys = Cosmos.System;
|
||||||
using Cosmos.Debug.Kernel;
|
using Cosmos.Debug.Kernel;
|
||||||
|
using Cosmos.Common.Extensions;
|
||||||
|
|
||||||
namespace BreakpointsKernel {
|
namespace BreakpointsKernel {
|
||||||
public class BreakpointsOS : Sys.Kernel {
|
public class BreakpointsOS : Sys.Kernel {
|
||||||
|
|
@ -11,6 +12,10 @@ namespace BreakpointsKernel {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void BeforeRun() {
|
protected override void BeforeRun() {
|
||||||
|
UInt32 x = 0x000010E1;
|
||||||
|
x = x & 0xFFFFFFFC;
|
||||||
|
Console.WriteLine(x.ToHex());
|
||||||
|
|
||||||
Console.WriteLine("Hello " + 6.ToString());
|
Console.WriteLine("Hello " + 6.ToString());
|
||||||
//Debugger.Send("Hello from Cosmos!");
|
//Debugger.Send("Hello from Cosmos!");
|
||||||
Console.WriteLine("Cosmos booted successfully. Type a line of text to get it echoed back.");
|
Console.WriteLine("Cosmos booted successfully. Type a line of text to get it echoed back.");
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,25 @@
|
||||||
<h3>
|
<h3>
|
||||||
Matthijs - Next Release</h3>
|
Matthijs - Next Release</h3>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li>Literal bug<ul>
|
||||||
|
<li>
|
||||||
|
<pre>UInt32 x = 0x000010E1;
|
||||||
|
x = x & 0xFFFFFFFC;
|
||||||
|
Console.WriteLine(x.ToHex());
|
||||||
|
|
||||||
|
This produces 000000E1
|
||||||
|
If you change it to
|
||||||
|
x = x & 0x0FFFFFFC;
|
||||||
|
|
||||||
|
it works. It seems our compiler is outputting wrong when the high bit is set. The outputted ASM when the high bit is set is wrong:
|
||||||
|
|
||||||
|
System_Void__BreakpointsKernel_BreakpointsOS_BeforeRun____DOT__00000008:
|
||||||
|
; [Cosmos.IL2CPU.X86.IL.Ldc_I4]
|
||||||
|
push dword 0xFC
|
||||||
|
; Stack contains 2 items: (4, 4) </pre>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
<li>Express isnt showing any templates</li>
|
<li>Express isnt showing any templates</li>
|
||||||
</ul>
|
</ul>
|
||||||
<h3>
|
<h3>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue