-
Notifications
You must be signed in to change notification settings - Fork 552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Multiboot2 modules and Module file system #3099
Open
ADev531
wants to merge
4
commits into
CosmosOS:master
Choose a base branch
from
ADev531:impl/mb2module
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,117 +1,123 @@ | ||
/* | ||
* PROJECT: Cosmos Development | ||
* CONTENT: Multiboot2 class | ||
* PROGRAMMERS: Valentin Charbonnier <[email protected]> | ||
* RESOURCES: https://www.gnu.org/software/grub/manual/multiboot2/multiboot.html | ||
*/ | ||
|
||
using Cosmos.Core.Multiboot.Tags; | ||
using IL2CPU.API.Attribs; | ||
|
||
namespace Cosmos.Core.Multiboot | ||
{ | ||
/// <summary> | ||
/// Multiboot2 class. Used for multiboot parsing. | ||
/// </summary> | ||
public unsafe class Multiboot2 | ||
{ | ||
#region Properties | ||
|
||
public static BasicMemoryInformation* BasicMemoryInformation { get; set; } | ||
public static bool IsVBEAvailable => Framebuffer->Address != 753664; // Some kinda default number. | ||
public static Framebuffer* Framebuffer { get; set; } | ||
public static MemoryMap* MemoryMap { get; set; } | ||
/* | ||
* PROJECT: Cosmos Development | ||
* CONTENT: Multiboot2 class | ||
* PROGRAMMERS: Valentin Charbonnier <[email protected]> | ||
* RESOURCES: https://www.gnu.org/software/grub/manual/multiboot2/multiboot.html | ||
*/ | ||
|
||
using System.Collections.Generic; | ||
using Cosmos.Core.Multiboot.Tags; | ||
using IL2CPU.API.Attribs; | ||
|
||
namespace Cosmos.Core.Multiboot | ||
{ | ||
/// <summary> | ||
/// Multiboot2 class. Used for multiboot parsing. | ||
/// </summary> | ||
public unsafe class Multiboot2 | ||
{ | ||
#region Properties | ||
|
||
public static BasicMemoryInformation* BasicMemoryInformation { get; set; } | ||
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 AcpiOld* AcpiOld { get; set; } | ||
public static AcpiNew* AcpiNew { get; set; } | ||
|
||
#endregion | ||
|
||
#region Methods | ||
|
||
/// /// <summary> | ||
/// Parse multiboot2 structure | ||
/// </summary> | ||
public static void Init() | ||
{ | ||
if (!isInitialized) | ||
{ | ||
isInitialized = true; | ||
|
||
uint MbAddress = GetMBIAddress(); | ||
|
||
MB2Tag* Tag; | ||
|
||
for (Tag = (MB2Tag*)(MbAddress + 8); Tag->Type != 0; Tag = (MB2Tag*)((byte*)Tag + (Tag->Size + 7 & ~7))) | ||
{ | ||
switch (Tag->Type) | ||
{ | ||
case 4: | ||
BasicMemoryInformation = (BasicMemoryInformation*)Tag; | ||
break; | ||
case 6: | ||
MemoryMap = (MemoryMap*)Tag; | ||
break; | ||
case 7: | ||
// Ignore because we use Framebuffer tags now :) | ||
//VBEInfo = (VBEInfo*)Tag; | ||
break; | ||
case 8: | ||
Framebuffer = (Framebuffer*)Tag; | ||
break; | ||
case 12: | ||
EFI64 = (EFI64*)Tag; | ||
public static AcpiNew* AcpiNew { get; set; } | ||
public static PointerList<MB2Module> Modules { get; set; } | ||
|
||
#endregion | ||
|
||
#region Methods | ||
|
||
/// <summary> | ||
/// Parse multiboot2 structure | ||
/// </summary> | ||
public static void Init() | ||
{ | ||
if (!isInitialized) | ||
{ | ||
isInitialized = true; | ||
|
||
Modules = new PointerList<MB2Module>(); | ||
|
||
uint MbAddress = GetMBIAddress(); | ||
MB2Tag* Tag; | ||
|
||
for (Tag = (MB2Tag*)(MbAddress + 8); Tag->Type != 0; Tag = (MB2Tag*)((byte*)Tag + (Tag->Size + 7 & ~7))) | ||
{ | ||
switch (Tag->Type) | ||
{ | ||
case 3: | ||
Modules.Add((MB2Module*)Tag); | ||
break; | ||
case 4: | ||
BasicMemoryInformation = (BasicMemoryInformation*)Tag; | ||
break; | ||
case 6: | ||
MemoryMap = (MemoryMap*)Tag; | ||
break; | ||
case 7: | ||
// Ignore because we use Framebuffer tags now :) | ||
//VBEInfo = (VBEInfo*)Tag; | ||
break; | ||
case 8: | ||
Framebuffer = (Framebuffer*)Tag; | ||
break; | ||
case 12: | ||
EFI64 = (EFI64*)Tag; | ||
break; | ||
case 14: | ||
AcpiOld = (AcpiOld*)Tag; | ||
break; | ||
case 15: | ||
AcpiNew = (AcpiNew*)Tag; | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Get MemLower | ||
/// </summary> | ||
/// <returns>MemLower</returns> | ||
public static uint GetMemLower() | ||
{ | ||
return BasicMemoryInformation->MemLower; | ||
} | ||
|
||
/// <summary> | ||
/// Get MemUpper | ||
/// </summary> | ||
/// <returns>MemUpper</returns> | ||
public static uint GetMemUpper() | ||
{ | ||
return BasicMemoryInformation->MemUpper; | ||
} | ||
|
||
/// <summary> | ||
/// Checks if Multiboot returned a memory map | ||
/// </summary> | ||
/// <returns>True if is available, false if not</returns> | ||
public static bool MemoryMapExists() => MemoryMap != null; | ||
|
||
/// /// <summary> | ||
/// Get Multiboot address. Plugged. | ||
/// </summary> | ||
/// <returns>The Multiboot Address</returns> | ||
[PlugMethod(PlugRequired = true)] | ||
public static uint GetMBIAddress() => throw null; | ||
|
||
#endregion | ||
|
||
#region Fields | ||
|
||
private static bool isInitialized = false; | ||
|
||
#endregion | ||
} | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
/// <summary> | ||
/// Get MemLower | ||
/// </summary> | ||
/// <returns>MemLower</returns> | ||
public static uint GetMemLower() | ||
{ | ||
return BasicMemoryInformation->MemLower; | ||
} | ||
/// <summary> | ||
/// Get MemUpper | ||
/// </summary> | ||
/// <returns>MemUpper</returns> | ||
public static uint GetMemUpper() | ||
{ | ||
return BasicMemoryInformation->MemUpper; | ||
} | ||
/// <summary> | ||
/// Checks if Multiboot returned a memory map | ||
/// </summary> | ||
/// <returns>True if is available, false if not</returns> | ||
public static bool MemoryMapExists() => MemoryMap != null; | ||
/// /// <summary> | ||
/// Get Multiboot address. Plugged. | ||
/// </summary> | ||
/// <returns>The Multiboot Address</returns> | ||
[PlugMethod(PlugRequired = true)] | ||
public static uint GetMBIAddress() => throw null; | ||
#endregion | ||
#region Fields | ||
private static bool isInitialized = false; | ||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
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 | ||
{ | ||
/// <summary> | ||
/// Multiboot2 Module tag | ||
/// </summary> | ||
[StructLayout(LayoutKind.Explicit, Size = 44)] | ||
public unsafe readonly struct MB2Module | ||
{ | ||
/// <summary> | ||
/// Information about the tag. | ||
/// </summary> | ||
[FieldOffset(0)] | ||
public readonly MB2Tag Info; | ||
|
||
/// <summary> | ||
/// Starting address of the module. | ||
/// </summary> | ||
[FieldOffset(8)] | ||
public readonly uint ModuleStartAddress; | ||
|
||
/// <summary> | ||
/// Ending address of the module. | ||
/// </summary> | ||
[FieldOffset(16)] | ||
public readonly uint ModuleEndAddress; | ||
|
||
/// <summary> | ||
/// Zero-end string of the command line. | ||
/// </summary> | ||
[FieldOffset(24)] | ||
public readonly char* CommandLine; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please undo the formatting changes to make reviewing easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry... but, how I can do that?