From b8f7ef086d1d1b1cd686fff04d0a587f8fd39d81 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 27 Mar 2025 17:24:21 +0100 Subject: add: new driver device kit API. (DDK) refactor: rename SCIKit -> user (then libuser.dylib) boot/modules/netboot: fixed compilation for amd64. Signed-off-by: Amlal El Mahrouss --- dev/kernel/FSKit/NeFS.h | 2 +- dev/kernel/KernelKit/FileMgr.h | 2 +- dev/kernel/KernelKit/LoaderInterface.h | 2 +- dev/kernel/KernelKit/MemoryMgr.h | 2 +- dev/kernel/KernelRsrc.rsrc | 25 ------------ dev/kernel/NetworkKit/IPC.h | 2 +- dev/kernel/NewKit/Variant.h | 3 +- dev/kernel/SwapKit/DiskSwap.h | 70 ++++++++++++++++++++++++++++++++++ dev/kernel/SwapKit/SwapDisk.h | 70 ---------------------------------- dev/kernel/amd64-ci.make | 2 +- dev/kernel/amd64-desktop.make | 2 +- dev/kernel/kernel_rsrc.rsrc | 25 ++++++++++++ dev/kernel/src/Swap/DiskSwap.cc | 67 ++++++++++++++++++++++++++++++++ dev/kernel/src/Swap/SwapDisk.cc | 67 -------------------------------- 14 files changed, 171 insertions(+), 170 deletions(-) delete mode 100644 dev/kernel/KernelRsrc.rsrc create mode 100644 dev/kernel/SwapKit/DiskSwap.h delete mode 100644 dev/kernel/SwapKit/SwapDisk.h create mode 100644 dev/kernel/kernel_rsrc.rsrc create mode 100644 dev/kernel/src/Swap/DiskSwap.cc delete mode 100644 dev/kernel/src/Swap/SwapDisk.cc (limited to 'dev/kernel') diff --git a/dev/kernel/FSKit/NeFS.h b/dev/kernel/FSKit/NeFS.h index b2f7095d..8ff9d9d2 100644 --- a/dev/kernel/FSKit/NeFS.h +++ b/dev/kernel/FSKit/NeFS.h @@ -17,7 +17,7 @@ default. #pragma once #include -#include +#include #include #include #include diff --git a/dev/kernel/KernelKit/FileMgr.h b/dev/kernel/KernelKit/FileMgr.h index 59203998..fec83d17 100644 --- a/dev/kernel/KernelKit/FileMgr.h +++ b/dev/kernel/KernelKit/FileMgr.h @@ -30,7 +30,7 @@ #endif // __FSKIT_INCLUDES_HeFS__ #include -#include +#include #include #include #include diff --git a/dev/kernel/KernelKit/LoaderInterface.h b/dev/kernel/KernelKit/LoaderInterface.h index 04e197aa..19c21ddb 100644 --- a/dev/kernel/KernelKit/LoaderInterface.h +++ b/dev/kernel/KernelKit/LoaderInterface.h @@ -7,7 +7,7 @@ #pragma once #include -#include +#include #include #include diff --git a/dev/kernel/KernelKit/MemoryMgr.h b/dev/kernel/KernelKit/MemoryMgr.h index 23a4721b..03bd4a2d 100644 --- a/dev/kernel/KernelKit/MemoryMgr.h +++ b/dev/kernel/KernelKit/MemoryMgr.h @@ -13,7 +13,7 @@ #include #include -#include +#include namespace NeOS { diff --git a/dev/kernel/KernelRsrc.rsrc b/dev/kernel/KernelRsrc.rsrc deleted file mode 100644 index d437c176..00000000 --- a/dev/kernel/KernelRsrc.rsrc +++ /dev/null @@ -1,25 +0,0 @@ -#include "CompilerKit/Version.h" - -1 VERSIONINFO -FILEVERSION 1,0,0,0 -PRODUCTVERSION 1,0,0,0 -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "080904E4" - BEGIN - VALUE "CompanyName", "Amlal El Mahrouss." - VALUE "FileDescription", "NeKernel." - VALUE "FileVersion", KERNEL_VERSION - VALUE "InternalName", "neoskrnl" - VALUE "LegalCopyright", "(c) 2024 Amlal El Mahrouss, all rights reserved." - VALUE "OriginalFilename", "neoskrnl.exe" - VALUE "ProductName", "NeKernel." - VALUE "ProductVersion", KERNEL_VERSION - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x809, 1252 - END -END diff --git a/dev/kernel/NetworkKit/IPC.h b/dev/kernel/NetworkKit/IPC.h index e8f0898f..0d28c080 100644 --- a/dev/kernel/NetworkKit/IPC.h +++ b/dev/kernel/NetworkKit/IPC.h @@ -12,7 +12,7 @@ #include #include -#include +#include /// @file IPC.h /// @brief IPC comm. protocol. diff --git a/dev/kernel/NewKit/Variant.h b/dev/kernel/NewKit/Variant.h index 99768016..3fa04496 100644 --- a/dev/kernel/NewKit/Variant.h +++ b/dev/kernel/NewKit/Variant.h @@ -9,7 +9,7 @@ #include #include #include -#include +#include namespace NeOS { @@ -24,6 +24,7 @@ namespace NeOS kJson, kXML, kSwap, + kInvalid, }; public: diff --git a/dev/kernel/SwapKit/DiskSwap.h b/dev/kernel/SwapKit/DiskSwap.h new file mode 100644 index 00000000..b9c31a65 --- /dev/null +++ b/dev/kernel/SwapKit/DiskSwap.h @@ -0,0 +1,70 @@ + +/* ------------------------------------------- + + Copyright (C) 2024-2025 Amlal EL Mahrouss Labs, all rights reserved. + +------------------------------------------- */ + +#pragma once + +#include +#include + +#define kSwapBlockMaxSize (mib_cast(16)) +#define kSwapPageFile "/boot/pagefile.sys" + +/// @file SwapDisk.h +/// @brief Virtual memory swap disk. + +namespace NeOS +{ + struct SWAP_DISK_HEADER; + + /// @brief Virtual memory interface to swap memory chunks onto disk. + class SwapDiskInterface final + { + public: + explicit SwapDiskInterface() = default; + ~SwapDiskInterface() = default; + + NE_COPY_DEFAULT(SwapDiskInterface); + + public: + /***********************************************************************************/ + /// @brief Write memory chunk onto disk. + /// @param fork_name The swap name to recognize this memory region. + /// @param fork_name_len length of fork name. + /// @param data the data packet. + /// @return Whether the swap was written to disk, or not. + /***********************************************************************************/ + BOOL Write(const Char* fork_name, const SizeT fork_name_len, SWAP_DISK_HEADER* data); + + /***********************************************************************************/ + /// @brief Read memory chunk from disk. + /// @param fork_name The swap name to recognize this memory region. + /// @param fork_name_len length of fork name. + /// @param data the data packet length. + /// @return Whether the swap was fetched to disk, or not. + /***********************************************************************************/ + SWAP_DISK_HEADER* Read(const Char* fork_name, const SizeT fork_name_len, const SizeT data_len); + }; + + /// @brief Swap disk header, containing information about the held virtual memory. + /// @param fMagic Ident number. + /// @param fHeaderSz This header size. + /// @param fTeamID Process Team ID. + /// @param fProcessID Process ID. + /// @param fVirtualAddress Virtual address pointed by data. + /// @param fBlobSz Blob's size. + /// @param fBlob Data blob. + typedef struct SWAP_DISK_HEADER + { + UInt32 fMagic; + SizeT fHeaderSz; + UInt64 fTeamID; + UInt64 fProcessID; + UInt64 fVirtualAddress; + SizeT fBlobSz; + UInt8 fBlob[]; + } PACKED SWAP_DISK_HEADER; +} // namespace NeOS diff --git a/dev/kernel/SwapKit/SwapDisk.h b/dev/kernel/SwapKit/SwapDisk.h deleted file mode 100644 index b9c31a65..00000000 --- a/dev/kernel/SwapKit/SwapDisk.h +++ /dev/null @@ -1,70 +0,0 @@ - -/* ------------------------------------------- - - Copyright (C) 2024-2025 Amlal EL Mahrouss Labs, all rights reserved. - -------------------------------------------- */ - -#pragma once - -#include -#include - -#define kSwapBlockMaxSize (mib_cast(16)) -#define kSwapPageFile "/boot/pagefile.sys" - -/// @file SwapDisk.h -/// @brief Virtual memory swap disk. - -namespace NeOS -{ - struct SWAP_DISK_HEADER; - - /// @brief Virtual memory interface to swap memory chunks onto disk. - class SwapDiskInterface final - { - public: - explicit SwapDiskInterface() = default; - ~SwapDiskInterface() = default; - - NE_COPY_DEFAULT(SwapDiskInterface); - - public: - /***********************************************************************************/ - /// @brief Write memory chunk onto disk. - /// @param fork_name The swap name to recognize this memory region. - /// @param fork_name_len length of fork name. - /// @param data the data packet. - /// @return Whether the swap was written to disk, or not. - /***********************************************************************************/ - BOOL Write(const Char* fork_name, const SizeT fork_name_len, SWAP_DISK_HEADER* data); - - /***********************************************************************************/ - /// @brief Read memory chunk from disk. - /// @param fork_name The swap name to recognize this memory region. - /// @param fork_name_len length of fork name. - /// @param data the data packet length. - /// @return Whether the swap was fetched to disk, or not. - /***********************************************************************************/ - SWAP_DISK_HEADER* Read(const Char* fork_name, const SizeT fork_name_len, const SizeT data_len); - }; - - /// @brief Swap disk header, containing information about the held virtual memory. - /// @param fMagic Ident number. - /// @param fHeaderSz This header size. - /// @param fTeamID Process Team ID. - /// @param fProcessID Process ID. - /// @param fVirtualAddress Virtual address pointed by data. - /// @param fBlobSz Blob's size. - /// @param fBlob Data blob. - typedef struct SWAP_DISK_HEADER - { - UInt32 fMagic; - SizeT fHeaderSz; - UInt64 fTeamID; - UInt64 fProcessID; - UInt64 fVirtualAddress; - SizeT fBlobSz; - UInt8 fBlob[]; - } PACKED SWAP_DISK_HEADER; -} // namespace NeOS diff --git a/dev/kernel/amd64-ci.make b/dev/kernel/amd64-ci.make index 692b7b54..71f49082 100644 --- a/dev/kernel/amd64-ci.make +++ b/dev/kernel/amd64-ci.make @@ -49,7 +49,7 @@ WINDRES=x86_64-w64-mingw32-windres .PHONY: newos-amd64-epm newos-amd64-epm: clean - $(WINDRES) KernelRsrc.rsrc -O coff -o KernelRsrc.obj + $(WINDRES) kernel_rsrc.rsrc -O coff -o kernel_rsrc.obj $(CXX) $(CCFLAGS) $(DISK_DRV) $(DEBUG_MACRO) $(wildcard src/*.cc) $(wildcard HALKit/AMD64/PCI/*.cc) $(wildcard src/Network/*.cc) $(wildcard src/Storage/*.cc) $(wildcard src/FS/*.cc) $(wildcard HALKit/AMD64/Storage/*.cc) $(wildcard HALKit/AMD64/*.cc) $(wildcard src/Swap/*.cc) $(wildcard HALKit/AMD64/*.s) $(ASM) $(ASMFLAGS) HALKit/AMD64/HalInterruptAPI.asm $(ASM) $(ASMFLAGS) HALKit/AMD64/HalCommonAPI.asm diff --git a/dev/kernel/amd64-desktop.make b/dev/kernel/amd64-desktop.make index 692b7b54..71f49082 100644 --- a/dev/kernel/amd64-desktop.make +++ b/dev/kernel/amd64-desktop.make @@ -49,7 +49,7 @@ WINDRES=x86_64-w64-mingw32-windres .PHONY: newos-amd64-epm newos-amd64-epm: clean - $(WINDRES) KernelRsrc.rsrc -O coff -o KernelRsrc.obj + $(WINDRES) kernel_rsrc.rsrc -O coff -o kernel_rsrc.obj $(CXX) $(CCFLAGS) $(DISK_DRV) $(DEBUG_MACRO) $(wildcard src/*.cc) $(wildcard HALKit/AMD64/PCI/*.cc) $(wildcard src/Network/*.cc) $(wildcard src/Storage/*.cc) $(wildcard src/FS/*.cc) $(wildcard HALKit/AMD64/Storage/*.cc) $(wildcard HALKit/AMD64/*.cc) $(wildcard src/Swap/*.cc) $(wildcard HALKit/AMD64/*.s) $(ASM) $(ASMFLAGS) HALKit/AMD64/HalInterruptAPI.asm $(ASM) $(ASMFLAGS) HALKit/AMD64/HalCommonAPI.asm diff --git a/dev/kernel/kernel_rsrc.rsrc b/dev/kernel/kernel_rsrc.rsrc new file mode 100644 index 00000000..b5273787 --- /dev/null +++ b/dev/kernel/kernel_rsrc.rsrc @@ -0,0 +1,25 @@ +#include "CompilerKit/Version.h" + +1 VERSIONINFO +FILEVERSION 1,0,0,0 +PRODUCTVERSION 1,0,0,0 +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "080904E4" + BEGIN + VALUE "CompanyName", "Amlal El Mahrouss." + VALUE "FileDescription", "NeKernel" + VALUE "FileVersion", KERNEL_VERSION + VALUE "InternalName", "neoskrnl" + VALUE "LegalCopyright", "(c) 2024-2025 Amlal El Mahrouss, all rights reserved" + VALUE "OriginalFilename", "neoskrnl.exe" + VALUE "ProductName", "NeKernel" + VALUE "ProductVersion", KERNEL_VERSION + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x809, 1252 + END +END diff --git a/dev/kernel/src/Swap/DiskSwap.cc b/dev/kernel/src/Swap/DiskSwap.cc new file mode 100644 index 00000000..c50a96a9 --- /dev/null +++ b/dev/kernel/src/Swap/DiskSwap.cc @@ -0,0 +1,67 @@ +/* ------------------------------------------- + + Copyright (C) 2024-2025 Amlal EL Mahrouss Labs, all rights reserved. + +------------------------------------------- */ + +#include +#include + +namespace NeOS +{ + /***********************************************************************************/ + /// @brief Write memory chunk onto disk. + /// @param fork_name The swap name to recognize this memory region. + /// @param fork_name_len length of fork name. + /// @param data the data packet. + /// @return Whether the swap was written to disk, or not. + /***********************************************************************************/ + BOOL SwapDiskInterface::Write(const Char* fork_name, const SizeT fork_name_len, SWAP_DISK_HEADER* data) + { + if (!fork_name || !fork_name_len) + return NO; + + if (*fork_name == 0) + return NO; + + if (!data) + return NO; + + FileStream file(kSwapPageFile, "wb"); + + auto ret = file.Write(fork_name, data, sizeof(SWAP_DISK_HEADER) + data->fBlobSz); + + if (ret.Error()) + return NO; + + return YES; + } + + /***********************************************************************************/ + /// @brief Read memory chunk from disk. + /// @param fork_name The swap name to recognize this memory region. + /// @param fork_name_len length of fork name. + /// @param data the data packet length. + /// @return Whether the swap was fetched to disk, or not. + /***********************************************************************************/ + SWAP_DISK_HEADER* SwapDiskInterface::Read(const Char* fork_name, const SizeT fork_name_len, const SizeT data_len) + { + if (!fork_name || !fork_name_len) + return nullptr; + + if (*fork_name == 0) + return nullptr; + + if (data_len > kSwapBlockMaxSize) + return nullptr; + + if (data_len == 0) + return nullptr; + + FileStream file(kSwapPageFile, "rb"); + + VoidPtr blob = file.Read(fork_name, sizeof(SWAP_DISK_HEADER) + data_len); + + return reinterpret_cast(blob); + } +} // namespace NeOS diff --git a/dev/kernel/src/Swap/SwapDisk.cc b/dev/kernel/src/Swap/SwapDisk.cc deleted file mode 100644 index fbc63b2f..00000000 --- a/dev/kernel/src/Swap/SwapDisk.cc +++ /dev/null @@ -1,67 +0,0 @@ -/* ------------------------------------------- - - Copyright (C) 2024-2025 Amlal EL Mahrouss Labs, all rights reserved. - -------------------------------------------- */ - -#include -#include - -namespace NeOS -{ - /***********************************************************************************/ - /// @brief Write memory chunk onto disk. - /// @param fork_name The swap name to recognize this memory region. - /// @param fork_name_len length of fork name. - /// @param data the data packet. - /// @return Whether the swap was written to disk, or not. - /***********************************************************************************/ - BOOL SwapDiskInterface::Write(const Char* fork_name, const SizeT fork_name_len, SWAP_DISK_HEADER* data) - { - if (!fork_name || !fork_name_len) - return NO; - - if (*fork_name == 0) - return NO; - - if (!data) - return NO; - - FileStream file(kSwapPageFile, "wb"); - - auto ret = file.Write(fork_name, data, sizeof(SWAP_DISK_HEADER) + data->fBlobSz); - - if (ret.Error()) - return NO; - - return YES; - } - - /***********************************************************************************/ - /// @brief Read memory chunk from disk. - /// @param fork_name The swap name to recognize this memory region. - /// @param fork_name_len length of fork name. - /// @param data the data packet length. - /// @return Whether the swap was fetched to disk, or not. - /***********************************************************************************/ - SWAP_DISK_HEADER* SwapDiskInterface::Read(const Char* fork_name, const SizeT fork_name_len, const SizeT data_len) - { - if (!fork_name || !fork_name_len) - return nullptr; - - if (*fork_name == 0) - return nullptr; - - if (data_len > kSwapBlockMaxSize) - return nullptr; - - if (data_len == 0) - return nullptr; - - FileStream file(kSwapPageFile, "rb"); - - VoidPtr blob = file.Read(fork_name, sizeof(SWAP_DISK_HEADER) + data_len); - - return reinterpret_cast(blob); - } -} // namespace NeOS -- cgit v1.2.3