diff options
| author | Amlal El Mahrouss <amlal@el-mahrouss-logic.com> | 2024-03-27 17:38:23 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@el-mahrouss-logic.com> | 2024-03-27 17:38:23 +0100 |
| commit | 1ce16b83dba0326b13dfa3399c1497ac6b1af14d (patch) | |
| tree | 8a5e4063b5d4cf6ce4f42dd500073994e9ef8954 | |
| parent | 6a18e607ffc4e83f2bd953c9de5c14f18e077df8 (diff) | |
Kernel && Developer:
Developer:
- Rework System API to use C instead of C++
- Add new calls in Thread.h
- Documented code.
Kernel:
- Rework handover stage, separated the Processor specific code from
the cross platform code.
Signed-off-by: Amlal El Mahrouss <amlal@el-mahrouss-logic.com>
37 files changed, 219 insertions, 151 deletions
diff --git a/Meta/HCore.svg b/Meta/HCore.svg deleted file mode 100644 index 91cb7dfb..00000000 --- a/Meta/HCore.svg +++ /dev/null @@ -1,15 +0,0 @@ -<svg width="125" height="49" viewBox="0 0 125 49" fill="none" xmlns="http://www.w3.org/2000/svg"> -<rect width="125" height="49" rx="24.5" fill="url(#paint0_linear_0_1)"/> -<rect x="5" y="4" width="42" height="41" rx="20.5" fill="url(#paint1_linear_0_1)"/> -<path d="M54.125 33V15.5455H58.8636V22.3636H65.1364V15.5455H69.875V33H65.1364V26.1818H58.8636V33H54.125ZM88.4205 22.0909H83.6136C83.5795 21.6932 83.4886 21.3324 83.3409 21.0085C83.1989 20.6847 83 20.4062 82.7443 20.1733C82.4943 19.9347 82.1903 19.7528 81.8324 19.6278C81.4744 19.4972 81.0682 19.4318 80.6136 19.4318C79.8182 19.4318 79.1449 19.625 78.5938 20.0114C78.0483 20.3977 77.6335 20.9517 77.3494 21.6733C77.071 22.3949 76.9318 23.2614 76.9318 24.2727C76.9318 25.3409 77.0739 26.2358 77.358 26.9574C77.6477 27.6733 78.0653 28.2131 78.6108 28.5767C79.1563 28.9347 79.8125 29.1136 80.5795 29.1136C81.017 29.1136 81.4091 29.0597 81.7557 28.9517C82.1023 28.8381 82.4034 28.6761 82.6591 28.4659C82.9148 28.2557 83.1222 28.0028 83.2812 27.7074C83.446 27.4062 83.5568 27.0682 83.6136 26.6932L88.4205 26.7273C88.3636 27.4659 88.1563 28.2187 87.7983 28.9858C87.4403 29.7472 86.9318 30.4517 86.2727 31.0994C85.6193 31.7415 84.8097 32.2585 83.8438 32.6506C82.8778 33.0426 81.7557 33.2386 80.4773 33.2386C78.875 33.2386 77.4375 32.8949 76.1648 32.2074C74.8977 31.5199 73.8949 30.5085 73.1562 29.1733C72.4233 27.8381 72.0568 26.2045 72.0568 24.2727C72.0568 22.3295 72.4318 20.6932 73.1818 19.3636C73.9318 18.0284 74.9432 17.0199 76.2159 16.3381C77.4886 15.6506 78.9091 15.3068 80.4773 15.3068C81.5795 15.3068 82.5938 15.4574 83.5199 15.7585C84.446 16.0597 85.2585 16.5 85.9574 17.0795C86.6563 17.6534 87.2188 18.3608 87.6449 19.2017C88.071 20.0426 88.3295 21.0057 88.4205 22.0909ZM90.5703 33V15.5455H98.1044C99.3999 15.5455 100.533 15.7812 101.505 16.2528C102.477 16.7244 103.232 17.4034 103.772 18.2898C104.312 19.1761 104.582 20.2386 104.582 21.4773C104.582 22.7273 104.303 23.7812 103.746 24.6392C103.195 25.4972 102.42 26.1449 101.42 26.5824C100.425 27.0199 99.2635 27.2386 97.9339 27.2386H93.4339V23.5568H96.9794C97.5362 23.5568 98.0107 23.4886 98.4027 23.3523C98.8004 23.2102 99.1044 22.9858 99.3146 22.679C99.5305 22.3722 99.6385 21.9716 99.6385 21.4773C99.6385 20.9773 99.5305 20.571 99.3146 20.2585C99.1044 19.9403 98.8004 19.7074 98.4027 19.5597C98.0107 19.4062 97.5362 19.3295 96.9794 19.3295H95.3089V33H90.5703ZM100.798 24.9886L105.161 33H100.013L95.7521 24.9886H100.798Z" fill="#26B345"/> -<defs> -<linearGradient id="paint0_linear_0_1" x1="62.5" y1="0" x2="62.5" y2="49" gradientUnits="userSpaceOnUse"> -<stop stop-color="white"/> -<stop offset="1" stop-color="#999999"/> -</linearGradient> -<linearGradient id="paint1_linear_0_1" x1="47" y1="24.5" x2="5" y2="24.5" gradientUnits="userSpaceOnUse"> -<stop stop-color="#0F8228"/> -<stop offset="1" stop-color="#1DDF48"/> -</linearGradient> -</defs> -</svg> diff --git a/Meta/NewKernel.svg b/Meta/NewKernel.svg new file mode 100644 index 00000000..863dcc0a --- /dev/null +++ b/Meta/NewKernel.svg @@ -0,0 +1,29 @@ +<svg width="98" height="98" viewBox="0 0 98 98" fill="none" xmlns="http://www.w3.org/2000/svg"> +<rect width="98" height="98" rx="10" fill="url(#paint0_linear_139_17)"/> +<path d="M89 49L49 9H79C84.5228 9 89 13.4772 89 19V49Z" fill="url(#paint1_linear_139_17)"/> +<path d="M49 49L9 9H49V49Z" fill="url(#paint2_linear_139_17)"/> +<path d="M9 49L49 89H19C13.4772 89 9 84.5228 9 79V49Z" fill="url(#paint3_linear_139_17)"/> +<path d="M49 49L89 89H49V49Z" fill="url(#paint4_linear_139_17)"/> +<defs> +<linearGradient id="paint0_linear_139_17" x1="49" y1="0" x2="49" y2="98" gradientUnits="userSpaceOnUse"> +<stop stop-color="#767A7F"/> +<stop offset="1" stop-color="#232A31"/> +</linearGradient> +<linearGradient id="paint1_linear_139_17" x1="69" y1="9" x2="69" y2="49" gradientUnits="userSpaceOnUse"> +<stop stop-color="#0075FF"/> +<stop offset="1" stop-color="#004699"/> +</linearGradient> +<linearGradient id="paint2_linear_139_17" x1="29" y1="9" x2="29" y2="49" gradientUnits="userSpaceOnUse"> +<stop stop-color="#0075FF"/> +<stop offset="1" stop-color="#004699"/> +</linearGradient> +<linearGradient id="paint3_linear_139_17" x1="29" y1="89" x2="29" y2="49" gradientUnits="userSpaceOnUse"> +<stop stop-color="#0075FF"/> +<stop offset="1" stop-color="#004699"/> +</linearGradient> +<linearGradient id="paint4_linear_139_17" x1="69" y1="89" x2="69" y2="49" gradientUnits="userSpaceOnUse"> +<stop stop-color="#0075FF"/> +<stop offset="1" stop-color="#004699"/> +</linearGradient> +</defs> +</svg> diff --git a/Private/Builtins/Toolbox/Toolbox.hxx b/Private/Builtins/Toolbox/Toolbox.hxx index 82d0f953..ebd8fc1e 100644 --- a/Private/Builtins/Toolbox/Toolbox.hxx +++ b/Private/Builtins/Toolbox/Toolbox.hxx @@ -15,4 +15,4 @@ EXTERN_C HCore::Boolean _hal_left_button_pressed(); EXTERN_C HCore::Boolean _hal_middle_button_pressed(); EXTERN_C HCore::Boolean _hal_right_button_pressed(); -#include <Builtins/Toolbox/Util.hxx> +#include <Builtins/Toolbox/Utils.hxx> diff --git a/Private/Builtins/Toolbox/Util.hxx b/Private/Builtins/Toolbox/Utils.hxx index 2be185e1..7dec8608 100644 --- a/Private/Builtins/Toolbox/Util.hxx +++ b/Private/Builtins/Toolbox/Utils.hxx @@ -10,7 +10,7 @@ #define ToolboxClearRsrc() uA = 0 -/// @brief draws a resource. +/// @brief Draws a resource. #define ToolboxDrawRsrc(ImgPtr, _Height, _Width, BaseX, BaseY) \ uA = 0; \ \ @@ -37,7 +37,7 @@ } -/// @brief cleans a resource. +/// @brief Cleans a resource. #define ToolboxClearZone(_Height, _Width, BaseX, BaseY) \ \ for (HCore::SizeT i = BaseX; i < _Height + BaseX; ++i) { \ @@ -52,6 +52,7 @@ } +/// @brief Draws inside a zone. #define ToolboxDrawZone(_Clr, _Height, _Width, BaseX, BaseY) \ \ for (HCore::SizeT i = BaseX; i < _Width + BaseX; ++i) { \ diff --git a/Private/FSKit/NewFS.hxx b/Private/FSKit/NewFS.hxx index ffd198d2..70ea0881 100644 --- a/Private/FSKit/NewFS.hxx +++ b/Private/FSKit/NewFS.hxx @@ -35,12 +35,16 @@ #define kNewFSIdent " NewFS" #define kNewFSPadLen 16 -//! On EPM and GPT disks. +/// @brief Partition GUID on EPM and GPT disks. #define kNewFSUUID "@{DD997393-9CCE-4288-A8D5-C0FDE3908DBE}" #define kNewFSVersionInteger 0x121 #define kNewFSVerionString "1.2.1" +/// @brief Standard fork types. +#define kNewFSDataFork "data" +#define kNewFSResourceFork "rsrc" + #define kNewFSCatalogKindFile 1 #define kNewFSCatalogKindDir 2 #define kNewFSCatalogKindAlias 3 diff --git a/Private/FirmwareKit/EPM.hxx b/Private/FirmwareKit/EPM.hxx index 2c68b40a..4c8d48f2 100644 --- a/Private/FirmwareKit/EPM.hxx +++ b/Private/FirmwareKit/EPM.hxx @@ -77,10 +77,10 @@ struct PACKED PartitionBlock { #define kEPMMaxBlks 128 -//! version types. -//! use in boot block version field. +///! @brief Version kind enum. +///! @brief Use in boot block version field. -enum { +enum kEPMKind { kEPMMpUx = 0xcf, kEPMLinux = 0x8f, kEPMBSD = 0x9f, diff --git a/Private/HALKit/AMD64/HalKernelMain.cxx b/Private/HALKit/AMD64/HalKernelMain.cxx index 266ef18a..29cbdff2 100644 --- a/Private/HALKit/AMD64/HalKernelMain.cxx +++ b/Private/HALKit/AMD64/HalKernelMain.cxx @@ -17,8 +17,9 @@ #include <NewKit/Json.hpp> EXTERN_C HCore::VoidPtr kInterruptVectorTable[]; +EXTERN_C void RuntimeMain(); -EXTERN_C void RuntimeMain( +EXTERN_C void hal_init_platform( HCore::HEL::HandoverInformationHeader* HandoverHeader) { kHandoverHeader = HandoverHeader; @@ -65,12 +66,6 @@ EXTERN_C void RuntimeMain( /// END POST - /// Mounts a NewFS block. - HCore::NewFilesystemManager* newFS = new HCore::NewFilesystemManager(); - HCore::ke_protect_ke_heap(newFS); - - HCore::FilesystemManagerInterface::Mount(newFS); - ToolboxInitRsrc(); ToolboxDrawRsrc( @@ -80,6 +75,7 @@ EXTERN_C void RuntimeMain( ToolboxClearRsrc(); - HCore::ke_delete_ke_heap(newFS); + RuntimeMain(); + HCore::ke_stop(RUNTIME_CHECK_BOOTSTRAP); } diff --git a/Private/HALKit/AMD64/HalNewBoot.asm b/Private/HALKit/AMD64/HalNewBoot.asm index 3a16cd24..54d05f2f 100644 --- a/Private/HALKit/AMD64/HalNewBoot.asm +++ b/Private/HALKit/AMD64/HalNewBoot.asm @@ -15,10 +15,11 @@ %define kTypeKernel 100 %define kArchAmd64 122 +%define kHandoverMagic 0xBADCC section .NewBoot -HandoverMagic: dq 0xBAD55 +HandoverMagic: dq kHandoverMagic HandoverType: dw kTypeKernel HandoverArch: dw kArchAmd64 ;; This NewBootStart points to Main. @@ -27,13 +28,13 @@ HandoverStart: dq Main section .text global Main -extern RuntimeMain +extern hal_init_platform ;; Just a simple setup, we'd also need to tell some before Main: push rax push rcx - call RuntimeMain + call hal_init_platform pop rcx pop rax ;; Go to sleep. diff --git a/Private/HALKit/AMD64/HalSMPCore.cxx b/Private/HALKit/AMD64/HalSMPCore.cxx index d213b2fc..3be9c0c7 100644 --- a/Private/HALKit/AMD64/HalSMPCore.cxx +++ b/Private/HALKit/AMD64/HalSMPCore.cxx @@ -7,7 +7,7 @@ #include <KernelKit/ProcessScheduler.hpp> using namespace HCore; -Void ProcessHeader::SetStart(UIntPtr &imageStart) noexcept { +Void ProcessHeader::SetEntrypoint(UIntPtr &imageStart) noexcept { if (imageStart == 0) this->Crash(); this->StackFrame->Rbp = imageStart; diff --git a/Private/HALKit/AMD64/HalSMPCoreManager.asm b/Private/HALKit/AMD64/HalSMPCoreManager.asm index 66cfec3a..d896a66c 100644 --- a/Private/HALKit/AMD64/HalSMPCoreManager.asm +++ b/Private/HALKit/AMD64/HalSMPCoreManager.asm @@ -14,8 +14,13 @@ section .text +;; writes to rdx the stackframe inside rcx. +;; rcx: Stack Pointer +;; rdx: SMP core address. rt_do_context_switch: - retfq + + retfq +;; gets the current stack frame. rt_get_current_context: retfq diff --git a/Private/KernelKit/DriveManager.hxx b/Private/KernelKit/DriveManager.hxx index bec490d9..8d0289aa 100644 --- a/Private/KernelKit/DriveManager.hxx +++ b/Private/KernelKit/DriveManager.hxx @@ -24,6 +24,7 @@ enum { kMassStorage = 0xDA, kFloppyDisc = 0xCD, kOpticalDisc = 0xDC, // CD-ROM/DVD-ROM/Blu-Ray + /// combine with below. kReadOnly = 0x10, // Read only drive kEPMDrive = 0x11, // Explicit Partition Map. kEPTDrive = 0x12, // ESP w/ EPM partition. @@ -42,10 +43,10 @@ struct DriveTrait final { /// @brief Packet drive (StorageKit compilant.) struct DrivePacket final { - VoidPtr fPacketContent; // packet body. + VoidPtr fPacketContent; //! packet body. Char fPacketMime[kDriveNameLen]; //! identify what we're sending. - SizeT fPacketSize; // packet size - UInt32 fPacketCRC32; // sanity crc, in case if good is set to false + SizeT fPacketSize; //! packet size + UInt32 fPacketCRC32; //! sanity crc, in case if good is set to false Boolean fPacketGood; } fPacket; diff --git a/Private/KernelKit/FileManager.hpp b/Private/KernelKit/FileManager.hpp index d02c087c..87de3d9e 100644 --- a/Private/KernelKit/FileManager.hpp +++ b/Private/KernelKit/FileManager.hpp @@ -18,13 +18,18 @@ #include <FSKit/NewFS.hxx> #endif // __FSKIT_NEWFS__ +#ifdef __FSKIT_HCFS__ +#include <FSKit/HCFS.hxx> +#endif // __FSKIT_HCFS__ + #include <CompilerKit/CompilerKit.hxx> #include <HintKit/CompilerHint.hxx> #include <NewKit/ErrorID.hpp> #include <NewKit/Ref.hpp> #include <NewKit/Stream.hpp> -/// Main filesystem abstraction manager. +/// @brief Filesystem abstraction manager. +/// Works like the VFS or IFS. #define kBootFolder "/Boot" #define kBinFolder "/Applications" diff --git a/Private/KernelKit/ProcessScheduler.hpp b/Private/KernelKit/ProcessScheduler.hpp index 4f499033..1b55be4a 100644 --- a/Private/KernelKit/ProcessScheduler.hpp +++ b/Private/KernelKit/ProcessScheduler.hpp @@ -121,7 +121,7 @@ class ProcessHeader final { HCORE_COPY_DEFAULT(ProcessHeader) public: - void SetStart(UIntPtr &imageStart) noexcept; + void SetEntrypoint(UIntPtr &imageStart) noexcept; public: Char Name[kProcessLen] = {"HCore Process"}; @@ -141,22 +141,27 @@ class ProcessHeader final { SizeT FreeMemory{0}; enum { - ExecutableType, - DLLType, - DriverType, - TypeCount, + kUserKind = 3, + kLibKind = 3, + kDriverKind = 0, + kKindCount, + }; + + enum { + kRingUserKind = 3, + kRingDriverKind = 0, }; ProcessTime PTime; - PID ProcessId{-1}; - Int32 Ring{3}; - Int32 Kind{0}; + PID ProcessId{kPIDInvalid}; + Int32 Ring{kRingDriverKind}; + Int32 Kind{kUserKind}; public: //! @brief boolean operator, check status. operator bool() { return Status != ProcessStatus::kDead; } - //! @brief Crash app, exits with code ~0. + //! @brief Crash the app, exits with code ~0. void Crash(); //! @brief Exits app. diff --git a/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx b/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx index bd650031..b8df12a0 100644 --- a/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx @@ -96,7 +96,7 @@ EXTERN_C Boolean boot_write_newfs_partition(const Char* namePart, SizeT namePart swapBlock->SectorSz = kATASectorSize; swapBlock->SectorStart = kEPMStartPartition; swapBlock->Version = kNewFSVersionInteger; - swapBlock->Kind = kNewFSPartitionTypeBoot; + swapBlock->Kind = kNewFSPartitionTypePage; swapBlock->SectorEnd = MIB(4); /// 4 MIB swap partition. ataInterface->Write(buf, 1); @@ -105,6 +105,6 @@ EXTERN_C Boolean boot_write_newfs_partition(const Char* namePart, SizeT namePart } } - writer.Write(L"NewBoot.exe: Partition found, everything is OK.\r\n"); + writer.Write(L"NewBoot.exe: Partition found, everything's OK.\r\n"); return Yes; }
\ No newline at end of file diff --git a/Private/NewBoot/Source/download-edk.ps1 b/Private/NewBoot/Source/download-edk.ps1 index 744d2c1d..5a2c5f0e 100644 --- a/Private/NewBoot/Source/download-edk.ps1 +++ b/Private/NewBoot/Source/download-edk.ps1 @@ -1,4 +1,4 @@ $client = new-object System.Net.WebClient $output = "$PSScriptRoot\OVMF.fd" -$client.DownloadFile("https://retrage.github.io/edk2-nightly/bin/DEBUGX64_OVMF.fd", $output)
\ No newline at end of file +$client.DownloadFile("https://retrage.github.io/edk2-nightly/bin/DEBUGX64_OVMF.fd", $output) diff --git a/Private/NewBoot/Source/run-qemu.ps1 b/Private/NewBoot/Source/run-qemu.ps1 deleted file mode 100644 index d84c9327..00000000 --- a/Private/NewBoot/Source/run-qemu.ps1 +++ /dev/null @@ -1 +0,0 @@ -qemu-system-x86_64w.exe -net none -smp 2 -m 4G -M q35 -bios OVMF.fd -drive file=fat:rw:CDROM,index=1,format=raw -d int
\ No newline at end of file diff --git a/Private/NewKit/Function.hpp b/Private/NewKit/Function.hpp index 04a93bee..20d63f80 100644 --- a/Private/NewKit/Function.hpp +++ b/Private/NewKit/Function.hpp @@ -3,48 +3,37 @@ #include <NewKit/Defines.hpp> -namespace HCore -{ - template <typename T, typename... Args> - class Function final - { - public: - Function() = default; - - public: - explicit Function(T (*Fn)(Args... args)) - : m_Fn(Fn) - {} - - ~Function() = default; - - Function &operator=(const Function &) = default; - Function(const Function &) = default; - - template <typename... XArgs> T operator()(Args... args) - { - return m_Fn(args...); - } - - template <typename... XArgs> T Call(Args... args) - { - return m_Fn(args...); - } - - operator bool() - { - return m_Fn; - } - - bool operator!() - { - return !m_Fn; - } - - private: - T (*m_Fn)(Args... args); - - }; -} // namespace HCore - -#endif // !_INC_FUNCTION_HPP__ +namespace HCore { +template <typename T, typename... Args> +class Function final { + public: + Function() = default; + + public: + explicit Function(T (*Fn)(Args... args)) : m_Fn(Fn) {} + + ~Function() = default; + + Function &operator=(const Function &) = default; + Function(const Function &) = default; + + template <typename... XArgs> + T operator()(Args... args) { + return m_Fn(args...); + } + + template <typename... XArgs> + T Call(Args... args) { + return m_Fn(args...); + } + + operator bool() { return m_Fn; } + + bool operator!() { return !m_Fn; } + + private: + T (*m_Fn)(Args... args); +}; +} // namespace HCore + +#endif // !_INC_FUNCTION_HPP__ diff --git a/Private/NewKit/Json.hpp b/Private/NewKit/Json.hpp index 115e893f..373b0772 100644 --- a/Private/NewKit/Json.hpp +++ b/Private/NewKit/Json.hpp @@ -16,6 +16,7 @@ #include <NewKit/Utils.hpp> namespace HCore { +/// @brief Json value class class JsonType final { public: explicit JsonType() : HCore::JsonType(1, 1) {} @@ -32,13 +33,18 @@ class JsonType final { StringView fValue; public: + /// @brief returns the key of the json + /// @return StringView &AsKey() { return fKey; } + /// @brief returns the value of the json. + /// @return StringView &AsValue() { return fValue; } static JsonType kUndefined; }; +/// @brief Json stream helper class. struct JsonStreamTrait final { JsonType In(const char *full_array) { SizeT len = rt_string_len(full_array); diff --git a/Private/Source/PEFSharedObjectRT.cxx b/Private/Source/PEFSharedObjectRT.cxx index dc75e8b6..871552d7 100644 --- a/Private/Source/PEFSharedObjectRT.cxx +++ b/Private/Source/PEFSharedObjectRT.cxx @@ -18,9 +18,9 @@ Revision History: - 01/02/24: Rework shared library ABI, except a rt_library_init and rt_library_free - (amlel) - 15/02/24: Breaking changes, changed the name of the routines. (amlel) + 01/02/24: Rework shared library ABI, except a rt_library_init and + rt_library_free (amlel) 15/02/24: Breaking changes, changed the name of the + routines. (amlel) ------------------------------------------- */ @@ -76,7 +76,7 @@ EXTERN_C SharedObjectPtr rt_library_init(void) { EXTERN_C Void rt_library_free(SharedObjectPtr lib, bool *successful) { MUST_PASS(successful); - // sanity check (will also trigger a bug check) + // sanity check (will also trigger a bug check if this fails) if (lib == nullptr) { *successful = false; ProcessScheduler::Shared().Leak().GetCurrent().Leak().Crash(); @@ -92,7 +92,9 @@ EXTERN_C Void rt_library_free(SharedObjectPtr lib, bool *successful) { /***********************************************************************************/ -extern "C" void __mh_purecall(void) { - // virtual placeholder. +/// @brief Unimplemented function (crashes by default) +/// @param +EXTERN_C void __mh_purecall(void) { + ProcessScheduler::Shared().Leak().GetCurrent().Leak().Crash(); return; } diff --git a/Private/Source/ProcessScheduler.cxx b/Private/Source/ProcessScheduler.cxx index ebcf82c0..54a4afe8 100644 --- a/Private/Source/ProcessScheduler.cxx +++ b/Private/Source/ProcessScheduler.cxx @@ -162,15 +162,15 @@ SizeT ProcessScheduler::Add(Ref<ProcessHeader> &process) { UIntPtr imageStart = reinterpret_cast<UIntPtr>(process.Leak().Image); - process.Leak().SetStart(imageStart); + process.Leak().SetEntrypoint(imageStart); mTeam.AsArray().Add(process); - if (!imageStart && process.Leak().Kind == ProcessHeader::ExecutableType) { + if (!imageStart && process.Leak().Kind == ProcessHeader::kUserKind) { process.Leak().Crash(); } - if (!imageStart && process.Leak().Kind == ProcessHeader::DriverType) { + if (!imageStart && process.Leak().Kind == ProcessHeader::kDriverKind) { if (process.Leak().Ring == 3) process.Leak().Crash(); else diff --git a/Private/Source/RuntimeMain.cxx b/Private/Source/RuntimeMain.cxx new file mode 100644 index 00000000..ffecaa18 --- /dev/null +++ b/Private/Source/RuntimeMain.cxx @@ -0,0 +1,30 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#include <ArchKit/ArchKit.hpp> +#include <Builtins/Toolbox/Rsrc/Splash.rsrc> +#include <Builtins/Toolbox/Toolbox.hxx> +#include <FirmwareKit/Handover.hxx> +#include <KernelKit/FileManager.hpp> +#include <KernelKit/Framebuffer.hpp> +#include <KernelKit/KernelHeap.hpp> +#include <KernelKit/PEFCodeManager.hxx> +#include <KernelKit/ProcessScheduler.hpp> +#include <KernelKit/UserHeap.hpp> +#include <NewKit/Json.hpp> + +/// @file Main microkernel entrypoint. + +EXTERN_C void RuntimeMain(void) { + ///! Mounts a NewFS block. + HCore::NewFilesystemManager* newFS = new HCore::NewFilesystemManager(); + HCore::ke_protect_ke_heap(newFS); + + HCore::FilesystemManagerInterface::Mount(newFS); + + ///! we're done, unmount. + delete newFS; +}
\ No newline at end of file diff --git a/Public/Developer/System.Containers/.gitkeep b/Public/Developer/System.Containers/.gitkeep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/Public/Developer/System.Containers/.gitkeep diff --git a/Public/Developer/System.Containers/Headers/ODF.hxx b/Public/Developer/System.Containers/Headers/ODF.h index 266726bf..48dc1e1e 100644 --- a/Public/Developer/System.Containers/Headers/ODF.hxx +++ b/Public/Developer/System.Containers/Headers/ODF.h @@ -5,7 +5,7 @@ #ifndef __ODF__ #define __ODF__ -#include <System.Core/Headers/Defines.hxx> +#include <System.Core/Headers/Defines.h> /** * @brief Open Document Format diff --git a/Public/Developer/System.Containers/Headers/XIFF.hxx b/Public/Developer/System.Containers/Headers/XIFF.h index faf8e947..dd4880cd 100644 --- a/Public/Developer/System.Containers/Headers/XIFF.hxx +++ b/Public/Developer/System.Containers/Headers/XIFF.h @@ -12,7 +12,7 @@ ------------------------------------------------------- */ -#include <System.Core/Headers/Defines.hxx> +#include <System.Core/Headers/Defines.h> /// @brief four-character code for XIFF. #define kFourCCLength_XIFF 4 @@ -29,7 +29,7 @@ * Used by XIFF based containers. */ -struct PACKED XiffHeader final { +struct PACKED XiffHeader { ByteType f_Magic[kFourCCLength_XIFF]; // XIFF string (includes \0) DWordType f_Size; // overall size of header (XiffHeader) in bytes DWordType f_FormatType; // format type. generic @@ -42,7 +42,7 @@ typedef struct XiffHeader XiffHeader; /// @brief XIFF metadata header, either located in forks or in file directly. /// @author Amlal EL Mahrouss -struct ML_PACKED XiffMetadataHeader final { +struct PACKED XiffMetadataHeader { ByteType f_Name[kXIFFNameLength]; DWordType f_Flags; DWordType f_Type; diff --git a/Public/Developer/System.Core/Headers/Defines.hxx b/Public/Developer/System.Core/Headers/Defines.h index 64b1295e..612f0462 100644 --- a/Public/Developer/System.Core/Headers/Defines.hxx +++ b/Public/Developer/System.Core/Headers/Defines.h @@ -130,8 +130,8 @@ enum RtProcessCall { kProcessCallsCount = 7, }; -#include <System.Core/Headers/Hint.hxx> -#include <System.Core/Headers/Dialog.hxx> +#include <System.Core/Headers/Hint.h> +#include <System.Core/Headers/Dialog.h> enum { kObjectTypeProcess, diff --git a/Public/Developer/System.Core/Headers/Dialog.hxx b/Public/Developer/System.Core/Headers/Dialog.h index 0faaae67..9d4521cf 100644 --- a/Public/Developer/System.Core/Headers/Dialog.hxx +++ b/Public/Developer/System.Core/Headers/Dialog.h @@ -6,11 +6,11 @@ #pragma once -#include <System.Core/Headers/Window.hxx> +#include <System.Core/Headers/Window.h> /// @brief Shows an message box with a formatting. /// @param title the message box title /// @param format the format /// @param va_list the va args, that goes along with it. -/// @return void +/// @return void this function returns nothing. CA_EXTERN_C VoidType DlgMsgBox(CharacterTypeUTF8* title, CharacterTypeUTF8* format, ...); diff --git a/Public/Developer/System.Core/Headers/FS.hxx b/Public/Developer/System.Core/Headers/File.h index 62ed1255..bd1d8d3f 100644 --- a/Public/Developer/System.Core/Headers/FS.hxx +++ b/Public/Developer/System.Core/Headers/File.h @@ -5,3 +5,7 @@ ------------------------------------------- */ #pragma once + +#include <System.Core/Headers/Defines.h> + +/// @brief Filesystem wrapper. diff --git a/Public/Developer/System.Core/Headers/Heap.hxx b/Public/Developer/System.Core/Headers/Heap.h index c6252c04..90f15aa5 100644 --- a/Public/Developer/System.Core/Headers/Heap.hxx +++ b/Public/Developer/System.Core/Headers/Heap.h @@ -6,7 +6,7 @@ #pragma once -#include <System.Core/Headers/Defines.hxx> +#include <System.Core/Headers/Defines.h> #define kAllocationTypes 2 diff --git a/Public/Developer/System.Core/Headers/Hint.hxx b/Public/Developer/System.Core/Headers/Hint.h index 86faf455..86faf455 100644 --- a/Public/Developer/System.Core/Headers/Hint.hxx +++ b/Public/Developer/System.Core/Headers/Hint.h diff --git a/Public/Developer/System.Core/Headers/Thread.hxx b/Public/Developer/System.Core/Headers/Thread.h index 6118ea21..7d2bfe3c 100644 --- a/Public/Developer/System.Core/Headers/Thread.hxx +++ b/Public/Developer/System.Core/Headers/Thread.h @@ -8,10 +8,10 @@ // Created by Amlal on 3/18/24 // -#ifndef __THREAD_API__ -#define __THREAD_API__ +#ifndef __THREAD__ +#define __THREAD__ -#include <System.Core/Headers/Defines.hxx> +#include <System.Core/Headers/Defines.h> #define kThreadErrorExit -33 @@ -31,8 +31,13 @@ typedef VoidType(*ThreadEntrypointKind)(VoidType); CA_EXTERN_C ThreadRef TmCreateThread(const CharacterTypeUTF8* threadName, ThreadEntrypointKind threadStart); /// @brief Dispoes the thread, and exits with code kThreadErrorExit -/// @param ref -/// @return +/// @param ref the thread reference. +/// @return nothing. CA_EXTERN_C VoidType TmDisposeThread(ThreadRef ref); -#endif // __THREAD_API__ +/// @brief Waits for the thread to complete. +/// @param ref the thread reference. +/// @return nothing. +CA_EXTERN_C VoidType TmWaitForCompletion(ThreadRef ref); + +#endif // __THREAD__ diff --git a/Public/Developer/System.Core/Headers/TrueType.hxx b/Public/Developer/System.Core/Headers/TrueType.h index 185bbc78..5ad9d7a7 100644 --- a/Public/Developer/System.Core/Headers/TrueType.hxx +++ b/Public/Developer/System.Core/Headers/TrueType.h @@ -6,12 +6,12 @@ #pragma once -#include <System.Core/Headers/Window.hxx> +#include <System.Core/Headers/Window.h> /************************************************************* * * File: TrueType.hxx - * Purpose: TrueType font implementation for System Software. + * Purpose: TrueType font implementation for HCore. * Date: 3/26/24 * * Copyright Mahrouss Logic, all rights reserved. @@ -28,4 +28,5 @@ CA_EXTERN_C TTFFontRef FnCreateFont(const char* name); /// @brief Dispose an allocated font. /// @param fon /// @return -CA_EXTERN_C VoidType FnDisposeFont(TTFFontRef fon);
\ No newline at end of file +CA_EXTERN_C VoidType FnDisposeFont(TTFFontRef fon); + diff --git a/Public/Developer/System.Core/Headers/Window.hxx b/Public/Developer/System.Core/Headers/Window.h index 39d5eb47..121ac502 100644 --- a/Public/Developer/System.Core/Headers/Window.hxx +++ b/Public/Developer/System.Core/Headers/Window.h @@ -6,20 +6,20 @@ #pragma once -#include <System.Core/Headers/Defines.hxx> +#include <System.Core/Headers/Defines.h> /************************************************************* * * File: Window.hxx - * Purpose: Window Manager implementation for System Software. + * Purpose: Window Manager API for HCore. * Date: 3/26/24 * * Copyright Mahrouss Logic, all rights reserved. * *************************************************************/ -struct _GraphicsPoint; -struct _GraphicsPort; +struct _WmPoint; +struct _WindowPort; #ifdef __SINGLE_PRECISION__ typedef float PositionType; @@ -27,13 +27,15 @@ typedef float PositionType; typedef double PositionType; #endif +typedef QWordType DCRef; + /// @brief A point, can represent the size, position of a window. -typedef struct _GraphicsPoint { +typedef struct _WmPoint { PositionType X, Y; -} GraphicsPoint; +} WmPoint; -/// @brief Tracker Graphics port. -typedef struct _GraphicsPort { +/// @brief Window port type, can be used to control the window. +typedef struct _WindowPort { WordType windowPort; WordType windowKind; BooleanType windowVisible; @@ -42,13 +44,14 @@ typedef struct _GraphicsPort { BooleanType windowMoving; BooleanType windowDisableClose; BooleanType windowDisableMinimize; - GraphicsPoint windowPosition; - GraphicsPoint windowSize; + WmPoint windowPosition; + WmPoint windowSize; BooleanType windowInvalidate; DWordType windowClearColor; WordType menuPort; WordType parentPort; -} GraphicsPort; + DCRef windowDeviceContext; +} WindowPort; typedef UInt32Type ColorRef; @@ -90,11 +93,11 @@ CA_EXTERN_C ControlRef WmCreateControl(const DWordType id); /// @return CA_EXTERN_C VoidType WmReleaseControl(const ControlRef id); -/// @brief Moves a control inside a GraphicsPort. +/// @brief Moves a control inside a WindowPort. /// @param id the control ref. /// @param where where to move at. /// @return -CA_EXTERN_C Int32Type WmSetControlPosition(const ControlRef id, GraphicsPoint where); +CA_EXTERN_C Int32Type WmSetControlPosition(const ControlRef id, WmPoint where); /// @brief Enable control. /// @param id @@ -112,29 +115,29 @@ CA_EXTERN_C Int32Type WmMakeControlVisible(const ControlRef id, BooleanType visi /// @param name the window name /// @param rsrcId the window fork rsrc id. /// @return the window graphics port. -CA_EXTERN_C GraphicsPort* WmCreateWindow(const char* name, const DWordType rsrcId); +CA_EXTERN_C WindowPort* WmCreateWindow(const char* name, const DWordType rsrcId); /// @brief Creates a new menu /// @param name the menu's name /// @param rsrcId the menu fork rsrc id. /// @return the menu graphics port. -CA_EXTERN_C GraphicsPort* WmCreateMenu(const char* name, const DWordType rsrcId); +CA_EXTERN_C WindowPort* WmCreateMenu(const char* name, const DWordType rsrcId); /// @brief Releases the window. /// @param port the window port. /// @return void -CA_EXTERN_C VoidType WmReleaseWindow(GraphicsPort* port); +CA_EXTERN_C VoidType WmReleaseWindow(WindowPort* port); /// @brief Releases the menu /// @param port the menu port. /// @return void -CA_EXTERN_C VoidType WmReleaseMenu(GraphicsPort* port); +CA_EXTERN_C VoidType WmReleaseMenu(WindowPort* port); /// @brief Moves a window on the desktop. (menu arent movable, will return kErrIncompatible is menu is provided.) /// @param id the gfx port. /// @param where to move. /// @return error code. -CA_EXTERN_C Int32Type WmMoveWindow(const GraphicsPort* id, GraphicsPoint where); +CA_EXTERN_C Int32Type WmMoveWindow(const WindowPort* id, WmPoint where); enum { kWmErrIncompatible = 0x74, diff --git a/Public/Developer/System.Core/Makefile b/Public/Developer/System.Core/Makefile index 11e4760f..0f20cc72 100644 --- a/Public/Developer/System.Core/Makefile +++ b/Public/Developer/System.Core/Makefile @@ -9,7 +9,7 @@ OUTPUT=System.Core.lib .PHONY: build-core-amd64 build-core-amd64: - $(CC) -I../ -I$(HOME) -I../../../Private/ $(CCFLAGS) $(wildcard Sources/*.cxx) $(wildcard AMD64/*.s) -o $(OUTPUT) + $(CC) -I../ -I$(HOME) -I../../../Private/ $(CCFLAGS) $(wildcard Sources/*.c) $(wildcard Sources/*.cxx) $(wildcard AMD64/*.s) -o $(OUTPUT) .PHONY: all all: build-core diff --git a/Public/Developer/System.Core/Sources/CRT0.cxx b/Public/Developer/System.Core/Sources/CRT0.c index 244e62d5..03aa62b8 100644 --- a/Public/Developer/System.Core/Sources/CRT0.cxx +++ b/Public/Developer/System.Core/Sources/CRT0.c @@ -2,7 +2,7 @@ (C) Mahrouss Logic ===========================================*/ -#include <System.Core/Headers/Heap.hxx> +#include <System.Core/Headers/Heap.h> /// @brief Inits the library. /// @return if it was succesful or not. diff --git a/Public/Developer/System.Core/Sources/Heap.cxx b/Public/Developer/System.Core/Sources/Heap.c index 991987ca..390ae072 100644 --- a/Public/Developer/System.Core/Sources/Heap.cxx +++ b/Public/Developer/System.Core/Sources/Heap.c @@ -4,7 +4,7 @@ ------------------------------------------- */ -#include <System.Core/Headers/Heap.hxx> +#include <System.Core/Headers/Heap.h> /// @brief Allocate from the user's heap. /// @param refObj Process object. diff --git a/Public/Developer/System.Core/Sources/New+Delete.cxx b/Public/Developer/System.Core/Sources/New+Delete.cxx index 3901aed1..3e2942c5 100644 --- a/Public/Developer/System.Core/Sources/New+Delete.cxx +++ b/Public/Developer/System.Core/Sources/New+Delete.cxx @@ -4,7 +4,7 @@ ------------------------------------------- */ -#include <System.Core/Headers/Heap.hxx> +#include <System.Core/Headers/Heap.h> typedef SizeType size_t; @@ -1,13 +1,10 @@ -# NewKernel+NewBoot (codename: HCore) + - - -## MicroKernel, bootloader and servers resides here. +# NewKernel and NewBoot You need: - MinGW for the kernel and bootloader. -- HintKit for Compilation check. - Netwide Assembler to output COFF object code. Start by cloning the repo: |
