summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-11-20 08:42:45 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-11-20 08:42:45 +0100
commite718262c5e5163378ef92469db9b94908dccf12b (patch)
tree98da3dbd414c14ff86e1d1c0f459285b78f63ec8
parentade3a2578ca8d6836b8e73160455df80d49cf045 (diff)
ADD: Add CoreBoot header, need to add missing fields for specific platforms.
-rw-r--r--dev/ZKAKit/FirmwareKit/CoreBoot/CoreBoot.h27
-rw-r--r--dev/ZKAKit/HALKit/AMD64/HalDebugOutput.cc2
-rw-r--r--dev/ZKAKit/HALKit/AMD64/Storage/AHCI-DMA.cc6
-rw-r--r--dev/ZKAKit/HALKit/ARM64/HalDebugOutput.cc2
-rw-r--r--dev/ZKAKit/KernelKit/DebugOutput.h6
-rw-r--r--dev/ZKAKit/KernelKit/Heap.h27
-rw-r--r--dev/ZKAKit/KernelKit/LPC.h6
-rw-r--r--dev/ZKAKit/src/FS/NeFS.cc6
-rw-r--r--dev/ZKAKit/src/Heap.cc14
-rw-r--r--dev/ZKAKit/src/NeFS+FileMgr.cc21
-rw-r--r--dev/ZKAKit/src/Utils.cc2
11 files changed, 81 insertions, 38 deletions
diff --git a/dev/ZKAKit/FirmwareKit/CoreBoot/CoreBoot.h b/dev/ZKAKit/FirmwareKit/CoreBoot/CoreBoot.h
new file mode 100644
index 00000000..b3f5a8b1
--- /dev/null
+++ b/dev/ZKAKit/FirmwareKit/CoreBoot/CoreBoot.h
@@ -0,0 +1,27 @@
+/* -------------------------------------------
+
+ Copyright (C) 2024, EL Mahrouss Logic, all rights reserved.
+
+------------------------------------------- */
+
+#pragma once
+
+#include <NewKit/Defines.h>
+
+namespace Kernel
+{
+ /// @brief Linear Executable Header
+ /// @author EL Mahrouss Logic
+ struct ATTRIBUTE(aligned(4)) mp_boot_header
+ {
+ const Char fMagic[2]; // magic number
+ const Char fName[10]; // operating system name
+ const UInt32 fRevision; // firmware revision
+ const UInt32 fStartAddress; // start address (master/slave(s) thread)
+
+#ifdef ZKA_IS_EXTENDED_COREBOOT
+ const UIntPtr fMasterStructure; // master structure for MP/PM and device tree and such (ARM)
+ const UIntPtr fMasterStructureVersion; // master structure version.
+#endif
+ };
+} // namespace Kernel \ No newline at end of file
diff --git a/dev/ZKAKit/HALKit/AMD64/HalDebugOutput.cc b/dev/ZKAKit/HALKit/AMD64/HalDebugOutput.cc
index 6f2795a0..9c31c036 100644
--- a/dev/ZKAKit/HALKit/AMD64/HalDebugOutput.cc
+++ b/dev/ZKAKit/HALKit/AMD64/HalDebugOutput.cc
@@ -61,6 +61,8 @@ namespace Kernel
}
} // namespace Detail
+ TerminalDevice::~TerminalDevice() = default;
+
EXTERN_C void ke_io_write(const Char* bytes)
{
#ifdef __DEBUG__
diff --git a/dev/ZKAKit/HALKit/AMD64/Storage/AHCI-DMA.cc b/dev/ZKAKit/HALKit/AMD64/Storage/AHCI-DMA.cc
index dd9a07b2..99e1b4c1 100644
--- a/dev/ZKAKit/HALKit/AMD64/Storage/AHCI-DMA.cc
+++ b/dev/ZKAKit/HALKit/AMD64/Storage/AHCI-DMA.cc
@@ -96,11 +96,7 @@ Kernel::Void drv_calculate_disk_geometry()
}
// Retrieve the max LBA value
- kCurrentDiskSectorCount = 0UL;
- kCurrentDiskSectorCount |= identify_data[100];
- kCurrentDiskSectorCount |= identify_data[101] << 16;
- kCurrentDiskSectorCount |= identify_data[102] << 32;
- kCurrentDiskSectorCount |= identify_data[103] << 48;
+ kCurrentDiskSectorCount = *(Kernel::UIntPtr*)identify_data;
kcout << "Max LBA: " << Kernel::number(kCurrentDiskSectorCount) << endl;
diff --git a/dev/ZKAKit/HALKit/ARM64/HalDebugOutput.cc b/dev/ZKAKit/HALKit/ARM64/HalDebugOutput.cc
index bffa3df2..7de5b0a9 100644
--- a/dev/ZKAKit/HALKit/ARM64/HalDebugOutput.cc
+++ b/dev/ZKAKit/HALKit/ARM64/HalDebugOutput.cc
@@ -36,6 +36,8 @@ namespace Kernel
#endif // __DEBUG__
}
+ TerminalDevice::~TerminalDevice() = default;
+
EXTERN_C void ke_io_read(const Char* bytes)
{
#ifdef __DEBUG__
diff --git a/dev/ZKAKit/KernelKit/DebugOutput.h b/dev/ZKAKit/KernelKit/DebugOutput.h
index c00df2e0..b268d874 100644
--- a/dev/ZKAKit/KernelKit/DebugOutput.h
+++ b/dev/ZKAKit/KernelKit/DebugOutput.h
@@ -11,7 +11,7 @@
#include <NewKit/OwnPtr.h>
#include <NewKit/Stream.h>
-#define kDebugMaxPorts 16
+#define kDebugMaxPorts 56
#define kDebugUnboundPort 0x0FEED
@@ -35,7 +35,7 @@ namespace Kernel
inline TerminalDevice hex_number(const Long& x);
// @brief Emulates a VT100 terminal.
- class TerminalDevice final : public DeviceInterface<const Char*>
+ class TerminalDevice final ZKA_DEVICE<const Char*>
{
public:
TerminalDevice(void (*print)(const Char*), void (*get)(const Char*))
@@ -43,7 +43,7 @@ namespace Kernel
{
}
- virtual ~TerminalDevice() = default;
+ ~TerminalDevice() override;
/// @brief returns device name (terminal name)
/// @return string type (const Char*)
diff --git a/dev/ZKAKit/KernelKit/Heap.h b/dev/ZKAKit/KernelKit/Heap.h
index 2bcda412..c0a646d9 100644
--- a/dev/ZKAKit/KernelKit/Heap.h
+++ b/dev/ZKAKit/KernelKit/Heap.h
@@ -9,10 +9,11 @@
// last-rev 30/01/24
// file: Heap.h
-// description: heap allocation for the Kernel.
+// description: heap allocation support.
-#include <NewKit/Defines.h>
#include <NewKit/Stop.h>
+#include <KernelKit/LPC.h>
+#include <HintKit/CompilerHint.h>
namespace Kernel
{
@@ -58,19 +59,27 @@ namespace Kernel
UInt64 mm_get_flags(VoidPtr heap_ptr);
/// @brief Allocate C++ class.
+ /// @param cls The class to allocate.
+ /// @param args The args to pass.
template <typename T, typename... Args>
- inline T* mm_new_class(Args&&... args)
+ inline Void mm_new_class(_Input _Output T** cls, _Input Args&&... args)
{
- T* cls = new T(move(args)...);
- return cls;
+ if (*cls)
+ {
+ ErrGlobal() = Kernel::kErrorInvalidData;
+ return;
+ }
+
+ *cls = new T(move(args)...);
}
- /// @brief Free C++ class.
+ /// @brief Delete and nullify C++ class.
+ /// @param cls The class to delete.
template <typename T>
- inline Void mm_delete_class(T* cls)
+ inline Void mm_delete_class(_Input _Output T** cls)
{
- delete cls;
- cls = nullptr;
+ delete *cls;
+ *cls = nullptr;
}
} // namespace Kernel
diff --git a/dev/ZKAKit/KernelKit/LPC.h b/dev/ZKAKit/KernelKit/LPC.h
index bbb14c05..ff19ec8a 100644
--- a/dev/ZKAKit/KernelKit/LPC.h
+++ b/dev/ZKAKit/KernelKit/LPC.h
@@ -15,10 +15,16 @@
#define ErrLocalFailed() (Kernel::UserProcessScheduler::The().GetCurrentProcess().Leak().GetLocalCode() != Kernel::kErrorSuccess)
#define ErrLocal() (Kernel::UserProcessScheduler::The().GetCurrentProcess().Leak().GetLocalCode())
+#define ErrGlobalIsOk() (Kernel::kErrorLocalNumber == Kernel::kErrorSuccess)
+#define ErrGlobalFailed() (Kernel::kErrorLocalNumber != Kernel::kErrorSuccess)
+#define ErrGlobal() (Kernel::kErrorLocalNumber)
+
namespace Kernel
{
typedef Int32 HError;
+ inline HError kErrorLocalNumber = 0UL;
+
inline constexpr HError kErrorSuccess = 0;
inline constexpr HError kErrorExecutable = 33;
inline constexpr HError kErrorExecutableLib = 34;
diff --git a/dev/ZKAKit/src/FS/NeFS.cc b/dev/ZKAKit/src/FS/NeFS.cc
index 34625fb3..bf1b54c5 100644
--- a/dev/ZKAKit/src/FS/NeFS.cc
+++ b/dev/ZKAKit/src/FS/NeFS.cc
@@ -1033,15 +1033,15 @@ namespace Kernel::Detail
/***********************************************************************************/
Boolean fs_init_newfs(Void) noexcept
{
- kcout << "Creating drives...\r";
- kcout << "Constructing A:\r";
+ kcout << "Creating A: drive...\r";
+ kcout << "Creating A:\r";
kDiskMountpoint.A() = io_construct_main_drive();
kDiskMountpoint.B() = io_construct_drive();
kDiskMountpoint.C() = io_construct_drive();
kDiskMountpoint.D() = io_construct_drive();
- kcout << "Constructing A: [ OK ]\r";
+ kcout << "Creating A: [ OK ]\r";
return true;
}
diff --git a/dev/ZKAKit/src/Heap.cc b/dev/ZKAKit/src/Heap.cc
index 9dfb9cca..3c95a205 100644
--- a/dev/ZKAKit/src/Heap.cc
+++ b/dev/ZKAKit/src/Heap.cc
@@ -72,7 +72,7 @@ namespace Kernel
/// @brief Check for heap address validity.
/// @param heap_ptr The address_ptr to check.
/// @return Bool if the pointer is valid or not.
- auto mm_check_heap_address(VoidPtr heap_ptr) -> Bool
+ _Output auto mm_check_heap_address(VoidPtr heap_ptr) -> Bool
{
if (!heap_ptr)
return false;
@@ -114,7 +114,7 @@ namespace Kernel
/// @param wr Read Write bit.
/// @param user User enable bit.
/// @return The newly allocated pointer.
- VoidPtr mm_new_heap(const SizeT sz, const bool wr, const bool user)
+ _Output VoidPtr mm_new_heap(const SizeT sz, const bool wr, const bool user)
{
auto sz_fix = sz;
@@ -154,7 +154,7 @@ namespace Kernel
/// @brief Makes a page heap.
/// @param heap_ptr the pointer to make a page heap.
/// @return kErrorSuccess if successful, otherwise an error code.
- Int32 mm_make_page(VoidPtr heap_ptr)
+ _Output Int32 mm_make_page(VoidPtr heap_ptr)
{
if (Detail::mm_check_heap_address(heap_ptr) == No)
return kErrorHeapNotPresent;
@@ -176,7 +176,7 @@ namespace Kernel
/// @brief Overwrites and set the flags of a heap header.
/// @param heap_ptr the pointer to update.
/// @param flags the flags to set.
- Int32 mm_make_flags(VoidPtr heap_ptr, UInt64 flags)
+ _Output Int32 mm_make_flags(VoidPtr heap_ptr, UInt64 flags)
{
if (Detail::mm_check_heap_address(heap_ptr) == No)
return kErrorHeapNotPresent;
@@ -195,7 +195,7 @@ namespace Kernel
/// @brief Gets the flags of a heap header.
/// @param heap_ptr the pointer to get.
- UInt64 mm_get_flags(VoidPtr heap_ptr)
+ _Output UInt64 mm_get_flags(VoidPtr heap_ptr)
{
Detail::HEAP_INFORMATION_BLOCK_PTR heap_info_ptr =
reinterpret_cast<Detail::HEAP_INFORMATION_BLOCK_PTR>(
@@ -210,7 +210,7 @@ namespace Kernel
/// @brief Declare pointer as free.
/// @param heap_ptr the pointer.
/// @return
- Int32 mm_delete_heap(VoidPtr heap_ptr)
+ _Output Int32 mm_delete_heap(VoidPtr heap_ptr)
{
if (Detail::mm_check_heap_address(heap_ptr) == No)
return kErrorHeapNotPresent;
@@ -264,7 +264,7 @@ namespace Kernel
/// @brief Check if pointer is a valid Kernel pointer.
/// @param heap_ptr the pointer
/// @return if it exists.
- Boolean mm_is_valid_heap(VoidPtr heap_ptr)
+ _Output Boolean mm_is_valid_heap(VoidPtr heap_ptr)
{
if (heap_ptr)
{
diff --git a/dev/ZKAKit/src/NeFS+FileMgr.cc b/dev/ZKAKit/src/NeFS+FileMgr.cc
index 2ad68115..5e9397e4 100644
--- a/dev/ZKAKit/src/NeFS+FileMgr.cc
+++ b/dev/ZKAKit/src/NeFS+FileMgr.cc
@@ -19,38 +19,39 @@ namespace Kernel
NeFileSystemMgr::NeFileSystemMgr()
{
MUST_PASS(Detail::fs_init_newfs());
- fImpl = mm_new_class<NeFSParser>();
+
+ NeFSParser* fImpl;
+ mm_new_class<NeFSParser>(&fImpl);
MUST_PASS(fImpl);
- kcout << "We are done here... (NeFileSystemMgr).\r";
+ kcout << "We are done allocating NeFSParser...\r";
}
NeFileSystemMgr::~NeFileSystemMgr()
{
if (fImpl)
{
- kcout << "Destroying FS class (NeFS)...\r";
+ kcout << "Destroying NeFSParser...\r";
- delete fImpl;
- fImpl = nullptr;
+ mm_delete_class(&fImpl);
}
}
/// @brief Removes a node from the filesystem.
- /// @param fileName The filename
+ /// @param path The filename
/// @return If it was deleted or not.
- bool NeFileSystemMgr::Remove(const Char* fileName)
+ bool NeFileSystemMgr::Remove(_Input const Char* path)
{
- if (fileName == nullptr || *fileName == 0)
+ if (path == nullptr || *path == 0)
return false;
- return fImpl->RemoveCatalog(fileName);
+ return fImpl->RemoveCatalog(path);
}
/// @brief Creates a node with the specified.
/// @param path The filename path.
/// @return The Node pointer.
- NodePtr NeFileSystemMgr::Create(const Char* path)
+ NodePtr NeFileSystemMgr::Create(_Input const Char* path)
{
return node_cast(fImpl->CreateCatalog(path));
}
diff --git a/dev/ZKAKit/src/Utils.cc b/dev/ZKAKit/src/Utils.cc
index 94ca1027..3b7bc046 100644
--- a/dev/ZKAKit/src/Utils.cc
+++ b/dev/ZKAKit/src/Utils.cc
@@ -211,7 +211,7 @@ namespace Kernel
}
} // namespace Kernel
-EXTERN_C Kernel::VoidPtr memset(Kernel::VoidPtr dst, Kernel::UInt32 c, Kernel::Size len)
+EXTERN_C void* memset(void* dst, int c, __SIZE_TYPE__ len)
{
return Kernel::rt_set_memory(dst, c, len);
}