summaryrefslogtreecommitdiffhomepage
path: root/dev/ZKA/Sources
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-08-27 19:37:29 +0200
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-08-27 19:37:29 +0200
commitc9e0e4b6058f833f39c2193e217dc38f4edd8b82 (patch)
tree7eadd57a88b51fc70ffd2668c7adc29386650e91 /dev/ZKA/Sources
parentfdbcbba07cac3dbf9ef377f2f5248dd662f6babd (diff)
[WIP] Finishing SMP support, and then working on system driver and
loader. Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/ZKA/Sources')
-rw-r--r--dev/ZKA/Sources/DLLMain.cxx33
-rw-r--r--dev/ZKA/Sources/KernelCheck.cxx34
-rw-r--r--dev/ZKA/Sources/NewFS+FileManager.cxx8
-rw-r--r--dev/ZKA/Sources/ProcessScheduler.cxx4
4 files changed, 54 insertions, 25 deletions
diff --git a/dev/ZKA/Sources/DLLMain.cxx b/dev/ZKA/Sources/DLLMain.cxx
index 8166a702..412f9bdd 100644
--- a/dev/ZKA/Sources/DLLMain.cxx
+++ b/dev/ZKA/Sources/DLLMain.cxx
@@ -34,12 +34,9 @@
EXTERN Kernel::Property cKernelVersion;
/***********************************************************************************/
-/* This is an external C symbol. */
+/* This is an external C symbol, to draw the mouse. */
/***********************************************************************************/
-EXTERN_C Kernel::Void _hal_init_mouse();
-EXTERN_C Kernel::Boolean _hal_draw_mouse();
-
STATIC CG::UI_WINDOW_STRUCT* cKernelWnd = nullptr;
namespace Kernel::Detail
@@ -55,12 +52,12 @@ namespace Kernel::Detail
{
if (Kernel::FilesystemManagerInterface::GetMounted())
{
- CG::CGDrawStringToWnd(cKernelWnd, "NewOSKrnl: NewFS filesystem already mounted...", 10, 10, RGB(0, 0, 0));
+ CG::CGDrawStringToWnd(cKernelWnd, "NewOSKrnl: NewFS already mounted by HAL...", 10, 10, RGB(0, 0, 0));
fNewFS = reinterpret_cast<Kernel::NewFilesystemManager*>(Kernel::FilesystemManagerInterface::GetMounted());
}
else
{
- CG::CGDrawStringToWnd(cKernelWnd, "NewOSKrnl: Mounting a NewFS filesystem...", 10, 10, RGB(0, 0, 0));
+ CG::CGDrawStringToWnd(cKernelWnd, "NewOSKrnl: Mounted NewFS filesystem...", 10, 10, RGB(0, 0, 0));
// Mounts a NewFS from main drive.
fNewFS = new Kernel::NewFilesystemManager();
@@ -84,8 +81,8 @@ namespace Kernel::Detail
{
Kernel::kcout << "newoskrnl: Already exists.\r";
- CG::CGDrawStringToWnd(cKernelWnd, "NewOSKrnl: Catalog already exists: ", 10 + (10 * (dirIndx + 1)), 10, RGB(0, 0, 0));
- CG::CGDrawStringToWnd(cKernelWnd, catalogDir->Name, 10 + (10 * (dirIndx + 1)), 10 + (FONT_SIZE_X * rt_string_len("NewOSKrnl: Catalog already exists: ")), RGB(0, 0, 0));
+ CG::CGDrawStringToWnd(cKernelWnd, "NewOSKrnl: Catalog directory already exists: ", 10 + (10 * (dirIndx + 1)), 10, RGB(0, 0, 0));
+ CG::CGDrawStringToWnd(cKernelWnd, catalogDir->Name, 10 + (10 * (dirIndx + 1)), 10 + (FONT_SIZE_X * rt_string_len("NewOSKrnl: Catalog directory already exists: ")), RGB(0, 0, 0));
delete catalogDir;
continue;
@@ -108,19 +105,19 @@ namespace Kernel::Detail
if (catalogDisk)
{
- CG::CGDrawStringToWnd(cKernelWnd, "NewOSKrnl: Catalog file exists: ", 10 + (10 * (cDirCount + 1)), 10, RGB(0, 0, 0));
- CG::CGDrawStringToWnd(cKernelWnd, kSysPage, 10 + (10 * (cDirCount + 1)), 10 + (FONT_SIZE_X * rt_string_len("NewOSKrnl: Catalog file exists: ")), RGB(0, 0, 0));
+ CG::CGDrawStringToWnd(cKernelWnd, "NewOSKrnl: Catalog swap file already exists: ", 10 + (10 * (cDirCount + 1)), 10, RGB(0, 0, 0));
+ CG::CGDrawStringToWnd(cKernelWnd, kSysPage, 10 + (10 * (cDirCount + 1)), 10 + (FONT_SIZE_X * rt_string_len("NewOSKrnl: Catalog swap file already exists: ")), RGB(0, 0, 0));
delete catalogDisk;
}
else
{
- CG::CGDrawStringToWnd(cKernelWnd, "NewOSKrnl: Catalog has been created: ", 10 + (10 * (cDirCount + 1)), 10, RGB(0, 0, 0));
- CG::CGDrawStringToWnd(cKernelWnd, kSysPage, 10 + (10 * (cDirCount + 1)), 10 + (FONT_SIZE_X * rt_string_len("NewOSKrnl: Catalog has been created: ")), RGB(0, 0, 0));
+ CG::CGDrawStringToWnd(cKernelWnd, "NewOSKrnl: Catalog swap file created: ", 10 + (10 * (cDirCount + 1)), 10, RGB(0, 0, 0));
+ CG::CGDrawStringToWnd(cKernelWnd, kSysPage, 10 + (10 * (cDirCount + 1)), 10 + (FONT_SIZE_X * rt_string_len("NewOSKrnl: Catalog swap file created: ")), RGB(0, 0, 0));
catalogDisk =
- (NFS_CATALOG_STRUCT*)this->Leak()->CreateAlias(kSysPage);
+ (NFS_CATALOG_STRUCT*)this->Leak()->CreateSwapFile(kSysPage);
NFS_FORK_STRUCT theDiskFork{0};
@@ -172,7 +169,7 @@ EXTERN_C Kernel::Void ke_dll_entrypoint(Kernel::Void)
cKernelWnd = nullptr;
cKernelWnd = CG::CGCreateWindow(CG::cWndFlagWindow, "ZKA Operating System Kernel Log", "Window", 20, 20, CG::UIAccessibilty::The().Height() - 20, CG::UIAccessibilty::The().Width() - 20);
- cKernelWnd->w_sub_type = CG::cWndFlagCloseControlSelect;
+ cKernelWnd->w_sub_type = 0;
cKernelWnd->w_x = 10;
cKernelWnd->w_y = 10;
@@ -183,6 +180,14 @@ EXTERN_C Kernel::Void ke_dll_entrypoint(Kernel::Void)
/// Now run kernel loop, until no process are running.
Kernel::Detail::FilesystemInstaller(); // automatic filesystem creation.
+ cKernelWnd->w_sub_type = CG::cWndFlagCloseControlSelect;
+ cKernelWnd->w_needs_repaint = Yes;
+
+ CG::CGDrawWindowList(&cKernelWnd, 1);
+
+ CG::CGDrawStringToWnd(cKernelWnd, "NewOSKrnl: Booting: ", 10, 10, RGB(0, 0, 0));
+ CG::CGDrawStringToWnd(cKernelWnd, kSysDrv, 10, 10 + (FONT_SIZE_X * Kernel::rt_string_len("NewOSKrnl: Booting: ")), RGB(0, 0, 0));
+
/// @note BThread doesn't parse the symbols so doesn't nullify them, .bss is though.
Kernel::cProcessScheduler = nullptr;
diff --git a/dev/ZKA/Sources/KernelCheck.cxx b/dev/ZKA/Sources/KernelCheck.cxx
index a5389b39..3057fe65 100644
--- a/dev/ZKA/Sources/KernelCheck.cxx
+++ b/dev/ZKA/Sources/KernelCheck.cxx
@@ -5,6 +5,7 @@
------------------------------------------- */
#include <ArchKit/ArchKit.hxx>
+#include <KernelKit/Timer.hxx>
#include <KernelKit/DebugOutput.hxx>
#include <NewKit/KernelCheck.hxx>
#include <NewKit/String.hxx>
@@ -20,7 +21,7 @@
#define CopyMem(dst, src, sz) Kernel::rt_copy_memory((Kernel::VoidPtr)src, (Kernel::VoidPtr)dst, sz)
#define MoveMem(dst, src, sz) Kernel::rt_copy_memory((Kernel::VoidPtr)src, (Kernel::VoidPtr)dst, sz)
-#define cWebsiteMacro "https://zka.nl/help"
+#define cWebsiteMacro "https://help.el-mahrouss-logic.com/"
/* Each error code is attributed with an ID, which will prompt a string onto the
* screen. Wait for debugger... */
@@ -31,7 +32,7 @@ namespace Kernel
{
CGInit();
- auto panicTxt = RGB(0xff, 0xff, 0xff);
+ auto panicTxt = RGB(0xff, 0xff, 0xff);
CG::CGDrawBackground();
@@ -39,6 +40,11 @@ namespace Kernel
auto x = 10;
CGDrawString("newoskrnl.dll Stopped working properly so it had to stop.", start_y, x, panicTxt);
+ start_y += 10;
+
+ // simply offset from previous string and then write the website.
+ CGDrawString("Please visit: ", start_y, x, panicTxt);
+ CGDrawString(cWebsiteMacro, start_y, x + (FONT_SIZE_X * rt_string_len("Please visit: ")), panicTxt);
CGFini();
@@ -54,34 +60,42 @@ namespace Kernel
}
case RUNTIME_CHECK_ACPI: {
CGDrawString("0x00000006 ACPI configuration error.", start_y, x, panicTxt);
+ RecoveryFactory::Recover();
break;
}
case RUNTIME_CHECK_FILESYSTEM: {
CGDrawString("0x0000000A Filesystem corruption error.", start_y, x, panicTxt);
+ RecoveryFactory::Recover();
break;
}
case RUNTIME_CHECK_POINTER: {
CGDrawString("0x00000000 Kernel heap pointer error, surely corrupted.", start_y, x, panicTxt);
+ RecoveryFactory::Recover();
break;
}
case RUNTIME_CHECK_BAD_BEHAVIOR: {
CGDrawString("0x00000009 Undefined behavior error, image had to stop.", start_y, x, panicTxt);
+ RecoveryFactory::Recover();
break;
}
case RUNTIME_CHECK_BOOTSTRAP: {
CGDrawString("0x0000000A End of boot code, but nothing to continue.", start_y, x, panicTxt);
+ RecoveryFactory::Recover();
break;
}
case RUNTIME_CHECK_HANDSHAKE: {
CGDrawString("0x00000005 Bad handshake error.", start_y, x, panicTxt);
+ RecoveryFactory::Recover();
break;
}
case RUNTIME_CHECK_IPC: {
CGDrawString("0x00000003 Bad kernel IPC error.", start_y, x, panicTxt);
+ RecoveryFactory::Recover();
break;
}
case RUNTIME_CHECK_INVALID_PRIVILEGE: {
CGDrawString("0x00000007 Kernel privilege violation.", start_y, x, panicTxt);
+ RecoveryFactory::Recover();
break;
case RUNTIME_CHECK_UNEXCPECTED: {
CGDrawString("0x0000000B Catasrophic kernel failure.", start_y, x, panicTxt);
@@ -89,24 +103,30 @@ namespace Kernel
}
case RUNTIME_CHECK_FAILED: {
CGDrawString("0x10000001 Assertion failed.", start_y, x, panicTxt);
+ RecoveryFactory::Recover();
break;
}
default: {
+ RecoveryFactory::Recover();
CGDrawString("0xFFFFFFFC Unknown kernel error.", start_y, x, panicTxt);
break;
}
}
};
- RecoveryFactory::Recover();
+ while (Yes)
+ ;
}
Void RecoveryFactory::Recover() noexcept
{
- while (Yes)
- {
- asm volatile("cli; hlt");
- }
+ const auto cMaxSeconds = Seconds(4);
+
+ HardwareTimer timer(cMaxSeconds);
+ timer.Wait();
+
+ PowerFactoryInterface power(nullptr);
+ power.Reboot();
}
void ke_runtime_check(bool expr, const Char* file, const Char* line)
diff --git a/dev/ZKA/Sources/NewFS+FileManager.cxx b/dev/ZKA/Sources/NewFS+FileManager.cxx
index e40e98aa..6f50733f 100644
--- a/dev/ZKA/Sources/NewFS+FileManager.cxx
+++ b/dev/ZKA/Sources/NewFS+FileManager.cxx
@@ -68,6 +68,14 @@ namespace Kernel
return node_cast(fImpl->CreateCatalog(path, 0, kNewFSCatalogKindAlias));
}
+ /// @brief Creates a node with is a page file.
+ /// @param path The filename path.
+ /// @return The Node pointer.
+ NodePtr NewFilesystemManager::CreateSwapFile(const Char* path)
+ {
+ return node_cast(fImpl->CreateCatalog(path, 0, kNewFSCatalogKindPage));
+ }
+
/// @brief Gets the root directory.
/// @return
const Char* NewFilesystemHelper::Root()
diff --git a/dev/ZKA/Sources/ProcessScheduler.cxx b/dev/ZKA/Sources/ProcessScheduler.cxx
index 965c5eb1..4186808e 100644
--- a/dev/ZKA/Sources/ProcessScheduler.cxx
+++ b/dev/ZKA/Sources/ProcessScheduler.cxx
@@ -314,8 +314,6 @@ namespace Kernel
/// @return
SizeT ProcessScheduler::Run() noexcept
{
- kcout << "newoskrnl: Entering scheduler control..\r";
-
SizeT process_index = 0; //! we store this guy to tell the scheduler how many
//! things we have scheduled.
@@ -352,8 +350,6 @@ namespace Kernel
}
}
- kcout << "newoskrnl: Exiting scheduler control..\r";
-
return process_index;
}