diff --git a/source/Cosmos.Hardware.PC/Bus/PCIBus.cs b/source/Cosmos.Hardware.PC/Bus/PCIBus.cs index c75d2d05c..f88e95a08 100644 --- a/source/Cosmos.Hardware.PC/Bus/PCIBus.cs +++ b/source/Cosmos.Hardware.PC/Bus/PCIBus.cs @@ -9,6 +9,7 @@ namespace Cosmos.Hardware.PC.Bus { protected const ushort ConfigData = 0xCFC; static public void Init() { + UInt32 xValue = Read32(0, 0, 0, 0); } static public UInt32 Read32(byte aBus, byte aSlot diff --git a/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IOReadWord.cs b/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IORead16.cs similarity index 92% rename from source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IOReadWord.cs rename to source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IORead16.cs index 5bd2f0c43..39adb3066 100644 --- a/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IOReadWord.cs +++ b/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IORead16.cs @@ -8,7 +8,7 @@ using CPUx86 = Indy.IL2CPU.Assembler.X86; using CPUNative = Indy.IL2CPU.Assembler.X86.Native; namespace Cosmos.Kernel.Plugs.Assemblers { - public sealed class IOReadWord : AssemblerMethod { + public sealed class IORead16 : AssemblerMethod { public override void Assemble(Assembler aAssembler) { //TODO: This is a lot of work to read a port. We need to have some kind of inline ASM option that can emit a single out instruction //TODO: Also make an attribute that forces normal inlining fo a method diff --git a/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IORead32.cs b/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IORead32.cs new file mode 100644 index 000000000..b2c8bd89f --- /dev/null +++ b/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IORead32.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Indy.IL2CPU.Assembler.X86; +using Indy.IL2CPU.Plugs; +using Assembler = Indy.IL2CPU.Assembler.Assembler; +using CPUx86 = Indy.IL2CPU.Assembler.X86; +using CPUNative = Indy.IL2CPU.Assembler.X86.Native; + +namespace Cosmos.Kernel.Plugs.Assemblers { + public sealed class IORead32 : AssemblerMethod { + public override void Assemble(Assembler aAssembler) { + //TODO: This is a lot of work to read a port. We need to have some kind of inline ASM option that can emit a single out instruction + //TODO: Also make an attribute that forces normal inlining fo a method + new CPUx86.Move(Registers.EDX, "[ebp + 0x08]"); + //TODO: Do we need to clear rest of EAX first? + // MTW: technically not, as in other places, it _should_ be working with AL too.. + new CPUx86.Move("eax", "0"); + new CPUNative.InDWord(Registers.EAX, Registers.EDX); + new CPUx86.Push(Registers.EAX); + } + } +} diff --git a/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IOReadByte.cs b/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IORead8.cs similarity index 92% rename from source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IOReadByte.cs rename to source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IORead8.cs index c9be60234..5da27ab54 100644 --- a/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IOReadByte.cs +++ b/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IORead8.cs @@ -8,7 +8,7 @@ using CPUx86 = Indy.IL2CPU.Assembler.X86; using CPUNative = Indy.IL2CPU.Assembler.X86.Native; namespace Cosmos.Kernel.Plugs.Assemblers { - public sealed class IOReadByte : AssemblerMethod { + public sealed class IORead8 : AssemblerMethod { public override void Assemble(Assembler aAssembler) { //TODO: This is a lot of work to read a port. We need to have some kind of inline ASM option that can emit a single out instruction //TODO: Also make an attribute that forces normal inlining fo a method diff --git a/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IOWriteWord.cs b/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IOWrite16.cs similarity index 90% rename from source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IOWriteWord.cs rename to source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IOWrite16.cs index 5f74f581a..0f8ac4cc5 100644 --- a/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IOWriteWord.cs +++ b/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IOWrite16.cs @@ -8,7 +8,7 @@ using CPUx86 = Indy.IL2CPU.Assembler.X86; using CPUNative = Indy.IL2CPU.Assembler.X86.Native; namespace Cosmos.Kernel.Plugs.Assemblers { - public sealed class IOWriteWord: AssemblerMethod { + public sealed class IOWrite16: AssemblerMethod { public override void Assemble(Assembler aAssembler) { //TODO: This is a lot of work to write to a single port. We need to have some kind of inline ASM option that can emit a single out instruction new CPUx86.Move(Registers.EDX, "[ebp + 0xC]"); diff --git a/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IOWrite32.cs b/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IOWrite32.cs new file mode 100644 index 000000000..61ee6c6a2 --- /dev/null +++ b/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IOWrite32.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Indy.IL2CPU.Assembler.X86; +using Indy.IL2CPU.Plugs; +using Assembler = Indy.IL2CPU.Assembler.Assembler; +using CPUx86 = Indy.IL2CPU.Assembler.X86; +using CPUNative = Indy.IL2CPU.Assembler.X86.Native; + +namespace Cosmos.Kernel.Plugs.Assemblers { + public sealed class IOWrite32 : AssemblerMethod { + public override void Assemble(Assembler aAssembler) { + //TODO: This is a lot of work to write to a single port. We need to have some kind of inline ASM option that can emit a single out instruction + new CPUx86.Move(Registers.EDX, "[ebp + 0xC]"); + new CPUx86.Move(Registers.EAX, "[ebp + 0x8]"); + new CPUNative.Out(Registers.DX, Registers.EAX); + } + } +} \ No newline at end of file diff --git a/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IOWriteByte.cs b/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IOWrite8.cs similarity index 90% rename from source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IOWriteByte.cs rename to source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IOWrite8.cs index be1d69e5b..7b856424e 100644 --- a/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IOWriteByte.cs +++ b/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IOWrite8.cs @@ -8,7 +8,7 @@ using CPUx86 = Indy.IL2CPU.Assembler.X86; using CPUNative = Indy.IL2CPU.Assembler.X86.Native; namespace Cosmos.Kernel.Plugs.Assemblers { - public sealed class IOWriteByte: AssemblerMethod { + public sealed class IOWrite8: AssemblerMethod { public override void Assemble(Assembler aAssembler) { //TODO: This is a lot of work to write to a single port. We need to have some kind of inline ASM option that can emit a single out instruction new CPUx86.Move(Registers.EDX, "[ebp + 0xC]"); diff --git a/source/Cosmos/Cosmos.Kernel.Plugs/Cosmos.Kernel.Plugs.csproj b/source/Cosmos/Cosmos.Kernel.Plugs/Cosmos.Kernel.Plugs.csproj index fbc25c68f..fbef077af 100644 --- a/source/Cosmos/Cosmos.Kernel.Plugs/Cosmos.Kernel.Plugs.csproj +++ b/source/Cosmos/Cosmos.Kernel.Plugs/Cosmos.Kernel.Plugs.csproj @@ -49,12 +49,14 @@ - - + + + - - + + + diff --git a/source/Cosmos/Cosmos.Kernel.Plugs/Hardware.cs b/source/Cosmos/Cosmos.Kernel.Plugs/Hardware.cs index 82e5fd39d..e9caa2421 100644 --- a/source/Cosmos/Cosmos.Kernel.Plugs/Hardware.cs +++ b/source/Cosmos/Cosmos.Kernel.Plugs/Hardware.cs @@ -7,17 +7,17 @@ using HW = Cosmos.Hardware; namespace Cosmos.Kernel.Plugs.Other { [Plug(Target = typeof(HW.Hardware))] public static class Hardware { - [PlugMethod(MethodAssembler = typeof(Assemblers.IOWriteByte))] + [PlugMethod(MethodAssembler = typeof(Assemblers.IOWrite8))] public static void IOWriteByte(ushort aPort, byte aData) { } - [PlugMethod(MethodAssembler = typeof(Assemblers.IOReadByte))] + [PlugMethod(MethodAssembler = typeof(Assemblers.IORead8))] public static byte IOReadByte(ushort aPort) { return 0; } - [PlugMethod(MethodAssembler = typeof(Assemblers.IOWriteWord))] + [PlugMethod(MethodAssembler = typeof(Assemblers.IOWrite16))] public static void IOWriteWord(ushort aPort, ushort aData) { } - [PlugMethod(MethodAssembler = typeof(Assemblers.IOReadWord))] + [PlugMethod(MethodAssembler = typeof(Assemblers.IORead16))] public static ushort IOReadWord(ushort aPort) { return 0; } diff --git a/source/Cosmos/Cosmos.Kernel.Plugs/Hardware/PC/Bus/CPUBus.cs b/source/Cosmos/Cosmos.Kernel.Plugs/Hardware/PC/Bus/CPUBus.cs index a170c816d..5c58a9453 100644 --- a/source/Cosmos/Cosmos.Kernel.Plugs/Hardware/PC/Bus/CPUBus.cs +++ b/source/Cosmos/Cosmos.Kernel.Plugs/Hardware/PC/Bus/CPUBus.cs @@ -6,20 +6,28 @@ using Indy.IL2CPU.Plugs; namespace Cosmos.Kernel.Plugs.Hardware.PC.Bus { [Plug(Target = typeof(Cosmos.Hardware.PC.Bus.CPUBus))] class CPUBus { - [PlugMethod(MethodAssembler = typeof(Assemblers.IOWriteByte))] + [PlugMethod(MethodAssembler = typeof(Assemblers.IOWrite8))] public static void Write8(UInt16 aPort, byte aData) { } - [PlugMethod(MethodAssembler = typeof(Assemblers.IOWriteWord))] + [PlugMethod(MethodAssembler = typeof(Assemblers.IOWrite16))] public static void Write16(UInt16 aPort, UInt16 aData) { } - [PlugMethod(MethodAssembler = typeof(Assemblers.IOReadByte))] + [PlugMethod(MethodAssembler = typeof(Assemblers.IOWrite32))] + public static void Write32(UInt16 aPort, UInt32 aData) { } + + [PlugMethod(MethodAssembler = typeof(Assemblers.IORead8))] public static byte Read8(UInt16 aPort) { return 0; } - [PlugMethod(MethodAssembler = typeof(Assemblers.IOReadWord))] + [PlugMethod(MethodAssembler = typeof(Assemblers.IORead16))] public static UInt16 Read16(UInt16 aPort) { return 0; } + + [PlugMethod(MethodAssembler = typeof(Assemblers.IORead32))] + public static UInt32 Read32(UInt16 aPort) { + return 0; + } } } diff --git a/source/Indy.IL2CPU.Assembler.X86.Native/InDWord.cs b/source/Indy.IL2CPU.Assembler.X86.Native/InDWord.cs new file mode 100644 index 000000000..893da8a21 --- /dev/null +++ b/source/Indy.IL2CPU.Assembler.X86.Native/InDWord.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Indy.IL2CPU.Assembler.X86.Native { + [OpCode(0xFFFFFFFF, "inw")] + public class InDWord : Instruction { + public readonly string Port; + public readonly string Data; + public InDWord(string aData, string aPort) { + Port = aPort; + Data = aData; + } + + public override string ToString() { + return "in dword " + Data + ", " + Port; + } + } +} \ No newline at end of file diff --git a/source/Indy.IL2CPU.Assembler.X86.Native/Indy.IL2CPU.Assembler.X86.Native.csproj b/source/Indy.IL2CPU.Assembler.X86.Native/Indy.IL2CPU.Assembler.X86.Native.csproj index 65025176f..911c8da87 100644 --- a/source/Indy.IL2CPU.Assembler.X86.Native/Indy.IL2CPU.Assembler.X86.Native.csproj +++ b/source/Indy.IL2CPU.Assembler.X86.Native/Indy.IL2CPU.Assembler.X86.Native.csproj @@ -49,6 +49,7 @@ +