diff --git a/source/Cosmos.Core/CPU.cs b/source/Cosmos.Core/CPU.cs index 14af04678..b8b3389a2 100644 --- a/source/Cosmos.Core/CPU.cs +++ b/source/Cosmos.Core/CPU.cs @@ -2,20 +2,25 @@ using System.Collections.Generic; using System.Linq; using System.Text; - +using Cosmos.IL2CPU.Plugs; namespace Cosmos.Core { // Non hardware class, only used by core and hardware drivers for ports etc. public class CPU { // Amount of RAM in MB's. // needs to be static, as Heap needs it before we can instantiate objects + [PlugMethod(PlugRequired = true)] public static uint GetAmountOfRAM() { return 0; } // Plugged // needs to be static, as Heap needs it before we can instantiate objects + [PlugMethod(PlugRequired = true)] public static uint GetEndOfKernel() { return 0; } // Plugged + [PlugMethod(PlugRequired = true)] public void UpdateIDT(bool aEnableInterruptsImmediately) { } // Plugged + [PlugMethod(PlugRequired = true)] public void InitFloat() { } // Plugged + [PlugMethod(PlugRequired = true)] public static void ZeroFill(uint aStartAddress, uint aLength) { } // Plugged + [PlugMethod(PlugRequired = true)] public void Halt() { } // Plugged - public void Reboot() { // Disable all interrupts DisableInterrupts(); diff --git a/source/Cosmos.Core/IOPort.cs b/source/Cosmos.Core/IOPort.cs index fcd67fea9..d20672026 100644 --- a/source/Cosmos.Core/IOPort.cs +++ b/source/Cosmos.Core/IOPort.cs @@ -1,5 +1,5 @@ using System; - +using Cosmos.IL2CPU.Plugs; namespace Cosmos.Core { public abstract class IOPortBase @@ -29,12 +29,17 @@ namespace Cosmos.Core } //TODO: Reads and writes can use this to get port instead of argument + [PlugMethod(PlugRequired = true)] static protected void Write8(UInt16 aPort, byte aData) { } // Plugged + [PlugMethod(PlugRequired = true)] static protected void Write16(UInt16 aPort, UInt16 aData) { } // Plugged + [PlugMethod(PlugRequired = true)] static protected void Write32(UInt16 aPort, UInt32 aData) { } // Plugged - + [PlugMethod(PlugRequired = true)] static protected byte Read8(UInt16 aPort) { return 0; } // Plugged + [PlugMethod(PlugRequired = true)] static protected UInt16 Read16(UInt16 aPort) { return 0; } // Plugged + [PlugMethod(PlugRequired = true)] static protected UInt32 Read32(UInt16 aPort) { return 0; } // Plugged //TODO: Plug these Reads with asm to read directly to RAM diff --git a/source/Cosmos.IL2CPU.Plugs/PlugMethodAttribute.cs b/source/Cosmos.IL2CPU.Plugs/PlugMethodAttribute.cs index 4d68dcddf..a617e2484 100644 --- a/source/Cosmos.IL2CPU.Plugs/PlugMethodAttribute.cs +++ b/source/Cosmos.IL2CPU.Plugs/PlugMethodAttribute.cs @@ -9,7 +9,7 @@ namespace Cosmos.IL2CPU.Plugs public Type Assembler = null; public bool IsMonoOnly = false; public bool IsMicrosoftdotNETOnly = false; - + public bool PlugRequired = false; public bool IsWildcard = false; public bool WildcardMatchParameters = false; } diff --git a/source/Cosmos.IL2CPU/Heap.cs b/source/Cosmos.IL2CPU/Heap.cs index 522cc4d72..e9e5bc39a 100644 --- a/source/Cosmos.IL2CPU/Heap.cs +++ b/source/Cosmos.IL2CPU/Heap.cs @@ -2,29 +2,29 @@ using System.Collections.Generic; using System.Linq; using System.Text; - +using Cosmos.IL2CPU.Plugs; namespace Cosmos.IL2CPU { partial class RuntimeEngine { public static uint HeapHandle = 0; public const uint InitialHeapSize = 4096; public const uint MaximumHeapSize = 10 * 1024 * InitialHeapSize; // 10 megabytes - public static void Heap_Initialize() { + public static void Heap_Initialize() { //HeapHandle = PInvokes.Kernel32_HeapCreate(0, InitialHeapSize, MaximumHeapSize); } - - public static uint Heap_AllocNewObject(uint aSize) { + [PlugMethod(PlugRequired = true)] + public static uint Heap_AllocNewObject(uint aSize) { // if (aSize == 0) { // aSize = 1; // } //return PInvokes.Kernel32_HeapAlloc(HeapHandle, 0x00000008, aSize); return 0; } - - public static void Heap_Free(uint aObject) { + [PlugMethod(PlugRequired = true)] + public static void Heap_Free(uint aObject) { // } - - public static void Heap_Shutdown() { + [PlugMethod(PlugRequired = true)] + public static void Heap_Shutdown() { //PInvokes.Kernel32_HeapDestroy(HeapHandle); //HeapHandle = 0; } diff --git a/source/Cosmos.IL2CPU/ILScanner.cs b/source/Cosmos.IL2CPU/ILScanner.cs index 4c9c5066f..f203ffa7b 100644 --- a/source/Cosmos.IL2CPU/ILScanner.cs +++ b/source/Cosmos.IL2CPU/ILScanner.cs @@ -918,6 +918,10 @@ namespace Cosmos.IL2CPU { continue; } + else if(xAttrib.PlugRequired) + { + throw new Exception(string.Format("Method {0} requires a plug, but none is implemented",xMethod.Name)); + } xPlugAssembler = xAttrib.Assembler; }