Repository navigation
Expand file tree
/
Copy pathinterface.cpp
More file actions
148 lines (141 loc) · 4.31 KB
/
Copy pathinterface.cpp
File metadata and controls
148 lines (141 loc) · 4.31 KB
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#include "interface.h"
char* commandPrompt;
void TakePrompt()
{
EnableKeyboard(true);
ReceiveInput(commandPrompt);
}
void InitializeTerminal()
{
commandPrompt = (char*)kmalloc(0x100);
GlobalRenderer->NextLine();
GlobalRenderer->color = 0xCECE5A;
GlobalRenderer->Print("Shell:/ > ");
GlobalRenderer->color = 0xffffffff;
TakePrompt();
}
void ExecutePrompt()
{
EnableKeyboard(false);
if (strcmp(commandPrompt, (const char*)"memory", 6))
{
if (strcmp(commandPrompt + 7, (const char*)"info", 4))
{
GlobalRenderer->color = 0xFEC260;
GlobalRenderer->PrintNL("--- Memory Information ---");
GlobalRenderer->color = 0x73BBC9;
GlobalRenderer->Print("Used RAM: ");
GlobalRenderer->color = 0xffffffff;
PrintMemorySize(GlobalAllocator.GetUsedRAM());
GlobalRenderer->NextLine();
GlobalRenderer->color = 0x73BBC9;
GlobalRenderer->Print("Reserved RAM: ");
GlobalRenderer->color = 0xffffffff;
PrintMemorySize(GlobalAllocator.GetReservedRAM());
GlobalRenderer->NextLine();
GlobalRenderer->color = 0x73BBC9;
GlobalRenderer->Print("Free RAM: ");
GlobalRenderer->color = 0xffffffff;
PrintMemorySize(GlobalAllocator.GetFreeRAM());
GlobalRenderer->NextLine();
}
}
else
if (strcmp(commandPrompt, (const char*)"drives", 6))
{
if (strcmp(commandPrompt + 7, (const char*)"list", 4))
{
GlobalRenderer->color = 0xFEC260;
GlobalRenderer->PrintNL("--- Connected Hard Drives ---");
PrintDrives();
}
else
if (strcmp(commandPrompt + 7, (const char*)"mount", 5))
{
MountedDrivePort = atoi(commandPrompt + 13);
GlobalRenderer->Print(to_string((int64_t)MountedDrivePort));
GlobalRenderer->Print(" - Drive Mounted");
GlobalRenderer->NextLine();
}
else
if (strcmp(commandPrompt + 7, (const char*)"format", 6))
{
uint8_t status = FormatDrive();
if(status > 0)
GlobalRenderer->PrintNL("Successfully Formatted Drive");
else if(status < 0)
GlobalRenderer->PrintNL("Drive already Formatted");
}
else
if (strcmp(commandPrompt + 7, (const char*)"size", 4))
{
int d = MountedDrivePort;
if (d >= 0)
{
PrintMemorySize(ReadDiskSize(d)*512);
GlobalRenderer->NextLine();
}
else
{
GlobalRenderer->PrintNL("No Drive is Mounted");
}
}
}
else
if (strcmp(commandPrompt, (const char*)"fs", 2))
{
FS fs;
if (strcmp(commandPrompt + 3, (const char*)"list", 4))
{
int d = MountedDrivePort;
if (d >= 0)
{
FileMetaData** l = fs.List();
int i = 0;
while (l[i])
{
GlobalRenderer->PrintNL(l[i]->Name);
i++;
}
}
else
{
GlobalRenderer->PrintNL("No Drive is Mounted");
}
}
else
if (strcmp(commandPrompt + 3, (const char*)"open", 4))
{
int d = MountedDrivePort;
if (d >= 0)
{
char* buf = fs.Open(commandPrompt + 8);
GlobalRenderer->PrintNL(buf);
}
else
{
GlobalRenderer->PrintNL("No Drive is Mounted");
}
}
else
if (strcmp(commandPrompt + 3, (const char*)"write", 5))
{
int d = MountedDrivePort;
if (d >= 0)
{
if(fs.WriteBuffer(commandPrompt + 9, "hello world"))
{
GlobalRenderer->PrintNL("Written successfully");
}
}
else
{
GlobalRenderer->PrintNL("No Drive is Mounted");
}
}
}
GlobalRenderer->color = 0xCECE5A;
GlobalRenderer->Print("Shell:/ > ");
GlobalRenderer->color = 0xffffffff;
TakePrompt();
}