summaryrefslogtreecommitdiffhomepage
path: root/dev/kernel
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-04-20 16:47:35 +0200
committerAmlal El Mahrouss <amlal@nekernel.org>2025-04-20 16:47:35 +0200
commitbc97b2b790eb06d8f9adb8ef8fa41874d7d19770 (patch)
treea6929db78467c2b07877abb9d9aad579d77139bb /dev/kernel
parent699e395505a602f4a731c481646233d87f87a85c (diff)
kernel, dev: python script to make an ESP from files.
- Started implementing the wrt_* APIs (Wide string functions) - Make user.sys link now, need to implement more syscalls. - Tiny HEFS refactors too. Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/kernel')
-rw-r--r--dev/kernel/FSKit/HeFS.h12
-rw-r--r--dev/kernel/NewKit/Utils.h1
-rw-r--r--dev/kernel/amd64-desktop.make2
-rw-r--r--dev/kernel/src/FS/HeFS.cc21
-rw-r--r--dev/kernel/src/KString.cc2
-rw-r--r--dev/kernel/src/Utils.cc10
6 files changed, 31 insertions, 17 deletions
diff --git a/dev/kernel/FSKit/HeFS.h b/dev/kernel/FSKit/HeFS.h
index 58f51ae3..d0311a38 100644
--- a/dev/kernel/FSKit/HeFS.h
+++ b/dev/kernel/FSKit/HeFS.h
@@ -26,9 +26,9 @@
#define kHeFSMinimumDiskSize (gib_cast(4))
-struct HeFS_BOOT_NODE;
-struct HeFS_INDEX_NODE;
-struct HeFS_INDEX_NODE_DIRECTORY;
+struct HEFS_BOOT_NODE;
+struct HEFS_INDEX_NODE;
+struct HEFS_INDEX_NODE_DIRECTORY;
enum
{
@@ -84,7 +84,7 @@ inline constexpr UInt16 kHeFSInvalidVID = 0xFFFF;
/// @brief HeFS Boot node.
/// @details Acts like a superblock, it contains the information about the filesystem.
/// @note The boot node is the first block of the filesystem.
-struct PACKED HeFS_BOOT_NODE final
+struct PACKED HEFS_BOOT_NODE final
{
Kernel::Char fMagic[kHeFSMagicLen]; /// @brief Magic number of the filesystem.
Kernel::Utf16Char fVolName[kHeFSPartNameLen]; /// @brief Volume name.
@@ -115,7 +115,7 @@ inline constexpr ATime kHeFSTimeMax = 0xFFFFFFFFFFFFFFFF;
/// @details This structure is used to store the file information of a file.
/// @note The index node is a special type of INode that contains the file information.
/// @note The index node is used to store the file information of a file.
-struct PACKED HeFS_INDEX_NODE final
+struct PACKED HEFS_INDEX_NODE final
{
Kernel::Utf16Char fName[kHeFSFileNameLen]; /// @brief File name.
Kernel::UInt32 fFlags; /// @brief File flags.
@@ -147,7 +147,7 @@ enum
/// @brief HeFS directory node.
/// @details This structure is used to store the directory information of a file.
/// @note The directory node is a special type of INode that contains the directory entries.
-struct PACKED HeFS_INDEX_NODE_DIRECTORY final
+struct PACKED HEFS_INDEX_NODE_DIRECTORY final
{
Kernel::Utf16Char fName[kHeFSFileNameLen]; /// @brief Directory name.
diff --git a/dev/kernel/NewKit/Utils.h b/dev/kernel/NewKit/Utils.h
index 5fc77366..7340631b 100644
--- a/dev/kernel/NewKit/Utils.h
+++ b/dev/kernel/NewKit/Utils.h
@@ -18,6 +18,7 @@ namespace Kernel
Int rt_string_cmp(const Char* src, const Char* cmp, Size len);
const Char* rt_alloc_string(const Char* text);
Size rt_string_len(const Char* str);
+ Size wrt_string_len(const Utf16Char* str);
Size rt_string_len(const Char* str, SizeT _len);
Boolean rt_to_string(Char* str_out, UInt64 base, Int32 limit);
Boolean rt_is_newln(Char chr);
diff --git a/dev/kernel/amd64-desktop.make b/dev/kernel/amd64-desktop.make
index 714b045d..ca31d130 100644
--- a/dev/kernel/amd64-desktop.make
+++ b/dev/kernel/amd64-desktop.make
@@ -5,7 +5,7 @@
CXX = x86_64-w64-mingw32-g++
LD = x86_64-w64-mingw32-ld
-CCFLAGS = -fshort-wchar -c -D__NE_AMD64__ -Wall -Wpedantic -Wextra -mno-red-zone -fno-rtti -fno-exceptions -std=c++20 -D__FSKIT_INCLUDES_HeFS__ -D__NE_SUPPORT_NX__ -O0 -I../vendor -D__FSKIT_INCLUDES_NEFS__ -D__NEOSKRNL__ -D__HAVE_NE_APIS__ -D__FREESTANDING__ -D__NE_VIRTUAL_MEMORY_SUPPORT__ -D__NE_AUTO_FORMAT__ -D__NE__ -I./ -I../ -I../boot
+CCFLAGS = -fshort-wchar -c -D__NE_AMD64__ -Wall -Wpedantic -Wextra -mno-red-zone -fno-rtti -fno-exceptions -std=c++20 -D__FSKIT_INCLUDES_HEFS__ -D__NE_SUPPORT_NX__ -O0 -I../vendor -D__FSKIT_INCLUDES_NEFS__ -D__NEOSKRNL__ -D__HAVE_NE_APIS__ -D__FREESTANDING__ -D__NE_VIRTUAL_MEMORY_SUPPORT__ -D__NE_AUTO_FORMAT__ -D__NE__ -I./ -I../ -I../boot
ASM = nasm
diff --git a/dev/kernel/src/FS/HeFS.cc b/dev/kernel/src/FS/HeFS.cc
index 0344309e..142ddbea 100644
--- a/dev/kernel/src/FS/HeFS.cc
+++ b/dev/kernel/src/FS/HeFS.cc
@@ -4,7 +4,7 @@
------------------------------------------- */
-#ifdef __FSKIT_INCLUDES_HeFS__
+#ifdef __FSKIT_INCLUDES_HEFS__
#include <modules/AHCI/AHCI.h>
#include <modules/ATA/ATA.h>
@@ -22,12 +22,12 @@ namespace Kernel
{
namespace Detail
{
- STATIC HeFS_INDEX_NODE* hefs_get_index_node(HeFS_BOOT_NODE* root, DriveTrait* mnt, const Utf16Char* dir_name, const Utf16Char* file_name, UInt8 kind) noexcept
+ STATIC HEFS_INDEX_NODE* hefs_get_index_node(HEFS_BOOT_NODE* root, DriveTrait* mnt, const Utf16Char* dir_name, const Utf16Char* file_name, UInt8 kind) noexcept
{
if (root)
{
- HeFS_INDEX_NODE* node = new HeFS_INDEX_NODE();
- HeFS_INDEX_NODE_DIRECTORY* dir = new HeFS_INDEX_NODE_DIRECTORY();
+ HEFS_INDEX_NODE* node = new HEFS_INDEX_NODE();
+ HEFS_INDEX_NODE_DIRECTORY* dir = new HEFS_INDEX_NODE_DIRECTORY();
if (!node)
{
@@ -45,7 +45,7 @@ namespace Kernel
if (hop_watch++ > 100)
{
kout << "Error: Hop watch exceeded.\r";
-
+
break;
}
@@ -56,7 +56,7 @@ namespace Kernel
}
mnt->fPacket.fPacketLba = start;
- mnt->fPacket.fPacketSize = sizeof(HeFS_INDEX_NODE_DIRECTORY);
+ mnt->fPacket.fPacketSize = sizeof(HEFS_INDEX_NODE_DIRECTORY);
mnt->fPacket.fPacketContent = dir;
mnt->fInput(mnt->fPacket);
@@ -81,7 +81,7 @@ namespace Kernel
if (dir->fIndexNodeStart[inode_index] != 0)
{
mnt->fPacket.fPacketLba = dir->fIndexNodeStart[inode_index];
- mnt->fPacket.fPacketSize = sizeof(HeFS_INDEX_NODE);
+ mnt->fPacket.fPacketSize = sizeof(HEFS_INDEX_NODE);
mnt->fPacket.fPacketContent = node;
mnt->fInput(mnt->fPacket);
@@ -103,7 +103,7 @@ namespace Kernel
else if (dir->fIndexNodeEnd[inode_index] != 0)
{
mnt->fPacket.fPacketLba = dir->fIndexNodeEnd[inode_index];
- mnt->fPacket.fPacketSize = sizeof(HeFS_INDEX_NODE);
+ mnt->fPacket.fPacketSize = sizeof(HEFS_INDEX_NODE);
mnt->fPacket.fPacketContent = node;
mnt->fInput(mnt->fPacket);
@@ -151,4 +151,7 @@ namespace Kernel
} // namespace Detail
} // namespace Kernel
-#endif // ifdef __FSKIT_INCLUDES_HeFS__
+/// @note HeFS will allocate inodes and ind in advance, to avoid having to allocate them in real-time.
+/// @note This is certainly take longer to format a disk with it, but worth-it in the long run.
+
+#endif // ifdef __FSKIT_INCLUDES_HEFS__
diff --git a/dev/kernel/src/KString.cc b/dev/kernel/src/KString.cc
index 2f81ad3d..cb21e003 100644
--- a/dev/kernel/src/KString.cc
+++ b/dev/kernel/src/KString.cc
@@ -146,7 +146,7 @@ namespace Kernel
/// @note This is unsafe!!!
bool KStringBuilder::Equals(const Utf16Char* lhs, const Utf16Char* rhs)
{
- for (Size index = 0; index[rhs] != 0; ++index)
+ for (Size index = 0; index < wrt_string_len(rhs); ++index)
{
if (rhs[index] != lhs[index])
return false;
diff --git a/dev/kernel/src/Utils.cc b/dev/kernel/src/Utils.cc
index f5e61ddf..10c5d714 100644
--- a/dev/kernel/src/Utils.cc
+++ b/dev/kernel/src/Utils.cc
@@ -42,6 +42,16 @@ namespace Kernel
return len;
}
+
+ Size wrt_string_len(const Utf16Char* str)
+ {
+ SizeT len{0};
+
+ while (str[len] != 0)
+ ++len;
+
+ return len;
+ }
Size rt_string_len(const Char* ptr)
{