From 9ac7b512ace3f8a3f5613dbf940484a9fa3c82c2 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 7 Aug 2025 23:30:55 +0100 Subject: feat: PEFCodeMgr.cc: `ldr_get_platform` shall be static. --- dev/kernel/src/PEFCodeMgr.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'dev') diff --git a/dev/kernel/src/PEFCodeMgr.cc b/dev/kernel/src/PEFCodeMgr.cc index 5611bafe..3cbc4faa 100644 --- a/dev/kernel/src/PEFCodeMgr.cc +++ b/dev/kernel/src/PEFCodeMgr.cc @@ -1,4 +1,3 @@ - /* ------------------------------------------- Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. @@ -31,7 +30,7 @@ namespace Detail { /***********************************************************************************/ /// @brief Get the PEF platform signature according to the compiled architecture. /***********************************************************************************/ - UInt32 ldr_get_platform(void) noexcept { + static UInt32 ldr_get_platform(void) noexcept { #if defined(__NE_32X0__) return kPefArch32x0; #elif defined(__NE_64X0__) -- cgit v1.2.3 From 408be791647c015c99963cc1b6d710f58d729dec Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sat, 9 Aug 2025 08:56:53 +0100 Subject: refactor! rename `tooling` to `tools` feat: BenchKit improvements and libMsg authorship refactors. --- .gitignore | 4 +- CODEOWNERS | 2 +- README.md | 6 +- compile_flags.txt | 2 +- debug_ahci_x64.sh | 2 +- debug_ata_x64.sh | 2 +- dev/libMsg/MsgKit/Server.h | 4 +- dev/misc/BenchKit/Chrono.h | 5 + dev/misc/BenchKit/X64Chrono.h | 16 +- release_ahci_x64.sh | 2 +- release_ata_x64.sh | 2 +- tooling/dist/.keep | 0 tooling/fsck.hefs.cc | 76 ------- tooling/fsck.hefs.json | 16 -- tooling/libmkfs/hefs.h | 116 ----------- tooling/libmkfs/mkfs.h | 83 -------- tooling/mk_app.py | 80 -------- tooling/mk_fwrk.py | 92 --------- tooling/mk_htman.py | 41 ---- tooling/mk_img.py | 41 ---- tooling/mkfs.hefs.cc | 197 ------------------ tooling/mkfs.hefs.json | 16 -- tooling/rang.h | 467 ------------------------------------------ tools/dist/.keep | 0 tools/fsck.hefs.cc | 76 +++++++ tools/fsck.hefs.json | 16 ++ tools/libmkfs/hefs.h | 116 +++++++++++ tools/libmkfs/mkfs.h | 83 ++++++++ tools/mk_app.py | 80 ++++++++ tools/mk_fwrk.py | 92 +++++++++ tools/mk_htman.py | 41 ++++ tools/mk_img.py | 41 ++++ tools/mkfs.hefs.cc | 197 ++++++++++++++++++ tools/mkfs.hefs.json | 16 ++ tools/rang.h | 467 ++++++++++++++++++++++++++++++++++++++++++ 35 files changed, 1253 insertions(+), 1244 deletions(-) delete mode 100644 tooling/dist/.keep delete mode 100644 tooling/fsck.hefs.cc delete mode 100644 tooling/fsck.hefs.json delete mode 100644 tooling/libmkfs/hefs.h delete mode 100644 tooling/libmkfs/mkfs.h delete mode 100755 tooling/mk_app.py delete mode 100755 tooling/mk_fwrk.py delete mode 100755 tooling/mk_htman.py delete mode 100755 tooling/mk_img.py delete mode 100644 tooling/mkfs.hefs.cc delete mode 100644 tooling/mkfs.hefs.json delete mode 100644 tooling/rang.h create mode 100644 tools/dist/.keep create mode 100644 tools/fsck.hefs.cc create mode 100644 tools/fsck.hefs.json create mode 100644 tools/libmkfs/hefs.h create mode 100644 tools/libmkfs/mkfs.h create mode 100644 tools/mk_app.py create mode 100644 tools/mk_fwrk.py create mode 100644 tools/mk_htman.py create mode 100644 tools/mk_img.py create mode 100644 tools/mkfs.hefs.cc create mode 100644 tools/mkfs.hefs.json create mode 100644 tools/rang.h (limited to 'dev') diff --git a/.gitignore b/.gitignore index 9722f662..781e9544 100644 --- a/.gitignore +++ b/.gitignore @@ -25,8 +25,8 @@ ne_bootz neoskrnl/neoskrnl.xcodeproj/project.xcworkspace/xcshareddata/ -tooling/dist/mkfs.* -tooling/dist/fsck.* +tools/dist/mkfs.* +tools/dist/fsck.* html/ latex/ diff --git a/CODEOWNERS b/CODEOWNERS index 8eae8622..bf706bfd 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -4,4 +4,4 @@ /dev/ddk/ @amlel-el-mahrouss /dev/libMsg/ @0xf00sec /dev/libSystem/ @0xf00sec -# some other parts (tooling, frameworks) need ownership too. \ No newline at end of file +# some other parts (tools, frameworks) need ownership too. \ No newline at end of file diff --git a/README.md b/README.md index dc9acf93..0557f531 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ ## Overview -**NeKernel** is a modern, multi-platform microkernel designed for security, modularity, and performance. It features a custom VFS, advanced memory management, a flexible DDK (Driver Development Kit), and robust userland tooling. NeKernel is built for research, education, and next-generation OS development. +**NeKernel** is a modern, multi-platform microkernel designed for security, modularity, and performance. It features a custom VFS, advanced memory management, a flexible DDK (Driver Development Kit), and robust userland tools. NeKernel is built for research, education, and next-generation OS development. --- @@ -36,9 +36,9 @@ - **System Call Interface**: low-level syscall ABI, with a stable high-level SDK for user applications. System calls are routed through a syscall manager and abstracted by `libSystem`. -- **Security and Robustness**: kernel and tooling (bounds checks, safe memory copy/set, error codes). Kernel panics and error reporting for critical failures. No dynamic code loading in kernel space. +- **Security and Robustness**: kernel and tools (bounds checks, safe memory copy/set, error codes). Kernel panics and error reporting for critical failures. No dynamic code loading in kernel space. -- **Documentation and Specs**: Full LaTeX specifications for HeFS and NeFS, with on-disk structure diagrams and API documentation. Markdown docs for tooling and usage. +- **Documentation and Specs**: Full LaTeX specifications for HeFS and NeFS, with on-disk structure diagrams and API documentation. Markdown docs for tools and usage. - **Cross-Platform Boot Support**: Bootloader and platform code for AMD64 and ARM64, with handover and hardware abstraction layers. diff --git a/compile_flags.txt b/compile_flags.txt index fbfd1d06..828dc123 100644 --- a/compile_flags.txt +++ b/compile_flags.txt @@ -15,7 +15,7 @@ -Ipublic/tools/open -Ipublic/frameworks -Idev/boot/BootKit --Itooling/ +-Itools/ -I./ -std=c++20 -D__NE_AMD64__ diff --git a/debug_ahci_x64.sh b/debug_ahci_x64.sh index 66121bb7..97ff57ee 100755 --- a/debug_ahci_x64.sh +++ b/debug_ahci_x64.sh @@ -11,6 +11,6 @@ cd ../boot make -f amd64-desktop.make all make -f amd64-desktop.make disk cd ../../ -./tooling/mk_img.py ./dev/boot/src/nekernel-esp.img ./dev/boot/src/root +./tools/mk_img.py ./dev/boot/src/nekernel-esp.img ./dev/boot/src/root cd dev/boot make -f amd64-desktop.make run-efi-amd64-ahci \ No newline at end of file diff --git a/debug_ata_x64.sh b/debug_ata_x64.sh index 6f40887b..b021c3ed 100755 --- a/debug_ata_x64.sh +++ b/debug_ata_x64.sh @@ -11,6 +11,6 @@ cd ../boot make -f amd64-desktop.make all make -f amd64-desktop.make disk cd ../../ -./tooling/mk_img.py ./dev/boot/src/nekernel-esp.img ./dev/boot/src/root +./tools/mk_img.py ./dev/boot/src/nekernel-esp.img ./dev/boot/src/root cd dev/boot make -f amd64-desktop.make run-efi-amd64-ata-pio diff --git a/dev/libMsg/MsgKit/Server.h b/dev/libMsg/MsgKit/Server.h index aee0dbdd..4fa73ccc 100644 --- a/dev/libMsg/MsgKit/Server.h +++ b/dev/libMsg/MsgKit/Server.h @@ -12,6 +12,9 @@ #include #endif +/// @author Amlal El Mahrouss +/// @brief libMsg LISP system. + struct LIBMSG_EXPR; /// @brief an expression chain of LibMSG. @@ -34,5 +37,4 @@ typedef Void (*libmsg_func_t)(LIBMSG_EXPR* self, VoidPtr arg, SizeT arg_size); IMPORT_C Void libmsg_init_library(libmsg_func_t* funcs, SizeT cnt); IMPORT_C UInt32 libmsg_close_library(Void); - IMPORT_C UInt32 libmsg_eval_expr(struct LIBMSG_EXPR* head); diff --git a/dev/misc/BenchKit/Chrono.h b/dev/misc/BenchKit/Chrono.h index 394f16fd..c6801de5 100644 --- a/dev/misc/BenchKit/Chrono.h +++ b/dev/misc/BenchKit/Chrono.h @@ -10,6 +10,11 @@ Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. #include #include +/// @author Amlal El Mahrouss +/// @brief BenchKit Chrono contract. + +#define BENCHKIT_INTERFACE : public ::Kernel::ChronoInterface + namespace Kernel { class ChronoInterface; diff --git a/dev/misc/BenchKit/X64Chrono.h b/dev/misc/BenchKit/X64Chrono.h index 706ce883..358c74d4 100644 --- a/dev/misc/BenchKit/X64Chrono.h +++ b/dev/misc/BenchKit/X64Chrono.h @@ -14,11 +14,13 @@ namespace Kernel { class X64Chrono; struct X64ChronoTraits; +/// @brief BenchKit chrono logic for x64. struct X64ChronoTraits { private: STATIC UInt64 TickImpl_(void) { UInt64 a = 0, d = 0; - __asm__ volatile("rdtsc" : "=a"(a), "=d"(d)); + + asm volatile("rdtsc" : "=a"(a), "=d"(d)); return (d << 32) | a; } @@ -26,7 +28,7 @@ struct X64ChronoTraits { }; /// @brief X86_64 hardware chrono implementation using the `rdtsc` instruction. -class X64Chrono : public ChronoInterface { +class X64Chrono BENCHKIT_INTERFACE { public: X64Chrono() = default; ~X64Chrono() override = default; @@ -34,11 +36,11 @@ class X64Chrono : public ChronoInterface { NE_COPY_DEFAULT(X64Chrono); public: - void Start() override { fStart = X64ChronoTraits::TickImpl_(); } + Void Start() override { fStart = X64ChronoTraits::TickImpl_(); } - void Stop() override { fStop = X64ChronoTraits::TickImpl_(); } + Void Stop() override { fStop = X64ChronoTraits::TickImpl_(); } - void Reset() override { + Void Reset() override { fStart = 0; fStop = 0; } @@ -46,8 +48,8 @@ class X64Chrono : public ChronoInterface { UInt64 GetElapsedTime() const override { return fStop - fStart; } private: - UInt64 fStart = 0; - UInt64 fStop = 0; + UInt64 fStart{}; + UInt64 fStop{}; }; } // namespace Kernel diff --git a/release_ahci_x64.sh b/release_ahci_x64.sh index d585e74e..f081c774 100755 --- a/release_ahci_x64.sh +++ b/release_ahci_x64.sh @@ -8,6 +8,6 @@ cd ../boot make -f amd64-desktop.make all make -f amd64-desktop.make disk cd ../../ -./tooling/mk_img.py ./dev/boot/src/nekernel-esp.img ./dev/boot/src/root +./tools/mk_img.py ./dev/boot/src/nekernel-esp.img ./dev/boot/src/root cd dev/boot make -f amd64-desktop.make run-efi-amd64-ahci \ No newline at end of file diff --git a/release_ata_x64.sh b/release_ata_x64.sh index c0a0e01e..d69e3d3f 100755 --- a/release_ata_x64.sh +++ b/release_ata_x64.sh @@ -8,6 +8,6 @@ cd ../boot make -f amd64-desktop.make all make -f amd64-desktop.make disk cd ../../ -./tooling/mk_img.py ./dev/boot/src/nekernel-esp.img ./dev/boot/src/root +./tools/mk_img.py ./dev/boot/src/nekernel-esp.img ./dev/boot/src/root cd dev/boot make -f amd64-desktop.make run-efi-amd64-ata-pio \ No newline at end of file diff --git a/tooling/dist/.keep b/tooling/dist/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/tooling/fsck.hefs.cc b/tooling/fsck.hefs.cc deleted file mode 100644 index 9d0b3e03..00000000 --- a/tooling/fsck.hefs.cc +++ /dev/null @@ -1,76 +0,0 @@ -/* ------------------------------------------- - - Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. - -------------------------------------------- */ - -#include -#include -#include -#include - -static uint16_t kNumericalBase = 10; - -int main(int argc, char** argv) { - if (argc < 2) { - mkfs::console_out() << "fsck: hefs: usage: fsck.hefs -i=" - << "\n"; - return EXIT_FAILURE; - } - - auto args = mkfs::detail::build_args(argc, argv); - - auto opt_disk = mkfs::get_option(args, "-i"); - - auto origin = mkfs::get_option(args, "-o"); - - if (opt_disk.empty()) { - mkfs::console_out() << "fsck: hefs: error: HeFS is empty! Exiting..." - << "\n"; - return EXIT_FAILURE; - } - - auto out_origin = 0L; - - if (!mkfs::detail::parse_signed(origin, out_origin, kNumericalBase)) { - mkfs::console_out() << "hefs: error: Invalid -o argument.\n"; - return EXIT_FAILURE; - } - - std::ifstream output_device(opt_disk, std::ios::binary); - - if (!output_device.good()) { - mkfs::console_out() << "hefs: error: Unable to open output device: " << opt_disk << "\n"; - return EXIT_FAILURE; - } - - output_device.seekg(out_origin); - - if (!output_device.good()) { - mkfs::console_out() << "hefs: error: Failed seek to origin.\n"; - return EXIT_FAILURE; - } - - mkfs::hefs::BootNode boot_node; - - std::memset(&boot_node, 0, sizeof(boot_node)); - - output_device.read(reinterpret_cast(&boot_node), sizeof(boot_node)); - - if (strncmp(boot_node.magic, kHeFSMagic, kHeFSMagicLen) != 0 || boot_node.sectorCount < 1 || - boot_node.sectorSize < kMkFsSectorSz) { - mkfs::console_out() << "hefs: error: Device is not an HeFS disk: " << opt_disk << "\n"; - return EXIT_FAILURE; - } - - if (boot_node.badSectors > kMkFsMaxBadSectors) { - mkfs::console_out() << "hefs: error: HeFS disk has too much bad sectors: " << opt_disk << "\n"; - return EXIT_FAILURE; - } - - mkfs::console_out() << "hefs: HeFS partition is is healthy, exiting...\n"; - - output_device.close(); - - return EXIT_SUCCESS; -} \ No newline at end of file diff --git a/tooling/fsck.hefs.json b/tooling/fsck.hefs.json deleted file mode 100644 index d6ff4b0f..00000000 --- a/tooling/fsck.hefs.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "compiler_path": "g++", - "compiler_std": "c++20", - "headers_path": [ - "../" - ], - "sources_path": [ - "fsck.hefs.cc" - ], - "output_name": "./dist/fsck.hefs", - "cpp_macros": [ - "kFSCKHEFSVersion=0x0100", - "kFSCKHEFSVersionHighest=0x0100", - "kFSCKHEFSVersionLowest=0x0100" - ] -} \ No newline at end of file diff --git a/tooling/libmkfs/hefs.h b/tooling/libmkfs/hefs.h deleted file mode 100644 index 52bb3086..00000000 --- a/tooling/libmkfs/hefs.h +++ /dev/null @@ -1,116 +0,0 @@ -/* ------------------------------------------- - - Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. - -------------------------------------------- */ - -#pragma once - -#include -#include - -#define kHeFSVersion (0x0101) -#define kHeFSMagic " HeFS" -#define kHeFSMagicLen (8) - -#define kHeFSFileNameLen (256U) -#define kHeFSPartNameLen (128U) - -#define kHeFSDefaultVolumeName u8"HeFS Volume" - -namespace mkfs::hefs { - -// Drive kinds -enum { - kHeFSHardDrive = 0xC0, // Hard Drive - kHeFSSolidStateDrive = 0xC1, // Solid State Drive - kHeFSOpticalDrive = 0x0C, // Blu-Ray/DVD - kHeFSMassStorageDevice = 0xCC, // USB - kHeFSScsiDrive = 0xC4, // SCSI Hard Drive - kHeFSFlashDrive = 0xC6, - kHeFSUnknown = 0xFF, // Unknown device. - kHeFSDriveCount = 8, -}; - -// Disk status -enum { - kHeFSStatusUnlocked = 0x18, - kHeFSStatusLocked, - kHeFSStatusError, - kHeFSStatusInvalid, - kHeFSStatusCount, -}; - -// Encodings -enum { - kHeFSEncodingFlagsUTF8 = 0x50, - kHeFSEncodingFlagsUTF16, - kHeFSEncodingFlagsUTF32, - kHeFSEncodingFlagsUTF16BE, - kHeFSEncodingFlagsUTF16LE, - kHeFSEncodingFlagsUTF32BE, - kHeFSEncodingFlagsUTF32LE, - kHeFSEncodingFlagsUTF8BE, - kHeFSEncodingFlagsUTF8LE, - kHeFSEncodingFlagsBinary, - kHeFSEncodingFlagsCount = 11, - kHeFSFlagsNone = 0, - kHeFSFlagsReadOnly = 0x100, - kHeFSFlagsHidden, - kHeFSFlagsSystem, - kHeFSFlagsArchive, - kHeFSFlagsDevice, - kHeFSFlagsCount = 7 -}; - -// Time type -using ATime = std::uint64_t; - -// File kinds -inline constexpr uint16_t kHeFSFileKindRegular = 0x00; -inline constexpr uint16_t kHeFSFileKindDirectory = 0x01; -inline constexpr uint16_t kHeFSFileKindBlock = 0x02; -inline constexpr uint16_t kHeFSFileKindCharacter = 0x03; -inline constexpr uint16_t kHeFSFileKindFIFO = 0x04; -inline constexpr uint16_t kHeFSFileKindSocket = 0x05; -inline constexpr uint16_t kHeFSFileKindSymbolicLink = 0x06; -inline constexpr uint16_t kHeFSFileKindUnknown = 0x07; -inline constexpr uint16_t kHeFSFileKindCount = 0x08; - -// Red-black tree colors -enum { - kHeFSInvalidColor = 0, - kHeFSRed = 100, - kHeFSBlack, - kHeFSColorCount, -}; - -// Time constants -inline constexpr ATime kHeFSTimeInvalid = 0x0000000000000000; -inline constexpr ATime kHeFSTimeMax = 0xFFFFFFFFFFFFFFFF - 1; - -// Boot Node -struct __attribute__((packed)) BootNode { - char magic[kHeFSMagicLen]{}; - char8_t volumeName[kHeFSPartNameLen]{}; - std::uint32_t version{}; - std::uint64_t badSectors{}; - std::uint64_t sectorCount{}; - std::uint64_t sectorSize{}; - std::uint32_t checksum{}; - std::uint8_t diskKind{}; - std::uint8_t encoding{}; - std::uint64_t startIND{}; - std::uint64_t endIND{}; - std::uint64_t indCount{}; - std::uint64_t diskSize{}; - std::uint16_t diskStatus{}; - std::uint16_t diskFlags{}; - std::uint16_t vid{}; - std::uint64_t startIN{}; - std::uint64_t endIN{}; - std::uint64_t startBlock{}; - std::uint64_t endBlock{}; - char pad[272]{}; -}; -} // namespace mkfs::hefs diff --git a/tooling/libmkfs/mkfs.h b/tooling/libmkfs/mkfs.h deleted file mode 100644 index 31f7a26a..00000000 --- a/tooling/libmkfs/mkfs.h +++ /dev/null @@ -1,83 +0,0 @@ -/* ------------------------------------------- - - Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. - -------------------------------------------- */ - -#pragma once - -#include -#include -#include -#include - -#define kMkFsSectorSz (512U) -#define kMkFsMaxBadSectors (128U) - -/// @internal -namespace mkfs { - -namespace detail { - /// @internal - /// @brief GB‐to‐byte conversion (use multiplication, not XOR). - inline constexpr size_t gib_cast(uint32_t gb) { - return static_cast(gb) * 1024ULL * 1024ULL * 1024ULL; - } - - inline bool parse_decimal(const std::string& opt, unsigned long long& out) { - if (opt.empty()) return false; - char* endptr = nullptr; - unsigned long long val = std::strtoull(opt.c_str(), &endptr, 10); - if (endptr == opt.c_str() || *endptr != '\0') return false; - out = val; - return true; - } - - inline bool parse_signed(const std::string& opt, long& out, int base = 10) { - out = 0L; - - if (opt.empty()) return true; - - char* endptr = nullptr; - long val = std::strtol(opt.c_str(), &endptr, base); - auto err = errno; - - if (err == ERANGE || err == EINVAL) return false; - if (endptr == opt.c_str() || *endptr != '\0') return false; - - out = val; - return true; - } - - inline std::string build_args(int argc, char** argv) { - std::string combined; - for (int i = 1; i < argc; ++i) { - combined += argv[i]; - combined += ' '; - } - return combined; - } -} // namespace detail - -/// @brief Helper function to get the option value from command line arguments. -template -inline std::basic_string get_option(const std::basic_string& args, - const std::basic_string& option) { - size_t pos = args.find(option + CharType('=')); - - if (pos != std::string::npos) { - size_t start = pos + option.length() + 1; - size_t end = args.find(' ', start); - return args.substr(start, end - start); - } - - return std::basic_string{}; -} - -inline auto console_out() -> std::ostream& { - std::ostream& conout = std::cout; - conout << rang::fg::red << "mkfs: " << rang::style::reset; - - return conout; -} -} // namespace mkfs \ No newline at end of file diff --git a/tooling/mk_app.py b/tooling/mk_app.py deleted file mode 100755 index 7f7cef17..00000000 --- a/tooling/mk_app.py +++ /dev/null @@ -1,80 +0,0 @@ -#! /usr/bin/env python3 -# -*- coding: utf-8 -*- - -import os -import json -import sys - -def create_directory_structure(base_path, project_name): - # Define the directory structure - structure = { - project_name: { - "dist": { - ".keep": None - }, - "src": { - ".keep": None, - "CommandLine.cc": None, - }, - "vendor": { - ".keep": None - }, - ".keep": None, - f"{project_name}.json": {} - } - } - - def create_structure(path, structure): - for name, content in structure.items(): - current_path = os.path.join(path, name) - # Create directories or files based on the content type - if isinstance(content, dict) and current_path.endswith(".json") == False: - os.makedirs(current_path, exist_ok=True) - create_structure(current_path, content) - elif content is None: - # Create an empty file - with open(current_path, 'w') as f: - pass - - # Create the base directory - os.makedirs(base_path, exist_ok=True) - create_structure(base_path, structure) - - # Create the JSON file - proj_json_path = os.path.join(base_path, project_name, f"{project_name}.json") - - manifest = { - "compiler_path": "clang++", - "compiler_std": "c++20", - "headers_path": ["./", "../../../dev/kernel", "../../../public/frameworks/", "../../../dev/", "./"], - "sources_path": [ - - ], - "output_name": f"./dist/{project_name}", - "cpp_macros": [ - "kSampleFWVersion=0x0100", - "kSampleFWVersionHighest=0x0100", - "kSampleFWVersionLowest=0x0100", - "__NE_SDK__" - ] - } - - with open(proj_json_path, 'w') as json_file: - json.dump(manifest, json_file, indent=4) - - proj_cpp_path = os.path.join(base_path, project_name, f"src/CommandLine.cc") - - cpp_file = "#include \n\nSInt32 _NeMain(SInt32 argc, Char* argv[]) {\n\treturn EXIT_FAILURE;\n}" - - with open(proj_cpp_path, 'w') as cpp_file_io: - cpp_file_io.write(cpp_file) - -if __name__ == "__main__": - if len(sys.argv) != 2: - print("HELP: mk_app.py ") - sys.exit(os.EX_CONFIG) - - base_path = os.getcwd() # Use the current working directory as the base path - create_directory_structure(base_path, sys.argv[1]) - - print("INFO: Application created successfully.") diff --git a/tooling/mk_fwrk.py b/tooling/mk_fwrk.py deleted file mode 100755 index b2ef99ff..00000000 --- a/tooling/mk_fwrk.py +++ /dev/null @@ -1,92 +0,0 @@ -#! /usr/bin/env python3 -# -*- coding: utf-8 -*- - -import os -import json -import sys - -""" - Create directory structure for the framework. -""" -def create_directory_structure(base_path_fwrk, project_file_name, project_name): - # Define the directory structure - structure = { - project_name: { - "headers": { - ".keep": None - }, - "dist": { - ".keep": None - }, - "src": { - ".keep": None, - "DylibMain.cc": None, - }, - "xml": { - ".keep": None - }, - ".keep": None, - f"{project_file_name}.json": {} - } - } - - def create_structure(path, structure_in): - for name, content in structure_in.items(): - current_path = os.path.join(path, name) - # Create directories or files based on the content type - if isinstance(content, dict) and current_path.endswith(".json") == False: - os.makedirs(current_path, exist_ok=True) - create_structure(current_path, content) - elif content is None: - # Create an empty file - with open(current_path, 'w') as f: - pass - - # Create the base directory - os.makedirs(base_path_fwrk, exist_ok=True) - create_structure(base_path_fwrk, structure) - - # Create the JSON file - proj_json_path = os.path.join(base_path_fwrk, project_name, f"{project_file_name}.json") - - manifest = { - "compiler_path": "clang++", - "compiler_std": "c++20", - "headers_path": ["./", "../../../dev/kernel", "../../../public/frameworks/", "../../../dev/", "./"], - "sources_path": [ - - ], - "output_name": f"./dist/lib{project_name}.dylib", - "cpp_macros": [ - "kSampleFWVersion=0x0100", - "kSampleFWVersionHighest=0x0100", - "kSampleFWVersionLowest=0x0100", - "__NE_SDK__" - ] - } - - with open(proj_json_path, 'w') as json_file: - json.dump(manifest, json_file, indent=4) - - proj_cpp_path = os.path.join(base_path_fwrk, project_name, f"src/DylibMain.cc") - - cpp_file = "#include \n\nSInt32 _DylibAttach(SInt32 argc, Char* argv[]) {\n\treturn EXIT_FAILURE;\n}" - - with open(proj_cpp_path, 'w') as cpp_file_io: - cpp_file_io.write(cpp_file) - - xml_blob = f"\n" - proj_xml_path = os.path.join(base_path_fwrk, project_name, f"xml/app.xml") - - with open(proj_xml_path, 'w') as cpp_file_io: - cpp_file_io.write(xml_blob) - -if __name__ == "__main__": - if len(sys.argv) != 2: - print("HELP: mk_fwrk.py ") - sys.exit(os.EX_CONFIG) - - base_path = os.getcwd() # Use the current working directory as the base path - create_directory_structure(base_path, sys.argv[1], sys.argv[1] + '.fwrk') - - print("INFO: Framework created successfully.") diff --git a/tooling/mk_htman.py b/tooling/mk_htman.py deleted file mode 100755 index e865f7c5..00000000 --- a/tooling/mk_htman.py +++ /dev/null @@ -1,41 +0,0 @@ -#! /usr/bin/env python3 -# -*- coding: utf-8 -*- - -import sys, os - -if __name__ == "__main__": - if len(sys.argv) != 2: - print("INFO: mk_htman.py ") - sys.exit(os.EX_CONFIG) - - manual_path = sys.argv[1] - if not os.path.exists(manual_path): - print(f"ERROR: Manual path '{manual_path}' does not exist.") - sys.exit(os.EX_NOINPUT) - - if os.path.isdir(manual_path): - print(f"ERROR: Manual path '{manual_path}' is a directory.") - sys.exit(os.EX_NOTDIR) - - if not manual_path.endswith('.man'): - print(f"ERROR: Manual path '{manual_path}' must end with '.man'") - sys.exit(os.EX_DATAERR) - - try: - with open(manual_path, 'r') as file: - content = file.read() - if not content.strip(): - print(f"ERROR: Manual file '{manual_path}' is empty.") - sys.exit(os.EX_DATAERR) - html_content = f"NeKernel Manual: {manual_path}
{content}
" - - html_path = manual_path.replace('.man', '.html') - - with open(html_path, 'w') as html_file: - html_file.write(html_content) - except IOError as e: - print(f"ERROR: Could not read manual file '{manual_path}': {e}") - sys.exit(os.EX_IOERR) - - print(f"INFO: Wrote manual '{manual_path}' to HTML.") - sys.exit(os.EX_OK) diff --git a/tooling/mk_img.py b/tooling/mk_img.py deleted file mode 100755 index f0fa0609..00000000 --- a/tooling/mk_img.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -import os -import sys -import subprocess -import glob as file_glob - -def copy_to_fat(image_path, source_dir): - if not os.path.isfile(image_path): - print(f"Error: FAT32 image {image_path} does not exist.") - sys.exit(1) - - if not os.path.isdir(source_dir): - print(f"Error: {source_dir} is not a valid directory.") - sys.exit(1) - - try: - files_to_copy = file_glob.glob(os.path.join(source_dir, "*")) - - if not files_to_copy: - print(f"Warning: No files found in {source_dir}, nothing to copy.") - sys.exit(1) - - command = ["mcopy", "-spm", "-i", image_path] + files_to_copy + ["::"] - subprocess.run(command, check=True) - except Exception as e: - print(f"Error: failed: {e}") - sys.exit(1) - -if __name__ == "__main__": - if len(sys.argv) != 3: - print("HELP: mk_img.py ") - sys.exit(1) - - image_path = sys.argv[1] - source_dir = sys.argv[2] - - copy_to_fat(image_path, source_dir) - - print("INFO: Image created successfully.") diff --git a/tooling/mkfs.hefs.cc b/tooling/mkfs.hefs.cc deleted file mode 100644 index b90b0fc5..00000000 --- a/tooling/mkfs.hefs.cc +++ /dev/null @@ -1,197 +0,0 @@ -/* ------------------------------------------- - - Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. - -------------------------------------------- */ - -#include -#include -#include -#include -#include -#include -#include - -static size_t kDiskSize = mkfs::detail::gib_cast(4UL); -static uint16_t kVersion = kHeFSVersion; -static std::u8string kLabel; -static size_t kSectorSize = 512; -static uint16_t kNumericalBase = 10; - -int main(int argc, char** argv) { - if (argc < 2) { - mkfs::console_out() - << "hefs: usage: mkfs.hefs -L=