summaryrefslogtreecommitdiffhomepage
path: root/public/frameworks
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-11-29 21:38:33 -0500
committerAmlal El Mahrouss <amlal@nekernel.org>2025-11-29 21:38:33 -0500
commitb456c928fecf78157270b052e441a427f06afdda (patch)
tree2dbea485a392789fc67aa590f8a7afb9f263be3c /public/frameworks
parentbb303088aa2ed0693e19e93158155dd85783ce76 (diff)
feat: kernel: Introduce Vet.h, better Ref.h, and more improved containers for better kernel code.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'public/frameworks')
-rw-r--r--public/frameworks/CoreFoundation.fwrk/headers/Dictionary.h5
-rw-r--r--public/frameworks/CoreFoundation.fwrk/headers/Foundation.h10
-rw-r--r--public/frameworks/DiskImage.fwrk/headers/DiskImage.h2
-rw-r--r--public/frameworks/DiskImage.fwrk/src/DiskImage+EPM.cc2
-rw-r--r--public/frameworks/DiskImage.fwrk/src/DiskImage+OpenHeFS.cc (renamed from public/frameworks/DiskImage.fwrk/src/DiskImage+HeFS.cc)18
-rw-r--r--public/frameworks/KernelTest.fwrk/headers/Foundation.h9
-rw-r--r--public/frameworks/KernelTest.fwrk/headers/SourceLocation.h8
-rw-r--r--public/frameworks/KernelTest.fwrk/headers/TestCase.h47
-rw-r--r--public/frameworks/KernelTest.fwrk/src/CSymbols.cc21
9 files changed, 44 insertions, 78 deletions
diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Dictionary.h b/public/frameworks/CoreFoundation.fwrk/headers/Dictionary.h
index fa4b17b9..75b6bb27 100644
--- a/public/frameworks/CoreFoundation.fwrk/headers/Dictionary.h
+++ b/public/frameworks/CoreFoundation.fwrk/headers/Dictionary.h
@@ -19,13 +19,12 @@ class CFDictionary final {
CFDictionary(const CFDictionary&) = default;
Value& operator[](Key& at) {
- MUST_PASS(this->Find(at));
- return fArray[at];
+ return this->Find(at);
}
Bool Empty() { return this->fCount > 0; }
- Bool Find(Key& key) { return No; }
+ Bool Find(Key& key) { NE_UNUSED(key); return false; }
operator bool() { return !this->Empty(); }
diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Foundation.h b/public/frameworks/CoreFoundation.fwrk/headers/Foundation.h
index a8a31559..d11697db 100644
--- a/public/frameworks/CoreFoundation.fwrk/headers/Foundation.h
+++ b/public/frameworks/CoreFoundation.fwrk/headers/Foundation.h
@@ -14,7 +14,7 @@
namespace CF {
class CFString;
-union CFGUID;
+union CFGuid;
class CFProperty;
class CFObject;
@@ -47,7 +47,7 @@ struct CFPoint {
CFInteger64 y_2{0UL};
CFReal ang{0UL};
- operator bool();
+ explicit operator bool();
/// @brief Check if point is within the current CFPoint.
/// @param point the current point to check.
@@ -67,13 +67,13 @@ struct CFRect final {
CFInteger64 width{0UL};
CFInteger64 height{0UL};
- operator bool();
+ explicit operator bool();
BOOL SizeMatches(CFRect& rect);
BOOL PositionMatches(CFRect& rect);
};
-union CFGUID final {
+union CFGuid final {
alignas(8) UInt16 fU8[16];
alignas(8) UInt16 fU16[8];
alignas(8) UInt32 fU32[4];
@@ -86,6 +86,4 @@ union CFGUID final {
UInt8 fMs4[8];
} fUuid;
};
-
-using CF_GUID_TYPE = union CFGUID;
} // namespace CF \ 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 9028592d..2ed66345 100644
--- a/public/frameworks/DiskImage.fwrk/headers/DiskImage.h
+++ b/public/frameworks/DiskImage.fwrk/headers/DiskImage.h
@@ -55,6 +55,6 @@ SInt32 DIFormatFilesystemNeFS(struct DI_DISK_IMAGE& img);
/// @brief OpenHeFS format over EPM.
/// @param img disk image structure.
/// @return Status code upon completion.
-SInt32 DIFormatFilesystemHeFS(struct DI_DISK_IMAGE& img);
+SInt32 DIFormatFilesystemOpenHeFS(struct DI_DISK_IMAGE& img);
} // namespace DI
diff --git a/public/frameworks/DiskImage.fwrk/src/DiskImage+EPM.cc b/public/frameworks/DiskImage.fwrk/src/DiskImage+EPM.cc
index ab533e20..b9cf42d1 100644
--- a/public/frameworks/DiskImage.fwrk/src/DiskImage+EPM.cc
+++ b/public/frameworks/DiskImage.fwrk/src/DiskImage+EPM.cc
@@ -12,7 +12,7 @@
#include <FSKit/NeFS.h>
#include <FirmwareKit/EPM.h>
-/// @brief EPM format disk
+/// @brief Format a disk under the EPM scheme.
/// @param img disk image structure.
/// @return Status code upon completion.
SInt32 DI::DIFormatPartitionEPM(struct DI_DISK_IMAGE& img) {
diff --git a/public/frameworks/DiskImage.fwrk/src/DiskImage+HeFS.cc b/public/frameworks/DiskImage.fwrk/src/DiskImage+OpenHeFS.cc
index f57de649..9d52f94d 100644
--- a/public/frameworks/DiskImage.fwrk/src/DiskImage+HeFS.cc
+++ b/public/frameworks/DiskImage.fwrk/src/DiskImage+OpenHeFS.cc
@@ -15,18 +15,12 @@
/// @brief format OpenHeFS over an EPM disk.
/// @param img disk image structure.
/// @return Status code upon completion.
-SInt32 DI::DIFormatFilesystemHeFS(struct DI_DISK_IMAGE& img) {
- if (!img.sector_sz || (img.sector_sz % kDISectorSz != 0)) return kDIFailureStatus;
+SInt32 DI::DIFormatFilesystemOpenHeFS(struct DI_DISK_IMAGE& img) {
+ NE_UNUSED(img);
- if (*img.out_name == 0 || *img.disk_name == 0) return kDIFailureStatus;
+ PrintOut(nullptr, "%s",
+ "DIFormatFilesystemOpenHeFS is not formattable on DI, work may be done in the future to "
+ "address that.");
- IORef handle = IoOpenFile(img.out_name, nullptr);
-
- if (!handle) return kDIFailureStatus;
-
- ::IoCloseFile(handle);
-
- handle = nullptr;
-
- return kDISuccessStatus;
+ return kDIFailureStatus;
} \ No newline at end of file
diff --git a/public/frameworks/KernelTest.fwrk/headers/Foundation.h b/public/frameworks/KernelTest.fwrk/headers/Foundation.h
index 4329af6b..8ff956a7 100644
--- a/public/frameworks/KernelTest.fwrk/headers/Foundation.h
+++ b/public/frameworks/KernelTest.fwrk/headers/Foundation.h
@@ -6,11 +6,14 @@
#pragma once
-#include <KernelKit/DebugOutput.h>
-#include <NeKit/KernelPanic.h>
+#include <libSystem/SystemKit/System.h>
+#include <libSystem/SystemKit/Err.h>
+
+#include <CoreFoundation.fwrk/headers/Object.h>
+#include <CoreFoundation.fwrk/headers/String.h>
#define KT_TEST_VERSION_BCD (0x0001)
-#define KT_TEST_VERSION "dev-nekernel-test"
+#define KT_TEST_VERSION "v0.0.1"
#define KT_TEST_SUCCESS (kErrorSuccess)
#define KT_TEST_FAILURE (kErrorSuccess + 1)
diff --git a/public/frameworks/KernelTest.fwrk/headers/SourceLocation.h b/public/frameworks/KernelTest.fwrk/headers/SourceLocation.h
index 6507864b..6cfddae2 100644
--- a/public/frameworks/KernelTest.fwrk/headers/SourceLocation.h
+++ b/public/frameworks/KernelTest.fwrk/headers/SourceLocation.h
@@ -6,8 +6,6 @@
#pragma once
-#include <CoreFoundation.fwrk/headers/Object.h>
-#include <CoreFoundation.fwrk/headers/String.h>
#include <KernelTest.fwrk/headers/Foundation.h>
class KTSourceLocation;
@@ -17,7 +15,7 @@ class KTSourceLocation;
/// ================================================================================
class KTSourceLocation final CF_OBJECT {
public:
- explicit KTSourceLocation() = delete;
+ KTSourceLocation() = delete;
~KTSourceLocation() override = default;
LIBSYS_COPY_DELETE(KTSourceLocation);
@@ -25,8 +23,8 @@ class KTSourceLocation final CF_OBJECT {
public:
KTSourceLocation(const Char*, const SInt32 = 0UL);
- CF::CFString File();
- SInt32 Line();
+ CF::CFString& File() { return mFile; }
+ SInt32 Line() { return mLine; }
CF::CFString operator()();
diff --git a/public/frameworks/KernelTest.fwrk/headers/TestCase.h b/public/frameworks/KernelTest.fwrk/headers/TestCase.h
index 26325d42..2dcc56ef 100644
--- a/public/frameworks/KernelTest.fwrk/headers/TestCase.h
+++ b/public/frameworks/KernelTest.fwrk/headers/TestCase.h
@@ -18,34 +18,29 @@
KTTestCase##OBJECT{}.Run(); \
}
-#define KT_MUST_PASS(MSG, LEFT_COND, RIGHT_COND) \
- if (LEFT_COND != RIGHT_COND) { \
- (Kernel::Void)(Kernel::kout << "[KERNEL-TEST] BREAK: LEFT_COND: " << #LEFT_COND \
- << " RIGHT_COND: " << #RIGHT_COND << Kernel::kendl); \
- (Kernel::Void)(Kernel::kout << "[KERNEL-TEST] BREAK: MSG: " << MSG << Kernel::kendl); \
- MUST_PASS(NO); \
- } else { \
- (Kernel::Void)(Kernel::kout << "[KERNEL-TEST] PASS: MSG: " << MSG << Kernel::kendl); \
+#define KT_MUST_PASS(MSG, LEFT_COND, RIGHT_COND) \
+ if (LEFT_COND != RIGHT_COND) { \
+ MUST_PASS(NO); \
}
-#define KT_DECL_TEST(NAME, FN) \
- class KTTestCase##NAME final { \
- public: \
- explicit KTTestCase##NAME() = default; \
- ~KTTestCase##NAME() = default; \
- LIBSYS_COPY_DELETE(KTTestCase##NAME); \
- Kernel::Void Run(); \
- const Kernel::Char* ToString(); \
- }; \
- inline Kernel::Void KTTestCase##NAME::Run() { \
- auto ret = FN() == YES; \
- if (!ret) { \
- Kernel::kout << "[KERNEL-TEST] TEST FAILED!" << Kernel::kendl; \
- MUST_PASS(ret); \
- } \
- } \
- inline const Kernel::Char* KTTestCase##NAME::ToString() { \
- return #FN; \
+#define KT_DECL_TEST(NAME, FN) \
+ class KTTestCase##NAME final { \
+ public: \
+ KTTestCase##NAME() = default; \
+ ~KTTestCase##NAME() = default; \
+ LIBSYS_COPY_DELETE(KTTestCase##NAME); \
+ Void Run(); \
+ const Char* ToString(); \
+ }; \
+ inline Void KTTestCase##NAME::Run() { \
+ auto ret = FN() == YES; \
+ if (!ret) { \
+ PrintOut(nullptr, "[KERNEL-TEST] TEST FAILED!"); \
+ MUST_PASS(ret); \
+ } \
+ } \
+ inline const Char* KTTestCase##NAME::ToString() { \
+ return #FN; \
}
KT_DECL_TEST(AlwaysBreak, []() -> bool {
diff --git a/public/frameworks/KernelTest.fwrk/src/CSymbols.cc b/public/frameworks/KernelTest.fwrk/src/CSymbols.cc
deleted file mode 100644
index 575525f0..00000000
--- a/public/frameworks/KernelTest.fwrk/src/CSymbols.cc
+++ /dev/null
@@ -1,21 +0,0 @@
-/* ========================================
-
- Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
-
-======================================== */
-
-#include <public/frameworks/KernelTest.fwrk/headers/TestCase.h>
-
-/// ================================================================================
-/// @brief Function to run breaking test.
-/// ================================================================================
-EXTERN_C Kernel::Void KT_TestBreak() {
- KT_RUN_TEST(AlwaysBreak);
-}
-
-/// ================================================================================
-/// @brief Function to run passing test.
-/// ================================================================================
-EXTERN_C Kernel::Void KT_TestPass() {
- KT_RUN_TEST(AlwaysPass);
-} \ No newline at end of file