diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2025-03-24 05:08:21 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2025-03-24 05:08:21 +0100 |
| commit | 77a1bd038f4288a7c24cfe52ad9824ca947c6671 (patch) | |
| tree | d7e3fe10fce24ddc6a2b3db15a6dc9d6aeee2451 | |
| parent | 66be78af046c20bd110793c03062a3ff67b04f9c (diff) | |
kernel(feat): Add basic wide system bug check (memory check), other
changes have been made too, see commit details for more information.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
60 files changed, 166 insertions, 215 deletions
@@ -2,7 +2,6 @@ syntax: glob xcuserdata/ -public/tools/diutil/dist/diutil *.hmap *.ipa @@ -15,7 +14,8 @@ public/tools/diutil/dist/diutil */xcuserdata/* *.xcworkspacedata -public/tools/make_app/dist/make_app +public/tools/*/dist/* +public/frameworks/*/dist/* neoskrnl/neoskrnl.xcodeproj/project.xcworkspace/xcshareddata/ @@ -14,7 +14,7 @@ Use the doxygen command to build documentation. ## Notice for Contributors: -- You must mount the contents to the neos.img prior running! Otherwise the emulator won't find a valid ESP. +- You must mount the contents to the neos_esp.img prior running! Otherwise the emulator won't find a valid ESP. - Always use `run_format.sh` before commiting and pushing your code! ## Quick Install: diff --git a/dev/SCIKit/CompilerHint.h b/dev/SCIKit/CompilerHint.h deleted file mode 100644 index a78e59bf..00000000 --- a/dev/SCIKit/CompilerHint.h +++ /dev/null @@ -1,12 +0,0 @@ -/* ------------------------------------------- - - Copyright (C) 2024-2025, Amlal EL Mahrouss, all rights reserved. - -------------------------------------------- */ - -#ifndef SCI_HINT_H -#define SCI_HINT_H - -#include <HintsKit/CompilerHint.h> - -#endif // ifndef SCI_HINT_H diff --git a/dev/SCIKit/LPC.h b/dev/SCIKit/LPC.h index 044d272e..b0bb2d83 100644 --- a/dev/SCIKit/LPC.h +++ b/dev/SCIKit/LPC.h @@ -9,7 +9,7 @@ #include <SCIKit/Macros.h> /// @file LPC.h -/// @brief Local Process Code type and values. +/// @brief Local Procedure Code type and values. #define err_local_ok() (kLastError == kErrorSuccess) #define err_local_fail() (kLastError != kErrorSuccess) diff --git a/dev/SCIKit/Macros.h b/dev/SCIKit/Macros.h index c7bd61e8..174d644a 100644 --- a/dev/SCIKit/Macros.h +++ b/dev/SCIKit/Macros.h @@ -11,10 +11,10 @@ Purpose: libsci Macros header. /***********************************************************************************/ /// @file SCIKit/Macros.h -/// @brief Macros and core types. +/// @brief Macros and Core types. /***********************************************************************************/ -#include <SCIKit/CompilerHint.h> +#include <HintsKit/CompilerHint.h> #define ATTRIBUTE(X) __attribute__((X)) @@ -23,10 +23,10 @@ Purpose: libsci Macros header. #define DEPRECATED ATTRIBUTE(deprecated) -#define EXIT_SUCCESS 0 -#define EXIT_FAILURE 1 +#define EXIT_SUCCESS (0) +#define EXIT_FAILURE (1) -#define FILE_MAX_LEN 256 +#define FILE_MAX_LEN (256) #ifndef BOOL #define BOOL bool @@ -37,8 +37,8 @@ typedef bool Boolean; typedef void Void; #ifndef __cplusplus -#define true 1 -#define false 0 +#define true (1) +#define false (0) #endif #define YES true @@ -87,7 +87,7 @@ IMPORT_C void _rtl_assert(Bool expr, const Char* origin); #define MUST_PASS(X) _rtl_assert(X, __FILE__) #ifndef ARRAY_SIZE -#define ARRAY_SIZE(a) \ - (((sizeof(a) / sizeof(*(a))) / \ - (static_cast<SizeT>(!(sizeof(a) % sizeof(*(a))))))) +#define ARRAY_SIZE(X) \ + (((sizeof(X) / sizeof(*(X))) / \ + (static_cast<SizeT>(!(sizeof(X) % sizeof(*(X))))))) #endif
\ No newline at end of file diff --git a/dev/SCIKit/SCI.h b/dev/SCIKit/SystemCalls.h index 3e769262..7615a2d1 100644 --- a/dev/SCIKit/SCI.h +++ b/dev/SCIKit/SystemCalls.h @@ -2,7 +2,7 @@ Copyright (C) 2024-2025, Amlal EL Mahrouss, all rights reserved.
-File: SCI.h
+File: SystemCalls.h
Purpose: System Call Interface.
------------------------------------------- */
@@ -336,4 +336,6 @@ IMPORT_C BOOL FsCreateAlias(const char* path, const char* from); IMPORT_C Char* StrFmt(const Char* fmt, ...);
+IMPORT_C UInt64 MathToNumber(const Char* in, const Char** endp, const SInt16 base);
+
#endif // ifndef SCI_SCI_H
diff --git a/dev/SCIKit/src/SCI.cc b/dev/SCIKit/src/SCI.cc index 3427ae4e..6556754d 100644 --- a/dev/SCIKit/src/SCI.cc +++ b/dev/SCIKit/src/SCI.cc @@ -4,7 +4,7 @@ ------------------------------------------- */
-#include <SCIKit/SCI.h>
+#include <SCIKit/SystemCalls.h>
/// @file libsci.cc
/// @brief Source file for the memory functions of the libsci.
diff --git a/dev/boot/amd64-desktop.make b/dev/boot/amd64-desktop.make index 212a61dc..22023923 100644 --- a/dev/boot/amd64-desktop.make +++ b/dev/boot/amd64-desktop.make @@ -28,7 +28,7 @@ BIOS=OVMF.fd IMG=epm-master-1.img IMG_2=epm-master-2.img -BOOT=./src/neos.img +BOOT=./src/neos_esp.img DISK_DRV = diff --git a/dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc b/dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc index da680afa..5880cc7c 100644 --- a/dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc +++ b/dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc @@ -30,7 +30,7 @@ /////////////////////////////////////////////////////////////////////////////////////// -//! NOTE: fGSI stands 'Field Global System Interrupt' +/// @brief The **HAL** namespace. /////////////////////////////////////////////////////////////////////////////////////// diff --git a/dev/kernel/HALKit/AMD64/MBCI/HalMBCI.cc b/dev/kernel/HALKit/AMD64/MBCI/HalMBCI.cc deleted file mode 100644 index 09632bc9..00000000 --- a/dev/kernel/HALKit/AMD64/MBCI/HalMBCI.cc +++ /dev/null @@ -1,7 +0,0 @@ -/* ------------------------------------------- - - Copyright (C) 2024-2025, Amlal EL Mahrouss, all rights reserved. - -------------------------------------------- */ - -#include <modules/MBCI/MBCI.h> diff --git a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc index 002266de..0180288c 100644 --- a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc +++ b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc @@ -18,7 +18,7 @@ #include <KernelKit/DeviceMgr.h> #include <KernelKit/DriveMgr.h> #include <KernelKit/UserProcessScheduler.h> -#include <KernelKit/LPC.h> +#include <KernelKit/KPC.h> #include <FirmwareKit/EPM.h> diff --git a/dev/kernel/HALKit/ARM64/APM/APM+IO.cc b/dev/kernel/HALKit/ARM64/APM/APM+IO.cc index 752f29f9..5fb45452 100644 --- a/dev/kernel/HALKit/ARM64/APM/APM+IO.cc +++ b/dev/kernel/HALKit/ARM64/APM/APM+IO.cc @@ -5,7 +5,7 @@ ------------------------------------------- */ #include <modules/APM/APM.h> -#include <KernelKit/LPC.h> +#include <KernelKit/KPC.h> using namespace NeOS; diff --git a/dev/kernel/HALKit/ARM64/MBCI/MBCI.cc b/dev/kernel/HALKit/ARM64/MBCI/MBCI.cc deleted file mode 100644 index d2df66e6..00000000 --- a/dev/kernel/HALKit/ARM64/MBCI/MBCI.cc +++ /dev/null @@ -1,7 +0,0 @@ -/* ------------------------------------------- - - Copyright (C) 2025, Amlal EL Mahrouss, all rights reserved. - -------------------------------------------- */ - -#include <modules/MBCI/MBCI.h>
\ No newline at end of file diff --git a/dev/kernel/HALKit/ARM64/ReadMe.md b/dev/kernel/HALKit/ARM64/ReadMe.md index c51229f2..a2807e5c 100644 --- a/dev/kernel/HALKit/ARM64/ReadMe.md +++ b/dev/kernel/HALKit/ARM64/ReadMe.md @@ -1,3 +1,3 @@ # ARM64 Hardware Abstraction Layer -- Supported Firmware: CoreBoot/EDK/OpenMobileBoot +- Supported Firmware: NeKernel CoreBoot/EDK diff --git a/dev/kernel/HALKit/POWER/ReadMe.md b/dev/kernel/HALKit/POWER/ReadMe.md index a9751581..a4919c4a 100644 --- a/dev/kernel/HALKit/POWER/ReadMe.md +++ b/dev/kernel/HALKit/POWER/ReadMe.md @@ -1,4 +1,4 @@ POWER Hardware Abstraction Layer - Supported CPU: POWER -- Supported Firmware: CoreBoot
\ No newline at end of file +- Supported Firmware: NeKernel CoreBoot
\ No newline at end of file diff --git a/dev/kernel/HALKit/RISCV/ReadMe.md b/dev/kernel/HALKit/RISCV/ReadMe.md index b099aa31..982a2acb 100644 --- a/dev/kernel/HALKit/RISCV/ReadMe.md +++ b/dev/kernel/HALKit/RISCV/ReadMe.md @@ -1,4 +1,4 @@ RISCV64 Hardware Abstraction Layer - Supported CPU: RISCV64 -- Supported Firmware: CoreBoot
\ No newline at end of file +- Supported Firmware: NeKernel CoreBoot
\ No newline at end of file diff --git a/dev/kernel/KernelKit/DriveMgr.h b/dev/kernel/KernelKit/DriveMgr.h index 87bd2714..fd972ab7 100644 --- a/dev/kernel/KernelKit/DriveMgr.h +++ b/dev/kernel/KernelKit/DriveMgr.h @@ -11,7 +11,7 @@ #include <CompilerKit/CompilerKit.h> #include <KernelKit/DebugOutput.h> #include <KernelKit/DeviceMgr.h> -#include <KernelKit/LPC.h> +#include <KernelKit/KPC.h> #include <NewKit/Defines.h> #include <NewKit/KString.h> #include <NewKit/Ref.h> diff --git a/dev/kernel/KernelKit/FileMgr.h b/dev/kernel/KernelKit/FileMgr.h index 7374df9d..59203998 100644 --- a/dev/kernel/KernelKit/FileMgr.h +++ b/dev/kernel/KernelKit/FileMgr.h @@ -31,7 +31,7 @@ #include <CompilerKit/CompilerKit.h> #include <HintsKit/CompilerHint.h> -#include <KernelKit/LPC.h> +#include <KernelKit/KPC.h> #include <KernelKit/DebugOutput.h> #include <NewKit/Stream.h> #include <NewKit/ErrorOr.h> diff --git a/dev/kernel/KernelKit/LPC.h b/dev/kernel/KernelKit/KPC.h index d76eeff1..9b62c14e 100644 --- a/dev/kernel/KernelKit/LPC.h +++ b/dev/kernel/KernelKit/KPC.h @@ -8,8 +8,8 @@ #include <NewKit/Defines.h> -/// @file LPC.h -/// @brief Local Process Codes. +/// @file KPC.h +/// @brief Kernel Procedure Code. #define err_local_ok() (NeOS::UserProcessScheduler::The().CurrentProcess().Leak().GetLocalCode() == NeOS::kErrorSuccess) #define err_local_fail() (NeOS::UserProcessScheduler::The().CurrentProcess().Leak().GetLocalCode() != NeOS::kErrorSuccess) @@ -60,11 +60,8 @@ namespace NeOS inline constexpr HError kErrorFileLocked = 64; inline constexpr HError kErrorUnimplemented = -1; - /// @brief Raises a bug check stop code. - Void err_bug_check_raise(Void) noexcept; - /// @brief Does a system wide bug check. /// @param void no params are needed. /// @return if error-free: false, otherwise true. - Boolean err_bug_check(Void) noexcept; + Boolean err_bug_check_raise(Void) noexcept; } // namespace NeOS diff --git a/dev/kernel/KernelKit/MemoryMgr.h b/dev/kernel/KernelKit/MemoryMgr.h index 93718493..139ae7aa 100644 --- a/dev/kernel/KernelKit/MemoryMgr.h +++ b/dev/kernel/KernelKit/MemoryMgr.h @@ -12,7 +12,7 @@ /// @brief: heap allocation support. #include <NewKit/KernelPanic.h> -#include <KernelKit/LPC.h> +#include <KernelKit/KPC.h> #include <HintsKit/CompilerHint.h> namespace NeOS diff --git a/dev/kernel/KernelKit/Timer.h b/dev/kernel/KernelKit/Timer.h index abca5352..e52f91e7 100644 --- a/dev/kernel/KernelKit/Timer.h +++ b/dev/kernel/KernelKit/Timer.h @@ -7,7 +7,7 @@ #pragma once #include <ArchKit/ArchKit.h> -#include <KernelKit/LPC.h> +#include <KernelKit/KPC.h> namespace NeOS { diff --git a/dev/kernel/KernelKit/User.h b/dev/kernel/KernelKit/User.h index 9ab2b02e..620b9bc9 100644 --- a/dev/kernel/KernelKit/User.h +++ b/dev/kernel/KernelKit/User.h @@ -16,7 +16,7 @@ ------------------------------------------- */ #include <CompilerKit/CompilerKit.h> -#include <KernelKit/LPC.h> +#include <KernelKit/KPC.h> #include <NewKit/KString.h> #include <NewKit/Defines.h> diff --git a/dev/kernel/NewKit/Defines.h b/dev/kernel/NewKit/Defines.h index 0b0b97e5..7758c053 100644 --- a/dev/kernel/NewKit/Defines.h +++ b/dev/kernel/NewKit/Defines.h @@ -27,7 +27,7 @@ #endif #endif -/// @brief The **Kernel** namespace where it's API resides. +/// @brief The **Kernel** namespace. namespace NeOS { using voidPtr = void*; diff --git a/dev/kernel/src/CxxAbi-AMD64.cc b/dev/kernel/src/CxxAbi-AMD64.cc index f0e57077..555c613f 100644 --- a/dev/kernel/src/CxxAbi-AMD64.cc +++ b/dev/kernel/src/CxxAbi-AMD64.cc @@ -8,7 +8,7 @@ #include <KernelKit/DebugOutput.h> #include <NewKit/CxxAbi.h> -#include <KernelKit/LPC.h> +#include <KernelKit/KPC.h> atexit_func_entry_t __atexit_funcs[kAtExitMacDestructors]; diff --git a/dev/kernel/src/CxxAbi-ARM64.cc b/dev/kernel/src/CxxAbi-ARM64.cc index b52be160..a24dfce3 100644 --- a/dev/kernel/src/CxxAbi-ARM64.cc +++ b/dev/kernel/src/CxxAbi-ARM64.cc @@ -8,7 +8,7 @@ #include <KernelKit/DebugOutput.h> #include <NewKit/CxxAbi.h> -#include <KernelKit/LPC.h> +#include <KernelKit/KPC.h> atexit_func_entry_t __atexit_funcs[kAtExitMacDestructors]; diff --git a/dev/kernel/src/FS/HeFS.cc b/dev/kernel/src/FS/HeFS.cc index 7615ed77..b6f1bede 100644 --- a/dev/kernel/src/FS/HeFS.cc +++ b/dev/kernel/src/FS/HeFS.cc @@ -10,7 +10,7 @@ #include <modules/ATA/ATA.h> #include <modules/Flash/Flash.h> #include <FSKit/HeFS.h> -#include <KernelKit/LPC.h> +#include <KernelKit/KPC.h> #include <NewKit/Crc32.h> #include <NewKit/KernelPanic.h> #include <NewKit/KString.h> diff --git a/dev/kernel/src/FS/NeFS.cc b/dev/kernel/src/FS/NeFS.cc index 00824122..5878067f 100644 --- a/dev/kernel/src/FS/NeFS.cc +++ b/dev/kernel/src/FS/NeFS.cc @@ -11,7 +11,7 @@ #include <modules/AHCI/AHCI.h> #include <modules/ATA/ATA.h> -#include <KernelKit/LPC.h> +#include <KernelKit/KPC.h> #include <NewKit/Crc32.h> #include <NewKit/KernelPanic.h> #include <NewKit/KString.h> diff --git a/dev/kernel/src/LPC.cc b/dev/kernel/src/KPC.cc index b6b2e11b..7081bf51 100644 --- a/dev/kernel/src/LPC.cc +++ b/dev/kernel/src/KPC.cc @@ -4,18 +4,37 @@ ------------------------------------------- */ -#include <KernelKit/LPC.h> +#include <KernelKit/KPC.h> #include <NewKit/KernelPanic.h> +#include <KernelKit/MemoryMgr.h> namespace NeOS { STATIC Bool kRaiseOnBugCheck = false; /// @brief Does a system wide bug check. - /// @param void no params. + /// @param void no params are needed. /// @return if error-free: false, otherwise true. - Boolean err_bug_check(void) noexcept + Boolean err_bug_check_raise(Void) noexcept { + Char* ptr = new Char[512]; + + if (ptr == nullptr) + goto bug_check_fail; + + if (!mm_is_valid_heap(ptr)) + goto bug_check_fail; + + delete[] ptr; + + return Yes; + + bug_check_fail: + if (ptr) + delete[] ptr; + + ptr = nullptr; + if (kRaiseOnBugCheck) { ke_panic(RUNTIME_CHECK_BAD_BEHAVIOR); @@ -23,12 +42,4 @@ namespace NeOS return No; } - - /// @brief Tells if we should raise a bug check not. - /// @param void - /// @return void - Void err_bug_check_raise(Void) noexcept - { - kRaiseOnBugCheck = true; - } } // namespace NeOS diff --git a/dev/kernel/src/MemoryMgr.cc b/dev/kernel/src/MemoryMgr.cc index 4e13ea15..5e595b51 100644 --- a/dev/kernel/src/MemoryMgr.cc +++ b/dev/kernel/src/MemoryMgr.cc @@ -5,7 +5,7 @@ ------------------------------------------- */ #include <KernelKit/DebugOutput.h> -#include <KernelKit/LPC.h> +#include <KernelKit/KPC.h> #include <KernelKit/MemoryMgr.h> #include <NewKit/Crc32.h> #include <NewKit/PageMgr.h> @@ -25,11 +25,11 @@ //! @brief Heap algorithm that serves as the main memory manager. #define kKernelHeapMagic (0xD4D75) -#define kKernelHeapAlignSz (__BIGGEST_ALIGNMENT__) +#define kKernelHeapAlignSz (4) namespace NeOS { - /// @brief Contains data structures and algorithms for the heap. + /// @brief Implementation details. namespace Detail { struct PACKED HEAP_INFORMATION_BLOCK; diff --git a/dev/kernel/src/Network/IPCAddr.cc b/dev/kernel/src/Network/IPCAddr.cc index 75a54a36..fb2d785a 100644 --- a/dev/kernel/src/Network/IPCAddr.cc +++ b/dev/kernel/src/Network/IPCAddr.cc @@ -5,7 +5,7 @@ ------------------------------------------- */ #include <NetworkKit/IPC.h> -#include <KernelKit/LPC.h> +#include <KernelKit/KPC.h> #include <KernelKit/UserProcessScheduler.h> namespace NeOS diff --git a/dev/kernel/src/Network/IPCMsg.cc b/dev/kernel/src/Network/IPCMsg.cc index f5bec6f7..5c18fe9c 100644 --- a/dev/kernel/src/Network/IPCMsg.cc +++ b/dev/kernel/src/Network/IPCMsg.cc @@ -5,7 +5,7 @@ ------------------------------------------- */ #include <NetworkKit/IPC.h> -#include <KernelKit/LPC.h> +#include <KernelKit/KPC.h> #include <KernelKit/UserProcessScheduler.h> namespace NeOS diff --git a/dev/kernel/src/User.cc b/dev/kernel/src/User.cc index 3c23c59e..fab5da88 100644 --- a/dev/kernel/src/User.cc +++ b/dev/kernel/src/User.cc @@ -11,7 +11,7 @@ */ #include <KernelKit/User.h> -#include <KernelKit/LPC.h> +#include <KernelKit/KPC.h> #include <NewKit/KernelPanic.h> #include <KernelKit/FileMgr.h> #include <KernelKit/MemoryMgr.h> diff --git a/dev/kernel/src/UserProcessScheduler.cc b/dev/kernel/src/UserProcessScheduler.cc index 1087ac6b..19861dbe 100644 --- a/dev/kernel/src/UserProcessScheduler.cc +++ b/dev/kernel/src/UserProcessScheduler.cc @@ -18,7 +18,7 @@ #include <ArchKit/ArchKit.h> #include <KernelKit/MemoryMgr.h> #include <NewKit/KString.h> -#include <KernelKit/LPC.h> +#include <KernelKit/KPC.h> ///! BUGS: 0 diff --git a/dev/modules/CoreGfx/AccessibilityMgr.h b/dev/modules/CoreGfx/AccessibilityMgr.h index a45470eb..a7cd24b5 100644 --- a/dev/modules/CoreGfx/AccessibilityMgr.h +++ b/dev/modules/CoreGfx/AccessibilityMgr.h @@ -8,7 +8,7 @@ #define GFX_MGR_ACCESSIBILITY_H #include <NewKit/NewKit.h> -#include <KernelKit/LPC.h> +#include <KernelKit/KPC.h> #include <modules/CoreGfx/FBMgr.h> #include <modules/CoreGfx/MathMgr.h> #include <ArchKit/ArchKit.h> diff --git a/dev/modules/ReadMe.md b/dev/modules/ReadMe.md index 1261e247..5e71937f 100644 --- a/dev/modules/ReadMe.md +++ b/dev/modules/ReadMe.md @@ -7,6 +7,5 @@ They are pluggable modules for specific hardware support. ## To-Do - [X] AHCI kernel module. -- [X] MBCI kernel module. ###### Copyright (C) 2024-2025, Amlal EL Mahrouss, all rights reserved. All rights reserved. diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Array.h b/public/frameworks/CoreFoundation.fwrk/headers/Array.h index b70d8503..8d7e6e90 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Array.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Array.h @@ -6,9 +6,9 @@ #pragma once -#include <SCIKit/SCI.h> +#include <SCIKit/SystemCalls.h> -namespace LibCF +namespace CF { template <typename T, SizeT N> class CFArray final @@ -68,4 +68,4 @@ namespace LibCF { return CFArray<ValueType, ARRAY_SIZE(val)>{val}; } -} // namespace LibCF +} // namespace CF diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Atom.h b/public/frameworks/CoreFoundation.fwrk/headers/Atom.h index d3152fd2..e205ed12 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Atom.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Atom.h @@ -7,7 +7,7 @@ #include <CoreFoundation.fwrk/headers/Foundation.h> -namespace LibCF +namespace CF { template <typename T> class CFAtom final @@ -44,4 +44,4 @@ namespace LibCF private: T fArrayOfAtoms; }; -} // namespace LibCF +} // namespace CF diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Foundation.h b/public/frameworks/CoreFoundation.fwrk/headers/Foundation.h index 6de3df0b..c2399376 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Foundation.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Foundation.h @@ -10,9 +10,9 @@ #pragma once -#include <SCIKit/SCI.h> +#include <SCIKit/SystemCalls.h> -namespace LibCF +namespace CF { class CFString; class CFGUID; @@ -75,4 +75,4 @@ namespace LibCF BOOL SizeMatches(CFRect& rect) noexcept; BOOL PositionMatches(CFRect& rect) noexcept; }; -} // namespace LibCF
\ No newline at end of file +} // namespace CF
\ No newline at end of file diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Object.h b/public/frameworks/CoreFoundation.fwrk/headers/Object.h index 7b8f3777..ad34e424 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Object.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Object.h @@ -9,9 +9,9 @@ #include <CoreFoundation.fwrk/headers/Foundation.h> -#define CF_OBJECT : public LibCF::CFObject +#define CF_OBJECT : public CF::CFObject -namespace LibCF +namespace CF { class CFObject; @@ -23,4 +23,4 @@ namespace LibCF SCI_COPY_DEFAULT(CFObject); }; -} // namespace LibCF
\ No newline at end of file +} // namespace CF
\ No newline at end of file diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Property.h b/public/frameworks/CoreFoundation.fwrk/headers/Property.h index f1a5c24e..aac883ee 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Property.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Property.h @@ -7,12 +7,12 @@ #ifndef _PROPS_H #define _PROPS_H -#include <SCIKit/SCI.h> +#include <SCIKit/SystemCalls.h> #include <CoreFoundation.fwrk/headers/Ref.h> #define kMaxPropLen (256U) -namespace LibCF +namespace CF { class CFString; class CFProperty; @@ -48,6 +48,6 @@ namespace LibCF template <SizeT N> using CFPropertyArray = CFArray<CFProperty, N>; -} // namespace LibCF +} // namespace CF #endif // !CFKIT_PROPS_H diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Ref.h b/public/frameworks/CoreFoundation.fwrk/headers/Ref.h index 074b5086..9941bece 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Ref.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Ref.h @@ -8,10 +8,10 @@ #ifndef _REF_H_ #define _REF_H_ -#include <SCIKit/SCI.h> +#include <SCIKit/SystemCalls.h> #include <CoreFoundation.fwrk/headers/Object.h> -namespace LibCF +namespace CF { template <typename T> class CFRef; @@ -105,6 +105,6 @@ namespace LibCF private: CFRef<T> fRef{nullptr}; }; -} // namespace LibCF +} // namespace CF #endif // ifndef _NEWKIT_REF_H_ diff --git a/public/frameworks/CoreFoundation.fwrk/headers/String.h b/public/frameworks/CoreFoundation.fwrk/headers/String.h index 10ce01a9..69b53a89 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/String.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/String.h @@ -9,7 +9,7 @@ #include <CoreFoundation.fwrk/headers/Object.h> -namespace LibCF +namespace CF { class CFString; @@ -17,4 +17,4 @@ namespace LibCF { public: }; -} // namespace LibCF
\ No newline at end of file +} // namespace CF
\ No newline at end of file diff --git a/public/frameworks/CoreFoundation.fwrk/src/Foundation.cc b/public/frameworks/CoreFoundation.fwrk/src/Foundation.cc index 219c3bfb..8dffdd02 100644 --- a/public/frameworks/CoreFoundation.fwrk/src/Foundation.cc +++ b/public/frameworks/CoreFoundation.fwrk/src/Foundation.cc @@ -6,7 +6,7 @@ #include <CoreFoundation.fwrk/headers/Foundation.h> -LibCF::CFRect::operator bool() +CF::CFRect::operator bool() { return width > 0 && height > 0; } @@ -14,7 +14,7 @@ LibCF::CFRect::operator bool() /***********************************************************************************/ /// @brief returns true if size matches. /***********************************************************************************/ -BOOL LibCF::CFRect::SizeMatches(LibCF::CFRect& rect) noexcept +BOOL CF::CFRect::SizeMatches(CF::CFRect& rect) noexcept { return rect.height == height && rect.width == width; } @@ -22,7 +22,7 @@ BOOL LibCF::CFRect::SizeMatches(LibCF::CFRect& rect) noexcept /***********************************************************************************/ /// @brief returns true if position matches. /***********************************************************************************/ -BOOL LibCF::CFRect::PositionMatches(LibCF::CFRect& rect) noexcept +BOOL CF::CFRect::PositionMatches(CF::CFRect& rect) noexcept { return rect.y == y && rect.x == x; } @@ -33,7 +33,7 @@ BOOL LibCF::CFRect::PositionMatches(LibCF::CFRect& rect) noexcept /// @retval true if point is within this point. /// @retval the validations have failed, false otherwise true. /***********************************************************************************/ -BOOL LibCF::CFPoint::IsWithin(LibCF::CFPoint& withinOf) +BOOL CF::CFPoint::IsWithin(CF::CFPoint& withinOf) { return x_1 >= withinOf.x_1 && x_2 <= (withinOf.x_2) && y_1 >= withinOf.y_1 && y_2 <= (withinOf.y_2); @@ -42,7 +42,7 @@ BOOL LibCF::CFPoint::IsWithin(LibCF::CFPoint& withinOf) /***********************************************************************************/ /// @brief if Point object is correctly set up. /***********************************************************************************/ -LibCF::CFPoint::operator bool() +CF::CFPoint::operator bool() { return x_1 > x_2 && y_1 > y_2; }
\ No newline at end of file diff --git a/public/frameworks/DiskImage.fwrk/headers/DiskImage.h b/public/frameworks/DiskImage.fwrk/headers/DiskImage.h index a029b43a..3a13caa0 100644 --- a/public/frameworks/DiskImage.fwrk/headers/DiskImage.h +++ b/public/frameworks/DiskImage.fwrk/headers/DiskImage.h @@ -9,7 +9,7 @@ #pragma once -#include <SCIKit/SCI.h> +#include <SCIKit/SystemCalls.h> #define kDISectorSz (512) #define kDIMinDiskSz (1024 * 1024 * 1024) @@ -18,15 +18,22 @@ #define kDISuccessStatus (0) #define kDIFailureStatus (1) -struct DI_DISK_IMAGE; +#define kDIDiskNameLen (16) +#define kDIOutNameLen (256) +/// @brief Disk Image file structure. +/// @param disk_name Disk partition name. +/// @param sector_sz Disk sector_sz. +/// @param block_cnt Disk block count. +/// @param disk_sz Disk size. +/// @param out_name Output file name. struct DI_DISK_IMAGE { - Char disk_name[512] = kDIDefaultDiskName; + Char disk_name[kDIDiskNameLen] = kDIDefaultDiskName; SInt32 sector_sz = kDISectorSz; SInt32 block_cnt = 0; SizeT disk_sz = kDIMinDiskSz; - Char out_name[256] = kDIDefaultOutputName; + Char out_name[kDIOutNameLen] = kDIDefaultOutputName; }; /// @brief Format with an EPM partition. diff --git a/tests/KernelTestKit/KernelTest.h b/public/frameworks/KernelTest.fwrk/headers/KernelTest.h index 3fb0f3de..3fb0f3de 100644 --- a/tests/KernelTestKit/KernelTest.h +++ b/public/frameworks/KernelTest.fwrk/headers/KernelTest.h diff --git a/public/frameworks/CoreFoundation.fwrk/headers/.keep b/public/frameworks/KernelTest.fwrk/headers/xml/.keep index e69de29b..e69de29b 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/.keep +++ b/public/frameworks/KernelTest.fwrk/headers/xml/.keep diff --git a/public/frameworks/KernelTest.fwrk/headers/xml/app.xml b/public/frameworks/KernelTest.fwrk/headers/xml/app.xml new file mode 100644 index 00000000..f0c48862 --- /dev/null +++ b/public/frameworks/KernelTest.fwrk/headers/xml/app.xml @@ -0,0 +1,3 @@ +<PropertyList/> +<PLEntry Type="MLString" Name="LibraryName" Len="255" Value="KernelTest" /> +<PLEntry Type="BOOL" Name="CacheLibs" Value="YES" /> diff --git a/public/tools/cc/cc.json b/public/tools/cc/cc.json index a81c1ed2..a40008ba 100644 --- a/public/tools/cc/cc.json +++ b/public/tools/cc/cc.json @@ -1,7 +1,7 @@ { "compiler_path": "g++", - "compiler_std": "c++23", - "headers_path": ["./"], + "compiler_std": "c++20", + "headers_path": ["./", "../../../dev"], "sources_path": ["src/CommandLine.cc"], "output_name": "./dist/cc", "cpp_macros": [ diff --git a/public/tools/cc/src/CommandLine.cc b/public/tools/cc/src/CommandLine.cc index 226554cc..7c5ccfaf 100644 --- a/public/tools/cc/src/CommandLine.cc +++ b/public/tools/cc/src/CommandLine.cc @@ -4,9 +4,9 @@ * Copyright (c) 2024 Amlal EL Mahrouss */ -#include <SCIKit/SCI.h> +#include <SCIKit/SystemCalls.h> -/// @brief This program loads a program for NeOS. +/// @brief Placeholder program. SInt32 main(SInt32 argc, Char* argv[]) { diff --git a/public/tools/diutil/CommandLine.cc b/public/tools/diutil/CommandLine.cc index e2f53746..7b95665a 100644 --- a/public/tools/diutil/CommandLine.cc +++ b/public/tools/diutil/CommandLine.cc @@ -2,126 +2,58 @@ Copyright (C) 2025, Amlal EL Mahrouss, all rights reserved. - FILE: NeFS.h - PURPOSE: NeFS (New extended File System) support. + FILE: CommandLine.cc + PURPOSE: DIUTIL CLI. ------------------------------------------- */ -#include <string> -#include <iostream> -#include <fstream> +#include <DiskImage.fwrk/headers/DiskImage.h> +#include <NewKit/Defines.h> -#include <FirmwareKit/EPM.h> -#include <FSKit/NeFS.h> -#include <uuid/uuid.h> - -#include <vendor/Dialogs.h> - -static std::string kDiskName = "Disk"; -static int kDiskSectorSz = 512; -static const int kDiskBlockCnt = 1; -static size_t kDiskSz = gib_cast(4); -static std::string kOutDisk = "disk.eimg"; +static const Char kDiskName[kDIDiskNameLen] = "Disk"; +static SInt32 kDiskSectorSz = 512; +static const SInt32 kDiskBlockCnt = 1; +static SizeT kDiskSz = gib_cast(4); +static const Char kOutDisk[kDIOutNameLen] = "disk.eimg"; /// @brief Filesystem tool entrypoint. int main(int argc, char** argv) { - for (size_t arg = 0; arg < argc; ++arg) + for (SizeT arg = 0; arg < argc; ++arg) { - std::string arg_s = argv[arg]; + const Char* arg_s = argv[arg]; - if (arg_s == "--disk-output-name") + if (MmCmpMemory((VoidPtr)arg_s, (VoidPtr)"--disk-output-name", MmStrLen("--disk-output-name") == 0)) { if ((arg + 1) < argc) { - kOutDisk = argv[arg + 1]; + MmCopyMemory((VoidPtr)kOutDisk, argv[arg + 1], kDIDiskNameLen); } } - else if (arg_s == "--disk-output-size") + else if (MmCmpMemory((VoidPtr)arg_s, (VoidPtr)"--disk-output-size", MmStrLen("--disk-output-size") == 0)) { if ((arg + 1) < argc) { - kDiskSz = strtol(argv[arg + 1], nullptr, 10); + kDiskSz = MathToNumber(argv[arg + 1], nullptr, 10); } } - else if (arg_s == "--disk-sector-size") + else if (MmCmpMemory((VoidPtr)arg_s, (VoidPtr)"--disk-sector-size", MmStrLen("--disk-sector-size") == 0)) { if ((arg + 1) < argc) { - kDiskSectorSz = strtol(argv[arg + 1], nullptr, 10); + kDiskSectorSz = MathToNumber(argv[arg + 1], nullptr, 10); } } - else if (arg_s == "--disk-part-name") + else if (MmCmpMemory((VoidPtr)arg_s, (VoidPtr)"--disk-part-name", MmStrLen("--disk-part-name") == 0)) { if ((arg + 1) < argc) { - kDiskName = argv[arg + 1]; + MmCopyMemory((VoidPtr)kDiskName, argv[arg + 1], kDIDiskNameLen); } } } - std::cout << "diutil: EPM partition tool.\n"; - - struct ::EPM_PART_BLOCK block - { - 0 - }; - - block.NumBlocks = kDiskBlockCnt; - block.SectorSz = kDiskSectorSz; - block.Version = kEPMRevisionBcd; - block.LbaStart = sizeof(struct ::EPM_PART_BLOCK); - block.LbaEnd = kDiskSz - sizeof(struct ::EPM_PART_BLOCK); - block.FsVersion = kNeFSVersionInteger; - - ::memcpy(block.Name, kDiskName.c_str(), strlen(kDiskName.c_str())); - ::memcpy(block.Magic, kEPMMagic86, strlen(kEPMMagic86)); - - ::uuid_generate_random((NeOS::UInt8*)&block.Guid); - - uuid_string_t str; - - ::uuid_unparse((NeOS::UInt8*)&block.Guid, str); - - std::cout << "diutil: Partition UUID: " << str << std::endl; - - std::ofstream output_epm(kOutDisk); - output_epm.write((NeOS::Char*)&block, sizeof(struct ::EPM_PART_BLOCK)); - - struct ::NEFS_ROOT_PARTITION_BLOCK rpb - { - 0 - }; - - ::memcpy(rpb.PartitionName, kDiskName.c_str(), strlen(kDiskName.c_str())); - ::memcpy(rpb.Ident, kNeFSIdent, strlen(kNeFSIdent)); - - rpb.Version = kNeFSVersionInteger; - rpb.EpmBlock = kEPMBootBlockLba; - - rpb.StartCatalog = kNeFSCatalogStartAddress; - rpb.CatalogCount = 0; - - rpb.DiskSize = kDiskSz; - - rpb.SectorSize = kDiskSectorSz; - rpb.SectorCount = rpb.DiskSize / rpb.SectorSize; - - rpb.FreeSectors = rpb.SectorCount; - rpb.FreeCatalog = rpb.DiskSize / sizeof(NEFS_CATALOG_STRUCT); - - auto p_prev = output_epm.tellp(); - - output_epm.seekp(kNeFSRootCatalogStartAddress); - output_epm.write((NeOS::Char*)&rpb, sizeof(struct ::NEFS_ROOT_PARTITION_BLOCK)); - - output_epm.seekp(p_prev); - output_epm.close(); - - std::cout << "diutil: EPM disk has been written to: " << kOutDisk << "\n"; - - pfd::notify("Disk Utility", kOutDisk + " has been formatted successfully.", - pfd::icon::info); + DI_DISK_IMAGE img{}; - return 0; + return DIFormatPartitionEPM(img); }
\ No newline at end of file diff --git a/public/tools/fwrkld/.keep b/public/tools/fwrkld/.keep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/public/tools/fwrkld/.keep diff --git a/public/tools/fwrkld/dist/.keep b/public/tools/fwrkld/dist/.keep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/public/tools/fwrkld/dist/.keep diff --git a/public/tools/fwrkld/fwrkld.json b/public/tools/fwrkld/fwrkld.json new file mode 100644 index 00000000..940c3a89 --- /dev/null +++ b/public/tools/fwrkld/fwrkld.json @@ -0,0 +1,12 @@ +{ + "compiler_path": "g++", + "compiler_std": "c++20", + "headers_path": ["./", "../../../dev"], + "sources_path": ["src/CommandLine.cc"], + "output_name": "./dist/fwrkld", + "cpp_macros": [ + "kLDVersion=0x0100", + "kLDVersionHighest=0x0100", + "kLDVersionLowest=0x0100" + ] +} diff --git a/public/tools/fwrkld/src/CommandLine.cc b/public/tools/fwrkld/src/CommandLine.cc new file mode 100644 index 00000000..d3860453 --- /dev/null +++ b/public/tools/fwrkld/src/CommandLine.cc @@ -0,0 +1,14 @@ +/* + * Created on Thu Oct 17 08:00:42 CEST 2024 + * + * Copyright (c) 2024 Amlal EL Mahrouss + */ + +#include <SCIKit/SystemCalls.h> + +/// @brief This program loads a code framework into NeOS's memory. + +SInt32 main(SInt32 argc, Char* argv[]) +{ + return EXIT_FAILURE; +} diff --git a/public/tools/ld/ld.json b/public/tools/ld/ld.json index f423df30..940c3a89 100644 --- a/public/tools/ld/ld.json +++ b/public/tools/ld/ld.json @@ -1,9 +1,9 @@ { "compiler_path": "g++", - "compiler_std": "c++23", - "headers_path": ["./"], + "compiler_std": "c++20", + "headers_path": ["./", "../../../dev"], "sources_path": ["src/CommandLine.cc"], - "output_name": "./dist/ld", + "output_name": "./dist/fwrkld", "cpp_macros": [ "kLDVersion=0x0100", "kLDVersionHighest=0x0100", diff --git a/public/tools/ld/src/CommandLine.cc b/public/tools/ld/src/CommandLine.cc index a6f98ee1..710b2a41 100644 --- a/public/tools/ld/src/CommandLine.cc +++ b/public/tools/ld/src/CommandLine.cc @@ -4,9 +4,9 @@ * Copyright (c) 2024 Amlal EL Mahrouss */ -#include <SCIKit/SCI.h> +#include <SCIKit/SystemCalls.h> -/// @brief This program loads a program for NeOS. +/// @brief Placeholder program. SInt32 main(SInt32 argc, Char* argv[]) { diff --git a/public/tools/make_app/Common.h b/public/tools/make_app/Common.h index 860cdd48..e54cf701 100644 --- a/public/tools/make_app/Common.h +++ b/public/tools/make_app/Common.h @@ -6,7 +6,7 @@ #ifndef APPS_COMMON_H #define APPS_COMMON_H -#include <SCIKit/SCI.h> +#include <SCIKit/SystemCalls.h> #include <CoreFoundation.fwrk/headers/Foundation.h> #endif // APPS_COMMON_H diff --git a/public/tools/make_app/make_app.json b/public/tools/make_app/make_app.json index abfe5cd3..f40b9eff 100644 --- a/public/tools/make_app/make_app.json +++ b/public/tools/make_app/make_app.json @@ -1,7 +1,7 @@ { "compiler_path": "g++", "compiler_std": "c++20", - "headers_path": ["./"], + "headers_path": ["./", "../../../dev"], "sources_path": ["src/CommandLine.cc"], "output_name": "./dist/make_app", "cpp_macros": [ diff --git a/public/tools/make_app/src/CommandLine.cc b/public/tools/make_app/src/CommandLine.cc index 0cc40106..7ffdb5b1 100644 --- a/public/tools/make_app/src/CommandLine.cc +++ b/public/tools/make_app/src/CommandLine.cc @@ -13,7 +13,7 @@ int main(int argc, char* argv[]) { - LibCF::CFArray<const char*, 256U> files; + CF::CFArray<const char*, 256U> files; auto ext = kFKExtension; diff --git a/public/tools/open/src/CommandLine.cc b/public/tools/open/src/CommandLine.cc index 746622fa..c0fa0925 100644 --- a/public/tools/open/src/CommandLine.cc +++ b/public/tools/open/src/CommandLine.cc @@ -4,7 +4,7 @@ * Copyright (c) 2024 Amlal EL Mahrouss */ -#include <SCIKit/SCI.h> +#include <SCIKit/SystemCalls.h> /// @brief This program opens an application from **OPEN_APP_BASE_PATH** |
