-
Notifications
You must be signed in to change notification settings - Fork 79
/
PlatformPlug.cs
124 lines (89 loc) · 4.96 KB
/
PlatformPlug.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Copyright (c) MOSA Project. Licensed under the New BSD License.
using Mosa.DeviceSystem.Misc;
using Mosa.Runtime;
using Mosa.Runtime.Plug;
namespace Mosa.Kernel.BareMetal.ARM32;
public static class PlatformPlug
{
private const uint BootReservedAddress = 0x00007E00; // Size=Undefined
private const uint InitialGCMemoryPoolAddress = 0x03000000; // @ 48MB
private const uint InitialGCMemoryPoolSize = 16 * 1024 * 1024; // [Size=16MB]
public static void ForceInclude()
{ }
[Plug("Mosa.Kernel.BareMetal.Platform::Initialization")]
public static void Initialization()
{
SystemBoard.Setup();
MMIO.Setup();
}
[Plug("Mosa.Kernel.BareMetal.Platform::GetBootReservedRegion")]
public static AddressRange GetBootReservedRegion() => new AddressRange(BootReservedAddress, Page.Size);
[Plug("Mosa.Kernel.BareMetal.Platform::GetInitialGCMemoryPool")]
public static AddressRange GetInitialGCMemoryPool() => new AddressRange(InitialGCMemoryPoolAddress, InitialGCMemoryPoolSize);
public static PlatformArchitecture GetPlatformArchitecture() => PlatformArchitecture.ARM32;
//[Plug("Mosa.Kernel.BareMetal.Platform::ConsoleWrite")]
//public static void ConsoleWrite(byte c) => ARM32.VGAConsole.Write(c);
//[Plug("Mosa.Kernel.BareMetal.Platform::DebugWrite")]
//public static void DebugWrite(byte c) => ARM32.SerialDebug.Write(c);
public static class PageTablePlug
{
//[Plug("Mosa.Kernel.BareMetal.Platform+PageTable::Setup")]
//public static void Setup() => ARM32.PageTable.Setup();
//[Plug("Mosa.Kernel.BareMetal.Platform+PageTable::GetPageShift")]
//public static uint GetPageShift() => 12;
//[Plug("Mosa.Kernel.BareMetal.Platform+PageTable::Initialize")]
//public static void Initialize() => ARM32.PageTable.Initialize();
//[Plug("Mosa.Kernel.BareMetal.Platform+PageTable::Enable")]
//public static void Enable() => ARM32.PageTable.Enable();
//[Plug("Mosa.Kernel.BareMetal.Platform+PageTable::MapVirtualAddressToPhysical")]
//public static void MapVirtualAddressToPhysical(Pointer virtualAddress, Pointer physicalAddress, bool present = true) => ARM32.PageTable.MapVirtualAddressToPhysical(virtualAddress, physicalAddress, present);
//[Plug("Mosa.Kernel.BareMetal.Platform+PageTable::GetPhysicalAddressFromVirtual")]
//public static Pointer GetPhysicalAddressFromVirtual(Pointer virtualAddress) => ARM32.PageTable.GetPhysicalAddressFromVirtual(virtualAddress);
}
public static class InterruptPlug
{
//[Plug("Mosa.Kernel.BareMetal.Platform+Interrupt::Setup")]
//public static void Setup() => IDT.Setup();
//[Plug("Mosa.Kernel.BareMetal.Platform+Interrupt::SetHandler")]
//public static void SetHandler(InterruptHandler handler) => IDT.SetInterruptHandler(handler);
//[Plug("Mosa.Kernel.BareMetal.Platform+Interrupt::Enable")]
//public static void Enable() => Native.Sti();
//[Plug("Mosa.Kernel.BareMetal.Platform+Interrupt::Disable")]
//public static void Disable() => Native.Cli();
}
public static class IOPlugPlug
{
[Plug("Mosa.Kernel.BareMetal.Platform+IO::In8")]
public static byte In8(ushort address) => new Pointer(address).Load8();
[Plug("Mosa.Kernel.BareMetal.Platform+IO::In16")]
public static ushort In16(ushort address) => new Pointer(address).Load16();
[Plug("Mosa.Kernel.BareMetal.Platform+IO::In32")]
public static uint In32(ushort address) => new Pointer(address).Load32();
[Plug("Mosa.Kernel.BareMetal.Platform+IO::Out8")]
public static void Out8(ushort address, byte data) => new Pointer(address).Store8(data);
[Plug("Mosa.Kernel.BareMetal.Platform+IO::Out16")]
public static void Out16(ushort address, ushort data) => new Pointer(address).Store16(data);
[Plug("Mosa.Kernel.BareMetal.Platform+IO::Out32")]
public static void Out32(ushort address, uint data) => new Pointer(address).Store32(data);
}
public static class SchedulerPlug
{
//[Plug("Mosa.Kernel.BareMetal.Platform+Scheduler::Start")]
//public static void Start() => ARM32.Scheduler.Start();
//[Plug("Mosa.Kernel.BareMetal.Platform+Scheduler::Yield")]
//public static void Yield() => ARM32.Scheduler.Yield();
//[Plug("Mosa.Kernel.BareMetal.Platform+Scheduler::SignalTermination")]
//public static void SignalTermination() => ARM32.Scheduler.SignalTermination();
//[Plug("Mosa.Kernel.BareMetal.Platform+Scheduler::SwitchToThread")]
//public static void SwitchToThread(Thread thread) => ARM32.Scheduler.SwitchToThread(thread);
//[Plug("Mosa.Kernel.BareMetal.Platform+Scheduler::SetupThreadStack")]
//public static Pointer SetupThreadStack(Pointer stackTop, Pointer methodAddress, Pointer termAddress) => ARM32.Scheduler.SetupThreadStack(stackTop, methodAddress, termAddress);
}
public static class SerialPlug
{
//public static void Setup(int serial) => ARM32.Serial.Setup((ushort)serial);
//public static void Write(int serial, byte data) => ARM32.Serial.Write((ushort)serial, data);
//public static byte Read(int serial) => ARM32.Serial.Read((ushort)serial);
//public static bool IsDataReady(int serial) => ARM32.Serial.IsDataReady((ushort)serial);
}
}