summaryrefslogtreecommitdiffhomepage
path: root/dev/kernel
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-04-02 08:10:08 +0200
committerAmlal El Mahrouss <amlal@nekernel.org>2025-04-02 08:10:08 +0200
commit6c7e5ebc003a0bc4f98c23a8f9754b273a6e3a28 (patch)
tree2fde230004e377f734983484f8e12fb0414a1668 /dev/kernel
parente2b41947cde11c870d96970712dcfb3aa76eb0cf (diff)
boot/net: rename Boot.S files, clarify EEPROM implication, and prep UDP read
- Renamed Boot.S → BootNetStartup.S and SysChk/Boot.S → SysChkStartup.S for clarity - Replaced BOOTNET_INTERNET_HEADER.ImpliesEEPROM with ImpliesProgram to better reflect the generic reprogramming intent - Introduced `bootnet_read_udp_packet()` stub for future UDP packet parsing from bootnet.json - Minor alignment and comment fixes in various headers (CoreBoot, EPM, Json) - Updated HalPagingMgr to use PageStore instead of NE_PAGE_STORE - Boot time now prints cycles since start; triggered fs_init_nefs() earlier during HAL init - Prep for extended MBCI and master structure support in COREBOOT_LINEAR_EXEC - Numerous cleanups across DMA, NewKit, and Json parsing to prep for extended patching and block-level bootstrap This lays groundwork for richer NetBoot infrastructure in NeKernel and aligns naming and structure conventions across subsystems. Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/kernel')
-rw-r--r--dev/kernel/CFKit/GUIDWrapper.h4
-rw-r--r--dev/kernel/CFKit/Utils.h1
-rw-r--r--dev/kernel/FirmwareKit/CoreBoot/BootNet.h2
-rw-r--r--dev/kernel/FirmwareKit/CoreBoot/CoreBoot.h11
-rw-r--r--dev/kernel/FirmwareKit/EPM.h4
-rw-r--r--dev/kernel/HALKit/AMD64/HalKernelMain.cc2
-rw-r--r--dev/kernel/HALKit/AMD64/HalPagingMgrAMD64.cc12
-rw-r--r--dev/kernel/HALKit/AMD64/PCI/DMA.cc22
-rw-r--r--dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc2
-rw-r--r--dev/kernel/NewKit/Json.h30
-rw-r--r--dev/kernel/NewKit/Macros.h8
-rw-r--r--dev/kernel/NewKit/OwnPtr.h5
-rw-r--r--dev/kernel/StorageKit/ATA.h7
-rw-r--r--dev/kernel/src/Json.cc2
-rw-r--r--dev/kernel/src/KernelProcessScheduler.cc12
15 files changed, 78 insertions, 46 deletions
diff --git a/dev/kernel/CFKit/GUIDWrapper.h b/dev/kernel/CFKit/GUIDWrapper.h
index a92fcbf3..e58fcc69 100644
--- a/dev/kernel/CFKit/GUIDWrapper.h
+++ b/dev/kernel/CFKit/GUIDWrapper.h
@@ -10,11 +10,11 @@
#include <NewKit/Ref.h>
#include <NewKit/Stream.h>
-/* GUID for C++ Components */
+/* GUID for C++ classes. */
#define kXRNNil "@{........-....-M...-N...-............}"
-// eXtensible Resource Information
+/// @brief eXtended Resource Namespace
namespace CF::XRN
{
using namespace Kernel;
diff --git a/dev/kernel/CFKit/Utils.h b/dev/kernel/CFKit/Utils.h
index cc65bbee..b2a8b708 100644
--- a/dev/kernel/CFKit/Utils.h
+++ b/dev/kernel/CFKit/Utils.h
@@ -4,6 +4,7 @@
#include <KernelKit/PE.h>
#include <KernelKit/MSDOS.h>
+/// @brief CFKit
namespace CF
{
using namespace Kernel;
diff --git a/dev/kernel/FirmwareKit/CoreBoot/BootNet.h b/dev/kernel/FirmwareKit/CoreBoot/BootNet.h
index a86ea81a..e3cda0ba 100644
--- a/dev/kernel/FirmwareKit/CoreBoot/BootNet.h
+++ b/dev/kernel/FirmwareKit/CoreBoot/BootNet.h
@@ -24,7 +24,7 @@ typedef struct BOOTNET_INTERNET_HEADER
Kernel::Char Name[kBootNetNameLen]; /// example: Modjo
Kernel::Int32 Length; /// the patch length.
Kernel::Char Target[kBootNetNameLen]; /// the target file.
- Kernel::Boolean ImpliesEEPROM : 1; /// does it imply an EEPROM reprogram?
+ Kernel::Boolean ImpliesProgram : 1; /// does it imply an EEPROM program?
Kernel::Boolean Preflight : 1; /// is it a preflight packet.
Kernel::Char Data[]; /// non preflight packet has a patch blob for a **PatchTarget**
} ATTRIBUTE(packed) BOOTNET_INTERNET_HEADER;
diff --git a/dev/kernel/FirmwareKit/CoreBoot/CoreBoot.h b/dev/kernel/FirmwareKit/CoreBoot/CoreBoot.h
index 80d3307b..d2711025 100644
--- a/dev/kernel/FirmwareKit/CoreBoot/CoreBoot.h
+++ b/dev/kernel/FirmwareKit/CoreBoot/CoreBoot.h
@@ -12,11 +12,11 @@ namespace Firmware::Detail::CoreBoot
{
using namespace Kernel;
- struct LEHeader;
+ struct COREBOOT_LINEAR_EXEC;
/// @brief Linear Executable Header
/// @author Amlal El Mahrouss
- struct ATTRIBUTE(aligned(4)) LEHeader
+ struct ATTRIBUTE(aligned(4)) COREBOOT_LINEAR_EXEC
{
const Char fMagic[2]; // magic number
const Char fName[10]; // operating system name
@@ -24,8 +24,13 @@ namespace Firmware::Detail::CoreBoot
const UInt32 fStartAddress; // start address (master/slave(s) thread)
#ifdef NE_IS_EXTENDED_COREBOOT
- const UIntPtr fMasterStructure; // master structure for MP/PM and device tree and such (ARM)
+ const UIntPtr fMasterStructure; // master structure for MP/PM and device tree and such. (ARM)
const UIntPtr fMasterStructureVersion; // master structure version.
#endif
+
+#ifdef NE_IS_MBCI_COREBOOT
+ const UIntPtr fMBCIStructure; // MBCI structure for MBCI (ARM)
+ const UIntPtr fMBCIStructureVersion; // MBCI structure version.
+#endif
};
} // namespace Firmware::Detail::CoreBoot
diff --git a/dev/kernel/FirmwareKit/EPM.h b/dev/kernel/FirmwareKit/EPM.h
index a5cb9fe7..548bb9a7 100644
--- a/dev/kernel/FirmwareKit/EPM.h
+++ b/dev/kernel/FirmwareKit/EPM.h
@@ -101,10 +101,10 @@ struct PACKED EPM_PART_BLOCK
enum
{
kEPMInvalid = 0x00,
- kEPMGenericOS = 0xcf, /// @brief Generic OS
+ kEPMGeneric = 0xcf, /// @brief Generic OS
kEPMLinux = 0x8f, /// @brief Linux on EPM
kEPMBSD = 0x9f, /// @brief Berkeley Soft. Distribution
- kEPMNeOS = 0x1f, /// @brief NeKernel.
+ kEPMNeKernel = 0x1f, /// @brief NeKernel.
kEPMInvalidOS = 0xff,
};
diff --git a/dev/kernel/HALKit/AMD64/HalKernelMain.cc b/dev/kernel/HALKit/AMD64/HalKernelMain.cc
index 0ebba546..0d58bb8a 100644
--- a/dev/kernel/HALKit/AMD64/HalKernelMain.cc
+++ b/dev/kernel/HALKit/AMD64/HalKernelMain.cc
@@ -98,6 +98,8 @@ EXTERN_C Kernel::Void hal_real_init(Kernel::Void) noexcept
kout << "Boot Time: " << Kernel::number(kEndTim - kStartTim) << kendl;
+ Kernel::NeFS::fs_init_nefs();
+
Kernel::HAL::mp_get_cores(kHandoverHeader->f_HardwareTables.f_VendorPtr);
Kernel::HAL::Register64 idt_reg;
diff --git a/dev/kernel/HALKit/AMD64/HalPagingMgrAMD64.cc b/dev/kernel/HALKit/AMD64/HalPagingMgrAMD64.cc
index 5819f1d9..63796393 100644
--- a/dev/kernel/HALKit/AMD64/HalPagingMgrAMD64.cc
+++ b/dev/kernel/HALKit/AMD64/HalPagingMgrAMD64.cc
@@ -17,7 +17,7 @@ namespace Kernel::HAL
/***********************************************************************************/
/// \brief Page store type.
/***********************************************************************************/
- struct NE_PAGE_STORE final
+ struct PageStore final
{
struct
{
@@ -43,9 +43,9 @@ namespace Kernel::HAL
return pte && pte->User;
}
- static NE_PAGE_STORE& The()
+ static PageStore& The()
{
- static NE_PAGE_STORE the;
+ static PageStore the;
return the;
}
};
@@ -60,7 +60,7 @@ namespace Kernel::HAL
UInt64 cr3 = (UInt64)hal_read_cr3();
- NE_PAGE_STORE& page_store = NE_PAGE_STORE::The();
+ PageStore& page_store = PageStore::The();
// Extract the indices from the virtual address
UInt64 pml4_index = ((UIntPtr)virtual_address >> 39) & kPmlIndexMask;
@@ -123,7 +123,7 @@ namespace Kernel::HAL
UInt64 cr3 = (UInt64)hal_read_cr3();
- NE_PAGE_STORE& page_store = NE_PAGE_STORE::The();
+ PageStore& page_store = PageStore::The();
// Extract the indices from the virtual address
UInt64 pml4_index = ((UIntPtr)virtual_address >> 39) & kPmlIndexMask;
@@ -189,7 +189,7 @@ namespace Kernel::HAL
mmi_page_status(pt_entry);
- NE_PAGE_STORE& page_store = NE_PAGE_STORE::The();
+ PageStore& page_store = PageStore::The();
// Update Internal store.
diff --git a/dev/kernel/HALKit/AMD64/PCI/DMA.cc b/dev/kernel/HALKit/AMD64/PCI/DMA.cc
index 747fab94..33cff13e 100644
--- a/dev/kernel/HALKit/AMD64/PCI/DMA.cc
+++ b/dev/kernel/HALKit/AMD64/PCI/DMA.cc
@@ -5,6 +5,7 @@
------------------------------------------- */
#include <KernelKit/PCI/DMA.h>
+#include <ArchKit/ArchKit.h>
namespace Kernel
{
@@ -26,37 +27,34 @@ namespace Kernel
if (offset == 0)
return false;
- kout << "[DMAWrapper::IsIn] Checking offset..\n";
+ kout << "[DMAWrapper::IsIn] Checking offset...\r";
return reinterpret_cast<UIntPtr>(this->fAddress) >= offset;
}
bool DMAWrapper::Write(const UIntPtr& bit, const UInt32& offset)
{
- kout << "[DMAWrapper::Read] Checking this->fAddress..\n";
+ kout << "[DMAWrapper::Read] Checking this->fAddress...\r";
if (!this->fAddress)
return false;
- kout << "[DMAWrapper::Write] Writing at address..\n";
+ kout << "[DMAWrapper::Write] Writing at address: " << hex_number(reinterpret_cast<UIntPtr>(this->fAddress) + offset) << kendl;
- auto addr =
- (volatile UIntPtr*)(reinterpret_cast<UIntPtr>(this->fAddress) + offset);
- *addr = bit;
+ ke_dma_write<UInt32>(reinterpret_cast<UIntPtr>(this->fAddress), offset, bit);
return true;
}
UIntPtr DMAWrapper::Read(const UInt32& offset)
{
- kout << "[DMAWrapper::Read] Checking this->fAddress..\n";
+ kout << "[DMAWrapper::Read] Checking this->fAddress...\r";
if (!this->fAddress)
- return 0;
+ return ~0;
- kout << "[DMAWrapper::Read] Reading this->fAddress..\n";
+ kout << "[DMAWrapper::Write] Writing at address: " << hex_number(reinterpret_cast<UIntPtr>(this->fAddress) + offset) << kendl;
- return *(volatile UIntPtr*)(reinterpret_cast<UIntPtr>(this->fAddress) + offset);
- ;
+ return ke_dma_read<UInt32>(reinterpret_cast<UIntPtr>(this->fAddress), offset);
}
UIntPtr DMAWrapper::operator[](const UIntPtr& offset)
@@ -70,7 +68,7 @@ namespace Kernel
return {};
OwnPtr<IOBuf<Char*>> dmaOwnPtr =
- make_ptr<IOBuf<Char*>, char*>(reinterpret_cast<char*>(dma->fAddress));
+ mm_make_own_ptr<IOBuf<Char*>, char*>(reinterpret_cast<char*>(dma->fAddress));
if (!dmaOwnPtr)
return {};
diff --git a/dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc b/dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc
index 300b959f..5aabf144 100644
--- a/dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc
+++ b/dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc
@@ -76,7 +76,7 @@ Boolean drv_std_init(UInt16 Bus, UInt8 Drive, UInt16& OutBus, UInt8& OutMaster)
/// IDE interface
if (kATADevice.Subclass() == 0x01)
{
-
+
break;
}
}
diff --git a/dev/kernel/NewKit/Json.h b/dev/kernel/NewKit/Json.h
index d159d915..5f979ceb 100644
--- a/dev/kernel/NewKit/Json.h
+++ b/dev/kernel/NewKit/Json.h
@@ -7,7 +7,7 @@
#pragma once
-// last-rev: 30/01/24
+// last-rev: 02/04/25
#include <CompilerKit/CompilerKit.h>
#include <NewKit/Defines.h>
@@ -15,9 +15,10 @@
#include <NewKit/KString.h>
#include <NewKit/Utils.h>
-#define kMaxJsonPath 8196
-#define kJSONLen 256
-#define kJSONNull "[]"
+#define kJSONMaxLen (8196)
+#define kJSONLen (256)
+#define kJSONNullArr "[]"
+#define kJSONNullObj "{}"
namespace Kernel
{
@@ -27,9 +28,9 @@ namespace Kernel
public:
explicit Json()
{
- auto len = kJSONLen;
+ auto len = kJSONMaxLen;
KString key = KString(len);
- key += kJSONNull;
+ key += kJSONNullObj;
this->AsKey() = key;
this->AsValue() = key;
@@ -97,7 +98,7 @@ namespace Kernel
SizeT key_len = 0;
SizeT value_len = 0;
- Json type(kMaxJsonPath, kMaxJsonPath);
+ Json type(kJSONMaxLen, kJSONMaxLen);
for (SizeT i = 1; i < len; ++i)
{
@@ -116,6 +117,12 @@ namespace Kernel
}
else
{
+ if (full_array[i] == '\'')
+ {
+ type.AsValue().Data()[value_len] = 0;
+ break;
+ }
+
type.AsValue().Data()[value_len] = full_array[i];
++value_len;
@@ -128,9 +135,16 @@ namespace Kernel
if (full_array[i] == ':')
{
- probe_value = true;
type.AsKey().Data()[key_len] = 0;
++key_len;
+
+ ++i;
+
+ while (full_array[i] == ' ' ||
+ full_array[i] == '\t')
+ ++i;
+
+ probe_value = true;
}
else
{
diff --git a/dev/kernel/NewKit/Macros.h b/dev/kernel/NewKit/Macros.h
index 264d74d7..eda454f9 100644
--- a/dev/kernel/NewKit/Macros.h
+++ b/dev/kernel/NewKit/Macros.h
@@ -147,8 +147,8 @@
#define BOOL Kernel::Boolean
-#ifdef RTL_INIT_OBJECT
-#undef RTL_INIT_OBJECT
-#endif // ifdef RTL_INIT_OBJECT
+#ifdef rtl_init_object
+#undef rtl_init_object
+#endif // ifdef rtl_init_object
-#define RTL_INIT_OBJECT(OBJ, TYPE, ...) TYPE OBJ = TYPE(__VA_ARGS__)
+#define rtl_init_object(OBJ, TYPE, ...) TYPE OBJ = TYPE(__VA_ARGS__)
diff --git a/dev/kernel/NewKit/OwnPtr.h b/dev/kernel/NewKit/OwnPtr.h
index b292aafc..f15bc339 100644
--- a/dev/kernel/NewKit/OwnPtr.h
+++ b/dev/kernel/NewKit/OwnPtr.h
@@ -58,7 +58,8 @@ namespace Kernel
T* operator->() const
{
return fCls;
- };
+ }
+
T* Raw()
{
return fCls;
@@ -83,7 +84,7 @@ namespace Kernel
};
template <typename T, typename... Args>
- OwnPtr<T> make_ptr(Args... args)
+ inline OwnPtr<T> mm_make_own_ptr(Args... args)
{
OwnPtr<T> ret;
ret.template New<Args...>(forward(args)...);
diff --git a/dev/kernel/StorageKit/ATA.h b/dev/kernel/StorageKit/ATA.h
index b5e4b2d9..917fa12b 100644
--- a/dev/kernel/StorageKit/ATA.h
+++ b/dev/kernel/StorageKit/ATA.h
@@ -34,19 +34,18 @@ namespace Kernel
const Char* Name() const override;
const UInt16& GetIO();
- Void SetIO(const UInt16& io);
+ Void SetIO(const UInt16& io);
const UInt16& GetMaster();
- Void SetMaster(const UInt16& master);
+ Void SetMaster(const UInt16& master);
const UInt32& GetIndex();
- Void SetIndex(const UInt32& drv);
+ Void SetIndex(const UInt32& drv);
private:
void (*fCleanup)(void) = {nullptr};
UInt32 fDriveIndex{0U};
UInt16 fIO, fMaster{0U};
-
};
/// @brief Initialize an PIO device (StorageKit function)
diff --git a/dev/kernel/src/Json.cc b/dev/kernel/src/Json.cc
index ec5f2c7e..187da6fd 100644
--- a/dev/kernel/src/Json.cc
+++ b/dev/kernel/src/Json.cc
@@ -7,4 +7,4 @@
#include <NewKit/Json.h>
/// @brief Undefined object, is null in length.
-RTL_INIT_OBJECT(Kernel::Json::kNull, Kernel::Json);
+rtl_init_object(Kernel::Json::kNull, Kernel::Json);
diff --git a/dev/kernel/src/KernelProcessScheduler.cc b/dev/kernel/src/KernelProcessScheduler.cc
index 340adb39..2a2384e2 100644
--- a/dev/kernel/src/KernelProcessScheduler.cc
+++ b/dev/kernel/src/KernelProcessScheduler.cc
@@ -7,8 +7,20 @@
------------------------------------------- */
+#include <KernelKit/ProcessScheduler.h>
+
/***********************************************************************************/
/// @file KernelProcessScheduler.cc
/// @brief Privileged/Ring-0 process scheduler.
/// @author Amlal El Mahrouss (amlal@nekernel.org)
/***********************************************************************************/
+
+namespace Kernel
+{
+ /***********************************************************************************/
+ /// @brief Exit Code global variable.
+ /***********************************************************************************/
+
+ STATIC UInt32 kLastExitCode = 0U;
+
+} // namespace Kernel \ No newline at end of file