mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-11 10:41:33 +00:00
This commit is contained in:
parent
ac62705dc7
commit
a4f6cfed20
5 changed files with 24 additions and 34 deletions
|
|
@ -9,8 +9,6 @@ namespace Cosmos.System {
|
|||
public readonly Debug.Kernel.Debugger Dbg = new Debug.Kernel.Debugger("User", "");
|
||||
|
||||
public bool ClearScreen = true;
|
||||
// Set to true to hide messages during boot.
|
||||
public bool Silent = false;
|
||||
|
||||
// Set after initial start. Can be started and stopped at same time
|
||||
protected bool mStarted = false;
|
||||
|
|
@ -20,51 +18,33 @@ namespace Cosmos.System {
|
|||
// Start the system up using the properties for configuration.
|
||||
public void Start() {
|
||||
Global.Dbg.Send("Starting kernel");
|
||||
if (mStarted)
|
||||
{
|
||||
if (mStarted) {
|
||||
Global.Dbg.Send("ERROR: Kernel Already Started");
|
||||
throw new Exception("Kernel has already been started. A kernel cannot be started twice.");
|
||||
}
|
||||
mStarted = true;
|
||||
|
||||
//TODO - Set and document the Console class (and its supporting classes) to default to 80x25
|
||||
//Hardware.VGAScreen.SetTextMode(VGAScreen.TextSize.Size80x25);
|
||||
|
||||
//TODO: System inits hardware, and hardware inits core
|
||||
Global.Init();
|
||||
|
||||
// Clear before booting
|
||||
Global.Dbg.Send("Clearing screen");
|
||||
Global.Console.Clear();
|
||||
WriteLine("Cosmos kernel boot initiated.");
|
||||
|
||||
WriteLine("Cosmos kernel boot completed.");
|
||||
// Provide the user with a clear scree if they requested it
|
||||
if (ClearScreen)
|
||||
{
|
||||
// Provide the user with a clear screen if they requested it
|
||||
if (ClearScreen) {
|
||||
Global.Console.Clear();
|
||||
}
|
||||
|
||||
BeforeRun();
|
||||
while (!mStopped)
|
||||
{
|
||||
while (!mStopped) {
|
||||
Run();
|
||||
}
|
||||
AfterRun();
|
||||
while (true)
|
||||
;
|
||||
while (true) {
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void BeforeRun() { }
|
||||
protected abstract void Run();
|
||||
protected virtual void AfterRun() { }
|
||||
|
||||
protected void WriteLine(string aMsg) {
|
||||
if (!Silent) {
|
||||
Global.Console.WriteLine(aMsg);
|
||||
}
|
||||
}
|
||||
|
||||
// Shut down the system and power off
|
||||
public void Stop() {
|
||||
mStopped = true;
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@ namespace Cosmos.Core {
|
|||
//Init Heap first - Hardware loads devices and they need heap
|
||||
// drag in the heap:
|
||||
Heap.Initialize();
|
||||
//TODO: Since this is FCL, its "common". Otherwise it should be
|
||||
// system level and not accessible from Core. Need to think about this
|
||||
// for the future.
|
||||
Console.WriteLine(" Heap OK");
|
||||
|
||||
// After heap init etc
|
||||
|
|
|
|||
|
|
@ -16,7 +16,9 @@ namespace Cosmos.Hardware {
|
|||
// DANGER! This is before heap? Yet somehow its working currently...
|
||||
// Leaving it for now because Core.Init outputs to Console, but we need
|
||||
// to change this...
|
||||
// Heap seems to self init on demand? But even before IDT/GDT etc?
|
||||
TextScreen = new TextScreen();
|
||||
TextScreen.Clear();
|
||||
|
||||
Global.Dbg.Send("Cosmos.Hardware.Global.Init");
|
||||
Core.PciBus.OnPCIDeviceFound = PCIDeviceFound;
|
||||
|
|
|
|||
|
|
@ -11,14 +11,17 @@ namespace Cosmos.Hardware {
|
|||
protected byte Color = 0x0F; // White
|
||||
|
||||
protected Core.IOGroup.TextScreen IO = Core.Global.BaseIOGroups.TextScreen;
|
||||
protected readonly MemoryBlock08 mMemory08;
|
||||
protected readonly MemoryBlock08 mRAM;
|
||||
|
||||
public TextScreen() {
|
||||
//Use Changeset 64921
|
||||
//This gets called before at least one of the initializers.
|
||||
//1) This is a bug.
|
||||
//2) This should throw a null ref, which it does not currently. Although its not null.. so maybe thats the issue.
|
||||
mMemory08 = IO.Memory.Bytes;
|
||||
mRAM = IO.Memory.Bytes;
|
||||
|
||||
//TODO - Set and document the Console class (and its supporting classes) to default to 80x25
|
||||
//Hardware.VGAScreen.SetTextMode(VGAScreen.TextSize.Size80x25);
|
||||
}
|
||||
|
||||
public int Rows { get { return 25; } }
|
||||
|
|
@ -26,7 +29,9 @@ namespace Cosmos.Hardware {
|
|||
|
||||
public void Clear() {
|
||||
// Empty + White + Empty + White
|
||||
UInt32 xData = 0x000F000F;
|
||||
//UInt32 xData = 0x000F000F;
|
||||
// This is just for testing...revert back to the one above...
|
||||
UInt32 xData = 0x430F430F;
|
||||
IO.Memory.Fill(0, (uint)(Cols * Rows * 2 / 4), xData);
|
||||
}
|
||||
|
||||
|
|
@ -36,13 +41,13 @@ namespace Cosmos.Hardware {
|
|||
|
||||
public char this[int aX, int aY] {
|
||||
get {
|
||||
UInt32 xScreenOffset = (UInt32)((aX + aY * Cols) * 2);
|
||||
return (char)mMemory08[xScreenOffset];
|
||||
var xScreenOffset = (UInt32)((aX + aY * Cols) * 2);
|
||||
return (char)mRAM[xScreenOffset];
|
||||
}
|
||||
set {
|
||||
var xScreenOffset = (UInt32)((aX + aY * Cols) * 2);
|
||||
mMemory08[xScreenOffset] = (byte)value;
|
||||
mMemory08[xScreenOffset + 1] = Color;
|
||||
mRAM[xScreenOffset] = (byte)value;
|
||||
mRAM[xScreenOffset + 1] = Color;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
<Framework>MicrosoftNET</Framework>
|
||||
<UseInternalAssembler>False</UseInternalAssembler>
|
||||
<DebugMode>Source</DebugMode>
|
||||
<EnableGDB>True</EnableGDB>
|
||||
<EnableGDB>False</EnableGDB>
|
||||
<TraceMode>
|
||||
</TraceMode>
|
||||
<VMWareFlavor>Workstation</VMWareFlavor>
|
||||
|
|
|
|||
Loading…
Reference in a new issue