summaryrefslogtreecommitdiffhomepage
path: root/Private/KernelKit
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlalelmahrouss@icloud.com>2024-02-05 11:12:42 +0100
committerAmlal El Mahrouss <amlalelmahrouss@icloud.com>2024-02-05 11:12:42 +0100
commit81144dd05a7c01701c3bf7b04e345dccfef2bf82 (patch)
tree163bd79816e97ca31484df86c008af3f9a803ffd /Private/KernelKit
parentf8c9b81ff120160af60af6e9d44cba338aceb65a (diff)
HCR-11:
Kernel: Improvements and more. Bootloader: Now works on real hardware (previous commit.) Signed-off-by: Amlal El Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Private/KernelKit')
-rw-r--r--Private/KernelKit/FileManager.hpp12
-rw-r--r--Private/KernelKit/PEF.hpp4
-rw-r--r--Private/KernelKit/SMPManager.hpp8
-rw-r--r--Private/KernelKit/ThreadLocalStorage.hxx12
4 files changed, 24 insertions, 12 deletions
diff --git a/Private/KernelKit/FileManager.hpp b/Private/KernelKit/FileManager.hpp
index a52daa7d..d31cdf68 100644
--- a/Private/KernelKit/FileManager.hpp
+++ b/Private/KernelKit/FileManager.hpp
@@ -162,7 +162,7 @@ class NewFilesystemManager final : public IFilesystemManager {
template <typename Encoding = char, typename FSClass = IFilesystemManager>
class FileStream final {
public:
- explicit FileStream(const Encoding *path);
+ explicit FileStream(const Encoding *path, const Encoding *restrict_type);
~FileStream();
public:
@@ -224,12 +224,18 @@ class FileStream final {
const Char *fMime{"application-type/*"};
};
+#define kRestrictRW "r+"
+#define kRestrictRWB "r+b"
+#define kRestrictR "r"
+#define kRestrictRB "rb"
+
using FileStreamUTF8 = FileStream<char>;
using FileStreamUTF16 = FileStream<wchar_t>;
template <typename Encoding, typename Class>
-FileStream<Encoding, Class>::FileStream(const Encoding *path)
- : fFile(Class::GetMounted()->Open(path, "r+")) {}
+FileStream<Encoding, Class>::FileStream(const Encoding *path,
+ const Encoding *restrict_type)
+ : fFile(Class::GetMounted()->Open(path, restrict_type)) {}
template <typename Encoding, typename Class>
FileStream<Encoding, Class>::~FileStream() = default;
diff --git a/Private/KernelKit/PEF.hpp b/Private/KernelKit/PEF.hpp
index 1add45f8..2ffc057f 100644
--- a/Private/KernelKit/PEF.hpp
+++ b/Private/KernelKit/PEF.hpp
@@ -37,8 +37,8 @@ enum {
kPefArchIntel86S,
kPefArchAMD64,
kPefArchRISCV,
- kPefArch64x0, /* 64x000. */
- kPefArch32x0,
+ kPefArch64x0, /* 64x0. ISA */
+ kPefArch32x0, /* 32x0. ISA */
kPefArchCount = (kPefArch32x0 - kPefArchIntel86S) + 1,
kPefArchInvalid = 0xFF,
};
diff --git a/Private/KernelKit/SMPManager.hpp b/Private/KernelKit/SMPManager.hpp
index 0a71a165..8cbe3259 100644
--- a/Private/KernelKit/SMPManager.hpp
+++ b/Private/KernelKit/SMPManager.hpp
@@ -14,6 +14,8 @@
#include <CompilerKit/CompilerKit.hpp>
#include <NewKit/Ref.hpp>
+#include "NewKit/Defines.hpp"
+
#define kMaxHarts 8
namespace HCore {
@@ -25,6 +27,8 @@ enum ThreadKind {
kFallback, // fallback thread, cannot be used by user if not clear or used by
// kernel.
kBoot, // The core we booted from, the mama.
+ kInvalidThread,
+ kThreadCount,
};
///
@@ -100,7 +104,9 @@ class SMPManager final {
private:
Array<HardwareThread, kMaxHarts> m_ThreadList;
- ThreadID m_CurrentThread;
+ ThreadID m_CurrentThread{0};
+ SizeT m_UsedThreads{0};
+ SizeT m_MaxThreads{0};
};
// @brief wakes up thread.
diff --git a/Private/KernelKit/ThreadLocalStorage.hxx b/Private/KernelKit/ThreadLocalStorage.hxx
index 5db78ca3..e7c55ee7 100644
--- a/Private/KernelKit/ThreadLocalStorage.hxx
+++ b/Private/KernelKit/ThreadLocalStorage.hxx
@@ -27,16 +27,16 @@ bool hcore_tls_delete_ptr(T *ptr);
template <typename T, typename... Args>
T *hcore_tls_new_class(Args &&...args);
-typedef char rt_cookie_type[3];
+typedef HCore::Char rt_cookie_type[3];
/// @brief Thread Information Block for Local Storage.
/// Located in GS on AMD64, Virtual Address 0x10000 (64x0, 32x0, ARM64)
struct ThreadInformationBlock final {
- HCore::Char Name[255]; // Module Name
- HCore::UIntPtr StartCode; // Start Address
- HCore::UIntPtr StartData; // Allocation Heap
- HCore::UIntPtr StartStack; // Stack Pointer.
- HCore::Int32 Arch; // Architecture and/or platform.
+ HCore::Char Name[kNameLen]; // Module Name
+ HCore::UIntPtr StartCode; // Start Address
+ HCore::UIntPtr StartData; // Allocation Heap
+ HCore::UIntPtr StartStack; // Stack Pointer.
+ HCore::Int32 Arch; // Architecture and/or platform.
rt_cookie_type Cookie; // Not shown in public header, this is the way we tell
// something went wrong.
};