diff options
24 files changed, 132 insertions, 123 deletions
diff --git a/BUG_LIST.TXT b/BUG_LIST.TXT index 9f26b768..6075a6ac 100644 --- a/BUG_LIST.TXT +++ b/BUG_LIST.TXT @@ -1 +1 @@ -- PS/2 Mouse doesn't raise interrupt on qemu q35, pc machines.
\ No newline at end of file +- PS/2 Mouse doesn't raise interrupt on qemu q35, pc machines. [WontFix]
\ No newline at end of file diff --git a/Private/CRT/__cxxkit_defines.hxx b/Private/CRT/__cxxkit_defines.hxx index 1558fbe9..54b50716 100644 --- a/Private/CRT/__cxxkit_defines.hxx +++ b/Private/CRT/__cxxkit_defines.hxx @@ -28,14 +28,12 @@ typedef char *caddr_t; #ifdef __GNUC__ #include <CRT/__cxxkit_alloca.hxx> #define __cxxkit_alloca(sz) __cxxkit_alloca_gcc(sz) -#elif defined(__HISYS__) +#elif defined(__MPCC__) -#define __alloca(SZ) __cxxkit_alloca(SZ) - -#define __deref(ptr) (*(PTR)) +#define __alloca(sz) __cxxkit_alloca(sz) +#endif -#define __libexport __lib(export) -#define __libimport __lib(import) +#define __deref(ptr) (*(ptr)) #ifdef __cplusplus #define __init_decl() \ @@ -48,7 +46,6 @@ typedef char *caddr_t; #define __init_decl() #define __fini_decl() #endif -#endif #if __has_builtin(__builtin_alloca) #define alloca(sz) __builtin_alloca(sz) diff --git a/Private/FirmwareKit/EFI/API.hxx b/Private/FirmwareKit/EFI/API.hxx index b2d6c940..e025e7e0 100644 --- a/Private/FirmwareKit/EFI/API.hxx +++ b/Private/FirmwareKit/EFI/API.hxx @@ -14,14 +14,15 @@ inline EfiSystemTable *ST = nullptr; inline EfiBootServices *BS = nullptr; -extern "C" void rt_cli(); +EXTERN_C void rt_cli(); +EXTERN_C void rt_hlt(); namespace EFI { -/** -@brief Stop Execution of program. -*/ +/// @brief Halt and clear interrupts. +/// @return inline Void Stop() noexcept { while (1) { + rt_hlt(); rt_cli(); } } diff --git a/Private/KernelKit/ProcessScheduler.hpp b/Private/KernelKit/ProcessScheduler.hpp index fa59be4b..ba453fbe 100644 --- a/Private/KernelKit/ProcessScheduler.hpp +++ b/Private/KernelKit/ProcessScheduler.hpp @@ -156,10 +156,10 @@ class Process final { //! @brief boolean operator, check status. operator bool() { return Status != ProcessStatus::kDead; } - //! @brief Crash program, exits with code ~0. + //! @brief Crash app, exits with code ~0. void Crash(); - //! @brief Exits program. + //! @brief Exits app. void Exit(Int32 exitCode = 0); //! @brief TLS Allocate diff --git a/Private/MoveAll.sh b/Private/MoveAll.sh index 0544cd8b..7170a262 100755 --- a/Private/MoveAll.sh +++ b/Private/MoveAll.sh @@ -4,4 +4,4 @@ for file in *.o; do mv -- "$file" "${file%.o}.obj" done -mv *.obj HALKit/AMD64/*.obj Obj/
\ No newline at end of file +mv *.obj HALKit/AMD64/*.obj Objects/
\ No newline at end of file diff --git a/Private/NewBoot/Source/makefile b/Private/NewBoot/Source/makefile index fbedfd52..d5490556 100644 --- a/Private/NewBoot/Source/makefile +++ b/Private/NewBoot/Source/makefile @@ -17,7 +17,7 @@ EMU=qemu-system-x86_64w.exe endif LD_FLAGS=-e efi_main --subsystem=10 -OBJ=$(wildcard *.o) $(wildcard ../../Obj/*.obj) $(wildcard HEL/AMD64/*.obj) +OBJ=$(wildcard *.o) $(wildcard ../../Objects/*.obj) $(wildcard HEL/AMD64/*.obj) REM=rm REM_FLAG=-f diff --git a/Private/ObjectKit/ObjectKit.hxx b/Private/ObjectKit/ObjectKit.hxx index 329b2c78..904e23cb 100644 --- a/Private/ObjectKit/ObjectKit.hxx +++ b/Private/ObjectKit/ObjectKit.hxx @@ -34,4 +34,4 @@ typedef struct Object final { HCore::Void(*Query)(struct Object* Self, HCore::VoidPtr* Dst, HCore::SizeT SzDst, HCore::XRN::GUIDSequence GuidOf); } Object, *ObjectPtr; -#define object_cast reinterpret_cast +#define object_cast reinterpret_cast<ObjectPtr> diff --git a/Private/Obj/.hgkeep b/Private/Objects/.hgkeep index e69de29b..e69de29b 100644 --- a/Private/Obj/.hgkeep +++ b/Private/Objects/.hgkeep diff --git a/Private/Source/PageManager.cxx b/Private/Source/PageManager.cxx index 572effae..843aa66c 100644 --- a/Private/Source/PageManager.cxx +++ b/Private/Source/PageManager.cxx @@ -11,8 +11,8 @@ #include <HALKit/AMD64/HalPageAlloc.hpp> #endif // ifdef __x86_64__ -//! null deref will throw (Page Zero detected, aborting program!) -#define kProtectedRegionEnd 512 +//! null deref will throw (Page Zero detected, aborting app!) +#define kProtectedRegionEnd (512) namespace HCore { PTEWrapper::PTEWrapper(Boolean Rw, Boolean User, Boolean ExecDisable, diff --git a/Private/makefile b/Private/makefile index e9528a48..56561324 100644 --- a/Private/makefile +++ b/Private/makefile @@ -11,7 +11,7 @@ ASM = nasm # Add assembler, linker, and object files variables. ASMFLAGS = -f win64 LDFLAGS = -e Main --subsystem=17 -LDOBJ = $(wildcard Obj/*.obj) +LDOBJ = $(wildcard Objects/*.obj) # This file is the kernel, responsible of task management, memory, drivers and more. KERNEL = HCoreKrnl.exe @@ -19,14 +19,14 @@ KERNEL = HCoreKrnl.exe # The kernel entrypoint SCRIPT = --script=Linker/Platforms/PC.lds -.PHONY: invalid-recipe -invalid-recipe: +.PHONY: error +error: @echo "Use a specific target." MOVEALL=./MoveAll.sh -.PHONY: h-core-amd64 -h-core-amd64: clean +.PHONY: h-core-amd64-pc +h-core-amd64-pc: clean $(CC) $(CCFLAGS) $(DEBUG) Source/*.cxx HALKit/AMD64/PCI/*.cxx Source/Network/*.cxx\ Source/Storage/*.cxx HALKit/AMD64/*.cxx HALKit/AMD64/*.cpp HALKit/AMD64/*.s $(ASM) $(ASMFLAGS) HALKit/AMD64/HalInterruptRouting.asm @@ -37,12 +37,12 @@ h-core-amd64: clean OBJCOPY=x86_64-w64-mingw32-objcopy -.PHONY: link-amd64 -link-amd64: +.PHONY: link-amd64-pc +link-amd64-pc: $(LD) $(LDFLAGS) $(LDOBJ) -o $(KERNEL) .PHONY: all -all: h-core-amd64 link-amd64 +all: h-core-amd64-pc link-amd64-pc @echo "Fully built." diff --git a/Public/Kits/System.Core/Defs.hxx b/Public/Kits/System.Core/Defs.hxx index bcb3585c..9a17d571 100644 --- a/Public/Kits/System.Core/Defs.hxx +++ b/Public/Kits/System.Core/Defs.hxx @@ -108,4 +108,21 @@ enum HcProcessCall { kProcessCallsCount = 7, }; -#include <System.Core/HintBase.hxx> +#include <System.Core/Hint.hxx> + +class Exception { + public: + explicit Exception() = default; + virtual ~Exception() = default; + + public: + HCORE_COPY_DEFAULT(Exception); + + public: + const char *Name(); + const char *Reason(); + + private: + const char *mReason{ + "System.Core: System Exception: Catastrophic failure!"}; +}; diff --git a/Public/Kits/System.Core/File.hxx b/Public/Kits/System.Core/File.hxx index 2f799330..97377800 100644 --- a/Public/Kits/System.Core/File.hxx +++ b/Public/Kits/System.Core/File.hxx @@ -25,10 +25,10 @@ class File final { public: voidPtr Read(SizeT off, SizeT sz); - void Write(voidPtr buf, SizeT off, SizeT sz); + void Write(VoidPtr buf, SizeT off, SizeT sz); void Seek(SizeT off); voidPtr Read(SizeT sz); - void Write(voidPtr buf, SizeT sz); + void Write(VoidPtr buf, SizeT sz); void Rewind(); public: diff --git a/Public/Kits/System.Core/HCoreBase.hxx b/Public/Kits/System.Core/HCoreBase.hxx deleted file mode 100644 index 774f9883..00000000 --- a/Public/Kits/System.Core/HCoreBase.hxx +++ /dev/null @@ -1,7 +0,0 @@ -/** =========================================== - (C) Mahrouss Logic - ===========================================*/ - -#pragma once - -#include <System.Core/Defs.hxx> diff --git a/Public/Kits/System.Core/HCoreHeap.hxx b/Public/Kits/System.Core/HCoreHeap.hxx deleted file mode 100644 index 41143495..00000000 --- a/Public/Kits/System.Core/HCoreHeap.hxx +++ /dev/null @@ -1,20 +0,0 @@ -/** =========================================== - (C) Mahrouss Logic - ===========================================*/ - -#pragma once - -#include <System.Core/HCoreBase.hxx> - -CA_EXTERN_C ObjectPtr HcGetProcessObject(void); -CA_EXTERN_C PVOID HcAllocateProcessHeap(ObjectPtr refObj, QWORD sz, DWORD flags); -CA_EXTERN_C VOID HcFreeProcessHeap(ObjectPtr refObj, PVOID ptr); -CA_EXTERN_C QWORD HcProcessHeapSize(ObjectPtr refObj, PVOID ptr); -CA_EXTERN_C QWORD HcProcessHeapExists(ObjectPtr refObj, PVOID ptr); - -enum HcAllocationKind { - kStandardAllocation = 0xC, - kArrayAllocation = 0xD, -}; - -#define kAllocationTypes 2 diff --git a/Public/Kits/System.Core/Heap+Impl.cxx b/Public/Kits/System.Core/Heap+Impl.cxx deleted file mode 100644 index e3dcb11c..00000000 --- a/Public/Kits/System.Core/Heap+Impl.cxx +++ /dev/null @@ -1,37 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#include <System.Core/Heap.hxx> -#include <System.Core/System.Core.hxx> - -using namespace System; - -Heap* Heap::Shared() noexcept { - static Heap* heap = nullptr; - - if (!heap) { - heap = new Heap(); - } - - return heap; -} - -void Heap::Delete(HeapPtr me) noexcept { - CA_MUST_PASS(me); - HcFreeProcessHeap(kInstanceObject, me); -} - -SizeT Heap::Size(HeapPtr me) noexcept { - CA_MUST_PASS(me); - return HcProcessHeapSize(kInstanceObject, me); -} - -HeapPtr Heap::New(const SizeT &sz, const Int32 flags) { - SizeT _sz = sz; - if (!_sz) ++_sz; - - return HcAllocateProcessHeap(kInstanceObject, _sz, flags); -}
\ No newline at end of file diff --git a/Public/Kits/System.Core/Heap.hxx b/Public/Kits/System.Core/Heap.hxx index dfcb4587..31e44c7e 100644 --- a/Public/Kits/System.Core/Heap.hxx +++ b/Public/Kits/System.Core/Heap.hxx @@ -6,8 +6,22 @@ #pragma once -#include <System.Core/Defs.hxx> #include <CompilerKit/CompilerKit.hxx> +#include <System.Core/Defs.hxx> + +#define kAllocationTypes 2 + +CA_EXTERN_C PVOID HcAllocateProcessHeap(ObjectPtr refObj, QWORD sz, + DWORD flags); +CA_EXTERN_C BOOL HcProcessHeapExists(ObjectPtr refObj, PVOID ptr); +CA_EXTERN_C QWORD HcProcessHeapSize(ObjectPtr refObj, PVOID ptr); +CA_EXTERN_C VOID HcFreeProcessHeap(ObjectPtr refObj, PVOID ptr); +CA_EXTERN_C ObjectPtr HcGetProcessObject(void); + +enum HcAllocationKind { + kStandardAllocation = 0xC, + kArrayAllocation = 0xD, +}; namespace System { using namespace HCore; @@ -29,7 +43,7 @@ class Heap final { explicit Heap() = default; public: - ~Heap() = default; + ~Heap(); public: HCORE_COPY_DEFAULT(Heap); @@ -56,9 +70,10 @@ class MemoryException final { const char *Reason(); private: - const char *mReason{"System.Core: Process Heap Exception: Catastrophic failure!"}; + const char *mReason{ + "System.Core: Process Heap Exception: Catastrophic failure!"}; private: friend Heap; }; -} // namespace System
\ No newline at end of file +} // namespace System
\ No newline at end of file diff --git a/Public/Kits/System.Core/HCoreHeap+Impl.cxx b/Public/Kits/System.Core/HeapCoreImpl.cxx index 0e1b1732..2980a3de 100644 --- a/Public/Kits/System.Core/HCoreHeap+Impl.cxx +++ b/Public/Kits/System.Core/HeapCoreImpl.cxx @@ -2,43 +2,46 @@ (C) Mahrouss Logic ===========================================*/ -#include <System.Core/HCoreHeap.hxx> +#include <System.Core/Heap.hxx> /// @brief Allocate from the user's heap. -/// @param refObj -/// @param sz -/// @param flags +/// @param refObj Process object. +/// @param sz size of object. +/// @param flags flags. /// @return CA_EXTERN_C PVOID HcAllocateProcessHeap(ObjectPtr refObj, QWORD sz, DWORD flags) { + CA_MUST_PASS(sz); + CA_MUST_PASS(flags); + return (PVOID)refObj->Invoke(refObj, kProcessCallAllocPtr, sz, flags); } /// @brief Free pointer from the user's heap. -/// @param refObj -/// @param ptr -/// @return +/// @param refObj Process object. +/// @param ptr the pointer to free. CA_EXTERN_C VOID HcFreeProcessHeap(ObjectPtr refObj, PVOID ptr) { + CA_MUST_PASS(ptr); CA_UNREFERENCED_PARAMETER(refObj->Invoke(refObj, kProcessCallFreePtr, ptr)); } /// @brief Get pointer size. -/// @param refObj -/// @param ptr -/// @return +/// @param refObj Process object. +/// @param ptr the pointer to find. +/// @return the size. CA_EXTERN_C QWORD HcProcessHeapSize(ObjectPtr refObj, PVOID ptr) { + CA_MUST_PASS(ptr); return refObj->Invoke(refObj, kProcessCallSizePtr, ptr); } /// @brief Check if the pointer exists. /// @param refObj Process object. -/// @param ptr -/// @return -CA_EXTERN_C QWORD HcProcessHeapExists(ObjectPtr refObj, PVOID ptr) +/// @param ptr the pointer to check. +/// @return if it exists +CA_EXTERN_C BOOL HcProcessHeapExists(ObjectPtr refObj, PVOID ptr) { + CA_MUST_PASS(ptr); return refObj->Invoke(refObj, kProcessCallCheckPtr, ptr); } - -// EOF. diff --git a/Public/Kits/System.Core/HeapImpl.cxx b/Public/Kits/System.Core/HeapImpl.cxx new file mode 100644 index 00000000..f41c868f --- /dev/null +++ b/Public/Kits/System.Core/HeapImpl.cxx @@ -0,0 +1,41 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#include <System.Core/Heap.hxx> +#include <System.Core/System.Core.hxx> + +using namespace System; + +/// @brief Shared instance of the heap. +/// @return +Heap* Heap::Shared() noexcept { + static Heap* heap = nullptr; + + if (!heap) { + heap = new Heap(); + } + + return heap; +} + +Heap::~Heap() { delete this; } + +void Heap::Delete(HeapPtr me) noexcept { + CA_MUST_PASS(me); + HcFreeProcessHeap(kInstanceObject, me); +} + +SizeT Heap::Size(HeapPtr me) noexcept { + CA_MUST_PASS(me); + return HcProcessHeapSize(kInstanceObject, me); +} + +HeapPtr Heap::New(const SizeT& sz, const Int32 flags) { + SizeT _sz = sz; + if (!_sz) ++_sz; + + return HcAllocateProcessHeap(kInstanceObject, _sz, flags); +}
\ No newline at end of file diff --git a/Public/Kits/System.Core/HintBase.hxx b/Public/Kits/System.Core/Hint.hxx index 86faf455..86faf455 100644 --- a/Public/Kits/System.Core/HintBase.hxx +++ b/Public/Kits/System.Core/Hint.hxx diff --git a/Public/Kits/System.Core/RuntimeInit.cxx b/Public/Kits/System.Core/InitRuntime.cxx index b6022bef..01eb2c1f 100644 --- a/Public/Kits/System.Core/RuntimeInit.cxx +++ b/Public/Kits/System.Core/InitRuntime.cxx @@ -2,7 +2,7 @@ (C) Mahrouss Logic ===========================================*/ -#include <System.Core/HCoreHeap.hxx> +#include <System.Core/Heap.hxx> /// @brief Inits the C runtime /// @return if it was succesful or not. diff --git a/Public/Kits/System.Core/New+Delete.cxx b/Public/Kits/System.Core/New+Delete.cxx index cac883f4..507cb7a3 100644 --- a/Public/Kits/System.Core/New+Delete.cxx +++ b/Public/Kits/System.Core/New+Delete.cxx @@ -4,7 +4,7 @@ ------------------------------------------- */ -#include <System.Core/HCoreHeap.hxx> +#include <System.Core/Heap.hxx> void* operator new[](size_t sz) { diff --git a/Public/Kits/System.Core/System.Core.hxx b/Public/Kits/System.Core/System.Core.hxx index b368b997..07b7199c 100644 --- a/Public/Kits/System.Core/System.Core.hxx +++ b/Public/Kits/System.Core/System.Core.hxx @@ -4,12 +4,11 @@ #pragma once -/// Core API -#include <System.Core/HCoreBase.hxx> - /// Process Heap API -#include <System.Core/HCoreHeap.hxx> +#include <System.Core/Heap.hxx> /// File API & Device API. +#include <System.Core/File.hxx> -/// Process & Threading API
\ No newline at end of file +/// Process & Threading API +#include <System.Core/Threading.hxx>
\ No newline at end of file diff --git a/Public/Kits/System.Graphics/Core.hxx b/Public/Kits/System.Graphics/Core.hxx index 43751891..a453e095 100644 --- a/Public/Kits/System.Graphics/Core.hxx +++ b/Public/Kits/System.Graphics/Core.hxx @@ -171,7 +171,7 @@ class GException final { const char* Reason() { return mReason; } private: - const char* mReason{"System.Graphics: User Interface error. Check HError."}; + const char* mReason{"System.Graphics: Graphics exception. Check HError."}; }; template <typename GFrameType, typename GFrameBase> @@ -1,6 +1,6 @@ -# h-core (codename: SuperTrouper) +# HCore (codename: SuperTrouper) -## uKernel and components source code. +## MicroKernel and Executives source code. You need: |
