summaryrefslogtreecommitdiffhomepage
path: root/dev/boot
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-05-29 10:51:53 +0200
committerGitHub <noreply@github.com>2025-05-29 10:51:53 +0200
commit5c0bb7ee7b1b0fee02cc179fb21f4c57a61d6c2d (patch)
treecb17577bcdc9714c97a84ce417a075117097f146 /dev/boot
parentd608230b1350b064ceb01e6572519b108f6139b0 (diff)
parent3167f59dbb401d6a79b1524537e04218baf49ee3 (diff)
Merge pull request #32 from nekernel-org/dev
0.0.2e3
Diffstat (limited to 'dev/boot')
-rw-r--r--dev/boot/BootKit/BootKit.h2
-rw-r--r--dev/boot/BootKit/Support.h4
-rw-r--r--dev/boot/amd64-ci.make8
-rw-r--r--dev/boot/amd64-desktop.make16
-rw-r--r--dev/boot/arm64-desktop.make6
-rw-r--r--dev/boot/modules/BootNet/BootNet.cc4
-rw-r--r--dev/boot/modules/SysChk/SysChk.cc7
-rw-r--r--dev/boot/modules/SysChk/amd64-ahci-epm.json1
-rw-r--r--dev/boot/src/BootFileReader.cc6
-rw-r--r--dev/boot/src/BootTextWriter.cc16
-rw-r--r--dev/boot/src/BootThread.cc3
-rw-r--r--dev/boot/src/BootloaderRsrc.rsrc2
-rw-r--r--dev/boot/src/HEL/AMD64/BootAPI.S17
-rw-r--r--dev/boot/src/HEL/AMD64/BootATA.cc256
-rw-r--r--dev/boot/src/HEL/AMD64/BootATAcc (renamed from dev/boot/src/HEL/AMD64/BootATA+Next.cc)4
-rw-r--r--dev/boot/src/HEL/AMD64/BootEFI.cc41
-rw-r--r--dev/boot/src/HEL/ARM64/BootEFI.cc12
-rw-r--r--dev/boot/src/docs/KERN_VER.md18
-rw-r--r--dev/boot/src/docs/MKFS_HEFS.md106
-rw-r--r--dev/boot/src/root/ifs.json10
20 files changed, 222 insertions, 317 deletions
diff --git a/dev/boot/BootKit/BootKit.h b/dev/boot/BootKit/BootKit.h
index 85de8d86..68e4b484 100644
--- a/dev/boot/BootKit/BootKit.h
+++ b/dev/boot/BootKit/BootKit.h
@@ -24,7 +24,7 @@
/// Include other APIs.
/***********************************************************************************/
-#include <NewKit/Defines.h>
+#include <NeKit/Defines.h>
#include <modules/ATA/ATA.h>
#include <FirmwareKit/EFI.h>
diff --git a/dev/boot/BootKit/Support.h b/dev/boot/BootKit/Support.h
index 6e1407c2..b4129abc 100644
--- a/dev/boot/BootKit/Support.h
+++ b/dev/boot/BootKit/Support.h
@@ -9,7 +9,7 @@
/// @file Support.h
/// @brief Purpose of this file is to help port libs into the bootloader.
-#ifndef __aarch64__
+#ifndef __NE_ARM64__
#include <string.h>
#endif
@@ -38,7 +38,9 @@ EXTERN_C int strcmp(const char* whatToCheck, const char* whatToCheckRight);
#else
+#ifndef __NE_ARM64__
#include <string.h>
+#endif
#endif // __BOOTZ__
diff --git a/dev/boot/amd64-ci.make b/dev/boot/amd64-ci.make
index b396b0d5..0715151c 100644
--- a/dev/boot/amd64-ci.make
+++ b/dev/boot/amd64-ci.make
@@ -69,11 +69,11 @@ FLAG_GNU=-fshort-wchar -Wall -Wpedantic -Wextra -Werror -D__EFI_x86_64__ -mno-re
-DEFI_FUNCTION_WRAPPER -I./ -I../kernel $(DEBUG_MACRO) $(DISK_DRV) -I../ -c -nostdlib -fno-rtti -fno-exceptions \
-std=c++20 -DBOOTZ_GPT_SUPPORT -DBOOTZ_EPM_SUPPORT -D__HAVE_NE_APIS__ -DZBA_USE_FB -D__NE_AMD64__ -D__NE__ -DNE_AUTO_FORMAT
-BOOTLOADER=bootz.efi
-KERNEL=krnl.efi
+BOOTLOADER=ne_bootz
+KERNEL=ne_kernel
SYSCHK=chk.efi
BOOTNET=net.efi
-SCIKIT=user.sys
+SCIKIT=libSystem.sys
.PHONY: invalid-recipe
invalid-recipe:
@@ -130,7 +130,7 @@ efi:
$(HTTP_GET) https://retrage.github.io/edk2-nightly/bin/DEBUGX64_OVMF.fd -O OVMF.fd
BINS=*.bin
-EXECUTABLES=bootz.efi krnl.efi OVMF.fd
+EXECUTABLES=ne_bootz ne_kernel OVMF.fd
TARGETS=$(REM_FLAG) $(OBJ) $(BIN) $(IMG) $(IMG_2) $(EXECUTABLES)
diff --git a/dev/boot/amd64-desktop.make b/dev/boot/amd64-desktop.make
index c660df87..d39c3bcd 100644
--- a/dev/boot/amd64-desktop.make
+++ b/dev/boot/amd64-desktop.make
@@ -49,7 +49,7 @@ DEBUG_MACRO = -D__DEBUG__
endif
ifeq ($(shell uname), Darwin)
-EMU_FLAGS=-M q35 -smp 4 -m 8G \
+EMU_FLAGS=-M q35 -smp 4 -m 8G \
-bios $(BIOS) -cdrom $(BOOT) -boot d
endif
@@ -71,11 +71,12 @@ FLAG_GNU=-fshort-wchar -D__EFI_x86_64__ -Wall -Wpedantic -Wextra -mno-red-zone -
-DEFI_FUNCTION_WRAPPER -I./ -I../kernel $(DISK_DRV) -I../ -c -nostdlib -fno-rtti -fno-exceptions \
-std=c++20 -DBOOTZ_GPT_SUPPORT -D__HAVE_NE_APIS__ -DZBA_USE_FB -D__NE_AMD64__ -D__NE__ -DNE_AUTO_FORMAT -Wl,--disable-reloc-section
-BOOTLOADER=bootz.efi
-KERNEL=krnl.efi
+BOOTLOADER=ne_bootz
+KERNEL=ne_kernel
SYSCHK=chk.efi
BOOTNET=net.efi
-SCIKIT=user.sys
+SCIKIT=libSystem.sys
+DDK=ddk.sys
.PHONY: invalid-recipe
invalid-recipe:
@@ -91,8 +92,9 @@ all: compile-amd64
$(COPY) ../kernel/$(KERNEL) src/root/$(KERNEL)
$(COPY) ./modules/SysChk/$(SYSCHK) src/root/$(SYSCHK)
$(COPY) ./modules/BootNet/$(BOOTNET) src/root/$(BOOTNET)
- $(COPY) ../user/$(SCIKIT) src/root/$(SCIKIT)
+ $(COPY) ../libSystem/$(SCIKIT) src/root/$(SCIKIT)
$(COPY) src/$(BOOTLOADER) src/root/$(BOOTLOADER)
+ $(COPY) ../ddk/$(DDK) src/root/$(DDK)
.PHONY: disk
disk:
@@ -115,7 +117,7 @@ compile-amd64:
.PHONY: run-efi-amd64-ahci
run-efi-amd64-ahci:
- $(EMU) $(EMU_FLAGS) -d int -hda $(IMG) -s -S -trace ahci_* -boot menu=on
+ $(EMU) $(EMU_FLAGS) -monitor stdio -hda $(IMG) -s -S -boot menu=on
.PHONY: run-efi-amd64-ata-pio
run-efi-amd64-ata-pio:
@@ -138,7 +140,7 @@ efi:
$(HTTP_GET) https://retrage.github.io/edk2-nightly/bin/DEBUGX64_OVMF.fd -O OVMF.fd
BINS=*.bin
-EXECUTABLES=bootz.efi krnl.efi OVMF.fd
+EXECUTABLES=ne_bootz ne_kernel OVMF.fd
TARGETS=$(REM_FLAG) $(OBJ) $(BIN) $(IMG) $(IMG_2) $(EXECUTABLES)
diff --git a/dev/boot/arm64-desktop.make b/dev/boot/arm64-desktop.make
index 114d2e7e..409975a4 100644
--- a/dev/boot/arm64-desktop.make
+++ b/dev/boot/arm64-desktop.make
@@ -47,8 +47,8 @@ FLAG_GNU=-fshort-wchar -c -ffreestanding -MMD -mno-red-zone -D__NE_ARM64__ -fno-
-target aarch64-unknown-windows \
-std=c++20 -DBOOTZ_EPM_SUPPORT -DZBA_USE_FB -D__FSKIT_USE_NEFS__ -D__BOOTZ_STANDALONE__ -D__NEOSKRNL__ -D__BOOTZ__ -D__HAVE_NE_APIS__ -D__NE__ -I../ -I../kernel
-BOOT_LOADER=bootz.efi
-KERNEL=krnl.efi
+BOOT_LOADER=ne_bootz
+KERNEL=ne_kernel
SYSCHK=chk.efi
STARTUP=startup.efi
@@ -94,7 +94,7 @@ efi:
$(HTTP_GET) https://retrage.github.io/edk2-nightly/bin/DEBUGAARCH64_QEMU_EFI.fd -O OVMF.fd
BINS=*.bin
-EXECUTABLES=bootz.efi krnl.efi OVMF.fd
+EXECUTABLES=ne_bootz ne_kernel OVMF.fd
TARGETS=$(REM_FLAG) $(OBJ) $(BIN) $(IMG) $(IMG_2) $(EXECUTABLES)
diff --git a/dev/boot/modules/BootNet/BootNet.cc b/dev/boot/modules/BootNet/BootNet.cc
index 3ea7350e..2fbd7edc 100644
--- a/dev/boot/modules/BootNet/BootNet.cc
+++ b/dev/boot/modules/BootNet/BootNet.cc
@@ -12,14 +12,14 @@
#include <FirmwareKit/EFI/API.h>
#include <modules/BootNet/BootNet.h>
-STATIC EfiGUID kEfiSimpleProtoGUID = EFI_SIMPLE_NETWORK_PROTOCOL_GUID;
+STATIC EFI_GUID kEfiSimpleProtoGUID = EFI_SIMPLE_NETWORK_PROTOCOL_GUID;
STATIC EFI_SIMPLE_NETWORK_PROTOCOL* kEfiProtocol = nullptr;
STATIC Void bootnet_read_ip_packet(BOOTNET_INTERNET_HEADER inet,
BOOTNET_INTERNET_HEADER** inet_out);
EXTERN_C Int32 BootNetModuleMain(Kernel::HEL::BootInfoHeader* handover) {
- fw_init_efi((EfiSystemTable*) handover->f_FirmwareCustomTables[1]);
+ fw_init_efi((EfiSystemTable*) handover->f_FirmwareCustomTables[Kernel::HEL::kHandoverTableST]);
Boot::BootTextWriter writer;
diff --git a/dev/boot/modules/SysChk/SysChk.cc b/dev/boot/modules/SysChk/SysChk.cc
index c93ef83b..ea3b1d6f 100644
--- a/dev/boot/modules/SysChk/SysChk.cc
+++ b/dev/boot/modules/SysChk/SysChk.cc
@@ -16,8 +16,8 @@
#include <KernelKit/MSDOS.h>
#include <KernelKit/PE.h>
#include <KernelKit/PEF.h>
-#include <NewKit/Macros.h>
-#include <NewKit/Ref.h>
+#include <NeKit/Macros.h>
+#include <NeKit/Ref.h>
#include <modules/CoreGfx/CoreGfx.h>
#include <modules/CoreGfx/TextGfx.h>
@@ -27,13 +27,14 @@
#endif // !kMachineModel
EXTERN_C Int32 SysChkModuleMain(Kernel::HEL::BootInfoHeader* handover) {
- fw_init_efi((EfiSystemTable*) handover->f_FirmwareCustomTables[1]);
+ fw_init_efi((EfiSystemTable*) handover->f_FirmwareCustomTables[Kernel::HEL::kHandoverTableST]);
#if defined(__ATA_PIO__)
Boot::BDiskFormatFactory<BootDeviceATA> partition_factory;
#elif defined(__AHCI__)
Boot::BDiskFormatFactory<BootDeviceSATA> partition_factory;
#endif
+
if (partition_factory.IsPartitionValid()) return kEfiOk;
return partition_factory.Format(kMachineModel);
diff --git a/dev/boot/modules/SysChk/amd64-ahci-epm.json b/dev/boot/modules/SysChk/amd64-ahci-epm.json
index 91c95941..8ce9bfd8 100644
--- a/dev/boot/modules/SysChk/amd64-ahci-epm.json
+++ b/dev/boot/modules/SysChk/amd64-ahci-epm.json
@@ -14,6 +14,7 @@
"../../../kernel/HALKit/AMD64/PCI/*.cc",
"../../../kernel/HALKit/AMD64/Storage/*.cc",
"../../../kernel/src/Storage/*.cc",
+ "../../../kernel/src/Network/*.cc",
"../../../kernel/HALKit/AMD64/*.cc",
"../../../kernel/HALKit/AMD64/*.s",
"../../../kernel/src/*.cc"
diff --git a/dev/boot/src/BootFileReader.cc b/dev/boot/src/BootFileReader.cc
index 32060bd7..2f409848 100644
--- a/dev/boot/src/BootFileReader.cc
+++ b/dev/boot/src/BootFileReader.cc
@@ -43,12 +43,12 @@ Boot::BootFileReader::BootFileReader(const CharacterTypeUTF16* path, EfiHandlePt
/// Load protocols with their GUIDs.
- EfiGUID guidEfp = EfiGUID(EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID);
+ EFI_GUID guidEfp = EFI_GUID(EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID);
EfiSimpleFilesystemProtocol* efp = nullptr;
EfiLoadImageProtocol* img = nullptr;
- EfiGUID guidImg = EfiGUID(EFI_LOADED_IMAGE_PROTOCOL_GUID);
+ EFI_GUID guidImg = EFI_GUID(EFI_LOADED_IMAGE_PROTOCOL_GUID);
if (BS->HandleProtocol(ImageHandle, &guidImg, (void**) &img) != kEfiOk) {
mWriter.Write(L"BootZ: Handle-Protocol: No-Such-Protocol").Write(L"\r");
@@ -116,7 +116,7 @@ Void Boot::BootFileReader::ReadAll(SizeT readUntil, SizeT chunkToRead, UIntPtr o
EfiFileInfo newPtrInfo{};
- EfiGUID kFileInfoGUID = EFI_FILE_INFO_GUID;
+ EFI_GUID kFileInfoGUID = EFI_FILE_INFO_GUID;
if (mFile->GetInfo(mFile, &kFileInfoGUID, &szInfo, &newPtrInfo) == kEfiOk) {
readUntil = newPtrInfo.FileSize;
diff --git a/dev/boot/src/BootTextWriter.cc b/dev/boot/src/BootTextWriter.cc
index 5e826c6d..6ffb7de6 100644
--- a/dev/boot/src/BootTextWriter.cc
+++ b/dev/boot/src/BootTextWriter.cc
@@ -24,6 +24,8 @@
@brief puts wrapper over EFI ConOut.
*/
Boot::BootTextWriter& Boot::BootTextWriter::Write(const CharacterTypeUTF16* str) {
+ NE_UNUSED(str);
+
#ifdef __DEBUG__
if (!str || *str == 0) return *this;
@@ -50,6 +52,8 @@ Boot::BootTextWriter& Boot::BootTextWriter::Write(const CharacterTypeUTF16* str)
/// @brief UTF-8 equivalent of Write (UTF-16).
/// @param str the input string.
Boot::BootTextWriter& Boot::BootTextWriter::Write(const Char* str) {
+ NE_UNUSED(str);
+
#ifdef __DEBUG__
if (!str || *str == 0) return *this;
@@ -74,6 +78,8 @@ Boot::BootTextWriter& Boot::BootTextWriter::Write(const Char* str) {
}
Boot::BootTextWriter& Boot::BootTextWriter::Write(const UChar* str) {
+ NE_UNUSED(str);
+
#ifdef __DEBUG__
if (!str || *str == 0) return *this;
@@ -101,6 +107,8 @@ Boot::BootTextWriter& Boot::BootTextWriter::Write(const UChar* str) {
@brief putc wrapper over EFI ConOut.
*/
Boot::BootTextWriter& Boot::BootTextWriter::WriteCharacter(CharacterTypeUTF16 c) {
+ NE_UNUSED(c);
+
#ifdef __DEBUG__
EfiCharType str[2];
@@ -113,6 +121,8 @@ Boot::BootTextWriter& Boot::BootTextWriter::WriteCharacter(CharacterTypeUTF16 c)
}
Boot::BootTextWriter& Boot::BootTextWriter::Write(const UInt64& x) {
+ NE_UNUSED(x);
+
#ifdef __DEBUG__
this->_Write(x);
this->Write("h");
@@ -122,6 +132,8 @@ Boot::BootTextWriter& Boot::BootTextWriter::Write(const UInt64& x) {
}
Boot::BootTextWriter& Boot::BootTextWriter::_Write(const UInt64& x) {
+ NE_UNUSED(x);
+
#ifdef __DEBUG__
UInt64 y = (x > 0 ? x : -x) / 16;
UInt64 h = (x > 0 ? x : -x) % 16;
@@ -136,9 +148,9 @@ Boot::BootTextWriter& Boot::BootTextWriter::_Write(const UInt64& x) {
if (y == ~0UL) y = -y;
- const char cNumbers[] = "0123456789ABCDEF";
+ const char kNumberList[] = "0123456789ABCDEF";
- this->WriteCharacter(cNumbers[h]);
+ this->WriteCharacter(kNumberList[h]);
#endif // ifdef __DEBUG__
return *this;
diff --git a/dev/boot/src/BootThread.cc b/dev/boot/src/BootThread.cc
index ada864bb..b502b52e 100644
--- a/dev/boot/src/BootThread.cc
+++ b/dev/boot/src/BootThread.cc
@@ -175,6 +175,9 @@ Int32 BootThread::Start(HEL::BootInfoHeader* handover, Bool own_stack) {
writer.Write("BootZ: Stack address: ").Write((UIntPtr) &fStack[mib_cast(16) - 1]).Write("\r");
writer.Write("BootZ: Stack size: ").Write(mib_cast(16)).Write("\r");
+ fHandover->f_StackTop = &fStack[mib_cast(16) - 1];
+ fHandover->f_StackSz = mib_cast(16);
+
auto ret = rt_jump_to_address(fStartAddress, fHandover, &fStack[mib_cast(16) - 1]);
// we don't need the stack anymore.
diff --git a/dev/boot/src/BootloaderRsrc.rsrc b/dev/boot/src/BootloaderRsrc.rsrc
index c634a8f6..33bce7f7 100644
--- a/dev/boot/src/BootloaderRsrc.rsrc
+++ b/dev/boot/src/BootloaderRsrc.rsrc
@@ -13,7 +13,7 @@ BEGIN
VALUE "FileVersion", BOOTLOADER_VERSION
VALUE "InternalName", "bootz"
VALUE "LegalCopyright", "Copyright (C) 2024, Amlal El Mahrouss all rights reserved."
- VALUE "OriginalFilename", "bootz.efi"
+ VALUE "OriginalFilename", "ne_bootz"
VALUE "ProductName", "bootz"
VALUE "ProductVersion", BOOTLOADER_VERSION
END
diff --git a/dev/boot/src/HEL/AMD64/BootAPI.S b/dev/boot/src/HEL/AMD64/BootAPI.S
index 43775fc2..33c1f5d3 100644
--- a/dev/boot/src/HEL/AMD64/BootAPI.S
+++ b/dev/boot/src/HEL/AMD64/BootAPI.S
@@ -1,10 +1,27 @@
.global rt_jump_to_address
.global rt_reset_hardware
+.data
+
+.global kApicBaseAddress
+
+kApicBaseAddress:
+ .long 0
+
.text
.intel_syntax noprefix
+.global hal_load_idt
+
+hal_load_idt:
+ ret
+
+.global sched_jump_to_task
+
+sched_jump_to_task:
+ ret
+
/**
@brief this function setups a stack and then jumps to
a function */
diff --git a/dev/boot/src/HEL/AMD64/BootATA.cc b/dev/boot/src/HEL/AMD64/BootATA.cc
deleted file mode 100644
index 903a650d..00000000
--- a/dev/boot/src/HEL/AMD64/BootATA.cc
+++ /dev/null
@@ -1,256 +0,0 @@
-/* -------------------------------------------
-
- Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
-
-------------------------------------------- */
-
-/**
- * @file BootATA.cc
- * @author Amlal El Mahrouss (amlal@nekernel.org)
- * @brief ATA driver.
- * @version 0.1
- * @date 2024-02-02
- *
- * @copyright Copyright (c) Amlal El Mahrouss
- *
- */
-
-#include <BootKit/BootKit.h>
-#include <BootKit/HW/ATA.h>
-#include <FirmwareKit/EFI.h>
-
-#define kATADataLen (256)
-
-/// bugs: 0
-
-using namespace Boot;
-
-static Boolean kATADetected = false;
-static UInt16 kATAData[kATADataLen] = {0};
-
-Boolean boot_ata_detected(Void);
-
-STATIC Boolean boot_ata_wait_io(UInt16 IO) {
- for (int i = 0; i < 400; i++) rt_in8(IO + ATA_REG_STATUS);
-
-ATAWaitForIO_Retry:
- auto status_rdy = rt_in8(IO + ATA_REG_STATUS);
-
- if ((status_rdy & ATA_SR_BSY)) goto ATAWaitForIO_Retry;
-
-ATAWaitForIO_Retry2:
- status_rdy = rt_in8(IO + ATA_REG_STATUS);
-
- if (status_rdy & ATA_SR_ERR) return false;
-
- if (!(status_rdy & ATA_SR_DRDY)) goto ATAWaitForIO_Retry2;
-
- return true;
-}
-
-Void boot_ata_select(UInt16 Bus) {
- if (Bus == ATA_PRIMARY_IO)
- rt_out8(Bus + ATA_REG_HDDEVSEL, ATA_PRIMARY_SEL);
- else
- rt_out8(Bus + ATA_REG_HDDEVSEL, ATA_SECONDARY_SEL);
-}
-
-Boolean boot_ata_init(UInt16 Bus, UInt8 Drive, UInt16& OutBus, UInt8& OutMaster) {
- NE_UNUSED(Drive);
-
- if (boot_ata_detected()) return true;
-
- BootTextWriter writer;
-
- UInt16 IO = Bus;
-
- boot_ata_select(IO);
-
- // Bus init, NEIN bit.
- rt_out8(IO + ATA_REG_NEIN, 1);
-
- // identify until it's good.
-ATAInit_Retry:
- auto status_rdy = rt_in8(IO + ATA_REG_STATUS);
-
- if (status_rdy & ATA_SR_ERR) {
- writer.Write(L"BootZ: ATA: Not an IDE based drive.\r");
-
- return false;
- }
-
- if ((status_rdy & ATA_SR_BSY)) goto ATAInit_Retry;
-
- rt_out8(IO + ATA_REG_COMMAND, ATA_CMD_IDENTIFY);
-
- /// fetch serial info
- /// model, speed, number of sectors...
-
- boot_ata_wait_io(IO);
-
- for (SizeT indexData = 0ul; indexData < kATADataLen; ++indexData) {
- kATAData[indexData] = Kernel::HAL::rt_in16(IO + ATA_REG_DATA);
- }
-
- OutBus = (Bus == ATA_PRIMARY_IO) ? BootDeviceATA::kPrimary : BootDeviceATA::kSecondary;
-
- OutMaster = (Bus == ATA_PRIMARY_IO) ? ATA_MASTER : ATA_SLAVE;
-
- // Why? the current disk driver writes whole word instead of a single byte (expected btw) so i'm
- // planning to finish +Next drivers for 0.0.3
- return NO;
-}
-
-Void boot_ata_read(UInt64 Lba, UInt16 IO, UInt8 Master, CharacterTypeASCII* Buf, SizeT SectorSz,
- SizeT Size) {
- Lba /= SectorSz;
-
- UInt8 Command = ((!Master) ? 0xE0 : 0xF0);
-
- boot_ata_wait_io(IO);
- boot_ata_select(IO);
-
- rt_out8(IO + ATA_REG_HDDEVSEL, (Command) | (((Lba) >> 24) & 0x0F));
-
- rt_out8(IO + ATA_REG_SEC_COUNT0, ((Size + SectorSz) / SectorSz));
-
- rt_out8(IO + ATA_REG_LBA0, (Lba) &0xFF);
- rt_out8(IO + ATA_REG_LBA1, (Lba) >> 8);
- rt_out8(IO + ATA_REG_LBA2, (Lba) >> 16);
- rt_out8(IO + ATA_REG_LBA3, (Lba) >> 24);
-
- rt_out8(IO + ATA_REG_COMMAND, ATA_CMD_READ_PIO);
-
- boot_ata_wait_io(IO);
-
- for (SizeT IndexOff = 0; IndexOff < Size; ++IndexOff) {
- boot_ata_wait_io(IO);
- Buf[IndexOff] = Kernel::HAL::rt_in16(IO + ATA_REG_DATA);
- boot_ata_wait_io(IO);
- }
-}
-
-Void boot_ata_write(UInt64 Lba, UInt16 IO, UInt8 Master, CharacterTypeASCII* Buf, SizeT SectorSz,
- SizeT Size) {
- Lba /= SectorSz;
-
- UInt8 Command = ((!Master) ? 0xE0 : 0xF0);
-
- boot_ata_wait_io(IO);
- boot_ata_select(IO);
-
- rt_out8(IO + ATA_REG_HDDEVSEL, (Command) | (((Lba) >> 24) & 0x0F));
-
- rt_out8(IO + ATA_REG_SEC_COUNT0, ((Size + (SectorSz)) / SectorSz));
-
- rt_out8(IO + ATA_REG_LBA0, (Lba) &0xFF);
- rt_out8(IO + ATA_REG_LBA1, (Lba) >> 8);
- rt_out8(IO + ATA_REG_LBA2, (Lba) >> 16);
- rt_out8(IO + ATA_REG_LBA3, (Lba) >> 24);
-
- rt_out8(IO + ATA_REG_COMMAND, ATA_CMD_WRITE_PIO);
-
- boot_ata_wait_io(IO);
-
- for (SizeT IndexOff = 0; IndexOff < Size; ++IndexOff) {
- boot_ata_wait_io(IO);
- rt_out16(IO + ATA_REG_DATA, Buf[IndexOff]);
- boot_ata_wait_io(IO);
- }
-
- boot_ata_wait_io(IO);
-}
-
-/// @check is ATA detected?
-Boolean boot_ata_detected(Void) {
- return kATADetected;
-}
-
-/***
- *
- *
- * @brief ATA Device class.
- *
- *
- */
-
-/**
- * @brief ATA Device constructor.
- * @param void none.
- */
-BootDeviceATA::BootDeviceATA() noexcept {
- if (boot_ata_init(ATA_PRIMARY_IO, true, this->Leak().mBus, this->Leak().mMaster) ||
- boot_ata_init(ATA_SECONDARY_IO, true, this->Leak().mBus, this->Leak().mMaster)) {
- kATADetected = true;
- }
-}
-/**
- * @brief Is ATA detected?
- */
-BootDeviceATA::operator bool() {
- return boot_ata_detected();
-}
-
-/**
- @brief Read Buf from disk
- @param Sz Sector size
- @param Buf buffer
-*/
-BootDeviceATA& BootDeviceATA::Read(CharacterTypeASCII* Buf, SizeT SectorSz) {
- if (!boot_ata_detected()) {
- Leak().mErr = true;
- return *this;
- }
-
- this->Leak().mErr = false;
-
- if (!Buf || SectorSz < 1) return *this;
-
- boot_ata_read(this->Leak().mBase, this->Leak().mBus, this->Leak().mMaster, Buf, SectorSz,
- this->Leak().mSize);
-
- return *this;
-}
-
-/**
- @brief Write Buf into disk
- @param Sz Sector size
- @param Buf buffer
-*/
-BootDeviceATA& BootDeviceATA::Write(CharacterTypeASCII* Buf, SizeT SectorSz) {
- if (!boot_ata_detected()) {
- Leak().mErr = true;
- return *this;
- }
-
- Leak().mErr = false;
-
- if (!Buf || SectorSz < 1 || this->Leak().mSize < 1) {
- Leak().mErr = true;
- return *this;
- }
-
- boot_ata_write(this->Leak().mBase, this->Leak().mBus, this->Leak().mMaster, Buf, SectorSz,
- this->Leak().mSize);
-
- return *this;
-}
-
-/**
- * @brief ATA trait getter.
- * @return BootDeviceATA::ATATrait& the drive config.
- */
-BootDeviceATA::ATATrait& BootDeviceATA::Leak() {
- return mTrait;
-}
-
-/***
- @brief Getter, gets the number of sectors inside the drive.
-*/
-SizeT BootDeviceATA::GetSectorsCount() noexcept {
- return (kATAData[61] << 16) | kATAData[60];
-}
-
-SizeT BootDeviceATA::GetDiskSize() noexcept {
- return this->GetSectorsCount() * BootDeviceATA::kSectorSize;
-}
diff --git a/dev/boot/src/HEL/AMD64/BootATA+Next.cc b/dev/boot/src/HEL/AMD64/BootATAcc
index 547d4f99..4fd6dc16 100644
--- a/dev/boot/src/HEL/AMD64/BootATA+Next.cc
+++ b/dev/boot/src/HEL/AMD64/BootATAcc
@@ -15,8 +15,6 @@
*
*/
-#if 0
-
#include <BootKit/BootKit.h>
#include <BootKit/HW/ATA.h>
#include <FirmwareKit/EFI.h>
@@ -266,5 +264,3 @@ SizeT BootDeviceATA::GetSectorsCount() noexcept {
SizeT BootDeviceATA::GetDiskSize() noexcept {
return this->GetSectorsCount() * BootDeviceATA::kSectorSize;
}
-
-#endif \ No newline at end of file
diff --git a/dev/boot/src/HEL/AMD64/BootEFI.cc b/dev/boot/src/HEL/AMD64/BootEFI.cc
index dbc12265..3685add5 100644
--- a/dev/boot/src/HEL/AMD64/BootEFI.cc
+++ b/dev/boot/src/HEL/AMD64/BootEFI.cc
@@ -12,8 +12,8 @@
#include <KernelKit/MSDOS.h>
#include <KernelKit/PE.h>
#include <KernelKit/PEF.h>
-#include <NewKit/Macros.h>
-#include <NewKit/Ref.h>
+#include <NeKit/Macros.h>
+#include <NeKit/Ref.h>
#include <modules/CoreGfx/CoreGfx.h>
#include <modules/CoreGfx/TextGfx.h>
@@ -21,7 +21,7 @@
STATIC EfiGraphicsOutputProtocol* kGop = nullptr;
STATIC UInt16 kGopStride = 0U;
-STATIC EfiGUID kGopGuid;
+STATIC EFI_GUID kGopGuid;
/** Related to jumping to the reset vector. */
@@ -33,7 +33,7 @@ EXTERN_C Kernel::VoidPtr boot_read_cr3(); // @brief Page directory inside cr3 r
@brief Finds and stores the GOP object.
*/
STATIC Bool boot_init_fb() noexcept {
- kGopGuid = EfiGUID(EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID);
+ kGopGuid = EFI_GUID(EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID);
kGop = nullptr;
if (BS->LocateProtocol(&kGopGuid, nullptr, (VoidPtr*) &kGop) != kEfiOk) return No;
@@ -43,7 +43,7 @@ STATIC Bool boot_init_fb() noexcept {
return Yes;
}
-EfiGUID kEfiGlobalNamespaceVarGUID = {
+EFI_GUID kEfiGlobalNamespaceVarGUID = {
0x8BE4DF61, 0x93CA, 0x11D2, {0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C}};
/// @brief BootloaderMain EFI entrypoint.
@@ -102,7 +102,7 @@ EFI_EXTERN_C EFI_API Int32 BootloaderMain(EfiHandlePtr image_handle, EfiSystemTa
// Grab MP services, extended to runtime. //
// ------------------------------------------- //
- EfiGUID guid_mp = EfiGUID(EFI_MP_SERVICES_PROTOCOL_GUID);
+ EFI_GUID guid_mp = EFI_GUID(EFI_MP_SERVICES_PROTOCOL_GUID);
EfiMpServicesProtocol* mp = nullptr;
BS->LocateProtocol(&guid_mp, nullptr, reinterpret_cast<VoidPtr*>(&mp));
@@ -156,8 +156,8 @@ EFI_EXTERN_C EFI_API Int32 BootloaderMain(EfiHandlePtr image_handle, EfiSystemTa
}
}
- handover_hdr->f_FirmwareCustomTables[0] = (VoidPtr) BS;
- handover_hdr->f_FirmwareCustomTables[1] = (VoidPtr) ST;
+ handover_hdr->f_FirmwareCustomTables[Kernel::HEL::kHandoverTableBS] = (VoidPtr) BS;
+ handover_hdr->f_FirmwareCustomTables[Kernel::HEL::kHandoverTableST] = (VoidPtr) ST;
// ------------------------------------------ //
// If we succeed in reading the blob, then execute it.
@@ -193,18 +193,8 @@ EFI_EXTERN_C EFI_API Int32 BootloaderMain(EfiHandlePtr image_handle, EfiSystemTa
handover_hdr->f_FirmwareVendorLen = Boot::BStrLen(sys_table->FirmwareVendor);
// Assign to global 'kHandoverHeader'.
- WideChar kernel_path[256U] = L"krnl.efi";
- UInt32 kernel_path_sz = StrLen("krnl.efi");
-
- if (ST->RuntimeServices->GetVariable(L"/props/kernel_path", kEfiGlobalNamespaceVarGUID, nullptr,
- &kernel_path_sz, kernel_path) != kEfiOk) {
- /// access attributes (in order)
- /// EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS
- UInt32 attr = 0x00000001 | 0x00000002 | 0x00000004;
-
- ST->RuntimeServices->SetVariable(L"/props/kernel_path", kEfiGlobalNamespaceVarGUID, &attr,
- &kernel_path_sz, kernel_path);
- }
+ WideChar kernel_path[256U] = L"ne_kernel";
+ UInt32 kernel_path_sz = StrLen("ne_kernel");
UInt32 sz_ver = sizeof(UInt64);
UInt64 ver = KERNEL_VERSION_BCD;
@@ -219,6 +209,16 @@ EFI_EXTERN_C EFI_API Int32 BootloaderMain(EfiHandlePtr image_handle, EfiSystemTa
&sz_ver, &ver);
writer.Write("BootZ: Version has been updated: ").Write(ver).Write("\r");
+
+ if (ST->RuntimeServices->GetVariable(L"/props/kernel_path", kEfiGlobalNamespaceVarGUID, nullptr,
+ &kernel_path_sz, kernel_path) != kEfiOk) {
+ /// access attributes (in order)
+ /// EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS
+ UInt32 attr = 0x00000001 | 0x00000002 | 0x00000004;
+
+ ST->RuntimeServices->SetVariable(L"/props/kernel_path", kEfiGlobalNamespaceVarGUID, &attr,
+ &kernel_path_sz, kernel_path);
+ }
} else {
writer.Write("BootZ: Version: ").Write(ver).Write("\r");
}
@@ -226,7 +226,6 @@ EFI_EXTERN_C EFI_API Int32 BootloaderMain(EfiHandlePtr image_handle, EfiSystemTa
// boot to kernel, if not bootnet this.
Boot::BootFileReader reader_kernel(kernel_path, image_handle);
-
reader_kernel.ReadAll(0);
// ------------------------------------------ //
diff --git a/dev/boot/src/HEL/ARM64/BootEFI.cc b/dev/boot/src/HEL/ARM64/BootEFI.cc
index 1e5b62f3..1633cb39 100644
--- a/dev/boot/src/HEL/ARM64/BootEFI.cc
+++ b/dev/boot/src/HEL/ARM64/BootEFI.cc
@@ -12,8 +12,8 @@
#include <KernelKit/MSDOS.h>
#include <KernelKit/PE.h>
#include <KernelKit/PEF.h>
-#include <NewKit/Macros.h>
-#include <NewKit/Ref.h>
+#include <NeKit/Macros.h>
+#include <NeKit/Ref.h>
#include <modules/CoreGfx/CoreGfx.h>
#include <modules/CoreGfx/TextGfx.h>
@@ -29,7 +29,7 @@
STATIC EfiGraphicsOutputProtocol* kGop = nullptr;
STATIC UInt16 kGopStride = 0U;
-STATIC EfiGUID kGopGuid;
+STATIC EFI_GUID kGopGuid;
EXTERN_C Void rt_reset_hardware();
@@ -39,7 +39,7 @@ EXTERN EfiBootServices* BS;
@brief Finds and stores the GOP object.
*/
STATIC Bool boot_init_fb() noexcept {
- kGopGuid = EfiGUID(EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID);
+ kGopGuid = EFI_GUID(EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID);
kGop = nullptr;
if (BS->LocateProtocol(&kGopGuid, nullptr, (VoidPtr*) &kGop) != kEfiOk) return No;
@@ -107,7 +107,7 @@ EFI_EXTERN_C EFI_API Int32 BootloaderMain(EfiHandlePtr image_handle, EfiSystemTa
// Grab MP services, extended to runtime. //
// ------------------------------------------- //
- EfiGUID guid_mp = EfiGUID(EFI_MP_SERVICES_PROTOCOL_GUID);
+ EFI_GUID guid_mp = EFI_GUID(EFI_MP_SERVICES_PROTOCOL_GUID);
EfiMpServicesProtocol* mp = nullptr;
BS->LocateProtocol(&guid_mp, nullptr, reinterpret_cast<VoidPtr*>(&mp));
@@ -210,7 +210,7 @@ EFI_EXTERN_C EFI_API Int32 BootloaderMain(EfiHandlePtr image_handle, EfiSystemTa
handover_hdr->f_FirmwareVendorLen = Boot::BStrLen(sys_table->FirmwareVendor);
- Boot::BootFileReader reader_kernel(L"krnl.efi", image_handle);
+ Boot::BootFileReader reader_kernel(L"ne_kernel", image_handle);
reader_kernel.ReadAll(0);
diff --git a/dev/boot/src/docs/KERN_VER.md b/dev/boot/src/docs/KERN_VER.md
index cabdb1d2..0659431b 100644
--- a/dev/boot/src/docs/KERN_VER.md
+++ b/dev/boot/src/docs/KERN_VER.md
@@ -1,6 +1,18 @@
-# The `/props/kern_ver` NVRAM variable
+# `/props/kern_ver` โ€” NVRAM EFI Variable
The `/props/kern_ver` variable is used to track NeKernel's current version in a BCD format.
-- Use it to track the current's NeKernel version, in order to adapt your drivers to it.
-- It is also useful to keep track of it, for other purposes (bug tracking, development of new features) \ No newline at end of file
+## ๐Ÿ›  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 โ€“ All rights reserved. \ No newline at end of file
diff --git a/dev/boot/src/docs/MKFS_HEFS.md b/dev/boot/src/docs/MKFS_HEFS.md
new file mode 100644
index 00000000..c9aa0628
--- /dev/null
+++ b/dev/boot/src/docs/MKFS_HEFS.md
@@ -0,0 +1,106 @@
+# `mkfs.hefs` โ€“ HeFS 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 (HeFS)** used by NeKernel. This tool initializes a HeFS 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 `kHeFSDefaultVolumeName`.
+- 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 HeFS 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 [HeFS 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 โ€“ All rights reserved. \ No newline at end of file
diff --git a/dev/boot/src/root/ifs.json b/dev/boot/src/root/ifs.json
new file mode 100644
index 00000000..354ab503
--- /dev/null
+++ b/dev/boot/src/root/ifs.json
@@ -0,0 +1,10 @@
+{
+ "type": "IFS",
+ "sys": [
+ "/~drivers/fat32.sys",
+ "/~drivers/ntfs.sys",
+ "/~drivers/ext4.sys",
+ "/~drivers/iso9660.sys",
+ "/~drivers/nfs4.sys"
+ ]
+} \ No newline at end of file