diff --git a/source/Cosmos.Core/GCImplementation.cs b/source/Cosmos.Core/GCImplementation.cs index 1d462c214b..f9b83849d1 100644 --- a/source/Cosmos.Core/GCImplementation.cs +++ b/source/Cosmos.Core/GCImplementation.cs @@ -84,13 +84,6 @@ public static unsafe void Init() { memPtr = (byte*)largestBlock->Address; memLength = largestBlock->Length; - if ((uint)memPtr < CPU.GetEndOfKernel() + 1024) - { - memPtr = (byte*)CPU.GetEndOfKernel() + 1024; - memPtr += RAT.PageSize - (uint)memPtr % RAT.PageSize; - memLength = largestBlock->Length - ((uint)memPtr - (uint)largestBlock->Address); - memLength += RAT.PageSize - memLength % RAT.PageSize; - } } else { diff --git a/source/Cosmos.Core/Memory/RAT.cs b/source/Cosmos.Core/Memory/RAT.cs index b3cd764284..3413e3e687 100644 --- a/source/Cosmos.Core/Memory/RAT.cs +++ b/source/Cosmos.Core/Memory/RAT.cs @@ -157,6 +157,11 @@ public static void Init(byte* aStartPtr, uint aSize) uint xRatTotalSize = xRatPageCount * PageSize; mRAT = RamStart + RamSize - xRatTotalSize; + if (mRAT > HeapEnd) + { + throw new Exception("mRAT is greater than heap. rattotalsize is "+xRatTotalSize); + } + // Mark empty pages as such in the RAT Table for (byte* p = mRAT; p < mRAT + TotalPageCount - xRatPageCount; p++) { diff --git a/source/Cosmos.Core/Multiboot/Multiboot2.cs b/source/Cosmos.Core/Multiboot/Multiboot2.cs index 421ae5fd45..76b3a2a4e0 100644 --- a/source/Cosmos.Core/Multiboot/Multiboot2.cs +++ b/source/Cosmos.Core/Multiboot/Multiboot2.cs @@ -21,7 +21,9 @@ public unsafe class Multiboot2 public static bool IsVBEAvailable => Framebuffer->Address != 753664; // Some kinda default number. public static Framebuffer* Framebuffer { get; set; } public static MemoryMap* MemoryMap { get; set; } - public static EFI64* EFI64 { get; set; } + public static EFI64* EFI64 { get; set; } + public static AcpiOld* AcpiOld { get; set; } + public static AcpiNew* AcpiNew { get; set; } #endregion @@ -59,6 +61,12 @@ public static void Init() break; case 12: EFI64 = (EFI64*)Tag; + break; + case 14: + AcpiOld = (AcpiOld*)Tag; + break; + case 15: + AcpiNew = (AcpiNew*)Tag; break; default: break; diff --git a/source/Cosmos.Core/Multiboot/Tags/AcpiNew.cs b/source/Cosmos.Core/Multiboot/Tags/AcpiNew.cs new file mode 100644 index 0000000000..3515112c35 --- /dev/null +++ b/source/Cosmos.Core/Multiboot/Tags/AcpiNew.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; + +namespace Cosmos.Core.Multiboot.Tags +{ + /// + /// Tag AcpiOld + /// + [StructLayout(LayoutKind.Explicit, Size = 44)] + public unsafe readonly struct AcpiNew + { + [FieldOffset(0)] + public readonly uint Type; + [FieldOffset(4)] + public readonly uint Size; + [FieldOffset(8)] + public readonly ulong Signature; + [FieldOffset(16)] + public readonly byte Checksum; + [FieldOffset(17)] + public readonly uint OEMID; + [FieldOffset(23)] + public readonly byte Revision; + [FieldOffset(24)] + public readonly uint RsdtAddress; + [FieldOffset(28)] + public readonly uint Length; + [FieldOffset(32)] + public readonly ulong XsdtAddress; + [FieldOffset(40)] + public readonly byte ExtendedChecksum; + } +} diff --git a/source/Cosmos.Core/Multiboot/Tags/AcpiOld.cs b/source/Cosmos.Core/Multiboot/Tags/AcpiOld.cs new file mode 100644 index 0000000000..a03a547c31 --- /dev/null +++ b/source/Cosmos.Core/Multiboot/Tags/AcpiOld.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; + +namespace Cosmos.Core.Multiboot.Tags +{ + /// + /// Tag AcpiOld + /// + [StructLayout(LayoutKind.Explicit, Size = 28)] + public unsafe readonly struct AcpiOld + { + [FieldOffset(0)] + public readonly uint Type; + [FieldOffset(4)] + public readonly uint Size; + [FieldOffset(8)] + public readonly ulong Signature; + [FieldOffset(16)] + public readonly byte Checksum; + [FieldOffset(17)] + public readonly uint OEMID; + [FieldOffset(23)] + public readonly byte Revision; + [FieldOffset(24)] + public readonly uint RsdtAddress; + } +}