diff options
| author | Amlal EL Mahrouss <amlalelmahrouss@icloud.com> | 2024-08-27 09:22:59 +0200 |
|---|---|---|
| committer | Amlal EL Mahrouss <amlalelmahrouss@icloud.com> | 2024-08-27 09:22:59 +0200 |
| commit | 1f9b7e979f656c255bb1bf51743f1001c613b963 (patch) | |
| tree | cb460c3a71828d2a8119c75389a1fadf23c3760f /dev/ZKA | |
| parent | 1f9473c6b591eead87405d2e1861ee48f9a38c0e (diff) | |
[IMP] Add log window when booting.
Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'dev/ZKA')
| -rw-r--r-- | dev/ZKA/Modules/CoreCG/WindowRenderer.hxx | 25 | ||||
| -rw-r--r-- | dev/ZKA/Sources/DLLMain.cxx | 37 | ||||
| -rw-r--r-- | dev/ZKA/Sources/KernelCheck.cxx | 45 |
3 files changed, 51 insertions, 56 deletions
diff --git a/dev/ZKA/Modules/CoreCG/WindowRenderer.hxx b/dev/ZKA/Modules/CoreCG/WindowRenderer.hxx index b377d7d0..1a7d1660 100644 --- a/dev/ZKA/Modules/CoreCG/WindowRenderer.hxx +++ b/dev/ZKA/Modules/CoreCG/WindowRenderer.hxx @@ -51,6 +51,16 @@ namespace CG typedef struct UI_WINDOW_STRUCT UI_WINDOW_STRUCT; + inline Void CGDrawBackground() noexcept + { + CGInit(); + + CGDrawInRegion(CGColor(0x45, 0x00, 0x06), CG::UIAccessibilty::The().Height(), CG::UIAccessibilty::The().Width(), + 0, 0); + + CGFini(); + } + inline struct UI_WINDOW_STRUCT* CGCreateWindow(Int32 kind, const Char* window_name, const Char* class_name, Int32 x, Int32 y, Int32 width, Int32 height, UI_WINDOW_STRUCT* parent = nullptr) { UI_WINDOW_STRUCT* wnd = new UI_WINDOW_STRUCT(); @@ -106,9 +116,15 @@ namespace CG inline Kernel::Void CGDrawStringToWnd(UI_WINDOW_STRUCT* wnd, const Kernel::Char* text, Kernel::Int32 y_dst, Kernel::Int32 x_dst, Kernel::Int32 color) { + y_dst += wnd->w_y + FLATCONTROLS_HEIGHT; + x_dst += wnd->w_x; + + if (y_dst > (wnd->w_h + wnd->w_y)) + return; + for (Kernel::SizeT i = 0; text[i] != 0; ++i) { - if (x_dst > wnd->w_w) + if (x_dst > (wnd->w_w + wnd->w_x)) break; CGRenderStringFromBitMap(&cFontBitmap[text[i]][0], FONT_SIZE_X, FONT_SIZE_Y, y_dst, x_dst, color); @@ -209,11 +225,8 @@ namespace CG for (SizeT child = 0; child < wnd[index]->w_child_count; ++child) { - if (wnd[index]->w_child_elements[child]->w_x < wnd[index]->w_x + FLATCONTROLS_WIDTH) - wnd[index]->w_child_elements[child]->w_x += wnd[index]->w_x + FLATCONTROLS_WIDTH; - - if (wnd[index]->w_child_elements[child]->w_y < (wnd[index]->w_y + FLATCONTROLS_HEIGHT)) - wnd[index]->w_child_elements[child]->w_y += wnd[index]->w_y + FLATCONTROLS_HEIGHT; + wnd[index]->w_child_elements[child]->w_x += wnd[index]->w_x; + wnd[index]->w_child_elements[child]->w_y += wnd[index]->w_y + FLATCONTROLS_HEIGHT; if ((wnd[index]->w_child_elements[child]->w_w + wnd[index]->w_child_elements[child]->w_x) > (wnd[index]->w_x + wnd[index]->w_w) || (wnd[index]->w_child_elements[child]->w_h + wnd[index]->w_child_elements[child]->w_y) > (wnd[index]->w_y + wnd[index]->w_h)) diff --git a/dev/ZKA/Sources/DLLMain.cxx b/dev/ZKA/Sources/DLLMain.cxx index 54254f73..da7a0d2f 100644 --- a/dev/ZKA/Sources/DLLMain.cxx +++ b/dev/ZKA/Sources/DLLMain.cxx @@ -40,6 +40,8 @@ EXTERN Kernel::Property cKernelVersion; EXTERN_C Kernel::Void _hal_init_mouse(); EXTERN_C Kernel::Boolean _hal_draw_mouse(); +STATIC CG::UI_WINDOW_STRUCT* cKernelWnd = nullptr; + namespace Kernel::Detail { /// @brief Filesystem auto formatter, additional checks are also done by the class. @@ -53,14 +55,13 @@ namespace Kernel::Detail { if (Kernel::FilesystemManagerInterface::GetMounted()) { - // Partition is mounted, cool! - Kernel::kcout - << "newoskrnl: No need to create for a new NewFS (EPM) partition here...\r"; - + CG::CGDrawStringToWnd(cKernelWnd, "NewOSKrnl: No need to allocate a NewFS filesystem here...", 10, 10, RGB(0, 0, 0)); fNewFS = reinterpret_cast<Kernel::NewFilesystemManager*>(Kernel::FilesystemManagerInterface::GetMounted()); } else { + CG::CGDrawStringToWnd(cKernelWnd, "NewOSKrnl: Allocating a NewFS filesystem here...", 10, 10, RGB(0, 0, 0)); + // Mounts a NewFS from main drive. fNewFS = new Kernel::NewFilesystemManager(); @@ -83,6 +84,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)); + delete catalogDir; continue; } @@ -124,6 +127,8 @@ namespace Kernel::Detail catalogDir, true, (Kernel::VoidPtr)(metadataFolder.CData()), metadataSz, cFolderInfo); + CG::CGDrawStringToWnd(cKernelWnd, "NewOSKrnl: Catalog has been created...", 10 + (10 * (dirIndx + 1)), 10, RGB(0, 0, 0)); + delete catalogDir; } } @@ -153,7 +158,7 @@ namespace Kernel::Detail Kernel::Size sz_hdr = kNewFSForkSz; - theDiskFork.DataSize =sz_hdr; + theDiskFork.DataSize = sz_hdr; theDiskFork.ResourceId = kNewFSCatalogKindExecutable | kNewFSCatalogKindPage; theDiskFork.ResourceKind = Kernel::kNewFSDataForkKind; theDiskFork.Kind = Kernel::kNewFSDataForkKind; @@ -187,22 +192,18 @@ namespace Kernel /// @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); + CG::CGDrawBackground(); - CGFini(); + 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); - auto root_zka_wnd = CG::CGCreateWindow(CG::cWndFlagWindow, "ZKA Operating System", "Window", 20, 20, CG::UIAccessibilty::The().Height() - 20, CG::UIAccessibilty::The().Width() - 20); + cKernelWnd->w_sub_type = CG::cWndFlagCloseControlSelect; + cKernelWnd->w_x = 10; + cKernelWnd->w_y = 10; - root_zka_wnd->w_sub_type = CG::cWndFlagCloseControlSelect; - root_zka_wnd->w_x = 10; - root_zka_wnd->w_y = 10; + cKernelWnd->w_needs_repaint = Yes; - root_zka_wnd->w_needs_repaint = Yes; - - CG::CGDrawWindowList(&root_zka_wnd, 1); + CG::CGDrawWindowList(&cKernelWnd, 1); /// Now run kernel loop, until no process are running. Kernel::Detail::FilesystemInstaller(); // automatic filesystem creation. @@ -210,6 +211,8 @@ EXTERN_C Kernel::Void ke_dll_entrypoint(Kernel::Void) /// @note BThread doesn't parse the symbols so doesn't nullify them, .bss is though. Kernel::cProcessScheduler = nullptr; + CG::CGDrawBackground(); + while (Yes) { Kernel::ProcessHelper::StartScheduling(); diff --git a/dev/ZKA/Sources/KernelCheck.cxx b/dev/ZKA/Sources/KernelCheck.cxx index 3d97ccfa..a5389b39 100644 --- a/dev/ZKA/Sources/KernelCheck.cxx +++ b/dev/ZKA/Sources/KernelCheck.cxx @@ -14,6 +14,7 @@ #include <Modules/CoreCG/Accessibility.hxx> #include <Modules/CoreCG/FbRenderer.hxx> #include <Modules/CoreCG/TextRenderer.hxx> +#include <Modules/CoreCG/WindowRenderer.hxx> #define SetMem(dst, byte, sz) Kernel::rt_set_memory((Kernel::VoidPtr)dst, byte, sz) #define CopyMem(dst, src, sz) Kernel::rt_copy_memory((Kernel::VoidPtr)src, (Kernel::VoidPtr)dst, sz) @@ -21,8 +22,6 @@ #define cWebsiteMacro "https://zka.nl/help" -#include <BootKit/Vendor/Qr.hxx> - /* Each error code is attributed with an ID, which will prompt a string onto the * screen. Wait for debugger... */ @@ -32,37 +31,17 @@ namespace Kernel { CGInit(); - auto panicBack = RGB(0xff, 0x3a, 0x3a); auto panicTxt = RGB(0xff, 0xff, 0xff); - CGDrawInRegion(panicBack, CG::UIAccessibilty::The().Height(), CG::UIAccessibilty::The().Width(), 0, 0); + CG::CGDrawBackground(); auto start_y = 10; auto x = 10; - CGDrawString("newoskrnl.dll stopped working properly so we had to stop.", start_y, x, panicTxt); + CGDrawString("newoskrnl.dll Stopped working properly so it had to stop.", start_y, x, panicTxt); CGFini(); - // Show the QR code now. - - constexpr auto cVer = 4; - const auto cECC = qr::Ecc::H; - const auto cInput = cWebsiteMacro; - const auto cInputLen = rt_string_len(cWebsiteMacro); - - qr::Qr<cVer> encoder; - qr::QrDelegate encoderDelegate; - - encoder.encode(cInput, cInputLen, cECC, 0); // Manual mask 0 - - const auto cWhereStartX = (kHandoverHeader->f_GOP.f_Width - encoder.side_size()) - 20; - const auto cWhereStartY = (kHandoverHeader->f_GOP.f_Height - encoder.side_size()) / 2; - - // tell delegate to draw encoded QR now. - encoderDelegate.draw<cVer>(encoder, cWhereStartX, - cWhereStartY); - start_y += 10; // show text according to error id. @@ -70,11 +49,11 @@ namespace Kernel switch (id) { case RUNTIME_CHECK_PROCESS: { - CGDrawString("0x00000008 Process scheduler error (Catasrophic failure).", start_y, x, panicTxt); + CGDrawString("0x00000008 Process execution fault, this is a catasrophic failure.", start_y, x, panicTxt); break; } case RUNTIME_CHECK_ACPI: { - CGDrawString("0x00000006 ACPI error.", start_y, x, panicTxt); + CGDrawString("0x00000006 ACPI configuration error.", start_y, x, panicTxt); break; } case RUNTIME_CHECK_FILESYSTEM: { @@ -82,30 +61,30 @@ namespace Kernel break; } case RUNTIME_CHECK_POINTER: { - CGDrawString("0x00000000 Kernel heap error.", start_y, x, panicTxt); + CGDrawString("0x00000000 Kernel heap pointer error, surely corrupted.", start_y, x, panicTxt); break; } case RUNTIME_CHECK_BAD_BEHAVIOR: { - CGDrawString("0x00000009 Undefined Behavior error.", start_y, x, panicTxt); + CGDrawString("0x00000009 Undefined behavior error, image had to stop.", start_y, x, panicTxt); break; } case RUNTIME_CHECK_BOOTSTRAP: { - CGDrawString("0x0000000A End of code.", start_y, x, panicTxt); + CGDrawString("0x0000000A End of boot code, but nothing to continue.", start_y, x, panicTxt); break; } case RUNTIME_CHECK_HANDSHAKE: { - CGDrawString("0x00000005 Handshake error.", start_y, x, panicTxt); + CGDrawString("0x00000005 Bad handshake error.", start_y, x, panicTxt); break; } case RUNTIME_CHECK_IPC: { - CGDrawString("0x00000003 Kernel IPC error.", start_y, x, panicTxt); + CGDrawString("0x00000003 Bad kernel IPC error.", start_y, x, panicTxt); break; } case RUNTIME_CHECK_INVALID_PRIVILEGE: { CGDrawString("0x00000007 Kernel privilege violation.", start_y, x, panicTxt); break; case RUNTIME_CHECK_UNEXCPECTED: { - CGDrawString("0x0000000B Catasrophic failure.", start_y, x, panicTxt); + CGDrawString("0x0000000B Catasrophic kernel failure.", start_y, x, panicTxt); break; } case RUNTIME_CHECK_FAILED: { @@ -113,7 +92,7 @@ namespace Kernel break; } default: { - CGDrawString("0xFFFFFFFF Unknown error.", start_y, x, panicTxt); + CGDrawString("0xFFFFFFFC Unknown kernel error.", start_y, x, panicTxt); break; } } |
