mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-13 11:41:44 +00:00
Ugh, we have a compiler bug :(
This commit is contained in:
parent
e1945e7966
commit
71250fe5e5
7 changed files with 62 additions and 65 deletions
|
|
@ -134,20 +134,7 @@ namespace Cosmos.System.Plugs.System {
|
|||
}
|
||||
|
||||
public static void Write(string aText) {
|
||||
for (int i = 0; i < aText.Length; i++) {
|
||||
if (aText[i] == '\n') {
|
||||
Global.Console.NewLine();
|
||||
continue;
|
||||
}
|
||||
if (aText[i] == '\r') {
|
||||
continue;
|
||||
}
|
||||
if (aText[i] == '\t') {
|
||||
Write(" ");
|
||||
continue;
|
||||
}
|
||||
Global.Console.WriteChar(aText[i]);
|
||||
}
|
||||
Global.Console.Write(aText);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -160,67 +147,67 @@ namespace Cosmos.System.Plugs.System {
|
|||
|
||||
public static void WriteLine(object value) {
|
||||
Write(value);
|
||||
WriteLine();
|
||||
Global.Console.NewLine();
|
||||
}
|
||||
|
||||
public static void WriteLine(char[] buffer) {
|
||||
Write(buffer);
|
||||
WriteLine();
|
||||
Global.Console.NewLine();
|
||||
}
|
||||
|
||||
public static void WriteLine(bool aBool) {
|
||||
Write(aBool);
|
||||
WriteLine();
|
||||
Global.Console.NewLine();
|
||||
}
|
||||
|
||||
public static void WriteLine(char aChar) {
|
||||
Write(aChar);
|
||||
WriteLine();
|
||||
Global.Console.NewLine();
|
||||
}
|
||||
|
||||
public static void WriteLine(byte aByte) {
|
||||
Write(aByte);
|
||||
WriteLine();
|
||||
Global.Console.NewLine();
|
||||
}
|
||||
|
||||
public static void WriteLine(string aLine) {
|
||||
Write(aLine);
|
||||
WriteLine();
|
||||
Global.Console.NewLine();
|
||||
}
|
||||
|
||||
public static void WriteLine(UInt16 aValue) {
|
||||
Write(aValue);
|
||||
WriteLine();
|
||||
Global.Console.NewLine();
|
||||
}
|
||||
|
||||
public static void WriteLine(Int16 aValue) {
|
||||
Write(aValue);
|
||||
WriteLine();
|
||||
Global.Console.NewLine();
|
||||
}
|
||||
|
||||
public static void WriteLine(UInt32 aValue) {
|
||||
Write(aValue);
|
||||
WriteLine();
|
||||
Global.Console.NewLine();
|
||||
}
|
||||
|
||||
public static void WriteLine(Int32 aValue) {
|
||||
Write(aValue);
|
||||
WriteLine();
|
||||
Global.Console.NewLine();
|
||||
}
|
||||
|
||||
public static void WriteLine(UInt64 aValue) {
|
||||
Write(aValue);
|
||||
WriteLine();
|
||||
Global.Console.NewLine();
|
||||
}
|
||||
|
||||
public static void WriteLine(Int64 aValue) {
|
||||
Write(aValue);
|
||||
WriteLine();
|
||||
Global.Console.NewLine();
|
||||
}
|
||||
|
||||
public static void WriteLine(char[] aBuffer, int aIndex, int aCount) {
|
||||
Write(aBuffer, aIndex, aCount);
|
||||
WriteLine();
|
||||
Global.Console.NewLine();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -303,11 +290,9 @@ namespace Cosmos.System.Plugs.System {
|
|||
currentCount++;
|
||||
}
|
||||
}
|
||||
|
||||
WriteLine();
|
||||
|
||||
char[] final = chars.ToArray();
|
||||
|
||||
return new string(final);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ namespace Cosmos.System {
|
|||
UpdateCursor();
|
||||
}
|
||||
|
||||
//TODO: This is slow, batch it and only do it at end of updates
|
||||
protected void UpdateCursor() {
|
||||
mText.SetCursorPos(mX, mY);
|
||||
}
|
||||
|
|
@ -64,10 +65,23 @@ namespace Cosmos.System {
|
|||
UpdateCursor();
|
||||
}
|
||||
|
||||
public void WriteLine(string aText) {
|
||||
public void WriteLine(string aText) {
|
||||
Write(aText);
|
||||
NewLine();
|
||||
}
|
||||
|
||||
//TODO: Optimize this
|
||||
public void Write(string aText) {
|
||||
for (int i = 0; i < aText.Length; i++) {
|
||||
if (aText[i] == '\n') {
|
||||
NewLine();
|
||||
} else if (aText[i] == '\r') {
|
||||
} else if (aText[i] == '\t') {
|
||||
Write(" ");
|
||||
} else {
|
||||
WriteChar(aText[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ using Cosmos.Hardware2;
|
|||
|
||||
namespace Cosmos.Core {
|
||||
public class IRQs {
|
||||
// TODO: Protect IRQs like memory and ports are
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size = 0x68)]
|
||||
public struct TSS {
|
||||
[FieldOffset(0)]
|
||||
|
|
@ -66,8 +68,12 @@ namespace Cosmos.Core {
|
|||
|
||||
private static InterruptDelegate[] mIRQ_Handlers = new InterruptDelegate[256];
|
||||
|
||||
public static void AddIRQHandler(byte IRQ, InterruptDelegate handler) {
|
||||
mIRQ_Handlers[IRQ] = handler;
|
||||
// We used to use:
|
||||
//Interrupts.IRQ01 += HandleKeyboardInterrupt;
|
||||
// But at one point we had issues with multi cast delegates, so we changed to this single cast option.
|
||||
// [1:48:37 PM] Matthijs ter Woord: the issues were: "they didn't work, would crash kernel". not sure if we still have them..
|
||||
public static void SetHandler(byte aIrqNo, InterruptDelegate aHandler) {
|
||||
mIRQ_Handlers[aIrqNo] = aHandler;
|
||||
}
|
||||
|
||||
private static void IRQ(uint irq, ref IRQContext aContext) {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ namespace Cosmos.Core {
|
|||
internal MemoryBlock(UInt32 aBase, UInt32 aSize) {
|
||||
Base = aBase;
|
||||
Size = aSize;
|
||||
Cosmos.Debug.Debugger.Send("32 Base, Size: " + Base.ToString() + ", " + Size.ToString());
|
||||
Bytes = new MemoryBlock08(aBase, aSize * 4);
|
||||
Words = new MemoryBlock16(aBase, aSize * 2);
|
||||
}
|
||||
|
|
@ -66,6 +67,7 @@ namespace Cosmos.Core {
|
|||
internal MemoryBlock08(UInt32 aBase, UInt32 aSize) {
|
||||
Base = aBase;
|
||||
Size = aSize;
|
||||
Cosmos.Debug.Debugger.Send("08 Base, Size: " + Base.ToString() + ", " + Size.ToString());
|
||||
}
|
||||
|
||||
public unsafe byte this[UInt32 aOffset] {
|
||||
|
|
@ -76,9 +78,13 @@ namespace Cosmos.Core {
|
|||
return *(byte*)(Base + aOffset);
|
||||
}
|
||||
set {
|
||||
Cosmos.Debug.Debugger.Send("Base, Offset, Size: " + Base.ToString() + ", " + aOffset.ToString() + ", " + Size.ToString());
|
||||
//Offset, Size: 0, 4294967295
|
||||
if (aOffset >= Size) {
|
||||
// Also this exception gets eaten?
|
||||
throw new Exception("Memory access violation");
|
||||
}
|
||||
Cosmos.Debug.Debugger.Send("Address: " + (Base + aOffset).ToString() + " = " + value.ToString());
|
||||
(*(byte*)(Base + aOffset)) = value;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,16 @@ namespace Cosmos.Hardware {
|
|||
mHandleKeyboardKey = aHandleKeyboardKeyDelegate;
|
||||
}
|
||||
|
||||
public void Initialize() {
|
||||
CheckInit();
|
||||
public Keyboard() {
|
||||
mBuffer = new Queue<uint>(BufferSize);
|
||||
|
||||
Initialize(HandleScancode);
|
||||
Core.IRQs.SetHandler(1, HandleIRQ);
|
||||
// TODO: Need to add support for mult keyboards. ie one in PS2 and one in USB, or even more
|
||||
|
||||
if (mKeys == null) {
|
||||
CreateDefaultKeymap();
|
||||
}
|
||||
}
|
||||
|
||||
public void HandleIRQ(ref HW2.IRQContext aContext) {
|
||||
|
|
@ -109,21 +117,6 @@ namespace Cosmos.Hardware {
|
|||
mHandleKeyboardKey(aValue, xReleased);
|
||||
}
|
||||
|
||||
private void CheckInit() {
|
||||
if (mBuffer == null) {
|
||||
mBuffer = new Queue<uint>(BufferSize);
|
||||
|
||||
Initialize(HandleScancode);
|
||||
//Interrupts.IRQ01 += HandleKeyboardInterrupt;
|
||||
Core.IRQs.AddIRQHandler(1, HandleIRQ);
|
||||
// TODO: Need to add support for mult keyboards. ie one in PS2 and one in USB, or even more
|
||||
|
||||
if (mKeys == null) {
|
||||
CreateDefaultKeymap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateDefaultKeymap() {
|
||||
mKeys = new List<KeyMapping>(164);
|
||||
|
||||
|
|
@ -354,7 +347,6 @@ namespace Cosmos.Hardware {
|
|||
}
|
||||
|
||||
public char ReadChar() {
|
||||
CheckInit();
|
||||
char xResult = '\0';
|
||||
while (mBuffer.Count == 0 || !GetCharValue(mBuffer.Dequeue(), out xResult)) {
|
||||
//Global.Sleep(10); //ToDo optimize value
|
||||
|
|
@ -364,7 +356,6 @@ namespace Cosmos.Hardware {
|
|||
}
|
||||
|
||||
public bool GetChar(out char c) {
|
||||
CheckInit();
|
||||
c = '\0';
|
||||
|
||||
if (mBuffer.Count > 0) {
|
||||
|
|
@ -376,7 +367,6 @@ namespace Cosmos.Hardware {
|
|||
}
|
||||
|
||||
public ConsoleKey ReadKey() {
|
||||
CheckInit();
|
||||
ConsoleKey xResult = ConsoleKey.NoName;
|
||||
while (mBuffer.Count == 0 || !GetKeyValue(mBuffer.Dequeue(), out xResult)) {
|
||||
//Global.Sleep(10); //ToDo optimize value
|
||||
|
|
@ -385,7 +375,6 @@ namespace Cosmos.Hardware {
|
|||
return xResult;
|
||||
}
|
||||
public bool GetKey(out ConsoleKey c) {
|
||||
CheckInit();
|
||||
c = ConsoleKey.NoName;
|
||||
|
||||
if (mBuffer.Count > 0) {
|
||||
|
|
@ -397,7 +386,6 @@ namespace Cosmos.Hardware {
|
|||
}
|
||||
|
||||
public KeyMapping ReadMapping() {
|
||||
CheckInit();
|
||||
KeyMapping xResult = null;
|
||||
while (mBuffer.Count == 0 || !GetKeyMapping(mBuffer.Dequeue(), out xResult)) {
|
||||
//Global.Sleep(10); //ToDo optimize value
|
||||
|
|
@ -406,7 +394,6 @@ namespace Cosmos.Hardware {
|
|||
return xResult;
|
||||
}
|
||||
public bool GetMapping(out KeyMapping c) {
|
||||
CheckInit();
|
||||
c = null;
|
||||
|
||||
if (mBuffer.Count > 0) {
|
||||
|
|
@ -418,8 +405,6 @@ namespace Cosmos.Hardware {
|
|||
}
|
||||
|
||||
public uint ReadScancode() {
|
||||
CheckInit();
|
||||
|
||||
while (mBuffer.Count == 0) {
|
||||
K2.CPU.Halt();
|
||||
}
|
||||
|
|
@ -427,8 +412,6 @@ namespace Cosmos.Hardware {
|
|||
return mBuffer.Dequeue();
|
||||
}
|
||||
public bool GetScancode(out uint c) {
|
||||
CheckInit();
|
||||
|
||||
if (mBuffer.Count > 0) {
|
||||
c = mBuffer.Dequeue();
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -35,6 +35,9 @@
|
|||
<TraceMode>
|
||||
</TraceMode>
|
||||
<VMWareFlavor>Workstation</VMWareFlavor>
|
||||
<StartCosmosGDB>
|
||||
</StartCosmosGDB>
|
||||
<TraceAssemblies>Cosmos</TraceAssemblies>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Breakpoints.cgdb">
|
||||
|
|
|
|||
|
|
@ -21,19 +21,19 @@
|
|||
<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 style="font-weight: 700">Post Release:</li>
|
||||
<li>Change to new kernel lib format</li>
|
||||
<li>2010 support<ul>
|
||||
<li>http://blogs.msdn.com/b/jacdavis/archive/2010/04/05/vs-2010-version-of-debugenginesample-is-now-available.aspx</li>
|
||||
<li>Trivalik worked on some already</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li style="font-weight: 700">Post Release:</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
|
||||
load the plugs etc so we can just rebuild and run and even trace them</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>2010 support<ul>
|
||||
<li>http://blogs.msdn.com/b/jacdavis/archive/2010/04/05/vs-2010-version-of-debugenginesample-is-now-available.aspx</li>
|
||||
<li>Trivalik worked on some already</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Ring attributes and enforcement<ul>
|
||||
<li>Also allow restriction of assembly references</li>
|
||||
<li>Only allow core to be /unsafe, no others</li>
|
||||
|
|
|
|||
Loading…
Reference in a new issue