-
Notifications
You must be signed in to change notification settings - Fork 85
/
EntryPoint.cs
106 lines (84 loc) · 2.56 KB
/
EntryPoint.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
using Internal.Runtime.CompilerHelpers;
using MOOS;
using MOOS.Driver;
using MOOS.FS;
using MOOS.Graph;
using MOOS.Misc;
using MOOS.NET;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Net;
using System.Runtime;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace MOOS.Misc
{
internal static unsafe class EntryPoint
{
[RuntimeExport("Entry")]
public static void Entry(MultibootInfo* Info, IntPtr Modules, IntPtr Trampoline)
{
Allocator.Initialize((IntPtr)0x20000000);
StartupCodeHelpers.InitializeModules(Modules, true);
#if HasGC
GC.AllowCollect = false;
#endif
PageTable.Initialise();
ASC16.Initialise();
VBEInfo* info = (VBEInfo*)Info->VBEInfo;
if (info->PhysBase != 0)
{
Framebuffer.Initialize(info->ScreenWidth, info->ScreenHeight, (uint*)info->PhysBase);
Framebuffer.Graphics.Clear(0x0);
}
else
{
for (; ; ) Native.Hlt();
}
Console.Setup();
IDT.Disable();
GDT.Initialise();
IDT.Initialize();
Interrupts.Initialize();
IDT.Enable();
SSE.enable_sse();
//AVX.init_avx();
ACPI.Initialize();
#if UseAPIC
PIC.Disable();
LocalAPIC.Initialize();
IOAPIC.Initialize();
#else
PIC.Enable();
#endif
Timer.Initialize();
Keyboard.Initialize();
Serial.Initialise();
PS2Controller.Initialize();
VMwareTools.Initialize();
SMBIOS.Initialise();
PCI.Initialise();
IDE.Initialize();
SATA.Initialize();
ThreadPool.Initialize();
Console.WriteLine($"[SMP] Trampoline: 0x{((ulong)Trampoline).ToString("x2")}");
Native.Movsb((byte*)SMP.Trampoline, (byte*)Trampoline, 512);
SMP.Initialize((uint)SMP.Trampoline);
#if HasGC
GC.AllowCollect = true;
#endif
//Only fixed size vhds are supported!
Console.Write("[Initrd] Initrd: 0x");
Console.WriteLine((Info->Modules[0]).ToString("x2"));
Console.WriteLine("[Initrd] Initializing Ramdisk");
new Ramdisk((IntPtr)(Info->Modules[0]));
//new FATFS();
new TarFS();
KMain();
}
[DllImport("*")]
public static extern void KMain();
}
}