mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-12 03:01:32 +00:00
This commit is contained in:
parent
67405de5fa
commit
fe40179b82
6 changed files with 42 additions and 43 deletions
|
|
@ -52,7 +52,6 @@
|
|||
<ItemGroup>
|
||||
<Compile Include="BlockDevice.cs" />
|
||||
<Compile Include="Bus\Bus.cs" />
|
||||
<Compile Include="Bus\CPUBus.cs" />
|
||||
<Compile Include="Device.cs" />
|
||||
<Compile Include="Extension\NumberSystem\Binary.cs" />
|
||||
<Compile Include="Extension\NumberSystem\Hex.cs" />
|
||||
|
|
@ -81,9 +80,8 @@
|
|||
<Compile Include="Network\TCPIPModel\TransportLayer\UDP\UDPPacket.cs" />
|
||||
<Compile Include="Storage\ATA\ATA.cs" />
|
||||
<Compile Include="PC\Bus\AddressSpace.cs" />
|
||||
<Compile Include="PC\Bus\CPUBus.cs" />
|
||||
<Compile Include="PC\Bus\CPU\Keyboard.cs" />
|
||||
<Compile Include="PC\Bus\CPU\PIC.cs" />
|
||||
<Compile Include="PC\Bus\Keyboard.cs" />
|
||||
<Compile Include="PC\Bus\PIC.cs" />
|
||||
<Compile Include="PC\Bus\PCIBus.cs" />
|
||||
<Compile Include="PC\DebugUtil.cs" />
|
||||
<Compile Include="PC\Interrupts.cs" />
|
||||
|
|
|
|||
|
|
@ -531,7 +531,8 @@ namespace Cosmos.Hardware.Network.Devices.RTL8139
|
|||
* The address is stored in the Transmit Start Address which corresponds to the Transmit Status Descriptor we are currently using (0-3).
|
||||
*/
|
||||
|
||||
IOSpace.Write32(address, GetMemoryAddress(ref bytearray));
|
||||
var xMem = new MemoryAddressSpace(address, 1);
|
||||
xMem.Write32(0, GetMemoryAddress(ref bytearray));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -181,64 +181,64 @@ namespace Cosmos.Hardware.PC.Bus {
|
|||
{
|
||||
if (offset < 0 || offset > Size)
|
||||
throw new ArgumentOutOfRangeException("offset");
|
||||
return CPUBus.Read8((UInt16)(this.Offset + offset));
|
||||
return Kernel.CPUBus.Read8((UInt16)(this.Offset + offset));
|
||||
}
|
||||
public override UInt16 Read16(UInt32 offset)
|
||||
{
|
||||
if (offset < 0 || offset > Size)
|
||||
throw new ArgumentOutOfRangeException("offset");
|
||||
return CPUBus.Read16((UInt16)(this.Offset + offset));
|
||||
return Kernel.CPUBus.Read16((UInt16)(this.Offset + offset));
|
||||
}
|
||||
public override UInt32 Read32(UInt32 offset)
|
||||
{
|
||||
if (offset < 0 || offset > Size)
|
||||
throw new ArgumentOutOfRangeException("offset");
|
||||
return CPUBus.Read32((UInt16)(this.Offset + offset));
|
||||
return Kernel.CPUBus.Read32((UInt16)(this.Offset + offset));
|
||||
}
|
||||
|
||||
public override byte Read8Unchecked(UInt32 offset)
|
||||
{
|
||||
return CPUBus.Read8((UInt16)(this.Offset + offset));
|
||||
return Kernel.CPUBus.Read8((UInt16)(this.Offset + offset));
|
||||
}
|
||||
public override UInt16 Read16Unchecked(UInt32 offset)
|
||||
{
|
||||
return CPUBus.Read16((UInt16)(this.Offset + offset));
|
||||
return Kernel.CPUBus.Read16((UInt16)(this.Offset + offset));
|
||||
}
|
||||
public override UInt32 Read32Unchecked(UInt32 offset)
|
||||
{
|
||||
return CPUBus.Read32((UInt16)(this.Offset + offset));
|
||||
return Kernel.CPUBus.Read32((UInt16)(this.Offset + offset));
|
||||
}
|
||||
|
||||
public override void Write8(UInt32 offset, byte value)
|
||||
{
|
||||
if (offset < 0 || offset > Size)
|
||||
throw new ArgumentOutOfRangeException("offset");
|
||||
CPUBus.Write8((UInt16)(this.Offset + offset), value);
|
||||
Kernel.CPUBus.Write8((UInt16)(this.Offset + offset), value);
|
||||
}
|
||||
public override void Write16(UInt32 offset, UInt16 value)
|
||||
{
|
||||
if (offset < 0 || offset > Size)
|
||||
throw new ArgumentOutOfRangeException("offset");
|
||||
CPUBus.Write16((UInt16)(this.Offset + offset), value);
|
||||
Kernel.CPUBus.Write16((UInt16)(this.Offset + offset), value);
|
||||
}
|
||||
public override void Write32(UInt32 offset, UInt32 value)
|
||||
{
|
||||
if (offset < 0 || offset > Size)
|
||||
throw new ArgumentOutOfRangeException("offset");
|
||||
CPUBus.Write32((UInt16)(this.Offset + offset), value);
|
||||
Kernel.CPUBus.Write32((UInt16)(this.Offset + offset), value);
|
||||
}
|
||||
|
||||
public override void Write8Unchecked(UInt32 offset, byte value)
|
||||
{
|
||||
CPUBus.Write8((UInt16)(this.Offset + offset), value);
|
||||
Kernel.CPUBus.Write8((UInt16)(this.Offset + offset), value);
|
||||
}
|
||||
public override void Write16Unchecked(UInt32 offset, UInt16 value)
|
||||
{
|
||||
CPUBus.Write16((UInt16)(this.Offset + offset), value);
|
||||
Kernel.CPUBus.Write16((UInt16)(this.Offset + offset), value);
|
||||
}
|
||||
public override void Write32Unchecked(UInt32 offset, UInt32 value)
|
||||
{
|
||||
CPUBus.Write32((UInt16)(this.Offset + offset), value);
|
||||
Kernel.CPUBus.Write32((UInt16)(this.Offset + offset), value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace Cosmos.Hardware.PC.Bus.CPU {
|
|||
}
|
||||
|
||||
public void InterruptReceived() {
|
||||
byte xByte = PC.Bus.CPUBus.Read8(0x60);
|
||||
byte xByte = Kernel.CPUBus.Read8(0x60);
|
||||
ByteReceived(xByte);
|
||||
}
|
||||
public override string Name {
|
||||
|
|
@ -587,38 +587,38 @@ namespace Cosmos.Hardware.PC.Bus
|
|||
|
||||
protected UInt32 Read32(byte aRegister)
|
||||
{
|
||||
CPUBus.Write32(ConfigAddr, GetAddress(aRegister));
|
||||
return CPUBus.Read32(ConfigData);
|
||||
Kernel.CPUBus.Write32(ConfigAddr, GetAddress(aRegister));
|
||||
return Kernel.CPUBus.Read32(ConfigData);
|
||||
}
|
||||
|
||||
protected UInt16 Read16(byte aRegister)
|
||||
{
|
||||
CPUBus.Write32(ConfigAddr, GetAddress(aRegister));
|
||||
return CPUBus.Read16(ConfigData);
|
||||
Kernel.CPUBus.Write32(ConfigAddr, GetAddress(aRegister));
|
||||
return Kernel.CPUBus.Read16(ConfigData);
|
||||
}
|
||||
|
||||
protected byte Read8(byte aRegister)
|
||||
{
|
||||
CPUBus.Write32(ConfigAddr, GetAddress(aRegister));
|
||||
return CPUBus.Read8(ConfigData);
|
||||
Kernel.CPUBus.Write32(ConfigAddr, GetAddress(aRegister));
|
||||
return Kernel.CPUBus.Read8(ConfigData);
|
||||
}
|
||||
|
||||
protected void Write32(byte aRegister, UInt32 value)
|
||||
{
|
||||
CPUBus.Write32(ConfigAddr, GetAddress(aRegister));
|
||||
CPUBus.Write32(ConfigData, value);
|
||||
Kernel.CPUBus.Write32(ConfigAddr, GetAddress(aRegister));
|
||||
Kernel.CPUBus.Write32(ConfigData, value);
|
||||
}
|
||||
|
||||
protected void Write16(byte aRegister, UInt16 value)
|
||||
{
|
||||
CPUBus.Write32(ConfigAddr, GetAddress(aRegister));
|
||||
CPUBus.Write16(ConfigData, value);
|
||||
Kernel.CPUBus.Write32(ConfigAddr, GetAddress(aRegister));
|
||||
Kernel.CPUBus.Write16(ConfigData, value);
|
||||
}
|
||||
|
||||
protected void Write8(byte aRegister, byte value)
|
||||
{
|
||||
CPUBus.Write32(ConfigAddr, GetAddress(aRegister));
|
||||
CPUBus.Write8(ConfigData, value);
|
||||
Kernel.CPUBus.Write32(ConfigAddr, GetAddress(aRegister));
|
||||
Kernel.CPUBus.Write8(ConfigData, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -16,31 +16,31 @@ namespace Cosmos.Hardware.PC.Bus.CPU {
|
|||
const ushort DataPort2 = 0xA1;
|
||||
|
||||
public static void SignalPrimary() {
|
||||
PC.Bus.CPUBus.Write8(CmdPort1, 0x20);
|
||||
Kernel.CPUBus.Write8(CmdPort1, 0x20);
|
||||
}
|
||||
|
||||
public static void SignalSecondary() {
|
||||
PC.Bus.CPUBus.Write8(CmdPort2, 0x20);
|
||||
PC.Bus.CPUBus.Write8(CmdPort1, 0x20);
|
||||
Kernel.CPUBus.Write8(CmdPort2, 0x20);
|
||||
Kernel.CPUBus.Write8(CmdPort1, 0x20);
|
||||
}
|
||||
|
||||
public static void Init() {
|
||||
// Init
|
||||
PC.Bus.CPUBus.Write8(CmdPort1, 0x11);
|
||||
PC.Bus.CPUBus.Write8(CmdPort2, 0x11);
|
||||
Kernel.CPUBus.Write8(CmdPort1, 0x11);
|
||||
Kernel.CPUBus.Write8(CmdPort2, 0x11);
|
||||
// Offsets
|
||||
PC.Bus.CPUBus.Write8(DataPort1, 0x20);
|
||||
PC.Bus.CPUBus.Write8(DataPort2, 0x28);
|
||||
Kernel.CPUBus.Write8(DataPort1, 0x20);
|
||||
Kernel.CPUBus.Write8(DataPort2, 0x28);
|
||||
// More Init
|
||||
PC.Bus.CPUBus.Write8(DataPort1, 0x04);
|
||||
PC.Bus.CPUBus.Write8(DataPort2, 0x02);
|
||||
Kernel.CPUBus.Write8(DataPort1, 0x04);
|
||||
Kernel.CPUBus.Write8(DataPort2, 0x02);
|
||||
// 8086 mode
|
||||
PC.Bus.CPUBus.Write8(DataPort1, 0x01);
|
||||
PC.Bus.CPUBus.Write8(DataPort2, 0x01);
|
||||
Kernel.CPUBus.Write8(DataPort1, 0x01);
|
||||
Kernel.CPUBus.Write8(DataPort2, 0x01);
|
||||
// Masks - 0 = receive all IRQ's
|
||||
// MTW, to disable PIT, send 0x1 to DataPort1
|
||||
PC.Bus.CPUBus.Write8(DataPort1, 0x00);
|
||||
PC.Bus.CPUBus.Write8(DataPort2, 0x00);
|
||||
Kernel.CPUBus.Write8(DataPort1, 0x00);
|
||||
Kernel.CPUBus.Write8(DataPort2, 0x00);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue