This commit is contained in:
kudzu_cp 2010-08-16 01:31:24 +00:00
parent ee9578a1f1
commit dc7f2b0e6f
18 changed files with 77893 additions and 239 deletions

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -94,26 +94,26 @@ namespace Cosmos.Hardware2.Audio.Devices.ES1370
/// <summary>
/// (Should be) Called when the PCI audio card raises an Interrupt.
/// </summary>
public void HandleAudioInterrupt(ref IRQContext aContext)
{
Console.Write("IRQ detected: ");
if (isr.IsCodecBusyIntEnabled)
Console.WriteLine("Codec busy Interrupt! ");
if(isr.IsCodecStatusIntEnabled)
Console.WriteLine("Codec Enabled Interrupt! ");
if (isr.IsCodecWriteInProgressEnabled)
Console.WriteLine("Codec WriteInProgress Interrupt!");
if (isr.IsDAC1InterruptEnabled)
Console.WriteLine("DAC1 Interrupt!");
if (isr.IsDAC2InterruptEnabled)
Console.WriteLine("DAC2 Interrupt!");
if (isr.IsUARTInterruptEnabled)
Console.WriteLine("UART Interrupt!");
if (isr.IsMCCBIntEnabled)
Console.WriteLine("MCCB Interrupt!");
this.ResetAllIRQ();
//public void HandleAudioInterrupt(ref IRQContext aContext)
//{
// Console.Write("IRQ detected: ");
// if (isr.IsCodecBusyIntEnabled)
// Console.WriteLine("Codec busy Interrupt! ");
// if(isr.IsCodecStatusIntEnabled)
// Console.WriteLine("Codec Enabled Interrupt! ");
// if (isr.IsCodecWriteInProgressEnabled)
// Console.WriteLine("Codec WriteInProgress Interrupt!");
// if (isr.IsDAC1InterruptEnabled)
// Console.WriteLine("DAC1 Interrupt!");
// if (isr.IsDAC2InterruptEnabled)
// Console.WriteLine("DAC2 Interrupt!");
// if (isr.IsUARTInterruptEnabled)
// Console.WriteLine("UART Interrupt!");
// if (isr.IsMCCBIntEnabled)
// Console.WriteLine("MCCB Interrupt!");
// this.ResetAllIRQ();
}
//}
private void ResetAllIRQ()
{

View file

@ -91,7 +91,6 @@
<Compile Include="Audio\PCMStream.cs" />
<Compile Include="BlockDevice.cs" />
<Compile Include="Enums.cs" />
<Compile Include="IRQContext.cs" />
<Compile Include="Mouse.cs" />
<Compile Include="Network\Devices\AMDPCNetII\AMDPCNet.cs" />
<Compile Include="Network\Devices\RTL8139\RTL8139.cs" />

View file

@ -1,62 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using Cosmos.Kernel;
namespace Cosmos.Hardware2 {
//TODO: Move these back to be nested classes of IRQ when kernel is fully imported
[StructLayout(LayoutKind.Explicit, Size = 512)]
public struct MMXContext {
}
[StructLayout(LayoutKind.Explicit, Size = 80)]
public struct IRQContext {
[FieldOffset(0)]
public unsafe MMXContext* MMXContext;
[FieldOffset(4)]
public uint EDI;
[FieldOffset(8)]
public uint ESI;
[FieldOffset(12)]
public uint EBP;
[FieldOffset(16)]
public uint ESP;
[FieldOffset(20)]
public uint EBX;
[FieldOffset(24)]
public uint EDX;
[FieldOffset(28)]
public uint ECX;
[FieldOffset(32)]
public uint EAX;
[FieldOffset(36)]
public uint Interrupt;
[FieldOffset(40)]
public uint Param;
[FieldOffset(44)]
public uint EIP;
[FieldOffset(48)]
public uint CS;
[FieldOffset(52)]
public EFlagsEnum EFlags;
[FieldOffset(56)]
public uint UserESP;
}
}

View file

@ -81,49 +81,49 @@ namespace Cosmos.Hardware2
private static byte mouse_cycle =0;
private static int[] mouse_byte = new int[4];
public static void HandleMouse(ref IRQContext context)
{
switch (mouse_cycle)
{
case 0:
mouse_byte[0] = CPUBus.Read8(0x60);
// public static void HandleMouse(ref IRQContext context)
// {
// switch (mouse_cycle)
// {
// case 0:
// mouse_byte[0] = CPUBus.Read8(0x60);
if ((mouse_byte[0] & 0x8) == 0x8)
mouse_cycle++;
// if ((mouse_byte[0] & 0x8) == 0x8)
// mouse_cycle++;
break;
case 1:
mouse_byte[1] = CPUBus.Read8(0x60);
mouse_cycle++;
break;
case 2:
mouse_byte[2] = CPUBus.Read8(0x60);
mouse_cycle = 0;
// break;
// case 1:
// mouse_byte[1] = CPUBus.Read8(0x60);
// mouse_cycle++;
// break;
// case 2:
// mouse_byte[2] = CPUBus.Read8(0x60);
// mouse_cycle = 0;
if ((mouse_byte[0] & 0x10) == 0x10)
X -= mouse_byte[1] ^ 0xff;
else
X += mouse_byte[1];
// if ((mouse_byte[0] & 0x10) == 0x10)
// X -= mouse_byte[1] ^ 0xff;
// else
// X += mouse_byte[1];
if ((mouse_byte[0] & 0x20) == 0x20)
Y += mouse_byte[2] ^ 0xff;
else
Y -= mouse_byte[2];
// if ((mouse_byte[0] & 0x20) == 0x20)
// Y += mouse_byte[2] ^ 0xff;
// else
// Y -= mouse_byte[2];
if (X < 0)
X = 0;
else if (X > 319)
X = 319;
// if (X < 0)
// X = 0;
// else if (X > 319)
// X = 319;
if (Y < 0)
Y = 0;
else if (Y > 199)
Y = 199;
// if (Y < 0)
// Y = 0;
// else if (Y > 199)
// Y = 199;
Buttons = (MouseState)(mouse_byte[0] & 0x7);
// Buttons = (MouseState)(mouse_byte[0] & 0x7);
break;
}
}
// break;
// }
// }
}
}

