-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKernel.cs
111 lines (103 loc) · 3.78 KB
/
Kernel.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
using System;
using System.Text;
using Cosmos.HAL;
using Cosmos.HAL.Drivers.Audio;
using TerminalOS_L.Driver;
using TerminalOS_L.Driver.AHCI;
using TerminalOS_L.FrameBuffer;
using TerminalOS_L.Misc;
using Sys = Cosmos.System;
namespace TerminalOS_L
{
public class Kernel: Sys.Kernel
{
public static FileIO f;
public static CommandManager cm;
public static string file;
public static string DOW(int day) {
switch (day)
{
case 0:
return "Sunday";
case 1:
return "Monday";
case 2:
return "Tuesday";
case 3:
return "Wednesday";
case 4:
return "Thursday";
case 5:
return "Friday";
case 6:
return "Saturday";
default:
break;
}
return "Unknown";
}
protected override void OnBoot()
{
//Disable IDE Cosmos Driver and focus on creating own.
Sys.Global.Init(GetTextScreen(),true,true,true,false);
}
public static void PrintByteArray(byte[] bytes)
{
var sb = new StringBuilder("new byte[] { ");
foreach (var b in bytes)
{
sb.AppendFormat("{0:x2},", b);
}
sb.Append('}');
FrConsole.WriteLine(sb.ToString());
}
public static bool SVGASupport;
private static string Username;
public static bool UseAC97;
private static bool[] ATADrives = {false,false,false,false};
protected override void BeforeRun()
{
_ = new FrConsole();
FrConsole.WriteLine("TerminalOS_L (TerminalOS reborn Linux version)");
FrConsole.WriteLine($"Boot date: {DOW(RTC.DayOfTheWeek)} - {RTC.DayOfTheMonth}/{RTC.Month}/{RTC.Century}{RTC.Year} {RTC.Hour:D2}:{RTC.Minute:D2}:{RTC.Second:D2}");
cm = new CommandManager();
PCIDevice dev = PCI.GetDevice(VendorID.VMWare,DeviceID.SVGAIIAdapter);
if (dev.VendorID == (ushort)VendorID.VMWare && dev.DeviceID == (ushort)DeviceID.SVGAIIAdapter) {
Message.Send("Detected VMWare SVGA-II Device, Replacing VGA method...");
SVGASupport=true;
}
dev = PCI.GetDeviceClass(ClassID.MultimediaDevice, SubclassID.IDEInterface); // SubClassID is actually Multimedia Audio Controller, not IDEInterface
if (dev.ClassCode == (byte)ClassID.MultimediaDevice && dev.Subclass == (byte)SubclassID.IDEInterface) {
Message.Send("Detected AC97 Driver.");
AC97.Initialize(4096); // Load builtin driver.
Message.Send("Completed in initializing AC97 Driver.");
UseAC97=true;
}
if (AHCI.IsAHCI()) {
Message.Send("Detected AHCI Driver.");
_ = new AHCI();
}
cm.Input("mount IDE_0");
do {
FrConsole.WriteLine("\nThis is root from Terminal OS.");
FrConsole.Write("root login: ");
Username = FrConsole.ReadLine();
FrConsole.WriteLine();
}while(string.IsNullOrEmpty(Username));
}
protected override void Run()
{
if (string.IsNullOrEmpty(Getroot.Path)) {
FrConsole.Write("# ");
} else {
FrConsole.Write($"[{Getroot.Path}]~# ");
}
var input = FrConsole.ReadLine();
FrConsole.WriteLine(cm.Input(input));
}
protected override void AfterRun()
{
base.AfterRun();
}
}
}