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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
|
/* -------------------------------------------
Copyright ZKA Technologies
File: Main.cxx
Purpose: Main entrypoint of kernel.
------------------------------------------- */
#include <ArchKit/ArchKit.hxx>
#include <CompilerKit/Detail.hxx>
#include <FirmwareKit/Handover.hxx>
#include <KernelKit/FileManager.hxx>
#include <KernelKit/Framebuffer.hxx>
#include <KernelKit/Heap.hxx>
#include <KernelKit/PEF.hxx>
#include <KernelKit/PEFCodeManager.hxx>
#include <KernelKit/ProcessScheduler.hxx>
#include <KernelKit/ProcessHeap.hxx>
#include <NewKit/Json.hxx>
#include <NewKit/KernelCheck.hxx>
#include <NewKit/String.hxx>
#include <NewKit/Utils.hxx>
#include <KernelKit/CodeManager.hxx>
#include <CFKit/Property.hxx>
#include <Modules/CoreCG/WindowRenderer.hxx>
EXTERN Kernel::Property cKernelVersion;
namespace Kernel::Detail
{
/// @brief Filesystem auto formatter, additional checks are also done by the class.
class FilesystemInstaller final
{
Kernel::NewFilesystemManager* fNewFS{nullptr};
public:
/// @brief wizard constructor.
explicit FilesystemInstaller()
{
if (Kernel::FilesystemManagerInterface::GetMounted())
{
// Partition is mounted, cool!
Kernel::kcout
<< "newoskrnl: No need to create for a new NewFS (EPM) partition here...\r";
fNewFS = reinterpret_cast<Kernel::NewFilesystemManager*>(Kernel::FilesystemManagerInterface::GetMounted());
}
else
{
// Mounts a NewFS from main drive.
fNewFS = new Kernel::NewFilesystemManager();
Kernel::FilesystemManagerInterface::Mount(fNewFS);
}
if (fNewFS->GetParser())
{
constexpr auto cFolderInfo = "META-INF";
const auto cDirCount = 7;
const char* cDirStr[cDirCount] = {
"\\Boot\\", "\\System\\", "\\Support\\", "\\Applications\\",
"\\Users\\", "\\Library\\", "\\Mount\\"};
for (Kernel::SizeT dirIndx = 0UL; dirIndx < cDirCount; ++dirIndx)
{
auto catalogDir = fNewFS->GetParser()->GetCatalog(cDirStr[dirIndx]);
if (catalogDir)
{
Kernel::kcout << "newoskrnl: already exists.\r";
delete catalogDir;
continue;
}
catalogDir = fNewFS->GetParser()->CreateCatalog(cDirStr[dirIndx], 0,
kNewFSCatalogKindDir);
NFS_FORK_STRUCT theFork{0};
const Kernel::Char* cSrcName = cFolderInfo;
Kernel::rt_copy_memory((Kernel::VoidPtr)(cSrcName), theFork.ForkName,
Kernel::rt_string_len(cSrcName));
Kernel::rt_copy_memory((Kernel::VoidPtr)(catalogDir->Name),
theFork.CatalogName,
Kernel::rt_string_len(catalogDir->Name));
delete catalogDir;
theFork.DataSize = kNewFSForkSize;
theFork.ResourceId = 0;
theFork.ResourceKind = Kernel::kNewFSRsrcForkKind;
theFork.Kind = Kernel::kNewFSDataForkKind;
Kernel::StringView metadataFolder(kNewFSSectorSz);
metadataFolder +=
"<!properties/>\r<p>Kind: folder</p>\r<p>Created by: system</p>\r<p>Edited by: "
"system</p>\r<p>Volume Type: Zeta</p>\r";
metadataFolder += "<p>Path: ";
metadataFolder += cDirStr[dirIndx];
metadataFolder += "</p>\r";
const Kernel::SizeT metadataSz = kNewFSSectorSz;
auto catalogSystem = fNewFS->GetParser()->GetCatalog(cDirStr[dirIndx]);
fNewFS->GetParser()->CreateFork(catalogSystem, theFork);
fNewFS->GetParser()->WriteCatalog(
catalogSystem, true, (Kernel::VoidPtr)(metadataFolder.CData()),
metadataSz, cFolderInfo);
delete catalogSystem;
}
}
NFS_CATALOG_STRUCT* catalogDisk =
this->fNewFS->GetParser()->GetCatalog("\\Mount\\NUL:");
const Kernel::Char* cSrcName = "DISK-INF";
if (catalogDisk)
{
delete catalogDisk;
}
else
{
catalogDisk =
(NFS_CATALOG_STRUCT*)this->Leak()->CreateAlias("\\Mount\\NUL:");
Kernel::StringView diskFolder(kNewFSSectorSz);
diskFolder +=
"<!properties/><p>Kind: alias to NULL.</p>\r<p>Created by: system</p>\r<p>Edited "
"by: "
"system</p>\r<p>Volume Type: NULL.</p>\r";
diskFolder += "<p>Root: NUL";
diskFolder += "</p>\r";
NFS_FORK_STRUCT theDiskFork{0};
Kernel::rt_copy_memory((Kernel::VoidPtr)(cSrcName), theDiskFork.ForkName,
Kernel::rt_string_len(cSrcName));
Kernel::rt_copy_memory((Kernel::VoidPtr)(catalogDisk->Name),
theDiskFork.CatalogName,
Kernel::rt_string_len(catalogDisk->Name));
theDiskFork.DataSize = kNewFSForkSize;
theDiskFork.ResourceId = 0;
theDiskFork.ResourceKind = Kernel::kNewFSRsrcForkKind;
theDiskFork.Kind = Kernel::kNewFSDataForkKind;
fNewFS->GetParser()->CreateFork(catalogDisk, theDiskFork);
fNewFS->GetParser()->WriteCatalog(catalogDisk,
true,
(Kernel::VoidPtr)diskFolder.CData(),
kNewFSSectorSz, cSrcName);
delete catalogDisk;
}
}
~FilesystemInstaller() = default;
NEWOS_COPY_DEFAULT(FilesystemInstaller);
/// @brief Grab the disk's NewFS reference.
/// @return NewFilesystemManager the filesystem interface
Kernel::NewFilesystemManager* Leak()
{
return fNewFS;
}
};
} // namespace Kernel::Detail
/// @brief Application entrypoint.
/// @param Void
/// @return Void
EXTERN_C Kernel::Void ke_dll_entrypoint(Kernel::Void)
{
CGInit();
CGDrawInRegion(CGColor(0x45, 0x00, 0x06), CG::UIAccessibilty::The().Height(), CG::UIAccessibilty::The().Width(),
0, 0);
CGFini();
auto root_zka_wnd = CG::CGCreateWindow(CG::cWndFlagWindow, "ZKA Setup", "Window", 0, 0, CG::UIAccessibilty::The().Height() - 20, CG::UIAccessibilty::The().Width() - 20);
root_zka_wnd->w_x = 10;
root_zka_wnd->w_y = 10;
root_zka_wnd->w_needs_repaint = Yes;
/// Now run kernel loop, until no process are running.
Kernel::Detail::FilesystemInstaller(); // automatic filesystem creation.
auto root_install_wnd = CG::CGCreateWindow(CG::cWndFlagButton, "Install ZKA.", "Button", 0, 0, 128, 32);
root_install_wnd->w_x = 30;
root_install_wnd->w_y = 60;
root_install_wnd->w_needs_repaint = Yes;
CG::UI_WINDOW_STRUCT* arr[] = {root_zka_wnd, root_install_wnd};
CGDrawInRegion(CGColor(0x45, 0x00, 0x06), CG::UIAccessibilty::The().Height(), CG::UIAccessibilty::The().Width(),
0, 0);
CGFini();
CG::CGDrawWindowList(arr, 2);
while (Yes)
{
}
}
|