summaryrefslogtreecommitdiffhomepage
path: root/src/boot
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-12-09 02:50:07 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2025-12-09 02:52:34 +0100
commit4d192e629a07ae457134cb0063e0136e54b01008 (patch)
treeb933444d27c2b9ac22693e2e65bd294792c79d39 /src/boot
parentf78c535aec66e02584e1b02995dc12c9e1bcb64c (diff)
chore: Codebase improvements and tweaks.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'src/boot')
-rw-r--r--src/boot/BootKit/BootKit.h7
-rw-r--r--src/boot/BootKit/Config.h16
-rw-r--r--src/boot/BootKit/Device.h20
-rw-r--r--src/boot/BootKit/EPM.h5
-rw-r--r--src/boot/BootKit/HW/ATA.h4
-rw-r--r--src/boot/BootKit/HW/SATA.h4
-rw-r--r--src/boot/src/docs/KERN_VER.md18
-rw-r--r--src/boot/src/docs/MKFS_HEFS.md106
8 files changed, 43 insertions, 137 deletions
diff --git a/src/boot/BootKit/BootKit.h b/src/boot/BootKit/BootKit.h
index fb8941e0..b00fd112 100644
--- a/src/boot/BootKit/BootKit.h
+++ b/src/boot/BootKit/BootKit.h
@@ -9,7 +9,10 @@
/// @brief Bootloader Application Programming Interface.
/***********************************************************************************/
-#pragma once
+#ifndef __BOOTKIT_H__
+#define __BOOTKIT_H__
+
+#include <BootKit/Config.h>
#include <BootKit/HW/ATA.h>
#include <CompilerKit/Version.h>
@@ -333,3 +336,5 @@ inline Boolean BDiskFormatFactory<BootDev>::Format(const Char* part_name) {
return YES;
}
} // namespace Boot
+
+#endif // __BOOTKIT_H__ \ No newline at end of file
diff --git a/src/boot/BootKit/Config.h b/src/boot/BootKit/Config.h
new file mode 100644
index 00000000..b2641b24
--- /dev/null
+++ b/src/boot/BootKit/Config.h
@@ -0,0 +1,16 @@
+/* ========================================
+
+ Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
+
+======================================== */
+
+#ifndef __BOOTKIT_CONFIG_H__
+#define __BOOTKIT_CONFIG_H__
+
+#include <NeKit/Config.h>
+
+namespace Boot {
+ using namespace Kernel;
+}
+
+#endif // ! __BOOTKIT_CONFIG_H__ \ No newline at end of file
diff --git a/src/boot/BootKit/Device.h b/src/boot/BootKit/Device.h
index 36e2b3d4..efe27659 100644
--- a/src/boot/BootKit/Device.h
+++ b/src/boot/BootKit/Device.h
@@ -4,13 +4,15 @@
======================================== */
-#pragma once
+#ifndef __BOOTKIT_DEVICE_H__
+#define __BOOTKIT_DEVICE_H__
+#include <BootKit/Config.h>
#include <modules/AHCI/AHCI.h>
#include <modules/ATA/ATA.h>
-namespace Kernel {
-/// @brief Device type.
+namespace Boot {
+/// @brief Physical/Virtual device type.
class Device {
public:
explicit Device() = default;
@@ -19,7 +21,7 @@ class Device {
NE_MOVE_DEFAULT(Device)
struct Trait {
- SizeT mBase{0};
+ Lba mBase{0};
SizeT mSize{0};
};
@@ -29,7 +31,9 @@ class Device {
virtual Device& Write(Char* Buf, SizeT SecCount) = 0;
};
-typedef Device BootDevice;
-typedef Device NetworkDevice;
-typedef Device DiskDevice;
-} // namespace Kernel \ No newline at end of file
+using BootDevice = Device;
+using NetworkDevice = Device;
+using DiskDevice = Device;
+} // namespace Boot
+
+#endif \ No newline at end of file
diff --git a/src/boot/BootKit/EPM.h b/src/boot/BootKit/EPM.h
index cc82dd41..5657337a 100644
--- a/src/boot/BootKit/EPM.h
+++ b/src/boot/BootKit/EPM.h
@@ -4,6 +4,9 @@
======================================== */
-#pragma once
+#ifndef __BOOTKIT_EPM_H__
+#define __BOOTKIT_EPM_H__
#include <FirmwareKit/EPM.h>
+
+#endif \ No newline at end of file
diff --git a/src/boot/BootKit/HW/ATA.h b/src/boot/BootKit/HW/ATA.h
index 7ebf296d..1842300b 100644
--- a/src/boot/BootKit/HW/ATA.h
+++ b/src/boot/BootKit/HW/ATA.h
@@ -9,8 +9,7 @@
#include <BootKit/Device.h>
#include <modules/ATA/ATA.h>
-using namespace Kernel;
-
+namespace Boot {
class BootDeviceATA final : public Device {
public:
enum {
@@ -45,3 +44,4 @@ class BootDeviceATA final : public Device {
private:
ATATrait mTrait;
};
+} // namespace Boot \ No newline at end of file
diff --git a/src/boot/BootKit/HW/SATA.h b/src/boot/BootKit/HW/SATA.h
index 68ed30c8..442ea399 100644
--- a/src/boot/BootKit/HW/SATA.h
+++ b/src/boot/BootKit/HW/SATA.h
@@ -12,6 +12,7 @@
#define kAHCISectorSz (512)
+namespace Boot {
class BootDeviceSATA final {
public:
explicit BootDeviceSATA();
@@ -23,7 +24,7 @@ class BootDeviceSATA final {
Kernel::Boolean mErr{false};
Kernel::Boolean mDetected{false};
- operator bool() { return !this->mErr; }
+ explicit operator bool() { return !this->mErr; }
};
operator bool() { return this->Leak().mDetected; }
@@ -40,3 +41,4 @@ class BootDeviceSATA final {
private:
SATATrait mTrait;
};
+} // namespace Boot \ No newline at end of file
diff --git a/src/boot/src/docs/KERN_VER.md b/src/boot/src/docs/KERN_VER.md
deleted file mode 100644
index c47c3d5b..00000000
--- a/src/boot/src/docs/KERN_VER.md
+++ /dev/null
@@ -1,18 +0,0 @@
-# `/props/kern_ver` โ€” NVRAM EFI Variable
-
-The `/props/kern_ver` variable is used to track NeKernel's current version in a BCD format.
-
-## ๐Ÿ›  Reason
-
-- It is also used for:
- - Bug tracking and system patching.
- - Version and compatibility checking.
-
-## ๐Ÿงช Usage
-
-N/A
-
-## ยฉ License
-
- Copyright (C) 2025,
- Amlal El Mahrouss โ€“ Licensed under the Apache 2.0 license. \ No newline at end of file
diff --git a/src/boot/src/docs/MKFS_HEFS.md b/src/boot/src/docs/MKFS_HEFS.md
deleted file mode 100644
index b42ad9c2..00000000
--- a/src/boot/src/docs/MKFS_HEFS.md
+++ /dev/null
@@ -1,106 +0,0 @@
-# `mkfs.hefs` โ€“ OpenHeFS Filesystem Formatter
-
-`mkfs.hefs` is a command-line utility used to format a block device or disk image with the **High-throughput Extended File System (OpenHeFS)** used by NeKernel. This tool initializes a OpenHeFS volume by writing a boot node and configuring directory and inode index regions, block ranges, and volume metadata.
-
----
-
-## ๐Ÿ›  Features
-
-- Writes a valid `BootNode` to the specified output device or file.
-- Sets disk size, sector size, and volume label.
-- Supports user-defined ranges for:
- - Index Node Directory (IND)
- - Inodes (IN)
- - Data blocks
-- UTF-8 encoded volume label support.
-- Fully compatible with NeKernel's VFS subsystem.
-
----
-
-## ๐Ÿงช Usage
-
- mkfs.hefs -L <label> -s <sector_size> \
- -b <ind_start> -e <ind_end> \
- -bs <block_start> -be <block_end> \
- -is <in_start> -ie <in_end> \
- -S <disk_size> -o <output_device>
-
----
-
-## ๐Ÿงพ Arguments
-
-| Option | Description |
-|---------------|-------------------------------------------------------------------------|
-| `-L` | Volume label (UTF-8, internally stored as UTF-16) |
-| `-s` | Sector size (e.g., 512) |
-| `-b` `-e` | Start and end addresses for the **Index Node Directory (IND)** region |
-| `-bs` `-be` | Start and end addresses for the **Block** data region |
-| `-is` `-ie` | Start and end addresses for the **Inode** region |
-| `-S` | Disk size in **gigabytes** |
-| `-o` | Path to the output device or image file |
-
-> All address-based inputs (`-b`, `-e`, etc.) must be specified in **hexadecimal** format.
-
----
-
-## ๐Ÿงท Notes
-
-- Default sector size is `512` bytes.
-- Default volume name is `"HeFS_VOLUME"`, defined as `kOpenHeFSDefaultVolumeName`.
-- The tool writes a `BootNode` at the beginning of the index node range.
-- A CRC-safe magic signature is embedded for boot and integrity validation.
-- After writing the metadata, the tool flushes and closes the file stream.
-
----
-
-## ๐Ÿ’ป Example
-
- mkfs.hefs -L "MyHeFS" -s 512 \
- -b 0x1000 -e 0x8000 \
- -bs 0x8000 -be 0x800000 \
- -is 0x800000 -ie 0xA00000 \
- -S 128 -o hefs.img
-
-This will create a 128 GiB formatted OpenHeFS image named `hefs.img` with specified region boundaries.
-
----
-
-## ๐Ÿ“ BootNode Structure
-
-The `BootNode` stores key filesystem metadata:
-
- struct BootNode {
- char magic[8];
- char16_t volumeName[64];
- uint16_t version;
- uint16_t diskKind;
- uint16_t encoding;
- uint64_t diskSize;
- uint32_t sectorSize;
- uint64_t startIND, endIND;
- uint64_t startIN, endIN;
- uint64_t startBlock, endBlock;
- uint64_t indCount;
- uint16_t diskStatus;
- };
-
----
-
-## โš ๏ธ Error Handling
-
-- Prints usage and exits on invalid/missing arguments.
-- Exits with error if the output device cannot be opened or written to.
-- Checks for zero sector size or disk size to prevent invalid formatting.
-
----
-
-## ๐Ÿ“š Source Location
-
-Part of the [OpenHeFS Tooling module](https://github.com/nekernel-org/nekernel) and used during system setup or disk preparation for NeKernel.
-
----
-
-## ยฉ License
-
- Copyright (C) 2025,
- Amlal El Mahrouss โ€“ Licensed under the Apache 2.0 license. \ No newline at end of file