summaryrefslogtreecommitdiffhomepage
path: root/dev
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-12-26 18:15:54 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-12-26 18:15:54 +0100
commitc0f7f3f300d603d355fc7ec5be317afe1f0ee1b6 (patch)
tree87189340d1b6f36474c52c0cf951310862fe9db7 /dev
parent4ed658c633ce5d7c5bde4acdbe322e5f51592369 (diff)
IMPL: Improvements and fixes.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev')
-rw-r--r--dev/BootLoader/BootKit/BootKit.h1
-rw-r--r--dev/BootLoader/BootKit/Thread.h2
-rw-r--r--dev/BootLoader/Modules/NetBoot/Module.cc2
-rw-r--r--dev/BootLoader/Modules/NetBoot/build.json2
-rw-r--r--dev/BootLoader/Modules/SysChk/Module.cc33
-rw-r--r--dev/BootLoader/src/BootThread.cc22
-rw-r--r--dev/BootLoader/src/HEL/AMD64/BootMain.cc65
-rw-r--r--dev/Kernel/FirmwareKit/EFI/EFI.h59
-rw-r--r--dev/Kernel/FirmwareKit/Handover.h2
-rw-r--r--dev/Kernel/HALKit/AMD64/HalKernelMain.cc3
-rw-r--r--dev/Kernel/HALKit/AMD64/HalTimerAMD64.cc6
-rw-r--r--dev/Kernel/HALKit/ARM64/HalKernelMain.cc3
-rw-r--r--dev/Kernel/KernelKit/Timer.h6
-rw-r--r--dev/Kernel/src/KernelMain.cc1
-rw-r--r--dev/Kernel/src/SoftwareTimer.cc39
-rw-r--r--dev/Kernel/src/Timer.cc32
-rw-r--r--dev/Modules/GfxMgr/AppearanceMgr.h266
-rw-r--r--dev/Modules/GfxMgr/FBMgr.h16
18 files changed, 188 insertions, 372 deletions
diff --git a/dev/BootLoader/BootKit/BootKit.h b/dev/BootLoader/BootKit/BootKit.h
index 90d6fae9..2e0099f2 100644
--- a/dev/BootLoader/BootKit/BootKit.h
+++ b/dev/BootLoader/BootKit/BootKit.h
@@ -15,7 +15,6 @@
#include <FirmwareKit/EPM.h>
#include <CompilerKit/Version.h>
#include <Modules/GfxMgr/FBMgr.h>
-#include <Modules/GfxMgr/AppearanceMgr.h>
#include <BootKit/Rsrc/zka_disk.rsrc>
#include <BootKit/Rsrc/zka_no_disk.rsrc>
#include <BootKit/Rsrc/zka_has_disk.rsrc>
diff --git a/dev/BootLoader/BootKit/Thread.h b/dev/BootLoader/BootKit/Thread.h
index 06fd84a0..42991d17 100644
--- a/dev/BootLoader/BootKit/Thread.h
+++ b/dev/BootLoader/BootKit/Thread.h
@@ -29,7 +29,7 @@ namespace Boot
BThread& operator=(const BThread&) = default;
BThread(const BThread&) = default;
- void Start(HEL::BootInfoHeader* handover, BOOL is_own_stack);
+ Int32 Start(HEL::BootInfoHeader* handover, BOOL is_own_stack);
void SetName(const char* name);
const char* GetName();
bool IsValid();
diff --git a/dev/BootLoader/Modules/NetBoot/Module.cc b/dev/BootLoader/Modules/NetBoot/Module.cc
index 1b4a4bb4..6277da70 100644
--- a/dev/BootLoader/Modules/NetBoot/Module.cc
+++ b/dev/BootLoader/Modules/NetBoot/Module.cc
@@ -10,7 +10,7 @@
#include <NetBoot.h>
#include <BootKit/BootKit.h>
-EXTERN_C Int32 main(Kernel::HEL::BootInfoHeader* Handover)
+EXTERN_C Int32 ModuleMain(Kernel::HEL::BootInfoHeader* Handover)
{
return kEfiOk;
}
diff --git a/dev/BootLoader/Modules/NetBoot/build.json b/dev/BootLoader/Modules/NetBoot/build.json
index 3844f9cb..9df27b3c 100644
--- a/dev/BootLoader/Modules/NetBoot/build.json
+++ b/dev/BootLoader/Modules/NetBoot/build.json
@@ -11,7 +11,7 @@
"-fPIC",
"-fno-rtti",
"-fno-exceptions",
- "-Wl,--subsystem=17,--image-base,0x1000000"
+ "-Wl,--subsystem=17,--image-base,0x10000000,-e,ModuleMain"
],
"cpp_macros": [
"__MINOSKRNL__",
diff --git a/dev/BootLoader/Modules/SysChk/Module.cc b/dev/BootLoader/Modules/SysChk/Module.cc
index b0808fde..28b89859 100644
--- a/dev/BootLoader/Modules/SysChk/Module.cc
+++ b/dev/BootLoader/Modules/SysChk/Module.cc
@@ -8,15 +8,40 @@
*/
#include <BootKit/BootKit.h>
+#include <Modules/GfxMgr/FBMgr.h>
+#include <Modules/GfxMgr/TextMgr.h>
+#include <FirmwareKit/EFI.h>
+#include <FirmwareKit/EFI/API.h>
+#include <FirmwareKit/Handover.h>
+#include <KernelKit/MSDOS.h>
+#include <KernelKit/PE.h>
+#include <KernelKit/PEF.h>
+#include <NewKit/Macros.h>
+#include <NewKit/Ref.h>
+#include <BootKit/Thread.h>
+#include <Modules/GfxMgr/FBMgr.h>
EXTERN_C Int32 ModuleMain(Kernel::HEL::BootInfoHeader* Handover)
{
EfiSystemTable* system_table = (EfiSystemTable*)Handover->f_FirmwareCustomTables[1];
- system_table->ConOut->ClearScreen(system_table->ConOut);
+ EfiInputKey key{};
- system_table->ConOut->OutputString(system_table->ConOut, L"SYSCHK: CHECKING FOR VALID NEFS OR HPFS PARTITIONS...\r\n");
- system_table->ConOut->OutputString(system_table->ConOut, L"SYSCHK: GOOD TO GO!\r\n");
+ system_table->ConIn->ReadKeyStroke(system_table->ConIn, &key);
- return kEfiOk;
+ if (key.UnicodeChar == 'F' ||
+ key.UnicodeChar == 'f')
+ {
+ UI::ui_draw_background();
+
+ fb_init();
+
+ FBDrawBitMapInRegion(zka_no_disk, ZKA_NO_DISK_HEIGHT, ZKA_NO_DISK_WIDTH, (kHandoverHeader->f_GOP.f_Width - ZKA_NO_DISK_WIDTH) / 2, (kHandoverHeader->f_GOP.f_Height - ZKA_NO_DISK_HEIGHT) / 2);
+
+ fb_fini();
+
+ return kEfiOk;
+ }
+
+ return kEfiFail;
}
diff --git a/dev/BootLoader/src/BootThread.cc b/dev/BootLoader/src/BootThread.cc
index 6d78d0d1..ae494a15 100644
--- a/dev/BootLoader/src/BootThread.cc
+++ b/dev/BootLoader/src/BootThread.cc
@@ -122,7 +122,7 @@ namespace Boot
#ifdef __ZKA_AMD64__
if (handover_struc->HandoverArch != HEL::kArchAMD64)
{
- fb_render_string("BootZ: NOT AN HANDOVER IMAGE, BAD ARCHITECTURE...", 40, 10, RGB(0xFF, 0xFF, 0xFF));
+ fb_render_string("BootZ: Not an handover header, bad CPU...", 40, 10, RGB(0xFF, 0xFF, 0xFF));
::EFI::Stop();
}
#endif
@@ -130,11 +130,11 @@ namespace Boot
#ifdef __ZKA_ARM64__
if (handover_struc->HandoverArch != HEL::kArchARM64)
{
- fb_render_string("BootZ: NOT AN HANDOVER IMAGE, BAD ARCHITECTURE...", 40, 10, RGB(0xFF, 0xFF, 0xFF));
+ fb_render_string("BootZ: Not an handover header, bad CPU...", 40, 10, RGB(0xFF, 0xFF, 0xFF));
::EFI::Stop();
}
#endif
- fb_render_string("BootZ: NOT AN HANDOVER IMAGE...", 40, 10, RGB(0xFF, 0xFF, 0xFF));
+ fb_render_string("BootZ: Not an handover header...", 40, 10, RGB(0xFF, 0xFF, 0xFF));
::EFI::Stop();
}
@@ -160,18 +160,20 @@ namespace Boot
}
else
{
- writer.Write("BootZ: INVALID EXECUTABLE.\r");
+ writer.Write("BootZ: Invalid Executable.\r");
}
fStack = new UInt8[mib_cast(8)];
}
/// @note handover header has to be valid!
- Void BThread::Start(HEL::BootInfoHeader* handover, Bool own_stack)
+ Int32 BThread::Start(HEL::BootInfoHeader* handover, Bool own_stack)
{
- HEL::HandoverProc err_fn = [](HEL::BootInfoHeader* rcx) -> void {
- fb_render_string("BootZ: INVALID IMAGE! ABORTING...", 50, 10, RGB(0xFF, 0xFF, 0xFF));
+ HEL::HandoverProc err_fn = [](HEL::BootInfoHeader* rcx) -> Int32 {
+ fb_render_string("BootZ: Invalid Boot Image...", 50, 10, RGB(0xFF, 0xFF, 0xFF));
::EFI::Stop();
+
+ return NO;
};
if (!fStartAddress)
@@ -182,12 +184,16 @@ namespace Boot
fHandover = handover;
if (own_stack)
+ {
rt_jump_to_address(fStartAddress, fHandover, &fStack[mib_cast(8) - 1]);
+ }
else
{
delete[] fStack;
- reinterpret_cast<HEL::HandoverProc>(fStartAddress)(fHandover);
+ return reinterpret_cast<HEL::HandoverProc>(fStartAddress)(fHandover);
}
+
+ return NO;
}
const Char* BThread::GetName()
diff --git a/dev/BootLoader/src/HEL/AMD64/BootMain.cc b/dev/BootLoader/src/HEL/AMD64/BootMain.cc
index dd7528d8..023976ae 100644
--- a/dev/BootLoader/src/HEL/AMD64/BootMain.cc
+++ b/dev/BootLoader/src/HEL/AMD64/BootMain.cc
@@ -157,40 +157,12 @@ EFI_EXTERN_C EFI_API Int32 Main(EfiHandlePtr ImageHandle,
handover_hdr->f_HardwareTables.f_MultiProcessingEnabled = cnt_enabled > 1;
// Fill handover header now.
- Boot::BDiskFormatFactory<BootDeviceATA> partition_factory;
-
// ---------------------------------------------------- //
// The following checks for an exisiting partition
// inside the disk, if it doesn't have one,
// format the disk.
// ---------------------------------------------------- //
-#ifdef ZKA_AUTO_FORMAT
- if (!partition_factory.IsPartitionValid())
- {
- UI::ui_draw_background();
-
- FBDrawBitMapInRegion(zka_no_disk, ZKA_NO_DISK_HEIGHT, ZKA_NO_DISK_WIDTH, (kHandoverHeader->f_GOP.f_Width - ZKA_NO_DISK_WIDTH) / 2, (kHandoverHeader->f_GOP.f_Height - ZKA_NO_DISK_HEIGHT) / 2);
-
- fb_fini();
-
- Boot::BDiskFormatFactory<BootDeviceATA>::BFileDescriptor root{};
-
- root.fFileName[0] = kNeFSRoot[0];
- root.fFileName[1] = 0;
-
- root.fKind = kNeFSCatalogKindDir;
-
- partition_factory.Format("FileSystem (A:)\0", &root, 1);
-
- UI::ui_draw_background();
-
- FBDrawBitMapInRegion(zka_has_disk, ZKA_HAS_DISK_HEIGHT, ZKA_HAS_DISK_WIDTH, (kHandoverHeader->f_GOP.f_Width - ZKA_HAS_DISK_WIDTH) / 2, (kHandoverHeader->f_GOP.f_Height - ZKA_HAS_DISK_HEIGHT) / 2);
-
- fb_fini();
- }
-#endif // ZKA_AUTO_FORMAT
-
BS->GetMemoryMap(&size_struct_ptr, struct_ptr, &map_key, &sz_desc, &rev_desc);
struct_ptr = new EfiMemoryDescriptor[sz_desc];
@@ -243,10 +215,31 @@ EFI_EXTERN_C EFI_API Int32 Main(EfiHandlePtr ImageHandle,
if (reader_syschk.Blob())
{
syschk_thread = new Boot::BThread(reader_syschk.Blob());
- syschk_thread->SetName("BootZ: System Check");
+ syschk_thread->SetName("BootZ: System Recovery Check");
}
- syschk_thread->Start(handover_hdr, NO);
+ Boot::BDiskFormatFactory<BootDeviceATA> partition_factory;
+
+ if (partition_factory.IsPartitionValid() == false &&
+ syschk_thread->Start(handover_hdr, NO) == kEfiOk)
+ {
+ fb_init();
+
+ Boot::BDiskFormatFactory<BootDeviceATA>::BFileDescriptor root{};
+
+ root.fFileName[0] = kNeFSRoot[0];
+ root.fFileName[1] = 0;
+
+ root.fKind = kNeFSCatalogKindDir;
+
+ partition_factory.Format("FileSystem (A:) <System_Build\"" __DATE__ "\">", &root, 1);
+
+ UI::ui_draw_background();
+
+ FBDrawBitMapInRegion(zka_has_disk, ZKA_HAS_DISK_HEIGHT, ZKA_HAS_DISK_WIDTH, (kHandoverHeader->f_GOP.f_Width - ZKA_HAS_DISK_WIDTH) / 2, (kHandoverHeader->f_GOP.f_Height - ZKA_HAS_DISK_HEIGHT) / 2);
+
+ fb_fini();
+ }
// ------------------------------------------ //
// null these fields, to avoid being reused later.
@@ -289,7 +282,7 @@ EFI_EXTERN_C EFI_API Int32 Main(EfiHandlePtr ImageHandle,
else
{
fb_init();
- FBDrawBitMapInRegion(zka_no_disk, ZKA_NO_DISK_HEIGHT, ZKA_NO_DISK_WIDTH, (kHandoverHeader->f_GOP.f_Width - ZKA_NO_DISK_WIDTH) / 2, (kHandoverHeader->f_GOP.f_Height - ZKA_NO_DISK_HEIGHT) / 2);
+ FBDrawBitMapInRegion(zka_no_disk, ZKA_NO_DISK_HEIGHT, ZKA_NO_DISK_WIDTH, (kHandoverHeader->f_GOP.f_Width - ZKA_NO_DISK_WIDTH) / 2, (kHandoverHeader->f_GOP.f_Height - ZKA_NO_DISK_HEIGHT) / 2);
EFI::Stop();
}
@@ -300,16 +293,16 @@ EFI_EXTERN_C EFI_API Int32 Main(EfiHandlePtr ImageHandle,
if (ttf_font.Blob())
{
- handover_hdr->f_KernelImage = reader_kernel.Blob();
- handover_hdr->f_KernelSz = reader_kernel.Size();
- handover_hdr->f_FontImage = ttf_font.Blob();
- handover_hdr->f_FontSz = ttf_font.Size();
+ handover_hdr->f_KernelImage = reader_kernel.Blob();
+ handover_hdr->f_KernelSz = reader_kernel.Size();
+ handover_hdr->f_FontImage = ttf_font.Blob();
+ handover_hdr->f_FontSz = ttf_font.Size();
}
else
{
fb_init();
FBDrawBitMapInRegion(zka_no_disk, ZKA_NO_DISK_HEIGHT, ZKA_NO_DISK_WIDTH, (kHandoverHeader->f_GOP.f_Width - ZKA_NO_DISK_WIDTH) / 2, (kHandoverHeader->f_GOP.f_Height - ZKA_NO_DISK_HEIGHT) / 2);
-
+
EFI::Stop();
}
diff --git a/dev/Kernel/FirmwareKit/EFI/EFI.h b/dev/Kernel/FirmwareKit/EFI/EFI.h
index befa4e87..2e168bcd 100644
--- a/dev/Kernel/FirmwareKit/EFI/EFI.h
+++ b/dev/Kernel/FirmwareKit/EFI/EFI.h
@@ -42,6 +42,7 @@ struct EfiHandle;
struct EfiGraphicsOutputProtocol;
struct EfiBitmask;
struct EfiFileProtocol;
+struct EfiSimpleTextInputProtocol;
typedef UInt64 EfiStatusType;
@@ -473,6 +474,14 @@ typedef struct EfiGUID EFI_FINAL
* Protocol stuff...
*/
+#define EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID \
+ { \
+ 0x387477c1, 0x69c7, 0x11d2, \
+ { \
+ 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b \
+ } \
+ }
+
/** some helpers */
#define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001
#define EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002
@@ -563,6 +572,36 @@ typedef struct EfiSimpleTextOutputProtocol
VoidPtr Mode;
} EfiSimpleTextOutputProtocol;
+typedef struct
+{
+ UInt16 ScanCode;
+ char16_t UnicodeChar;
+} EfiInputKey;
+
+typedef EfiStatusType(EFI_API* EfiInputReadKey)(
+ IN EfiSimpleTextInputProtocol* This,
+ OUT EfiInputKey* Key);
+
+typedef EfiStatusType(EFI_API* EfiInputReset)(
+ IN EfiSimpleTextInputProtocol* This,
+ IN Boolean ExtendedChk );
+
+typedef
+EfiStatusType
+(EFI_API *EfiWaitForEvent) (
+ IN UInt32 NumberOfEvents,
+ IN VoidPtr Event,
+ OUT UInt32 *Index
+ );
+
+typedef struct EfiSimpleTextInputProtocol
+{
+ EfiInputReset Reset;
+ EfiInputReadKey ReadKeyStroke;
+ EfiWaitForEvent WaitForKey;
+} EfiSimpleTextInputProtocol;
+
+/// @biref Open Volume procedure ptr.
typedef UInt64(EFI_API* EfiOpenVolume)(struct EfiSimpleFilesystemProtocol*,
struct EfiFileProtocol**);
@@ -581,7 +620,7 @@ typedef struct EfiSystemTable
WideChar* FirmwareVendor;
UInt32 FirmwareRevision;
EfiHandlePtr ConsoleInHandle;
- VoidPtr ConIn;
+ EfiSimpleTextInputProtocol* ConIn;
EfiHandlePtr ConsoleOutHandle;
EfiSimpleTextOutputProtocol* ConOut;
EfiHandlePtr StandardErrorHandle;
@@ -826,11 +865,11 @@ typedef struct _EfiProcessorInformation
typedef EfiStatusType EFI_API (*EfiMpServicesGetNumberOfProcessors)(
IN struct _EfiMpServicesProtocol* Self,
- OUT UInt32* NumberOfProcessors,
- OUT UInt32* NumberOfEnabledProcessors);
+ OUT UInt32* NumberOfProcessors,
+ OUT UInt32* NumberOfEnabledProcessors);
typedef EfiStatusType EFI_API (*EfiMpServicesGetProcessorInfo)(
- IN struct _EfiMpServicesProtocol* Self,
+ IN struct _EfiMpServicesProtocol* Self,
IN UInt32* ProcessorNumber,
OUT struct _EfiProcessorInformation* NumberOfEnabledProcessors);
@@ -843,8 +882,8 @@ typedef EfiStatusType EFI_API (*EfiMpServicesStartupAllAPS)(
IN Boolean SingleThread,
IN VoidPtr WaitEvent OPTIONAL, // EFI_EVENT first, but unused here.
IN UInt32 TimeoutInMicroSeconds,
- IN Void* ProcedureArgument OPTIONAL,
- OUT UInt32** FailedCpuList OPTIONAL);
+ IN Void* ProcedureArgument OPTIONAL,
+ OUT UInt32** FailedCpuList OPTIONAL);
typedef EfiStatusType EFI_API (*EfiMpServicesSwitchBSP)(
IN struct _EfiMpServicesProtocol* Self,
@@ -857,18 +896,18 @@ typedef EfiStatusType EFI_API (*EfiMpServicesStartupThisAP)(
IN UInt32 ProcessorNumber,
IN VoidPtr WaitEvent OPTIONAL,
IN UInt32 TimeoutInMicroseconds,
- IN Void* ProcedureArgument OPTIONAL,
- OUT Boolean* Finished OPTIONAL);
+ IN Void* ProcedureArgument OPTIONAL,
+ OUT Boolean* Finished OPTIONAL);
typedef EfiStatusType EFI_API (*EfiMpServicesDisableThisAP)(
IN struct _EfiMpServicesProtocol* Self,
IN UInt32 ProcessorNumber,
IN Boolean EnableAP,
- IN UInt32* HealthFlag OPTIONAL);
+ IN UInt32* HealthFlag OPTIONAL);
typedef EfiStatusType EFI_API (*EfiMpServicesWhoAmI)(
IN struct _EfiMpServicesProtocol* Self,
- OUT UInt32* ProcessorNumber);
+ OUT UInt32* ProcessorNumber);
typedef struct _EfiMpServicesProtocol
{
diff --git a/dev/Kernel/FirmwareKit/Handover.h b/dev/Kernel/FirmwareKit/Handover.h
index 86650d34..9a7e7e80 100644
--- a/dev/Kernel/FirmwareKit/Handover.h
+++ b/dev/Kernel/FirmwareKit/Handover.h
@@ -103,7 +103,7 @@ namespace Kernel::HEL
};
/// @brief Alias of bootloader main type.
- typedef void (*HandoverProc)(BootInfoHeader* boot_info);
+ typedef Int32 (*HandoverProc)(BootInfoHeader* boot_info);
} // namespace Kernel::HEL
/// @brief Bootloader information header global variable.
diff --git a/dev/Kernel/HALKit/AMD64/HalKernelMain.cc b/dev/Kernel/HALKit/AMD64/HalKernelMain.cc
index 75c41433..690ece70 100644
--- a/dev/Kernel/HALKit/AMD64/HalKernelMain.cc
+++ b/dev/Kernel/HALKit/AMD64/HalKernelMain.cc
@@ -11,7 +11,6 @@
#include <Modules/ACPI/ACPIFactoryInterface.h>
#include <NetworkKit/IPC.h>
#include <CFKit/Property.h>
-#include <Modules/GfxMgr/AppearanceMgr.h>
#include <Modules/GfxMgr/TextMgr.h>
EXTERN_C Kernel::VoidPtr kInterruptVectorTable[];
@@ -84,8 +83,6 @@ EXTERN_C void hal_init_platform(
EXTERN_C Kernel::Void hal_real_init(Kernel::Void) noexcept
{
- UI::ui_draw_background();
-
auto str_proc = Kernel::rt_alloc_string("System");
Kernel::rtl_create_process(rtl_kernel_main, str_proc);
diff --git a/dev/Kernel/HALKit/AMD64/HalTimerAMD64.cc b/dev/Kernel/HALKit/AMD64/HalTimerAMD64.cc
index 97da8c48..9e42fe3f 100644
--- a/dev/Kernel/HALKit/AMD64/HalTimerAMD64.cc
+++ b/dev/Kernel/HALKit/AMD64/HalTimerAMD64.cc
@@ -62,10 +62,10 @@ HardwareTimer::~HardwareTimer()
fWaitFor = 0;
}
-Int32 HardwareTimer::Wait() noexcept
+BOOL HardwareTimer::Wait() noexcept
{
if (fWaitFor < 1)
- return 1;
+ return NO;
// if not enabled yet.
if (!(*(fDigitalTimer + cHPETConfigRegValue) & (1 << 0)))
@@ -82,5 +82,5 @@ Int32 HardwareTimer::Wait() noexcept
while (*(fDigitalTimer + cHPETCounterRegValue) < (ticks))
;
- return 0;
+ return YES;
}
diff --git a/dev/Kernel/HALKit/ARM64/HalKernelMain.cc b/dev/Kernel/HALKit/ARM64/HalKernelMain.cc
index ff4676e4..4a81fa64 100644
--- a/dev/Kernel/HALKit/ARM64/HalKernelMain.cc
+++ b/dev/Kernel/HALKit/ARM64/HalKernelMain.cc
@@ -15,7 +15,6 @@
#include <KernelKit/CodeMgr.h>
#include <Modules/ACPI/ACPIFactoryInterface.h>
#include <NetworkKit/IPC.h>
-#include <Modules/GfxMgr/AppearanceMgr.h>
#include <CFKit/Property.h>
Kernel::Void hal_real_init(Kernel::Void) noexcept;
@@ -47,8 +46,6 @@ EXTERN_C void hal_init_platform(
/// @note do initialize the interrupts after it.
- UI::ui_draw_background();
-
auto str_proc = Kernel::rt_alloc_string("System");
Kernel::rtl_create_process(rtl_kernel_main, str_proc);
diff --git a/dev/Kernel/KernelKit/Timer.h b/dev/Kernel/KernelKit/Timer.h
index a2dae8cd..db8b49fe 100644
--- a/dev/Kernel/KernelKit/Timer.h
+++ b/dev/Kernel/KernelKit/Timer.h
@@ -26,7 +26,7 @@ namespace Kernel
ZKA_COPY_DEFAULT(TimerInterface);
public:
- virtual Int32 Wait() noexcept;
+ virtual BOOL Wait() noexcept;
};
class SoftwareTimer final : public TimerInterface
@@ -39,7 +39,7 @@ namespace Kernel
ZKA_COPY_DEFAULT(SoftwareTimer);
public:
- Int32 Wait() noexcept override;
+ BOOL Wait() noexcept override;
private:
IntPtr* fDigitalTimer{nullptr};
@@ -56,7 +56,7 @@ namespace Kernel
ZKA_COPY_DEFAULT(HardwareTimer);
public:
- Int32 Wait() noexcept override;
+ BOOL Wait() noexcept override;
private:
IntPtr* fDigitalTimer{nullptr};
diff --git a/dev/Kernel/src/KernelMain.cc b/dev/Kernel/src/KernelMain.cc
index d3498f24..fdbda512 100644
--- a/dev/Kernel/src/KernelMain.cc
+++ b/dev/Kernel/src/KernelMain.cc
@@ -22,7 +22,6 @@
#include <NewKit/Utils.h>
#include <KernelKit/CodeMgr.h>
#include <CFKit/Property.h>
-#include <Modules/GfxMgr/AppearanceMgr.h>
#include <KernelKit/Timer.h>
namespace Kernel::Detail
diff --git a/dev/Kernel/src/SoftwareTimer.cc b/dev/Kernel/src/SoftwareTimer.cc
new file mode 100644
index 00000000..797722d3
--- /dev/null
+++ b/dev/Kernel/src/SoftwareTimer.cc
@@ -0,0 +1,39 @@
+/* -------------------------------------------
+
+ Copyright (C) 2024, Theater Quality Inc, all rights reserved.
+
+------------------------------------------- */
+
+#include <KernelKit/Timer.h>
+
+/// @brief SoftwareTimer class, meant to be generic.
+
+using namespace Kernel;
+
+SoftwareTimer::SoftwareTimer(Int64 seconds)
+ : fWaitFor(seconds)
+{
+ fDigitalTimer = new IntPtr();
+ MUST_PASS(fDigitalTimer);
+}
+
+SoftwareTimer::~SoftwareTimer()
+{
+ delete fDigitalTimer;
+ fDigitalTimer = nullptr;
+
+ fWaitFor = 0;
+}
+
+BOOL SoftwareTimer::Wait() noexcept
+{
+ if (fWaitFor < 1)
+ return NO;
+
+ while (*fDigitalTimer < (*fDigitalTimer + fWaitFor))
+ {
+ ++(*fDigitalTimer);
+ }
+
+ return YES;
+}
diff --git a/dev/Kernel/src/Timer.cc b/dev/Kernel/src/Timer.cc
index 8795dd66..d304f6ee 100644
--- a/dev/Kernel/src/Timer.cc
+++ b/dev/Kernel/src/Timer.cc
@@ -13,35 +13,7 @@
using namespace Kernel;
/// @brief Unimplemented as it is an interface.
-Int32 TimerInterface::Wait() noexcept
+BOOL TimerInterface::Wait() noexcept
{
- return kErrorUnimplemented;
-}
-
-/// @brief SoftwareTimer class, meant to be generic.
-
-SoftwareTimer::SoftwareTimer(Int64 seconds)
- : fWaitFor(seconds)
-{
- fDigitalTimer = new IntPtr();
- MUST_PASS(fDigitalTimer);
-}
-
-SoftwareTimer::~SoftwareTimer()
-{
- delete fDigitalTimer;
- fWaitFor = 0;
-}
-
-Int32 SoftwareTimer::Wait() noexcept
-{
- if (fWaitFor < 1)
- return 1;
-
- while (*fDigitalTimer < (*fDigitalTimer + fWaitFor))
- {
- ++(*fDigitalTimer);
- }
-
- return 0;
+ return NO;
}
diff --git a/dev/Modules/GfxMgr/AppearanceMgr.h b/dev/Modules/GfxMgr/AppearanceMgr.h
deleted file mode 100644
index 2318231d..00000000
--- a/dev/Modules/GfxMgr/AppearanceMgr.h
+++ /dev/null
@@ -1,266 +0,0 @@
-/* -------------------------------------------
-
- Copyright Theater Quality Inc.
-
-------------------------------------------- */
-
-#pragma once
-
-#include <Modules/GfxMgr/AccessibilityMgr.h>
-#include <KernelKit/Heap.h>
-#include <KernelKit/UserProcessScheduler.h>
-#include <KernelKit/LPC.h>
-#include <NewKit/Defines.h>
-#include <NewKit/Utils.h>
-#include <Modules/GfxMgr/FBMgr.h>
-#include <Modules/GfxMgr/Rsrc/Controls.rsrc>
-#include <Modules/GfxMgr/TextMgr.h>
-
-namespace UI
-{
- using namespace Kernel;
-
- struct UIObject;
-
- enum
- {
- kUIFlagNoShow = 0x02,
- kUIFlagButton = 0x04,
- kUIFlagWindow = 0x06,
- kUIFlagButtonSelect = 0x08,
- kUIFlagHideCloseControl = 0x010,
- kUIFlagCloseControlSelect = 0x012,
- };
-
- struct UIObject final
- {
- Char w_window_name[255]{0};
- Char w_class_name[255]{0};
- Int32 w_type{0};
- Int32 w_sub_type{0};
- Int32 w_x{0};
- Int32 w_y{0};
- Int32 w_w{0};
- Int32 w_h{0};
- Int32 w_display_ptr_w{0};
- Int32 w_display_ptr_h{0};
- SizeT w_child_count{0};
- struct UIObject* w_child_elements[255]{0};
- struct UIObject* w_parent{nullptr};
- UInt32* w_display_ptr{nullptr};
- Bool w_needs_repaint{false};
-
- Void (*w_display_custom_draw)(struct UIObject* am_win){nullptr};
- };
-
- typedef struct UIObject UIObject;
-
- inline Void ui_draw_background() noexcept
- {
- fb_init();
-
- FBDrawInRegion(fb_get_clear_clr(), UI::UIAccessibilty::Height(), UI::UIAccessibilty::Width(),
- 0, 0);
-
- fb_fini();
- }
-
- inline struct UIObject* ui_create_object(Int32 kind, const Char* obj_name, const Char* class_name, Int32 x, Int32 y, Int32 width, Int32 height, UIObject* parent = nullptr)
- {
- UIObject* obj = new UIObject();
-
- if (!obj)
- {
- err_local_get() = kErrorHeapOutOfMemory;
- return nullptr;
- }
-
- rt_copy_memory((VoidPtr)obj_name, obj->w_window_name, rt_string_len(obj_name));
- rt_copy_memory((VoidPtr)class_name, obj->w_class_name, rt_string_len(class_name));
-
- if (parent)
- {
- obj->w_parent = parent;
-
- ++obj->w_parent->w_child_count;
- obj->w_parent->w_child_elements[obj->w_parent->w_child_count - 1] = obj;
- }
-
- obj->w_sub_type = 0;
- obj->w_type = kind;
- obj->w_x = x;
- obj->w_y = y;
- obj->w_display_ptr = nullptr;
- obj->w_w = width;
- obj->w_h = height;
- obj->w_display_custom_draw = nullptr;
-
- return obj;
- }
-
- inline bool ui_destroy_object(struct UIObject* obj)
- {
- if (obj)
- {
- delete obj;
-
- if (!mm_is_valid_heap(obj))
- {
- obj = nullptr;
- return false;
- }
-
- obj = nullptr;
- return true;
- }
-
- return false;
- }
-
- inline Kernel::Void ui_render_text(UIObject* obj, const Kernel::Char* text, Kernel::Int32 y_dst, Kernel::Int32 x_dst, Kernel::Int32 color)
- {
- y_dst += obj->w_y + FLAT_CONTROLS_HEIGHT;
- x_dst += obj->w_x;
-
- if (y_dst > (obj->w_h + obj->w_y))
- return;
-
- for (Kernel::SizeT i = 0; text[i] != 0; ++i)
- {
- if (x_dst > (obj->w_w + obj->w_x))
- break;
-
- fb_render_string_for_bitmap(&kFontBitmap[text[i]][0], FONT_SIZE_X, FONT_SIZE_Y, y_dst, x_dst, color);
- x_dst += FONT_SIZE_X;
- }
- }
-
- inline SizeT ui_render_object(UIObject* obj)
- {
- if (!obj ||
- (obj->w_type == kUIFlagNoShow) ||
- !obj->w_needs_repaint)
- return 1;
-
- fb_init();
-
- obj->w_needs_repaint = false;
-
- kcout << "Begin paint\r";
-
- if (UIAccessibilty::Width() < obj->w_x)
- {
- if ((obj->w_x - UIAccessibilty::Width()) > 1)
- {
- obj->w_x -= obj->w_x - UIAccessibilty::Width();
- }
- else
- {
- obj->w_x = 0;
- }
- }
-
- if (UIAccessibilty::Height() < obj->w_y)
- {
- if ((obj->w_y - UIAccessibilty::Height()) > 1)
- {
- obj->w_y -= obj->w_y - UIAccessibilty::Width();
- }
- else
- {
- obj->w_y = 0;
- }
- }
-
- // Draw fake controls, just for the looks of it (WINDOW ONLY)
- if (obj->w_type == kUIFlagWindow)
- {
- kcout << "Begin paint window\r";
-
- if (!obj->w_display_custom_draw)
- {
- if (obj->w_display_ptr)
- {
- FBDrawInRegion(fb_color(0xDF, 0xDF, 0xDF), obj->w_h, obj->w_w, obj->w_x, obj->w_y);
- FBDrawBitMapInRegion(obj->w_display_ptr, obj->w_display_ptr_h, obj->w_display_ptr_w, obj->w_x, obj->w_y);
- }
- else
- {
- FBDrawInRegion(fb_color(0xDF, 0xDF, 0xDF), obj->w_w, obj->w_h, obj->w_y, obj->w_x);
- }
-
- FBDrawInRegion(fb_color(0xFF, 0xFF, 0xFF), obj->w_w, FLAT_CONTROLS_HEIGHT, obj->w_y, obj->w_x);
-
- if (obj->w_sub_type != kUIFlagHideCloseControl)
- {
- FBDrawBitMapInRegion(zka_flat_controls, FLAT_CONTROLS_HEIGHT, FLAT_CONTROLS_WIDTH, obj->w_y, obj->w_x + obj->w_w - FLAT_CONTROLS_WIDTH);
- }
- else if (obj->w_sub_type == kUIFlagCloseControlSelect)
- {
- FBDrawBitMapInRegion(zka_flat_controls_active, FLAT_CONTROLS_CLOSE_HEIGHT, FLAT_CONTROLS_CLOSE_WIDTH, obj->w_y, obj->w_x + obj->w_w - FLAT_CONTROLS_WIDTH);
- }
-
- fb_render_string(obj->w_window_name, obj->w_x + 8, obj->w_y + 8, fb_color(0x00, 0x00, 0x00));
- }
- else
- {
- obj->w_display_custom_draw(obj);
- }
- }
- /// @note buttons in this library are dynamic, it's because we want to avoid as much as computations as possible.
- /// (Such as getting the middle coordinates of a button, to center the text.)
- else if (obj->w_type == kUIFlagButtonSelect)
- {
- auto x_center = obj->w_x + 6;
- auto y_center = obj->w_y + 7;
-
- if (!obj->w_display_custom_draw)
- {
- FBDrawInRegion(fb_color(0xD3, 0x74, 0x00), obj->w_w + 1, obj->w_h + 1, obj->w_x, obj->w_y);
- FBDrawInRegion(fb_color(0xFF, 0xFF, 0xFF), obj->w_w - 1, obj->w_h - 1, obj->w_x + 1, obj->w_y + 1);
- ui_render_text(obj, obj->w_window_name, y_center, x_center, fb_color(0x00, 0x00, 0x00));
- }
- else
- {
- obj->w_display_custom_draw(obj);
- }
- }
- else if (obj->w_type == kUIFlagButton)
- {
- auto x_center = obj->w_x + 6;
- auto y_center = obj->w_y + 7;
-
- if (!obj->w_display_custom_draw)
- {
- FBDrawInRegion(fb_color(0xDC, 0xDC, 0xDC), obj->w_w + 1, obj->w_h + 1, obj->w_y, obj->w_x);
- FBDrawInRegion(fb_color(0xFF, 0xFF, 0xFF), obj->w_w - 1, obj->w_h - 1, obj->w_y + 1, obj->w_x + 1);
- fb_render_string(obj->w_window_name, y_center, x_center, fb_color(0x00, 0x00, 0x00));
- }
- else
- {
- obj->w_display_custom_draw(obj);
- }
- }
-
- fb_fini();
-
- // draw child windows and controls.
- // doesn't have to be a window, enabling then windows in windows.
-
- for (SizeT child = 0; child < obj->w_child_count; ++child)
- {
- obj->w_child_elements[child]->w_x += obj->w_x;
- obj->w_child_elements[child]->w_y += obj->w_y + FLAT_CONTROLS_HEIGHT;
-
- if ((obj->w_child_elements[child]->w_w + obj->w_child_elements[child]->w_x) > (obj->w_x + obj->w_w) ||
- (obj->w_child_elements[child]->w_h + obj->w_child_elements[child]->w_y) > (obj->w_y + obj->w_h))
- continue;
-
- ui_render_object(obj->w_child_elements[child]);
- }
-
- fb_fini();
-
- return 0;
- }
-} // namespace CG
diff --git a/dev/Modules/GfxMgr/FBMgr.h b/dev/Modules/GfxMgr/FBMgr.h
index f5cdf4d2..0b685ee0 100644
--- a/dev/Modules/GfxMgr/FBMgr.h
+++ b/dev/Modules/GfxMgr/FBMgr.h
@@ -139,3 +139,19 @@
4 * y_base))) |= _Clr; \
} \
}
+
+#include <Modules/GfxMgr/AccessibilityMgr.h>
+
+namespace UI
+{
+ inline void ui_draw_background() noexcept
+ {
+ fb_init();
+
+ FBDrawInRegion(fb_get_clear_clr(), UI::UIAccessibilty::Height(), UI::UIAccessibilty::Width(),
+ 0, 0);
+
+ fb_fini();
+ }
+
+} // namespace UI \ No newline at end of file