This commit is contained in:
kudzu_cp 2008-09-21 18:24:24 +00:00
parent e05e67330d
commit 7ee5c63742
9 changed files with 45 additions and 90 deletions

View file

@ -20,7 +20,7 @@ namespace Cosmos.Playground.Kudzu {
//PCITest.Test();
//Tests.DoAll();
//RTL8139.Test();
//Debugger.Main();
Debugger.Main();
Console.WriteLine("Done - Waiting");
Console.ReadLine();

View file

@ -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

View file

@ -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; }
}
}

View file

@ -123,9 +123,6 @@
<CheckBox IsChecked="True" Name="chbxShowOptions">Always show this window</CheckBox>
<TextBlock TextWrapping="Wrap" Margin="35,0">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.</TextBlock>
<CheckBox Margin="0,10,0,0" Name="chbxShowConsoleWindow" IsChecked="False">Show console window during build</CheckBox>
<TextBlock TextWrapping="Wrap" Margin="35,0">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.</TextBlock>
<CheckBox Margin="0,10,0,0" Name="chbxCompileIL" IsChecked="True">Compile IL.</CheckBox>
<TextBlock TextWrapping="Wrap" Margin="35,0">Warning: This is an advanced option and normally should remain checked.</TextBlock>
</StackPanel>

View file

@ -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

View file

@ -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");
}
}

View file

@ -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);
}

View file

@ -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<StackContent> StackContents = new Stack<StackContent>();
public bool DebugMode {
get;
set;
}
private static ReaderWriterLocker mCurrentInstanceLocker = new ReaderWriterLocker();
private static SortedList<int, Stack<Assembler>> mCurrentInstance = new SortedList<int, Stack<Assembler>>();
@ -110,13 +103,9 @@ namespace Indy.IL2CPU.Assembler {
return aPrefix + mDataMemberCounter.ToString("X8").ToUpper();
}
public Assembler(Func<string, string> aGetStreamForGroup)
: this(aGetStreamForGroup,
false) {
}
public Assembler(Func<string, string> aGetStreamForGroup) : this(aGetStreamForGroup, false) { }
public Assembler(Func<string, string> aGetFileNameForGroup,
bool aInMetalMode) {
public Assembler(Func<string, string> aGetFileNameForGroup, bool aInMetalMode) {
mGetFileNameForGroup = aGetFileNameForGroup;
mInMetalMode = aInMetalMode;
CurrentInstance.Push(this);
@ -141,15 +130,11 @@ namespace Indy.IL2CPU.Assembler {
}
public List<KeyValuePair<string, DataMember>> DataMembers {
get {
return mDataMembers;
}
get { return mDataMembers; }
}
public List<KeyValuePair<string, string>> 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<string, Instruction>(CurrentGroup,
xInstruction));
mInstructions.Add(new KeyValuePair<string, Instruction>(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<KeyValuePair<string, Instruction>> aInstructions) {
EmitCodeSectionHeader(aGroup,
aOutputWriter);
protected void EmitCodeSection(string aGroup, TextWriter aOutputWriter
, List<KeyValuePair<string, Instruction>> 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; }
}
}

View file

@ -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;