View file

@ -147,32 +147,32 @@ namespace Cosmos.Hardware2.Network.Devices.AMDPCNetII
}
}
protected void HandleNetworkInterrupt(ref IRQContext aContext)
{
UInt32 cur_status = StatusRegister;
//protected void HandleNetworkInterrupt(ref IRQContext aContext)
//{
// UInt32 cur_status = StatusRegister;
if ((cur_status & 0x100) != 0)
{
mInitDone = true;
}
if ((cur_status & 0x200) != 0)
{
if (mTransmitBuffer.Count > 0)
{
byte[] data = mTransmitBuffer.Peek();
if (SendBytes(ref data) == true)
{
mTransmitBuffer.Dequeue();
}
}
}
if ((cur_status & 0x400) != 0)
{
ReadRawData();
}
// if ((cur_status & 0x100) != 0)
// {
// mInitDone = true;
// }
// if ((cur_status & 0x200) != 0)
// {
// if (mTransmitBuffer.Count > 0)
// {
// byte[] data = mTransmitBuffer.Peek();
// if (SendBytes(ref data) == true)
// {
// mTransmitBuffer.Dequeue();
// }
// }
// }
// if ((cur_status & 0x400) != 0)
// {
// ReadRawData();
// }
StatusRegister = cur_status;
}
// StatusRegister = cur_status;
//}
public bool InitDone
{

View file

@ -99,40 +99,40 @@ namespace Cosmos.Hardware2.Network.Devices.RTL8139
}
}
protected void HandleNetworkInterrupt(ref IRQContext aContext)
{
UInt16 cur_status = IntStatusRegister;
//protected void HandleNetworkInterrupt(ref IRQContext aContext)
//{
// UInt16 cur_status = IntStatusRegister;
//Console.WriteLine("RTL8139 Interrupt: ISR=" + cur_status.ToString());
if ((cur_status & 0x01) != 0)
{
while ((CommandRegister & 0x01) == 0)
{
//UInt32 packetHeader = BitConverter.ToUInt32(rxBuffer, rxBufferOffset + capr);
UInt32 packetHeader = rxBuffer.Read32(capr);
UInt16 packetLen = (UInt16)(packetHeader >> 16);
if ((packetHeader & 0x3E) != 0x00)
{
CommandRegister = 0x04; // TX Only;
capr = CurBufferAddressRegister;
CommandRegister = 0x0C; // RX and TX Enabled
}
else if ((packetHeader & 0x01) == 0x01)
{
ReadRawData(packetLen);
}
// //Console.WriteLine("RTL8139 Interrupt: ISR=" + cur_status.ToString());
// if ((cur_status & 0x01) != 0)
// {
// while ((CommandRegister & 0x01) == 0)
// {
// //UInt32 packetHeader = BitConverter.ToUInt32(rxBuffer, rxBufferOffset + capr);
// UInt32 packetHeader = rxBuffer.Read32(capr);
// UInt16 packetLen = (UInt16)(packetHeader >> 16);
// if ((packetHeader & 0x3E) != 0x00)
// {
// CommandRegister = 0x04; // TX Only;
// capr = CurBufferAddressRegister;
// CommandRegister = 0x0C; // RX and TX Enabled
// }
// else if ((packetHeader & 0x01) == 0x01)
// {
// ReadRawData(packetLen);
// }
CurAddressPointerReadRegister = (UInt16)(capr - 0x10);
}
}
if ((cur_status & 0x10) != 0)
{
CurAddressPointerReadRegister = (UInt16)(CurBufferAddressRegister - 0x10);
cur_status = (UInt16)(cur_status | 0x01);
}
// CurAddressPointerReadRegister = (UInt16)(capr - 0x10);
// }
// }
// if ((cur_status & 0x10) != 0)
// {
// CurAddressPointerReadRegister = (UInt16)(CurBufferAddressRegister - 0x10);
// cur_status = (UInt16)(cur_status | 0x01);
// }
IntStatusRegister = cur_status;
}
// IntStatusRegister = cur_status;
//}
#region Register Access
protected UInt32 RBStartRegister

View file

@ -485,49 +485,49 @@ namespace Cosmos.Hardware2.Network.Devices.RTL8139
/// <summary>
/// (Should be) Called when the PCI network card raises an Interrupt.
/// </summary>
public static void HandleNetworkInterrupt(ref IRQContext aContext)
{
if (mInstance.isr.ReceiveOK)
{
DebugWriteLine("IRQ detected: Receive OK");
mInstance.HandleReceiveInterrupt();
}
//public static void HandleNetworkInterrupt(ref IRQContext aContext)
//{
// if (mInstance.isr.ReceiveOK)
// {
// DebugWriteLine("IRQ detected: Receive OK");
// mInstance.HandleReceiveInterrupt();
// }
if (mInstance.isr.ReceiveError)
DebugWriteLine("IRQ detected: Receive ERROR");
// if (mInstance.isr.ReceiveError)
// DebugWriteLine("IRQ detected: Receive ERROR");
if (mInstance.isr.TransmitOK)
DebugWriteLine("IRQ detected: Transmit OK");
// if (mInstance.isr.TransmitOK)
// DebugWriteLine("IRQ detected: Transmit OK");
if (mInstance.imr.TransmitError & mInstance.isr.TransmitError)
DebugWriteLine("IRQ detected: Transmit Error");
// if (mInstance.imr.TransmitError & mInstance.isr.TransmitError)
// DebugWriteLine("IRQ detected: Transmit Error");
if (mInstance.imr.RxBufferOverflow & mInstance.isr.RxBufferOverflow)
DebugWriteLine("IRQ detected: RxBufferOverflow");
// if (mInstance.imr.RxBufferOverflow & mInstance.isr.RxBufferOverflow)
// DebugWriteLine("IRQ detected: RxBufferOverflow");
if (mInstance.imr.RxFifoOverflow & mInstance.isr.RxFifoOverflow)
DebugWriteLine("IRQ detected: RxFIFOOverflow");
// if (mInstance.imr.RxFifoOverflow & mInstance.isr.RxFifoOverflow)
// DebugWriteLine("IRQ detected: RxFIFOOverflow");
if (mInstance.imr.CableLengthChange & mInstance.isr.CableLengthChange)
DebugWriteLine("IRQ detected: Cable Length Change");
// if (mInstance.imr.CableLengthChange & mInstance.isr.CableLengthChange)
// DebugWriteLine("IRQ detected: Cable Length Change");
if (mInstance.imr.PacketUnderrun & mInstance.isr.PacketUnderrun)
DebugWriteLine("IRQ detected: Packet Underrun");
// if (mInstance.imr.PacketUnderrun & mInstance.isr.PacketUnderrun)
// DebugWriteLine("IRQ detected: Packet Underrun");
if (mInstance.imr.SoftwareInterrupt & mInstance.isr.SoftwareInterrupt)
DebugWriteLine("IRQ detected: Software Interrupt");
// if (mInstance.imr.SoftwareInterrupt & mInstance.isr.SoftwareInterrupt)
// DebugWriteLine("IRQ detected: Software Interrupt");
if (mInstance.imr.TxDescriptorUnavailable & mInstance.isr.TxDescriptorUnavailable)
DebugWriteLine("IRQ detected: TxDescriptorUnavailable");
// if (mInstance.imr.TxDescriptorUnavailable & mInstance.isr.TxDescriptorUnavailable)
// DebugWriteLine("IRQ detected: TxDescriptorUnavailable");
if (mInstance.imr.SystemError & mInstance.isr.SystemError)
DebugWriteLine("IRQ detected: System Error!");
// if (mInstance.imr.SystemError & mInstance.isr.SystemError)
// DebugWriteLine("IRQ detected: System Error!");
mInstance.ResetAllIRQ();
//Console.ReadLine();
// mInstance.ResetAllIRQ();
// //Console.ReadLine();
}
//}
private void ResetAllIRQ()
{

View file

@ -143,17 +143,17 @@ namespace Cosmos.Hardware2.Network.Devices.ViaRhine
}
}
protected void HandleNetworkInterrupt(ref IRQContext aContext)
{
UInt16 cur_status = IntStatusRegister;
//protected void HandleNetworkInterrupt(ref IRQContext aContext)
//{
// UInt16 cur_status = IntStatusRegister;
if ((cur_status & 0x01) != 0)
{
ReadRawData();
}
// if ((cur_status & 0x01) != 0)
// {
// ReadRawData();
// }
IntStatusRegister = cur_status;
}
// IntStatusRegister = cur_status;
//}
#region Register Access
protected UInt16 CommandRegister

View file

@ -9,6 +9,7 @@ using Cosmos.Hardware2;
namespace Cosmos.Core {
public class IRQs {
// TODO: Protect IRQs like memory and ports are
// TODO: Make IRQs so they are not hookable, and instead release high priority threads like FreeBSD (When we get threading)
[StructLayout(LayoutKind.Explicit, Size = 0x68)]
public struct TSS {
@ -66,6 +67,58 @@ namespace Cosmos.Core {
public ushort IOPBOffset;
}
[StructLayout(LayoutKind.Explicit, Size = 512)]
public struct MMXContext {
}
[StructLayout(LayoutKind.Explicit, Size = 80)]
public struct IRQContext {
[FieldOffset(0)]
public unsafe MMXContext* MMXContext;
[FieldOffset(4)]
public uint EDI;
[FieldOffset(8)]
public uint ESI;
[FieldOffset(12)]
public uint EBP;
[FieldOffset(16)]
public uint ESP;
[FieldOffset(20)]
public uint EBX;
[FieldOffset(24)]
public uint EDX;
[FieldOffset(28)]
public uint ECX;
[FieldOffset(32)]
public uint EAX;
[FieldOffset(36)]
public uint Interrupt;
[FieldOffset(40)]
public uint Param;
[FieldOffset(44)]
public uint EIP;
[FieldOffset(48)]
public uint CS;
[FieldOffset(52)]
public EFlagsEnum EFlags;
[FieldOffset(56)]
public uint UserESP;
}
private static InterruptDelegate[] mIRQ_Handlers = new InterruptDelegate[256];
// We used to use:
@ -96,20 +149,6 @@ namespace Cosmos.Core {
public delegate void InterruptDelegate(ref IRQContext aContext);
public delegate void ExceptionInterruptDelegate(ref IRQContext aContext, ref bool aHandled);
//IRQ 2 - Cascaded signals from IRQs 8-15. A device configured to use IRQ 2 will actually be using IRQ 9
//IRQ 3 - COM2 (Default) and COM4 (User) serial ports
//IRQ 4 - COM1 (Default) and COM3 (User) serial ports
//IRQ 5 - LPT2 Parallel Port 2 or sound card
//IRQ 6 - Floppy disk controller
//IRQ 7 - LPT1 Parallel Port 1 or sound card (8-bit Sound Blaster and compatibles)
//IRQ 8 - Real time clock
//IRQ 9 - Free / Open interrupt / Available / SCSI. Any devices configured to use IRQ 2 will actually be using IRQ 9.
//IRQ 10 - Free / Open interrupt / Available / SCSI
//IRQ 11 - Free / Open interrupt / Available / SCSI
//IRQ 12 - PS/2 connector Mouse. If no PS/2 connector mouse is used, this can be used for other peripherals
//IRQ 13 - ISA / Math Co-Processor
//IRQ 0 - System timer. Reserved for the system. Cannot be changed by a user.
public static void HandleInterrupt_20(ref IRQContext aContext) {
//TODO New Kernel

View file

@ -5,7 +5,16 @@
</head>
<body>
<p>
<h3>
Questions</h3>
<p>
Higher priority IRQs can happen while lower ones are in progress</p>
<p>
Can a signle IRQ happen while one is already in progress? ie Int 2 happen while
Int 2 is already in progress? If so does it call again, queue it? or lose it?</p>
<h3>
Links</h3>
<p>
<a href="http://en.wikipedia.org/wiki/Interrupt">
http://en.wikipedia.org/wiki/Interrupt</a><br />
<a href="http://en.wikipedia.org/wiki/Interrupt_request">
@ -18,11 +27,61 @@
http://en.wikipedia.org/wiki/Interrupt_descriptor_table</a><br />
Interrupt Threads - <a href="http://en.wikipedia.org/wiki/Interrupt_handler">
http://en.wikipedia.org/wiki/Interrupt_handler</a><br />
</p>
Efficiency <a href="http://lwn.net/Articles/395783/">
http://lwn.net/Articles/395783/</a></p>
<h3>
<span id="Master_PIC" class="mw-headline">Master PIC</span></h3>
<ul>
<li>IRQ 0 — system timer (cannot be changed);</li>
<li>IRQ 1 — <a class="mw-redirect"
href="http://en.wikipedia.org/wiki/Computer_keyboard" title="Computer keyboard">
keyboard</a> (cannot be changed);</li>
<li>IRQ 2 — cascaded signals from IRQs 815 (<i>any devices configured to use IRQ 2
will actually be using IRQ 9</i>);</li>
<li>IRQ 3 — <a href="http://en.wikipedia.org/wiki/Serial_port" title="Serial port">
serial port</a> 2 or 4;</li>
<li>IRQ 4 — serial port 1 or 3;</li>
<li>IRQ 5 — <a href="http://en.wikipedia.org/wiki/LPT" title="LPT">LPT</a> port 2 or
<a href="http://en.wikipedia.org/wiki/Sound_card" title="Sound card">sound card</a>;</li>
<li>IRQ 6 — <a href="http://en.wikipedia.org/wiki/Floppy_disk_controller"
title="Floppy disk controller">floppy disk controller</a>;</li>
<li>IRQ 7 — <a href="http://en.wikipedia.org/wiki/LPT" title="LPT">LPT</a> port 1 or
sound card (8-bit <a href="http://en.wikipedia.org/wiki/Sound_Blaster"
title="Sound Blaster">Sound Blaster</a> and compatibles).</li>
</ul>
<h3>
<span id="Slave_PIC" class="mw-headline">Slave PIC</span></h3>
<ul>
<li>IRQ 8 — <a href="http://en.wikipedia.org/wiki/Real-time_clock"
title="Real-time clock">real-time clock</a>;</li>
<li>IRQ 9 — free / open interrupt / available /
<a href="http://en.wikipedia.org/wiki/SCSI" title="SCSI">SCSI</a> (<i>any
devices configured to use IRQ 2 will actually be using IRQ 9</i>);</li>
<li>IRQ 10 — free / open interrupt / available /
<a href="http://en.wikipedia.org/wiki/SCSI" title="SCSI">SCSI</a> /
<a class="mw-redirect" href="http://en.wikipedia.org/wiki/Network_card"
title="Network card">NIC</a>;</li>
<li>IRQ 11 — free / open interrupt / available /
<a href="http://en.wikipedia.org/wiki/SCSI" title="SCSI">SCSI</a> /
<a class="mw-redirect" href="http://en.wikipedia.org/wiki/Network_card"
title="Network card">NIC</a>;</li>
<li>IRQ 12 — <a href="http://en.wikipedia.org/wiki/PS/2_connector"
title="PS/2 connector">PS/2 connector</a> mouse;</li>
<li>IRQ 13 — math <a class="mw-redirect"
href="http://en.wikipedia.org/wiki/Co-processor" title="Co-processor">
co-processor</a> / integrated <a class="mw-redirect"
href="http://en.wikipedia.org/wiki/Floating_point_unit"
title="Floating point unit">floating point unit</a> /
<a href="http://en.wikipedia.org/wiki/Inter-processor_interrupt"
title="Inter-processor interrupt">inter-processor interrupt</a> (Use depends
on OS);</li>
<li>IRQ 14 — primary <a href="http://en.wikipedia.org/wiki/Parallel_ATA"
title="Parallel ATA">ATA</a> channel;</li>
<li>IRQ 15 — secondary <a href="http://en.wikipedia.org/wiki/Parallel_ATA"
title="Parallel ATA">ATA</a> channel</li>
</ul>
<p>
Efficiency<br />
<a href="http://lwn.net/Articles/395783/">http://lwn.net/Articles/395783/</a><br />
</p>
&nbsp;</p>
</body>
</html>

View file

@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HW2 = Cosmos.Hardware2;
using K2 = Cosmos.Kernel;
namespace Cosmos.Hardware {
@ -27,7 +26,7 @@ namespace Cosmos.Hardware {
}
}
public void HandleIRQ(ref HW2.IRQContext aContext) {
public void HandleIRQ(ref Core.IRQs.IRQContext aContext) {
if (mHandleKeyboardKey != null) {
byte xScanCode = IO.Port60.Byte;
bool xReleased = (xScanCode & 0x80) == 0x80;
@ -104,7 +103,6 @@ namespace Cosmos.Hardware {
break;
}
}
//DebugUtil.SendKeyboardEvent(xTheScancode, aReleased);
}
// Can merge HandleScancode after we remove old code

View file

@ -3,8 +3,12 @@
<h3>
To Do</h3>
<ul>
<li>New clean kernel with no links to old one, just console..</li>
<li>New clean kernel with no links to old one, just console..<ul>
<li>keyboard PIC GDT CPU CPUBus and plug </li>
</ul>
</li>
<li>Guess Demo</li>
<li>use INT3 for BP?</li>
<li>Plugs<ul>
<li>To add a plug<ul>
<li>Cosmos.Build.MSBuild add ref to the plug asm</li>
@ -17,12 +21,16 @@
<h3>
Matthijs</h3>
<ul>
<li>Write a manual cleanup util that runs as part of our install first</li>
<li>New projects should be: C# Operating System, VB.NET Operating System, C#
<li>Next Release<ul>
<li>Write a manual cleanup utility that runs as part of our install first</li>
<li>New projects should be: C# Operating System, VB.NET Operating System, C#
Library, VB.NET Library, Cosmos Project (Empty)</li>
<li>Express</li>
<li>Change to new kernel lib format</li>
<li>Express</li>
<li>Change to new kernel lib format</li>
</ul>
</li>
<li style="font-weight: 700">Post Release:</li>
<li>IL2CPU.AlwaysCompile attribute and get rid of IDT.Dummy</li>
<li>Change plugs to be included by assembly reference<ul>
<li>Many kernel functions (TextScreen is linked to by console plug) requires
rebuilding of bat each time? And thus wont trace either? We need to dynamically