summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-04-01 19:00:28 +0200
committerAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-04-01 19:00:28 +0200
commit9805813dea123dcf4293e4f4b28152a10604fef7 (patch)
tree5b5a39d385a100730c99be91a8012dd4cf5c4314
parent3c4efadf68e2071429925ea7f90f73341200a42f (diff)
NewKernel: v412024
- ke_bug_check returns true by default now. BugFix. - Document file manager. - Improv - Add \r\n instead of \n endings - Improv.
-rw-r--r--Private/NewKit/Json.hpp4
-rw-r--r--Private/Source/HError.cxx5
-rw-r--r--Private/Source/KernelHeap.cxx23
-rw-r--r--Private/Source/LockDelegate.cxx2
-rw-r--r--Private/Source/NewFS+FileManager.cxx25
-rw-r--r--Private/Source/ProcessScheduler.cxx4
-rw-r--r--Private/Source/ThreadLocalStorage.cxx6
-rw-r--r--Private/Source/URL.cxx4
-rw-r--r--Private/makefile7
9 files changed, 55 insertions, 25 deletions
diff --git a/Private/NewKit/Json.hpp b/Private/NewKit/Json.hpp
index 6be7430d..cc8afe1a 100644
--- a/Private/NewKit/Json.hpp
+++ b/Private/NewKit/Json.hpp
@@ -34,11 +34,11 @@ class JsonType final {
public:
/// @brief returns the key of the json
- /// @return
+ /// @return the key as string view.
StringView &AsKey() { return fKey; }
/// @brief returns the value of the json.
- /// @return
+ /// @return the key as string view.
StringView &AsValue() { return fValue; }
static JsonType kUndefined;
diff --git a/Private/Source/HError.cxx b/Private/Source/HError.cxx
index d5995150..ea5d0974 100644
--- a/Private/Source/HError.cxx
+++ b/Private/Source/HError.cxx
@@ -7,5 +7,8 @@
#include <KernelKit/HError.hpp>
namespace NewOS {
-Boolean ke_bug_check(void) noexcept { return false; }
+/// @brief Doea a system wide bug check.
+/// @param void no params.
+/// @return if error-free: true, otherwise false.
+Boolean ke_bug_check(void) noexcept { return true; }
} // namespace NewOS
diff --git a/Private/Source/KernelHeap.cxx b/Private/Source/KernelHeap.cxx
index 10991b36..a4a0b323 100644
--- a/Private/Source/KernelHeap.cxx
+++ b/Private/Source/KernelHeap.cxx
@@ -25,11 +25,16 @@ namespace Detail {
/// Located before the address bytes.
/// | HIB | ADDRESS |
struct PACKED HeapInformationBlock final {
+ ///! @brief 32-bit value which contains the magic number of the executable.
UInt32 hMagic;
+ ///! @brief Boolean value which tells if the pointer is allocated.
Boolean hPresent;
+ ///! @brief 32-bit CRC checksum
UInt32 hCRC32;
- SizeT hSizeAddress;
- UIntPtr hTargetAddress;
+ /// @brief 64-bit pointer size.
+ SizeT hSizePtr;
+ /// @brief 64-bit target pointer.
+ UIntPtr hTargetPtr;
UInt8 hPadding[kHeapHeaderPaddingSz];
};
@@ -50,10 +55,10 @@ VoidPtr ke_new_ke_heap(SizeT sz, const bool rw, const bool user) {
reinterpret_cast<Detail::HeapInformationBlockPtr>(
wrapper.VirtualAddress());
- heapInfo->hSizeAddress = sz;
+ heapInfo->hSizePtr = sz;
heapInfo->hMagic = kHeapMagic;
heapInfo->hCRC32 = 0; // dont fill it for now.
- heapInfo->hTargetAddress = wrapper.VirtualAddress();
+ heapInfo->hTargetPtr = wrapper.VirtualAddress();
++kHeapCount;
@@ -78,15 +83,15 @@ Int32 ke_delete_ke_heap(VoidPtr heapPtr) {
if (virtualAddress->hCRC32 != 0) {
if (virtualAddress->hCRC32 !=
- ke_calculate_crc32((Char *)virtualAddress->hTargetAddress,
- virtualAddress->hSizeAddress)) {
+ ke_calculate_crc32((Char *)virtualAddress->hTargetPtr,
+ virtualAddress->hSizePtr)) {
ke_stop(RUNTIME_CHECK_POINTER);
}
}
- virtualAddress->hSizeAddress = 0UL;
+ virtualAddress->hSizePtr = 0UL;
virtualAddress->hPresent = false;
- virtualAddress->hTargetAddress = 0;
+ virtualAddress->hTargetPtr = 0;
virtualAddress->hCRC32 = 0;
virtualAddress->hMagic = 0;
@@ -127,7 +132,7 @@ Boolean ke_protect_ke_heap(VoidPtr heapPtr) {
if (virtualAddress->hPresent && virtualAddress->hMagic == kHeapMagic) {
virtualAddress->hCRC32 =
- ke_calculate_crc32((Char *)heapPtr, virtualAddress->hSizeAddress);
+ ke_calculate_crc32((Char *)heapPtr, virtualAddress->hSizePtr);
return true;
}
}
diff --git a/Private/Source/LockDelegate.cxx b/Private/Source/LockDelegate.cxx
index 34cb490d..7bb77fbc 100644
--- a/Private/Source/LockDelegate.cxx
+++ b/Private/Source/LockDelegate.cxx
@@ -5,3 +5,5 @@
------------------------------------------- */
#include <KernelKit/LockDelegate.hpp>
+
+namespace NewOS {} // namespace NewOS \ No newline at end of file
diff --git a/Private/Source/NewFS+FileManager.cxx b/Private/Source/NewFS+FileManager.cxx
index 171f0c6f..4ba95d89 100644
--- a/Private/Source/NewFS+FileManager.cxx
+++ b/Private/Source/NewFS+FileManager.cxx
@@ -12,35 +12,54 @@
/// BUGS: 0
namespace NewOS {
+/// @brief C++ constructor
NewFilesystemManager::NewFilesystemManager() = default;
NewFilesystemManager::~NewFilesystemManager() = default;
-bool NewFilesystemManager::Remove(const char* node_name) {
- if (node_name == nullptr || *node_name == 0) return false;
+/// @brief Removes a node from the filesystem.
+/// @param fileName The filename
+/// @return If it was deleted or not.
+bool NewFilesystemManager::Remove(const char* fileName) {
+ if (fileName == nullptr || *fileName == 0) return false;
- if (auto catalog = fImpl->GetCatalog(node_name); catalog)
+ if (auto catalog = fImpl->GetCatalog(fileName); catalog)
return fImpl->RemoveCatalog(catalog);
return false;
}
+/// @brief Creates a node with the specified.
+/// @param path The filename path.
+/// @return The Node pointer.
NodePtr NewFilesystemManager::Create(const char* path) {
return node_cast(fImpl->CreateCatalog(path, 0, kNewFSCatalogKindFile));
}
+/// @brief Creates a node with is a directory.
+/// @param path The filename path.
+/// @return The Node pointer.
NodePtr NewFilesystemManager::CreateDirectory(const char* path) {
return node_cast(fImpl->CreateCatalog(path, 0, kNewFSCatalogKindDir));
}
+/// @brief Creates a node with is a alias.
+/// @param path The filename path.
+/// @return The Node pointer.
NodePtr NewFilesystemManager::CreateAlias(const char* path) {
return node_cast(fImpl->CreateCatalog(path, 0, kNewFSCatalogKindAlias));
}
+/// @brief Gets the root directory.
+/// @return
const char* NewFilesystemHelper::Root() { return kNewFSRoot; }
+/// @brief Gets the up-dir directory.
+/// @return
const char* NewFilesystemHelper::UpDir() { return kNewFSUpDir; }
+/// @brief Gets the separator character.
+/// @return
const char NewFilesystemHelper::Separator() { return kNewFSSeparator; }
} // namespace NewOS
diff --git a/Private/Source/ProcessScheduler.cxx b/Private/Source/ProcessScheduler.cxx
index 88e0e074..5d8a7f56 100644
--- a/Private/Source/ProcessScheduler.cxx
+++ b/Private/Source/ProcessScheduler.cxx
@@ -33,7 +33,7 @@ const Int32 &rt_get_exit_code() noexcept { return kExitCode; }
void ProcessHeader::Crash() {
kcout << "ProcessScheduler: Crashed, ExitCode: -1.\r\n";
- MUST_PASS(!ke_bug_check());
+ MUST_PASS(ke_bug_check());
this->Exit(-1);
}
@@ -225,6 +225,8 @@ Ref<ProcessScheduler> ProcessScheduler::Shared() {
return {ref};
}
+/// @brief Gets current running process.
+/// @return
Ref<ProcessHeader> &ProcessScheduler::GetCurrent() { return mTeam.AsRef(); }
PID &ProcessHelper::GetCurrentPID() {
diff --git a/Private/Source/ThreadLocalStorage.cxx b/Private/Source/ThreadLocalStorage.cxx
index 20f9d337..3d0a8cdb 100644
--- a/Private/Source/ThreadLocalStorage.cxx
+++ b/Private/Source/ThreadLocalStorage.cxx
@@ -31,7 +31,7 @@ Boolean tls_check_tib(ThreadInformationBlock* tib) {
Encoder encoder;
const char* tibAsBytes = encoder.AsBytes(tib);
- kcout << "NewOS: Checking for a valid cookie...\n";
+ kcout << "NewOS: Checking for a valid cookie...\r\n";
return tibAsBytes[0] == kCookieMag0 && tibAsBytes[1] == kCookieMag1 &&
tibAsBytes[2] == kCookieMag2;
@@ -46,9 +46,9 @@ EXTERN_C Void tls_check_syscall_impl(NewOS::HAL::StackFramePtr stackPtr) noexcep
ThreadInformationBlock* tib = (ThreadInformationBlock*)stackPtr->Gs;
if (!tls_check_tib(tib)) {
- kcout << "NewOS: Verification failed, Crashing...\n";
+ kcout << "NewOS: Verification failed, Crashing...\r\n";
ProcessScheduler::Shared().Leak().GetCurrent().Leak().Crash();
}
- kcout << "NewOS: Verification succeeded! Keeping on...\n";
+ kcout << "NewOS: Verification succeeded! Keeping on...\r\n";
}
diff --git a/Private/Source/URL.cxx b/Private/Source/URL.cxx
index 004717ae..fba6bca9 100644
--- a/Private/Source/URL.cxx
+++ b/Private/Source/URL.cxx
@@ -16,8 +16,8 @@ Url::Url(StringView &strUrl) : m_urlView(strUrl, false) {}
Url::~Url() = default;
constexpr const char *kURLProtocols[] = {
- "https", // http with the secure.
- "http", // http without the secure
+ "https", // http with tls.
+ "http", // http
"file", // filesystem protocol
"ftp", // file transfer protocol
};
diff --git a/Private/makefile b/Private/makefile
index b8bd757e..a1661bb6 100644
--- a/Private/makefile
+++ b/Private/makefile
@@ -43,15 +43,14 @@ link-amd64-epm:
.PHONY: all
all: h-core-amd64-epm link-amd64-epm
- @echo "Fully built."
-
+ @echo "NewKernel => OK."
.PHONY: help
help:
@echo "=== HELP ==="
@echo "all: Build kernel and link it."
- @echo "link-amd64: Link kernel. (PC AMD64)"
- @echo "h-core-amd64: Build kernel. (PC AMD64)"
+ @echo "link-amd64-epm: Link kernel. (PC AMD64)"
+ @echo "h-core-amd64-epm: Build kernel. (PC AMD64)"
.PHONY: clean
clean: