summaryrefslogtreecommitdiffhomepage
path: root/Private
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-03-19 22:50:16 +0100
committerAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-03-19 22:50:16 +0100
commita0f82d57976648c5bfcf165b2e304d2a4c8fb0c7 (patch)
treec24cd3e850a9fc47b352ac8efa50a93b28388925 /Private
parentde413aa50bac1342e4ac8c7a66697ea3b551c2e4 (diff)
Kernel:Secret: Fix String class.
Improve kernel APIs.
Diffstat (limited to 'Private')
-rw-r--r--Private/KernelKit/ProcessScheduler.hpp3
-rw-r--r--Private/KernelKit/ThreadLocalStorage.hxx4
-rw-r--r--Private/NewBoot/BootKit/BootKit.hxx4
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/BootString.cxx (renamed from Private/NewBoot/Source/BootString.cxx)0
-rw-r--r--Private/Source/String.cxx9
-rw-r--r--Private/Source/ThreadLocalStorage.cxx4
-rw-r--r--Private/Source/Utils.cxx17
7 files changed, 25 insertions, 16 deletions
diff --git a/Private/KernelKit/ProcessScheduler.hpp b/Private/KernelKit/ProcessScheduler.hpp
index ba453fbe..e3cbbe86 100644
--- a/Private/KernelKit/ProcessScheduler.hpp
+++ b/Private/KernelKit/ProcessScheduler.hpp
@@ -205,7 +205,8 @@ public:
using ProcessPtr = Process *;
-//! @brief Kernel scheduler..
+/// @brief Process manager class.
+/// The main class which you call to schedule an app.
class ProcessManager final {
private:
explicit ProcessManager() = default;
diff --git a/Private/KernelKit/ThreadLocalStorage.hxx b/Private/KernelKit/ThreadLocalStorage.hxx
index c6be2c2b..09017fc0 100644
--- a/Private/KernelKit/ThreadLocalStorage.hxx
+++ b/Private/KernelKit/ThreadLocalStorage.hxx
@@ -11,9 +11,9 @@
//! @brief TLS implementation in C++
-#define kCookieMag0 'h'
+#define kCookieMag0 'H'
#define kCookieMag1 'C'
-#define kCookieMag2 'o'
+#define kCookieMag2 'R'
template <typename T>
T *tls_new_ptr(void);
diff --git a/Private/NewBoot/BootKit/BootKit.hxx b/Private/NewBoot/BootKit/BootKit.hxx
index 93f5c6e2..31acff3f 100644
--- a/Private/NewBoot/BootKit/BootKit.hxx
+++ b/Private/NewBoot/BootKit/BootKit.hxx
@@ -154,6 +154,10 @@ inline UInt32 In32(UInt16 port) {
return value;
}
+inline Void rt_hlt() {
+ asm volatile("hlt");
+}
+
#endif // __EFI_x86_64__
/***********************************************************************************/
diff --git a/Private/NewBoot/Source/BootString.cxx b/Private/NewBoot/Source/HEL/AMD64/BootString.cxx
index 9fbe1a11..9fbe1a11 100644
--- a/Private/NewBoot/Source/BootString.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/BootString.cxx
diff --git a/Private/Source/String.cxx b/Private/Source/String.cxx
index 23955068..a27a3a37 100644
--- a/Private/Source/String.cxx
+++ b/Private/Source/String.cxx
@@ -60,8 +60,7 @@ ErrorOr<StringView> StringBuilder::Construct(const Char *data) {
StringView view(rt_string_len(data));
- rt_copy_memory(reinterpret_cast<voidPtr>(const_cast<Char *>(data)),
- reinterpret_cast<voidPtr>(view.Data()), view.Length());
+ view += data;
return ErrorOr<StringView>(view);
}
@@ -165,16 +164,16 @@ const char *StringBuilder::Format(const char *fmt, const char *fmt2) {
}
static void string_append(char *lhs, char *rhs, int cur) {
- if (lhs && rhs && cur < rt_string_len(lhs)) {
+ if (lhs && rhs) {
SizeT sz_rhs = rt_string_len(rhs);
+ if (sz_rhs == 0) return;
+
rt_copy_memory(rhs, lhs + cur, sz_rhs);
}
}
StringView &StringView::operator+=(const Char *rhs) {
- if (rt_string_len(rhs) > rt_string_len(this->m_Data)) return *this;
-
string_append(this->m_Data, const_cast<char *>(rhs), this->m_Cur);
this->m_Cur += rt_string_len(rhs);
diff --git a/Private/Source/ThreadLocalStorage.cxx b/Private/Source/ThreadLocalStorage.cxx
index 30a241ea..ab3b8383 100644
--- a/Private/Source/ThreadLocalStorage.cxx
+++ b/Private/Source/ThreadLocalStorage.cxx
@@ -21,14 +21,14 @@ using namespace HCore;
/**
* Check for cookie inside TIB.
- * @param ptr
+ * @param tib the TIB to check.
* @return if the cookie is enabled.
*/
Boolean tls_check_tib(ThreadInformationBlock* tib) {
if (!tib) return false;
- HCore::Encoder encoder;
+ Encoder encoder;
const char* tibAsBytes = encoder.AsBytes(tib);
kcout << "HCoreKrnl\\TLS: Checking for a valid cookie...\n";
diff --git a/Private/Source/Utils.cxx b/Private/Source/Utils.cxx
index b9264e36..d1b146f8 100644
--- a/Private/Source/Utils.cxx
+++ b/Private/Source/Utils.cxx
@@ -5,6 +5,7 @@
------------------------------------------- */
#include <NewKit/Utils.hpp>
+#include <KernelKit/DebugOutput.hpp>
namespace HCore {
Int rt_string_cmp(const Char *src, const Char *cmp, Size size) {
@@ -36,13 +37,17 @@ Size rt_string_len(const Char *str, SizeT _len) {
return len;
}
-Size rt_string_len(const Char *str) {
- if (*str == '\0') return 0;
+Size rt_string_len(const Char *ptr) {
+ if (!ptr) return 0;
- Size len{0};
- while (str[len] != '\0') ++len;
+ SizeT cnt = 0;
- return len;
+ while (*ptr != (Char)0) {
+ ++ptr;
+ ++cnt;
+ }
+
+ return cnt;
}
voidPtr rt_set_memory(voidPtr src, char value, Size len) {
@@ -70,7 +75,7 @@ Int rt_move_memory(const voidPtr src, voidPtr dst, Size len) {
dstChar[index] = srcChr[index];
srcChr[index] = 0;
- index++;
+ ++index;
}
return 0;