mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-21 05:18:38 +00:00
32 bit port support
This commit is contained in:
parent
2fcf25dee0
commit
49f736d602
12 changed files with 90 additions and 16 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
23
source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IORead32.cs
Normal file
23
source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IORead32.cs
Normal file
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
@ -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]");
|
||||
19
source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IOWrite32.cs
Normal file
19
source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/IOWrite32.cs
Normal file
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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]");
|
||||
|
|
@ -49,12 +49,14 @@
|
|||
<ItemGroup>
|
||||
<Compile Include="Assemblers\GetAmountOfRAM.cs" />
|
||||
<Compile Include="Assemblers\GetEndOfKernel.cs" />
|
||||
<Compile Include="Assemblers\IOReadWord.cs" />
|
||||
<Compile Include="Assemblers\IOWriteWord.cs" />
|
||||
<Compile Include="Assemblers\IORead16.cs" />
|
||||
<Compile Include="Assemblers\IORead32.cs" />
|
||||
<Compile Include="Assemblers\IOWrite16.cs" />
|
||||
<Compile Include="Assemblers\CreateGDT.cs" />
|
||||
<Compile Include="Assemblers\CreateIDT.cs" />
|
||||
<Compile Include="Assemblers\IOReadByte.cs" />
|
||||
<Compile Include="Assemblers\IOWriteByte.cs" />
|
||||
<Compile Include="Assemblers\IORead8.cs" />
|
||||
<Compile Include="Assemblers\IOWrite32.cs" />
|
||||
<Compile Include="Assemblers\IOWrite8.cs" />
|
||||
<Compile Include="Assemblers\ZeroFill.cs" />
|
||||
<Compile Include="CultureInfo.cs" />
|
||||
<Compile Include="Hardware\PC\Bus\CPUBus.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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
20
source/Indy.IL2CPU.Assembler.X86.Native/InDWord.cs
Normal file
20
source/Indy.IL2CPU.Assembler.X86.Native/InDWord.cs
Normal file
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -49,6 +49,7 @@
|
|||
<Compile Include="Cli.cs" />
|
||||
<Compile Include="Break.cs" />
|
||||
<Compile Include="InByte.cs" />
|
||||
<Compile Include="InDWord.cs" />
|
||||
<Compile Include="InWord.cs" />
|
||||
<Compile Include="Out.cs" />
|
||||
<Compile Include="Sti.cs" />
|
||||
|
|
|
|||
Loading…
Reference in a new issue