From 7ee5c637420437c0735fbb2efd7a0f9e4d667a2d Mon Sep 17 00:00:00 2001
From: kudzu_cp <6d05c8c8ef5431987001abfdb2eadc9593ac9498>
Date: Sun, 21 Sep 2008 18:24:24 +0000
Subject: [PATCH]
---
.../Playgrounds/Kudzu/KudzuTest/Program.cs | 2 +-
source/Cosmos.Build.Windows/BuildUI.cs | 13 ++--
source/Cosmos.Build.Windows/Options.cs | 5 +-
source/Cosmos.Build.Windows/OptionsUC.xaml | 3 -
source/Cosmos.Build.Windows/OptionsUC.xaml.cs | 2 -
.../Assemblers/Debugger.cs | 16 ++--
source/Indy.IL2CPU.Assembler.X86/Assembler.cs | 14 ++--
source/Indy.IL2CPU.Assembler/Assembler.cs | 76 +++++--------------
source/Indy.IL2CPU/Engine.cs | 4 +-
9 files changed, 45 insertions(+), 90 deletions(-)
diff --git a/source/Boot/Playgrounds/Kudzu/KudzuTest/Program.cs b/source/Boot/Playgrounds/Kudzu/KudzuTest/Program.cs
index 5c6a01c86..cced55287 100644
--- a/source/Boot/Playgrounds/Kudzu/KudzuTest/Program.cs
+++ b/source/Boot/Playgrounds/Kudzu/KudzuTest/Program.cs
@@ -20,7 +20,7 @@ namespace Cosmos.Playground.Kudzu {
//PCITest.Test();
//Tests.DoAll();
//RTL8139.Test();
- //Debugger.Main();
+ Debugger.Main();
Console.WriteLine("Done - Waiting");
Console.ReadLine();
diff --git a/source/Cosmos.Build.Windows/BuildUI.cs b/source/Cosmos.Build.Windows/BuildUI.cs
index 9d9540e93..a25d8c4ad 100644
--- a/source/Cosmos.Build.Windows/BuildUI.cs
+++ b/source/Cosmos.Build.Windows/BuildUI.cs
@@ -24,9 +24,6 @@ namespace Cosmos.Build.Windows {
protected void OptionsProceed() {
// Call IL2CPU
if (mOptionsUC.chbxCompileIL.IsChecked.Value) {
- if (mOptionsUC.chbxShowConsoleWindow.IsChecked.Value) {
- ShowWindow(mConsoleWindow, 1);
- }
var xBuildUC = new BuildUC();
mMainWindow.LoadControl(xBuildUC);
xBuildUC.CompileCompleted += new Action(BuildUC_CompileCompleted);
@@ -35,8 +32,14 @@ namespace Cosmos.Build.Windows {
}
protected void BuildUC_CompileCompleted() {
- mBuilder.Assemble();
- mBuilder.Link();
+ if (mOptionsUC.chbxCompileIL.IsChecked.Value) {
+ // We always show the window now since when its shown its
+ // for a short time and not in "paralell" as it was before.
+ ShowWindow(mConsoleWindow, 1);
+ mBuilder.Assemble();
+ mBuilder.Link();
+ ShowWindow(mConsoleWindow, 0);
+ }
// Debug Window is only displayed if Qemu + Debug checked
// or if other VM + Debugport selected
diff --git a/source/Cosmos.Build.Windows/Options.cs b/source/Cosmos.Build.Windows/Options.cs
index 5b1b8b3c8..acc114b35 100644
--- a/source/Cosmos.Build.Windows/Options.cs
+++ b/source/Cosmos.Build.Windows/Options.cs
@@ -39,14 +39,13 @@ namespace Cosmos.Build.Windows {
VMWareEdition = (string)xKey.GetValue("VMWare Edition");
USBDevice = (string)xKey.GetValue("USB Device");
ShowOptions = Boolean.Parse((string)xKey.GetValue("Show Options", "true"));
- ShowConsoleWindow = Boolean.Parse((string)xKey.GetValue("Show Console", "false"));
CompileIL = Boolean.Parse((string)xKey.GetValue("CompileIL", "true"));
}
}
public void Save() {
using (var xKey = Registry.CurrentUser.CreateSubKey(Options.RegKey)) {
- xKey.SetValue("Debug Trace Assemblies", TraceAssemblies.ToString());
+ xKey.SetValue("Debug Trace Assemblies", TraceAssemblies);
xKey.SetValue("Target", Target);
xKey.SetValue("Debug Port", DebugPort);
xKey.SetValue("Debug Mode", DebugMode);
@@ -58,7 +57,6 @@ namespace Cosmos.Build.Windows {
xKey.SetValue("VMWare Edition", VMWareEdition ?? "");
xKey.SetValue("USB Device", USBDevice??"");
xKey.SetValue("Show Options", ShowOptions.ToString());
- xKey.SetValue("Show Console", ShowConsoleWindow.ToString());
xKey.SetValue("CompileIL", CompileIL.ToString());
xKey.Flush();
}
@@ -76,7 +74,6 @@ namespace Cosmos.Build.Windows {
public string VMWareEdition { get; set; }
public string USBDevice { get; set; }
public bool ShowOptions { get; set; }
- public bool ShowConsoleWindow { get; set; }
public bool CompileIL { get; set; }
}
}
diff --git a/source/Cosmos.Build.Windows/OptionsUC.xaml b/source/Cosmos.Build.Windows/OptionsUC.xaml
index f4d3e7022..5983449fa 100644
--- a/source/Cosmos.Build.Windows/OptionsUC.xaml
+++ b/source/Cosmos.Build.Windows/OptionsUC.xaml
@@ -123,9 +123,6 @@
Always show this window
If unchecked, this screen will not be shown on each build and the last options will be used. To redisplay this window, hold down the Control key.
- Show console window during build
- If the build window hangs, this option can be used to view the output from the assembler and other tools called by the build process.
-
Compile IL.
Warning: This is an advanced option and normally should remain checked.
diff --git a/source/Cosmos.Build.Windows/OptionsUC.xaml.cs b/source/Cosmos.Build.Windows/OptionsUC.xaml.cs
index 0e3e776f4..56017f69c 100644
--- a/source/Cosmos.Build.Windows/OptionsUC.xaml.cs
+++ b/source/Cosmos.Build.Windows/OptionsUC.xaml.cs
@@ -190,7 +190,6 @@ namespace Cosmos.Build.Windows {
mOptions.USBDevice = cmboUSBDevice.Text;
}
mOptions.ShowOptions = chbxShowOptions.IsChecked.Value;
- mOptions.ShowConsoleWindow = chbxShowConsoleWindow.IsChecked.Value;
mOptions.CompileIL = chbxCompileIL.IsChecked.Value;
mOptions.Save();
}
@@ -224,7 +223,6 @@ namespace Cosmos.Build.Windows {
// Misc
chbxShowOptions.IsChecked = mOptions.ShowOptions;
- chbxShowConsoleWindow.IsChecked = mOptions.ShowConsoleWindow;
chbxCompileIL.IsChecked = mOptions.CompileIL;
// Debug
diff --git a/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/Debugger.cs b/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/Debugger.cs
index afc26744e..6e792eb61 100644
--- a/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/Debugger.cs
+++ b/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/Debugger.cs
@@ -7,33 +7,33 @@ using X86 = Indy.IL2CPU.Assembler.X86;
namespace Cosmos.Kernel.Plugs.Assemblers {
public class DebugAsm : X86.X.Y86 {
public void Break() {
- //new Indy.IL2CPU.Assembler.Literal("%ifdef DEBUGSTUB");
+ new Indy.IL2CPU.Assembler.Literal("%ifdef DEBUGSTUB");
Memory["DebugBreakOnNextTrace", 32] = 1;
- //new Indy.IL2CPU.Assembler.Literal("%endif");
+ new Indy.IL2CPU.Assembler.Literal("%endif");
}
public void SendText() {
- //new Indy.IL2CPU.Assembler.Literal("%ifdef DEBUGSTUB");
+ new Indy.IL2CPU.Assembler.Literal("%ifdef DEBUGSTUB");
PushAll32();
Call("DebugStub_SendText");
PopAll32();
- //new Indy.IL2CPU.Assembler.Literal("%endif");
+ new Indy.IL2CPU.Assembler.Literal("%endif");
}
public void TraceOff() {
- //new Indy.IL2CPU.Assembler.Literal("%ifdef DEBUGSTUB");
+ new Indy.IL2CPU.Assembler.Literal("%ifdef DEBUGSTUB");
PushAll32();
Call("DebugStub_TraceOff");
PopAll32();
- //new Indy.IL2CPU.Assembler.Literal("%endif");
+ new Indy.IL2CPU.Assembler.Literal("%endif");
}
public void TraceOn() {
- //new Indy.IL2CPU.Assembler.Literal("%ifdef DEBUGSTUB");
+ new Indy.IL2CPU.Assembler.Literal("%ifdef DEBUGSTUB");
PushAll32();
Call("DebugStub_TraceOn");
PopAll32();
- //new Indy.IL2CPU.Assembler.Literal("%endif");
+ new Indy.IL2CPU.Assembler.Literal("%endif");
}
}
diff --git a/source/Indy.IL2CPU.Assembler.X86/Assembler.cs b/source/Indy.IL2CPU.Assembler.X86/Assembler.cs
index a502d38cd..7b4454202 100644
--- a/source/Indy.IL2CPU.Assembler.X86/Assembler.cs
+++ b/source/Indy.IL2CPU.Assembler.X86/Assembler.cs
@@ -6,7 +6,7 @@ using System.Text;
namespace Indy.IL2CPU.Assembler.X86 {
public class Assembler : Indy.IL2CPU.Assembler.Assembler {
-
+ //TODO: COM Port info - should be in assembler? Assembler should not know about comports...
protected byte mComNumber = 0;
protected UInt16[] mComPortAddresses = { 0x3F8, 0x2F8, 0x3E8, 0x2E8 };
@@ -51,7 +51,6 @@ namespace Indy.IL2CPU.Assembler.X86 {
if (mComNumber > 0) {
UInt16 xComAddr = mComPortAddresses[mComNumber - 1];
// 9600 baud, 8 databits, no parity, 1 stopbit
- aOutputWriter.WriteLine("%define DEBUGSTUB 1");
aOutputWriter.WriteLine("mov dx, 0x{0}", (xComAddr + 1).ToString("X"));
aOutputWriter.WriteLine("mov al, 0x00");
aOutputWriter.WriteLine("out DX, AL"); // disable all interrupts
@@ -125,13 +124,7 @@ namespace Indy.IL2CPU.Assembler.X86 {
aOutputWriter.WriteLine("dd -0x1BADB002-MBFLAGS ; checksum=-(FLAGS+0x1BADB002) ");
aOutputWriter.WriteLine("; other data - that is the additional (optional) header which helps to load ");
aOutputWriter.WriteLine("; the kernel. ");
- //aOutputWriter.WriteLine(" dd _start ; header_addr ");
- //aOutputWriter.WriteLine(" dd _start ; load_addr ");
- //aOutputWriter.WriteLine(" dd _end_data ; load_end_addr ");
- //aOutputWriter.WriteLine(" dd _end ; bss_end_addr ");
- //aOutputWriter.WriteLine(" dd Kernel_Start ; entry ");
aOutputWriter.WriteLine("; end of header ");
- //aOutputWriter.WriteLine("mb_info multiboot_info");
aOutputWriter.WriteLine("MultiBootInfo_Memory_High dd 0");
aOutputWriter.WriteLine("MultiBootInfo_Memory_Low dd 0");
if (Signature != null && Signature.Length > 0) {
@@ -156,13 +149,16 @@ namespace Indy.IL2CPU.Assembler.X86 {
aOutputWriter.WriteLine("_end: ; end of BSS - here's the virtual and logical end.");
}
}
-
+
protected override void EmitHeader(string aGroup, TextWriter aOutputWriter) {
aOutputWriter.WriteLine("use32 ; the kernel will be run in 32-bit protected mode, ");
aOutputWriter.WriteLine("");
aOutputWriter.WriteLine("%ifdef {0}", GetValidGroupName(aGroup));
aOutputWriter.WriteLine("%else");
aOutputWriter.WriteLine(" %define {0} 1", GetValidGroupName(aGroup));
+ if (mComNumber > 0) {
+ aOutputWriter.WriteLine("%define DEBUGSTUB 1");
+ }
aOutputWriter.WriteLine("");
EmitIncludes(aGroup, aOutputWriter);
}
diff --git a/source/Indy.IL2CPU.Assembler/Assembler.cs b/source/Indy.IL2CPU.Assembler/Assembler.cs
index d332eaf49..2edc6ea37 100644
--- a/source/Indy.IL2CPU.Assembler/Assembler.cs
+++ b/source/Indy.IL2CPU.Assembler/Assembler.cs
@@ -14,11 +14,12 @@ namespace Indy.IL2CPU.Assembler {
public static Exception CurrentException;
public static void PrintException() {
+ // The RSOD - Red Screen of Death
Console.BackgroundColor = ConsoleColor.DarkRed;
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Clear();
- Console.WriteLine("Cosmos Kernel. Copyright 2008 The Cosmos Project.");
+ Console.WriteLine("Cosmos Kernel. Copyright 2007-2008, The Cosmos Project.");
Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
Console.WriteLine("");
Console.WriteLine("An unhandled kernel exception occurred.");
@@ -58,10 +59,7 @@ namespace Indy.IL2CPU.Assembler {
}
}
- public byte[] Signature {
- get;
- set;
- }
+ public byte[] Signature { get; set; }
public static void ExceptionOccurred() {
System.Diagnostics.Debugger.Break();
@@ -74,11 +72,6 @@ namespace Indy.IL2CPU.Assembler {
private readonly bool mInMetalMode = false;
public readonly Stack StackContents = new Stack();
- public bool DebugMode {
- get;
- set;
- }
-
private static ReaderWriterLocker mCurrentInstanceLocker = new ReaderWriterLocker();
private static SortedList> mCurrentInstance = new SortedList>();
@@ -110,13 +103,9 @@ namespace Indy.IL2CPU.Assembler {
return aPrefix + mDataMemberCounter.ToString("X8").ToUpper();
}
- public Assembler(Func aGetStreamForGroup)
- : this(aGetStreamForGroup,
- false) {
- }
+ public Assembler(Func aGetStreamForGroup) : this(aGetStreamForGroup, false) { }
- public Assembler(Func aGetFileNameForGroup,
- bool aInMetalMode) {
+ public Assembler(Func aGetFileNameForGroup, bool aInMetalMode) {
mGetFileNameForGroup = aGetFileNameForGroup;
mInMetalMode = aInMetalMode;
CurrentInstance.Push(this);
@@ -141,15 +130,11 @@ namespace Indy.IL2CPU.Assembler {
}
public List> DataMembers {
- get {
- return mDataMembers;
- }
+ get { return mDataMembers; }
}
public List> Includes {
- get {
- return mIncludes;
- }
+ get { return mIncludes; }
}
public void Dispose() {
@@ -162,8 +147,7 @@ namespace Indy.IL2CPU.Assembler {
public void Add(params Instruction[] aReaders) {
foreach (Instruction xInstruction in aReaders) {
- mInstructions.Add(new KeyValuePair(CurrentGroup,
- xInstruction));
+ mInstructions.Add(new KeyValuePair(CurrentGroup, xInstruction));
}
}
@@ -221,12 +205,10 @@ namespace Indy.IL2CPU.Assembler {
}
}
}
- EmitHeader(xGroup,
- xOutputWriter);
+ EmitHeader(xGroup, xOutputWriter);
xOutputWriter.WriteLine();
if (mDataMembers.Count > 0) {
- EmitDataSectionHeader(xGroup,
- xOutputWriter);
+ EmitDataSectionHeader(xGroup, xOutputWriter);
xOutputWriter.WriteLine();
foreach (DataMember xMember in (from item in mDataMembers
where String.Equals(item.Key,
@@ -244,24 +226,21 @@ namespace Indy.IL2CPU.Assembler {
xOutputWriter,
mMergedInstructions);
}
- EmitFooter(xGroup,
- xOutputWriter);
+ EmitFooter(xGroup, xOutputWriter);
}
}
}
- protected void EmitCodeSection(string aGroup,
- TextWriter aOutputWriter,
- List> aInstructions) {
- EmitCodeSectionHeader(aGroup,
- aOutputWriter);
+ protected void EmitCodeSection(string aGroup, TextWriter aOutputWriter
+ , List> aInstructions) {
+ EmitCodeSectionHeader(aGroup, aOutputWriter);
aOutputWriter.WriteLine();
string xMainLabel = "";
foreach (Instruction x in (from item in aInstructions
where String.Equals(item.Key,
aGroup,
StringComparison.InvariantCultureIgnoreCase)
- select item.Value)) {
+ select item.Value)) {
string prefix = "\t\t\t";
Label xLabel = x as Label;
if (xLabel != null) {
@@ -278,14 +257,12 @@ namespace Indy.IL2CPU.Assembler {
} else {
prefix = "\t";
}
- aOutputWriter.WriteLine(prefix + xFullName.Replace(".",
- "__DOT__") + ":");
+ aOutputWriter.WriteLine(prefix + xFullName.Replace(".", "__DOT__") + ":");
continue;
}
aOutputWriter.WriteLine(prefix + x);
}
- EmitCodeSectionFooter(aGroup,
- aOutputWriter);
+ EmitCodeSectionFooter(aGroup, aOutputWriter);
aOutputWriter.WriteLine();
}
@@ -301,21 +278,10 @@ namespace Indy.IL2CPU.Assembler {
TextWriter aOutputWriter) {
}
- protected virtual void EmitDataSectionHeader(string aGroup,
- TextWriter aOutputWriter) {
- }
+ protected virtual void EmitDataSectionHeader(string aGroup, TextWriter aOutputWriter) { }
- protected virtual void EmitDataSectionFooter(string aGroup,
- TextWriter aOutputWriter) {
- }
-
- public string MainGroup {
- get;
- set;
- }
-
- protected virtual void EmitFooter(string aGroup,
- TextWriter aOutputWriter) {
- }
+ protected virtual void EmitDataSectionFooter(string aGroup, TextWriter aOutputWriter) { }
+ protected virtual void EmitFooter(string aGroup, TextWriter aOutputWriter) { }
+ public string MainGroup { get; set; }
}
}
\ No newline at end of file
diff --git a/source/Indy.IL2CPU/Engine.cs b/source/Indy.IL2CPU/Engine.cs
index 229df90d9..b170e3a17 100644
--- a/source/Indy.IL2CPU/Engine.cs
+++ b/source/Indy.IL2CPU/Engine.cs
@@ -208,9 +208,7 @@ namespace Indy.IL2CPU {
// }
// }
//}
- mMap.Initialize(mAssembler,
- xAppDefs);
- mAssembler.DebugMode = false;
+ mMap.Initialize(mAssembler, xAppDefs);
//!String.IsNullOrEmpty(aDebugSymbols);
IL.Op.QueueMethod += QueueMethod;
IL.Op.QueueStaticField += QueueStaticField;