diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-31 09:42:54 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-31 09:42:54 +0100 |
| commit | fc55f0d69d24fb4908cbd811681f2c3fac53614d (patch) | |
| tree | ba09a2cdbb225df7ba1a9ec5a12bcbb90b673ead /Public/Kits/SystemKit | |
| parent | 7bed9287589293bd9d712d152539591dee0b28c0 (diff) | |
kernel: add GKit, improve AMD64 HAL.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Public/Kits/SystemKit')
| -rw-r--r-- | Public/Kits/SystemKit/.gitkeep | 0 | ||||
| -rw-r--r-- | Public/Kits/SystemKit/CoreAPI.hxx | 17 | ||||
| -rw-r--r-- | Public/Kits/SystemKit/FileAPI.hxx | 40 | ||||
| -rw-r--r-- | Public/Kits/SystemKit/HeapAPI.hxx | 65 | ||||
| -rw-r--r-- | Public/Kits/SystemKit/SystemCall.hxx | 16 | ||||
| -rw-r--r-- | Public/Kits/SystemKit/SystemKit.hxx | 12 | ||||
| -rw-r--r-- | Public/Kits/SystemKit/ThreadAPI.hxx | 39 |
7 files changed, 189 insertions, 0 deletions
diff --git a/Public/Kits/SystemKit/.gitkeep b/Public/Kits/SystemKit/.gitkeep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/Public/Kits/SystemKit/.gitkeep diff --git a/Public/Kits/SystemKit/CoreAPI.hxx b/Public/Kits/SystemKit/CoreAPI.hxx new file mode 100644 index 00000000..f3e67e96 --- /dev/null +++ b/Public/Kits/SystemKit/CoreAPI.hxx @@ -0,0 +1,17 @@ +/* + * ======================================================== + * + * h-core + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#pragma once + +#ifdef MUST_PASS +#undef MUST_PASS +#endif + +// unused by user side, it's a kernel thing. +#define MUST_PASS(e) ((void)e) diff --git a/Public/Kits/SystemKit/FileAPI.hxx b/Public/Kits/SystemKit/FileAPI.hxx new file mode 100644 index 00000000..c55d26ff --- /dev/null +++ b/Public/Kits/SystemKit/FileAPI.hxx @@ -0,0 +1,40 @@ +/* + * ======================================================== + * + * h-core + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#ifndef _SYSTEM_KIT_HCORE_FILE_HPP +#define _SYSTEM_KIT_HCORE_FILE_HPP + +#include <CompilerKit/CompilerKit.hpp> +#include <NewKit/Defines.hpp> + +using namespace HCore; + +class HFile final { + public: + explicit HFile(const char *path); + ~HFile(); + + public: + HCORE_COPY_DEFAULT(HFile); + + public: + void *Read(SizeT off, SizeT sz); + void Write(void *buf, SizeT off, SizeT sz); + void Seek(SizeT off); + void *Read(SizeT sz); + void Write(void *buf, SizeT sz); + void Rewind(); + + public: + void SetMIME(const char *mime); +}; + +typedef HFile *HFilePtr; + +#endif // ifndef _SYSTEM_KIT_HCORE_FILE_HPP diff --git a/Public/Kits/SystemKit/HeapAPI.hxx b/Public/Kits/SystemKit/HeapAPI.hxx new file mode 100644 index 00000000..11d4c265 --- /dev/null +++ b/Public/Kits/SystemKit/HeapAPI.hxx @@ -0,0 +1,65 @@ +/* + * ======================================================== + * + * h-core + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#pragma once + +#include <CompilerKit/CompilerKit.hpp> +#include <NewKit/Defines.hpp> + +using namespace HCore; + +class HMemoryException; + +typedef VoidPtr HHeapPtr; + +enum { + kHeapExpandable = 2, + kHeapNoExecute = 4, + kHeapShared = 6, + kHeapReadOnly = 8, + kHeapNoFlags = 0 +}; + +class HHeap final { + private: + explicit HHeap(); + + public: + ~HHeap(); + + public: + HCORE_COPY_DEFAULT(HHeap); + + public: + static HHeap *Shared() noexcept; + + public: + void Delete(HHeapPtr me) noexcept; + SizeT Tell(HHeapPtr me) noexcept; + HHeapPtr New(const SizeT &sz, const Int32 flags = kHeapNoFlags); +}; + +class HMemoryException final { + public: + HMemoryException() = default; + ~HMemoryException() = default; + + public: + HCORE_COPY_DEFAULT(HMemoryException); + + public: + const char *Name(); + const char *Reason(); + + private: + const char *mReason{"HeapAPI: Memory Exception!"}; + + private: + friend HHeap; +}; diff --git a/Public/Kits/SystemKit/SystemCall.hxx b/Public/Kits/SystemKit/SystemCall.hxx new file mode 100644 index 00000000..77614099 --- /dev/null +++ b/Public/Kits/SystemKit/SystemCall.hxx @@ -0,0 +1,16 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + + File: SystemCall.hxx + Purpose: + + Revision History: + + 31/01/24: Added file (amlel) + +------------------------------------------- */ + +#pragma once + +/// @brief System Call Interface diff --git a/Public/Kits/SystemKit/SystemKit.hxx b/Public/Kits/SystemKit/SystemKit.hxx new file mode 100644 index 00000000..eca53757 --- /dev/null +++ b/Public/Kits/SystemKit/SystemKit.hxx @@ -0,0 +1,12 @@ +/*** =========================================== + (C) Mahrouss Logic + ===========================================*/ + +#pragma once + +#include <SystemKit/CoreAPI.hxx> +#include <SystemKit/FileAPI.hxx> +#include <SystemKit/HeapAPI.hxx> +#include <SystemKit/ThreadAPI.hxx> + +using namespace HCore; diff --git a/Public/Kits/SystemKit/ThreadAPI.hxx b/Public/Kits/SystemKit/ThreadAPI.hxx new file mode 100644 index 00000000..a9490033 --- /dev/null +++ b/Public/Kits/SystemKit/ThreadAPI.hxx @@ -0,0 +1,39 @@ +/* + * ======================================================== + * + * h-core + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +// +// Created by Amlal on 1/27/24. +// + +#ifndef __THREAD_API__ +#define __THREAD_API__ + +#include <NewKit/Defines.hpp> + +namespace HCore { +/// @brief Thread Information Block for Local Storage. +/// Located in GS on AMD64, Virtual Address 0x10000 (64x0, 32x0, ARM64) +struct ThreadInformationBlock final { + const Char NAME[255]; // Module Name + const UIntPtr START_ADDRESS; // Start Address + const UIntPtr START_ALLOC; // Allocation Heap + const UIntPtr START_STACK; // Stack Pointer. + const Int32 ARCH; // Architecture and/or platform. +}; + +enum { + kPC_IA64, + kPC_AMD64 = kPC_IA64, + kPC_ARM, + kMACS_64x0, + kMACS_32x0, +}; +} // namespace HCore + +#endif // __THREAD_API__ |
