mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-27 22:12:25 +00:00
This commit is contained in:
parent
439da46c55
commit
6f576e13f0
13 changed files with 70 additions and 77 deletions
|
|
@ -80,19 +80,18 @@
|
|||
<Compile Include="Network\TCPIPModel\PhysicalLayer\Ethernet2\Ethernet2Frame.cs" />
|
||||
<Compile Include="Network\TCPIPModel\TransportLayer\UDP\UDPPacket.cs" />
|
||||
<Compile Include="Storage\ATA\ATA.cs" />
|
||||
<Compile Include="PC\Bus\PIC.cs" />
|
||||
<Compile Include="PC\Bus\PCIBus.cs" />
|
||||
<Compile Include="PC\DebugUtil.cs" />
|
||||
<Compile Include="PC\Interrupts.cs" />
|
||||
<Compile Include="PIC.cs" />
|
||||
<Compile Include="PC\PCIBus.cs" />
|
||||
<Compile Include="Interrupts.cs" />
|
||||
<Compile Include="Old\TempDictionary.cs" />
|
||||
<Compile Include="Global.cs" />
|
||||
<Compile Include="Old\DebugUtil.cs" />
|
||||
<Compile Include="Old\Hardware.cs" />
|
||||
<Compile Include="Old\PIT.cs" />
|
||||
<Compile Include="DebugUtil.cs" />
|
||||
<Compile Include="Hardware.cs" />
|
||||
<Compile Include="PIT.cs" />
|
||||
<Compile Include="Bus\PCIBus.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Old\RTC.cs" />
|
||||
<Compile Include="Old\Serial.cs" />
|
||||
<Compile Include="RTC.cs" />
|
||||
<Compile Include="Serial.cs" />
|
||||
<Compile Include="Old\Storage\ATA.cs" />
|
||||
<Compile Include="Old\Storage\ATAOld.cs" />
|
||||
<Compile Include="Old\Storage\Storage.cs" />
|
||||
|
|
|
|||
|
|
@ -4,7 +4,50 @@ using System.Text;
|
|||
|
||||
namespace Cosmos.Hardware {
|
||||
public static class DebugUtil {
|
||||
public static void Initialize() {
|
||||
public static unsafe void LogInterruptOccurred(Interrupts.InterruptContext* aContext) {
|
||||
uint aInterrupt = aContext->Interrupt;
|
||||
Cosmos.Hardware.DebugUtil.StartLogging();
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("<InterruptOccurred Interrupt=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->Interrupt, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" SS=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->SS, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" GS=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->GS, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" FS=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->FS, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" ES=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->ES, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" DS=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->DS, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" CS=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->CS, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" ESI=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->ESI, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" EDI=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->EDI, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" EBP=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->EBP, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" ESP=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->ESP, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" EBX=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->EBX, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" EDX=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->EDX, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" ECX=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->ECX, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" EAX=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->EAX, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" Param=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->Param, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" EFlags=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->EFlags, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" UserESP=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->UserESP, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\"/>\r\n");
|
||||
Cosmos.Hardware.DebugUtil.EndLogging();
|
||||
}
|
||||
|
||||
public static void Initialize() {
|
||||
}
|
||||
|
||||
public static void StartLogging() {
|
||||
|
|
@ -9,13 +9,13 @@ namespace Cosmos.Hardware {
|
|||
|
||||
public static void Init() {
|
||||
Kernel.CPU.CreateGDT();
|
||||
PC.Bus.CPU.PIC.Init();
|
||||
PIC.Init();
|
||||
|
||||
Serial.InitSerial(0);
|
||||
PIT.Initialize(Tick);
|
||||
|
||||
//HW.Interrupts.IRQ01 += new Interrupts.InterruptDelegate(Cosmos.Hardware.Keyboard.HandleKeyboardInterrupt);
|
||||
PC.Interrupts.Init();
|
||||
Interrupts.Init();
|
||||
Kernel.CPU.CreateIDT();
|
||||
|
||||
PC.Bus.PCIBus.Init();
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Cosmos.Hardware.PC {
|
||||
namespace Cosmos.Hardware {
|
||||
public class Interrupts {
|
||||
[StructLayout(LayoutKind.Explicit, Size=76)]
|
||||
public struct InterruptContext {
|
||||
|
|
@ -55,9 +55,9 @@ namespace Cosmos.Hardware.PC {
|
|||
DebugUtil.LogInterruptOccurred(aContext);
|
||||
if (aContext->Interrupt >= 0x20 && aContext->Interrupt <= 0x2F) {
|
||||
if (aContext->Interrupt >= 0x28) {
|
||||
Bus.CPU.PIC.SignalSecondary();
|
||||
PIC.SignalSecondary();
|
||||
} else {
|
||||
Bus.CPU.PIC.SignalPrimary();
|
||||
PIC.SignalPrimary();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -81,7 +81,7 @@ namespace Cosmos.Hardware.PC {
|
|||
//IRQ 0 - System timer. Reserved for the system. Cannot be changed by a user.
|
||||
public static unsafe void HandleInterrupt_20(InterruptContext* aContext) {
|
||||
PIT.HandleInterrupt();
|
||||
Bus.CPU.PIC.SignalPrimary();
|
||||
PIC.SignalPrimary();
|
||||
}
|
||||
|
||||
static public InterruptDelegate IRQ01;
|
||||
|
|
@ -100,7 +100,7 @@ namespace Cosmos.Hardware.PC {
|
|||
//
|
||||
// - End change area
|
||||
|
||||
Bus.CPU.PIC.SignalPrimary();
|
||||
PIC.SignalPrimary();
|
||||
}
|
||||
|
||||
//IRQ 11 - (Added for RTL8139 network card)
|
||||
|
|
@ -112,10 +112,11 @@ namespace Cosmos.Hardware.PC {
|
|||
//Cosmos.Hardware.DebugUtil.SendMessage("Interrupts", "Interrupt 2B handler (for RTL)");
|
||||
//Console.WriteLine("IRQ 11 raised!");
|
||||
|
||||
if (IRQ11 != null)
|
||||
if (IRQ11 != null) {
|
||||
IRQ11();
|
||||
}
|
||||
|
||||
Bus.CPU.PIC.SignalSecondary();
|
||||
PIC.SignalSecondary();
|
||||
}
|
||||
|
||||
//IRQ 14 - Primary IDE. If no Primary IDE this can be changed
|
||||
|
|
@ -123,7 +124,7 @@ namespace Cosmos.Hardware.PC {
|
|||
Cosmos.Hardware.DebugUtil.SendMessage("IRQ", "Primary IDE");
|
||||
//Storage.ATAOld.HandleInterruptPrimary();
|
||||
Storage.ATA2.ATA.HandleInterruptPrimary();
|
||||
Bus.CPU.PIC.SignalSecondary();
|
||||
PIC.SignalSecondary();
|
||||
}
|
||||
|
||||
public static unsafe void HandleInterrupt_35(InterruptContext* aContext) {
|
||||
|
|
@ -139,7 +140,7 @@ namespace Cosmos.Hardware.PC {
|
|||
public static unsafe void HandleInterrupt_2F(InterruptContext* aContext) {
|
||||
Storage.ATA2.ATA.HandleInterruptSecondary();
|
||||
Cosmos.Hardware.DebugUtil.SendMessage("IRQ", "Secondary IDE");
|
||||
Bus.CPU.PIC.SignalSecondary();
|
||||
PIC.SignalSecondary();
|
||||
}
|
||||
|
||||
public static unsafe void HandleInterrupt_00(InterruptContext* aContext) {
|
||||
|
|
@ -88,7 +88,7 @@ namespace Cosmos.Hardware.Network.Devices.RTL8139
|
|||
|
||||
//Enable IRQ Interrupt
|
||||
InitIRQMaskRegister();
|
||||
Cosmos.Hardware.PC.Interrupts.IRQ11 = new Cosmos.Hardware.PC.Interrupts.InterruptDelegate(this.HandleNetworkInterrupt);
|
||||
Cosmos.Hardware.Interrupts.IRQ11 = new Cosmos.Hardware.Interrupts.InterruptDelegate(this.HandleNetworkInterrupt);
|
||||
//Console.WriteLine("Listening for IRQ" + pciCard.InterruptLine + ".");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,50 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Cosmos.Hardware.PC {
|
||||
public static class DebugUtil {
|
||||
public static unsafe void LogInterruptOccurred(Interrupts.InterruptContext* aContext) {
|
||||
uint aInterrupt = aContext->Interrupt;
|
||||
Cosmos.Hardware.DebugUtil.StartLogging();
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("<InterruptOccurred Interrupt=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->Interrupt, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" SS=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->SS, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" GS=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->GS, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" FS=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->FS, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" ES=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->ES, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" DS=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->DS, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" CS=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->CS, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" ESI=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->ESI, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" EDI=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->EDI, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" EBP=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->EBP, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" ESP=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->ESP, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" EBX=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->EBX, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" EDX=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->EDX, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" ECX=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->ECX, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" EAX=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->EAX, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" Param=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->Param, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" EFlags=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->EFlags, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\" UserESP=\"");
|
||||
Cosmos.Hardware.DebugUtil.WriteNumber(aContext->UserESP, 32);
|
||||
Cosmos.Hardware.DebugUtil.WriteSerialString("\"/>\r\n");
|
||||
Cosmos.Hardware.DebugUtil.EndLogging();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Cosmos.Hardware.PC.Bus.CPU {
|
||||
namespace Cosmos.Hardware {
|
||||
//TODO: Change this to be an instance like other drivers
|
||||
public abstract class PIC : Cosmos.Hardware.Device {
|
||||
/// <summary>
|
||||
|
|
@ -29,8 +29,8 @@ namespace Cosmos.Kernel.Plugs.Assemblers {
|
|||
}
|
||||
|
||||
private static MethodBase GetInterruptHandler(byte aInterrupt) {
|
||||
return GetMethodDef(typeof(Cosmos.Hardware.PC.Interrupts).Assembly,
|
||||
typeof(Cosmos.Hardware.PC.Interrupts).FullName,
|
||||
return GetMethodDef(typeof(Cosmos.Hardware.Interrupts).Assembly,
|
||||
typeof(Cosmos.Hardware.Interrupts).FullName,
|
||||
"HandleInterrupt_" + aInterrupt.ToString("X2"),
|
||||
false);
|
||||
}
|
||||
|
|
@ -147,8 +147,8 @@ namespace Cosmos.Kernel.Plugs.Assemblers {
|
|||
new Label("__ISR_Handler_" + j.ToString("X2") + "_SetCS");
|
||||
MethodBase xHandler = GetInterruptHandler((byte) j);
|
||||
if (xHandler == null) {
|
||||
xHandler = GetMethodDef(typeof(Cosmos.Hardware.PC.Interrupts).Assembly,
|
||||
typeof(Cosmos.Hardware.PC.Interrupts).FullName,
|
||||
xHandler = GetMethodDef(typeof(Cosmos.Hardware.Interrupts).Assembly,
|
||||
typeof(Cosmos.Hardware.Interrupts).FullName,
|
||||
"HandleInterrupt_Default",
|
||||
true);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue