From af8a516fc22865abd80d6e26f1541fa3d6bebfdc Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 9 May 2024 00:42:44 +0200 Subject: MHR-23: :boom:, refactors. - Move NewBoot to /Boot, thus making Kernel directory only containing the kernel. Signed-off-by: Amlal El Mahrouss --- SDK/Developer/.gitkeep | 0 SDK/Developer/CoreCxxRuntime/.gitkeep | 0 .../CoreCxxRuntime/Sources/New+Delete.cxx | 33 --- SDK/Developer/CorePEFRuntime/.gitkeep | 0 SDK/Developer/CorePEFRuntime/Sources/PEFStart.c | 23 --- SDK/Developer/CoreSystem/.gitkeep | 0 SDK/Developer/CoreSystem/AMD64/CoreAssembly.s | 28 --- SDK/Developer/CoreSystem/ARM64/.gitkeep | 0 SDK/Developer/CoreSystem/Headers/Alert.h | 21 -- SDK/Developer/CoreSystem/Headers/Defines.h | 230 --------------------- SDK/Developer/CoreSystem/Headers/File.h | 52 ----- SDK/Developer/CoreSystem/Headers/Heap.h | 39 ---- SDK/Developer/CoreSystem/Headers/Hint.h | 20 -- SDK/Developer/CoreSystem/Headers/Intl.h | 24 --- SDK/Developer/CoreSystem/Headers/Math.h | 27 --- SDK/Developer/CoreSystem/Headers/Rsrc.h | 9 - SDK/Developer/CoreSystem/Headers/Thread.h | 47 ----- SDK/Developer/CoreSystem/POWER/CoreAssembly.s | 23 --- SDK/Developer/CoreSystem/RISCV/.gitkeep | 0 SDK/Developer/CoreSystem/ReadMe.md | 14 -- SDK/Developer/CoreSystem/Sources/App.c | 31 --- SDK/Developer/CoreSystem/Sources/File.c | 43 ---- SDK/Developer/CoreSystem/Sources/Heap.c | 55 ----- SDK/Developer/CoreSystem/Sources/Math.c | 14 -- SDK/Developer/CoreSystem/amd64.mk | 22 -- SDK/Developer/CoreSystem/compile_flags.txt | 4 - SDK/Library/.gitkeep | 0 SDK/Library/CoreCxxRuntime/.gitkeep | 0 SDK/Library/CoreCxxRuntime/Sources/New+Delete.cxx | 33 +++ SDK/Library/CorePEFRuntime/.gitkeep | 0 SDK/Library/CorePEFRuntime/Sources/PEFStart.c | 23 +++ SDK/Library/CoreSystem/.gitkeep | 0 SDK/Library/CoreSystem/AMD64/CoreAssembly.s | 28 +++ SDK/Library/CoreSystem/ARM64/.gitkeep | 0 SDK/Library/CoreSystem/Headers/Alert.h | 21 ++ SDK/Library/CoreSystem/Headers/Defines.h | 230 +++++++++++++++++++++ SDK/Library/CoreSystem/Headers/File.h | 52 +++++ SDK/Library/CoreSystem/Headers/Heap.h | 39 ++++ SDK/Library/CoreSystem/Headers/Hint.h | 20 ++ SDK/Library/CoreSystem/Headers/Intl.h | 24 +++ SDK/Library/CoreSystem/Headers/Math.h | 27 +++ SDK/Library/CoreSystem/Headers/Rsrc.h | 9 + SDK/Library/CoreSystem/Headers/Thread.h | 47 +++++ SDK/Library/CoreSystem/POWER/CoreAssembly.s | 23 +++ SDK/Library/CoreSystem/RISCV/.gitkeep | 0 SDK/Library/CoreSystem/ReadMe.md | 13 ++ SDK/Library/CoreSystem/Sources/App.c | 31 +++ SDK/Library/CoreSystem/Sources/File.c | 43 ++++ SDK/Library/CoreSystem/Sources/Heap.c | 55 +++++ SDK/Library/CoreSystem/Sources/Math.c | 14 ++ SDK/Library/CoreSystem/amd64.mk | 22 ++ SDK/Library/CoreSystem/compile_flags.txt | 4 + SDK/Tools/.gitkeep | 0 53 files changed, 758 insertions(+), 759 deletions(-) delete mode 100644 SDK/Developer/.gitkeep delete mode 100644 SDK/Developer/CoreCxxRuntime/.gitkeep delete mode 100644 SDK/Developer/CoreCxxRuntime/Sources/New+Delete.cxx delete mode 100644 SDK/Developer/CorePEFRuntime/.gitkeep delete mode 100644 SDK/Developer/CorePEFRuntime/Sources/PEFStart.c delete mode 100644 SDK/Developer/CoreSystem/.gitkeep delete mode 100644 SDK/Developer/CoreSystem/AMD64/CoreAssembly.s delete mode 100644 SDK/Developer/CoreSystem/ARM64/.gitkeep delete mode 100644 SDK/Developer/CoreSystem/Headers/Alert.h delete mode 100644 SDK/Developer/CoreSystem/Headers/Defines.h delete mode 100644 SDK/Developer/CoreSystem/Headers/File.h delete mode 100644 SDK/Developer/CoreSystem/Headers/Heap.h delete mode 100644 SDK/Developer/CoreSystem/Headers/Hint.h delete mode 100644 SDK/Developer/CoreSystem/Headers/Intl.h delete mode 100644 SDK/Developer/CoreSystem/Headers/Math.h delete mode 100644 SDK/Developer/CoreSystem/Headers/Rsrc.h delete mode 100644 SDK/Developer/CoreSystem/Headers/Thread.h delete mode 100644 SDK/Developer/CoreSystem/POWER/CoreAssembly.s delete mode 100644 SDK/Developer/CoreSystem/RISCV/.gitkeep delete mode 100644 SDK/Developer/CoreSystem/ReadMe.md delete mode 100644 SDK/Developer/CoreSystem/Sources/App.c delete mode 100644 SDK/Developer/CoreSystem/Sources/File.c delete mode 100644 SDK/Developer/CoreSystem/Sources/Heap.c delete mode 100644 SDK/Developer/CoreSystem/Sources/Math.c delete mode 100644 SDK/Developer/CoreSystem/amd64.mk delete mode 100644 SDK/Developer/CoreSystem/compile_flags.txt create mode 100644 SDK/Library/.gitkeep create mode 100644 SDK/Library/CoreCxxRuntime/.gitkeep create mode 100644 SDK/Library/CoreCxxRuntime/Sources/New+Delete.cxx create mode 100644 SDK/Library/CorePEFRuntime/.gitkeep create mode 100644 SDK/Library/CorePEFRuntime/Sources/PEFStart.c create mode 100644 SDK/Library/CoreSystem/.gitkeep create mode 100644 SDK/Library/CoreSystem/AMD64/CoreAssembly.s create mode 100644 SDK/Library/CoreSystem/ARM64/.gitkeep create mode 100644 SDK/Library/CoreSystem/Headers/Alert.h create mode 100644 SDK/Library/CoreSystem/Headers/Defines.h create mode 100644 SDK/Library/CoreSystem/Headers/File.h create mode 100644 SDK/Library/CoreSystem/Headers/Heap.h create mode 100644 SDK/Library/CoreSystem/Headers/Hint.h create mode 100644 SDK/Library/CoreSystem/Headers/Intl.h create mode 100644 SDK/Library/CoreSystem/Headers/Math.h create mode 100644 SDK/Library/CoreSystem/Headers/Rsrc.h create mode 100644 SDK/Library/CoreSystem/Headers/Thread.h create mode 100644 SDK/Library/CoreSystem/POWER/CoreAssembly.s create mode 100644 SDK/Library/CoreSystem/RISCV/.gitkeep create mode 100644 SDK/Library/CoreSystem/ReadMe.md create mode 100644 SDK/Library/CoreSystem/Sources/App.c create mode 100644 SDK/Library/CoreSystem/Sources/File.c create mode 100644 SDK/Library/CoreSystem/Sources/Heap.c create mode 100644 SDK/Library/CoreSystem/Sources/Math.c create mode 100644 SDK/Library/CoreSystem/amd64.mk create mode 100644 SDK/Library/CoreSystem/compile_flags.txt create mode 100644 SDK/Tools/.gitkeep (limited to 'SDK') diff --git a/SDK/Developer/.gitkeep b/SDK/Developer/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/SDK/Developer/CoreCxxRuntime/.gitkeep b/SDK/Developer/CoreCxxRuntime/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/SDK/Developer/CoreCxxRuntime/Sources/New+Delete.cxx b/SDK/Developer/CoreCxxRuntime/Sources/New+Delete.cxx deleted file mode 100644 index 6ed8fecf..00000000 --- a/SDK/Developer/CoreCxxRuntime/Sources/New+Delete.cxx +++ /dev/null @@ -1,33 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#include - -typedef SizeType size_t; - -void* operator new[](size_t sz) -{ - if (sz == 0) - ++sz; - - return RtTlsAllocate(sz, kStandardAllocation); -} - -void* operator new(size_t sz) -{ - if (sz == 0) - ++sz; - - return RtTlsAllocate(sz, kArrayAllocation); -} - -void operator delete[](void* ptr) -{ - if (ptr == nullptr) - return; - - RtTlsFree(ptr); -} \ No newline at end of file diff --git a/SDK/Developer/CorePEFRuntime/.gitkeep b/SDK/Developer/CorePEFRuntime/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/SDK/Developer/CorePEFRuntime/Sources/PEFStart.c b/SDK/Developer/CorePEFRuntime/Sources/PEFStart.c deleted file mode 100644 index 0dd6c3b7..00000000 --- a/SDK/Developer/CorePEFRuntime/Sources/PEFStart.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#include - -/// @brief Application entrypoint. -/// @param void -/// @return void -CA_EXTERN_C VoidType AppMain(VoidType); - -/// @brief Process entrypoint. -/// @param void -/// @return void -CA_EXTERN_C VoidType __ImageStart(VoidType) -{ - kSharedApplication = RtGetAppPointer(); - CA_MUST_PASS(kSharedApplication); - - AppMain(); -} diff --git a/SDK/Developer/CoreSystem/.gitkeep b/SDK/Developer/CoreSystem/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/SDK/Developer/CoreSystem/AMD64/CoreAssembly.s b/SDK/Developer/CoreSystem/AMD64/CoreAssembly.s deleted file mode 100644 index 5d1484cf..00000000 --- a/SDK/Developer/CoreSystem/AMD64/CoreAssembly.s +++ /dev/null @@ -1,28 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - - Purpose: AMD64 low level I/O - -------------------------------------------- */ - -.text - -.globl RtGetAppPointer -.globl RtAssertTriggerInterrupt - -/* @brief Application getter */ -/* @throws: ApptError: appartement error. */ -RtGetAppPointer: - mov $0x10, %rcx /* sysGetProcessObject */ - int $0x32 - - /* rax gets saved and returned. */ - ret - -RtAssertTriggerInterrupt: - mov $0x11, %rcx /* sysTerminateCurrentProcess */ - int $0x32 - - ret - diff --git a/SDK/Developer/CoreSystem/ARM64/.gitkeep b/SDK/Developer/CoreSystem/ARM64/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/SDK/Developer/CoreSystem/Headers/Alert.h b/SDK/Developer/CoreSystem/Headers/Alert.h deleted file mode 100644 index 57c9afeb..00000000 --- a/SDK/Developer/CoreSystem/Headers/Alert.h +++ /dev/null @@ -1,21 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -/************************************************************* - * - * File: Alert.h - * Purpose: New OS alert dialog. - * Date: 3/26/24 - * - * Copyright SoftwareLabs, all rights reserved. - * - *************************************************************/ - -#pragma once - -#include - -CA_EXTERN_C VoidType Alert(const CharacterTypeUTF8* fmt, ...); diff --git a/SDK/Developer/CoreSystem/Headers/Defines.h b/SDK/Developer/CoreSystem/Headers/Defines.h deleted file mode 100644 index 600e9ab6..00000000 --- a/SDK/Developer/CoreSystem/Headers/Defines.h +++ /dev/null @@ -1,230 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#pragma once - -#ifdef CA_MUST_PASS -#undef CA_MUST_PASS -#endif - -#ifdef _DEBUG -#define CA_MUST_PASS(e) \ - { \ - if (!e) \ - { \ - Alert("Sorry, an assertion failed.\nFile: %s\nLine: %i", __FILE__, __LINE__) RtAssertTriggerInterrupt() \ - } \ - } -#else -#define CA_MUST_PASS(e) CA_UNREFERENCED_PARAMETER(e) -#endif - -#ifdef __cplusplus - -#define CA_EXTERN_C extern "C" - -#else - -#define CA_EXTERN_C extern - -#endif - -struct ApplicationInterface; -struct GUID; - -CA_EXTERN_C void RtAssertTriggerInterrupt(void); - -#define CA_STDCALL __attribute__((stdcall)) -#define CA_CDECL __attribute__((cdecl)) -#define CA_MSCALL __attribute__((ms_abi)) - -#define PACKED __attribute__((packed)) - -#define CA_PASCAL CA_STDCALL - -#include - -typedef __UINT8_TYPE__ ByteType; -typedef __UINT16_TYPE__ WordType; -typedef __UINT32_TYPE__ DWordType; -typedef __UINT64_TYPE__ QWordType; -typedef __SIZE_TYPE__ SizeType; - -typedef char CharacterTypeUTF8; -typedef CharacterTypeUTF8* PtrCharacterType; - -typedef void* PtrVoidType; -typedef void VoidType; - -#ifdef __SINGLE_PRECISION__ -typedef float FloatType; -typedef float PositionType; -#else -typedef double FloatType; -typedef double PositionType; -#endif - -typedef __UINTPTR_TYPE__ UIntPtrType; -typedef __INTPTR_TYPE__ IntPtrType; -typedef __UINT64_TYPE__ UInt64Type; -typedef __INT64_TYPE__ Int64Type; -typedef __UINT32_TYPE__ UInt32Type; -typedef __INT32_TYPE__ Int32Type; - -typedef CharacterTypeUTF8 BooleanType; - -#define Yes 1 -#define No 0 - -#define CA_PTR * - -#define CA_UNREFERENCED_PARAMETER(e) ((VoidType)(e)) - -#ifdef __x86_64__ - -#define CA_FAR __far -#define CA_NEAR __near - -#define _M_AMD64 2 -#else - -#define CA_FAR -#define CA_NEAR - -#endif - -#ifdef __aarch64__ -#define _M_AARCH64 3 -#endif - -#ifdef __powerpc64__ -#define _M_PPC64 4 -#endif - -#ifdef __64x0__ -#define _M_64000 5 -#endif - -#ifdef __riscv__ -#define _M_RISCV 6 -#endif - -#define CA_STATIC static -#define CA_INLINE inline -#define CA_CONST const - -#ifdef __cplusplus -#define CA_CONSTEXPR constexpr -#else -#define CA_CONSTEXPR -#endif // __cplusplus - -enum RtProcessCall -{ - kCallAllocPtr = 1, - kCallFreePtr, - kCallSizePtr, - kCallCheckPtr, - kCallAllocStack, - /// @brief Open a specific handle - /// (can be used as sel to call methods related to it.) - kCallOpenFile, - kCallCloseFile, - kCallOpenDir, - kCallCloseDir, - kCallOpenDevice, - kCallCloseDevice, - kCallCreateWindow, - kCallCloseWindow, - kCallCreateMenu, - kCallCloseMenu, - kCallRandomNumberGenerator, - kCallGetArgsCount, - kCallGetArgsPtr, - /// @brief Number of process calls. - kCallsCount, -}; - -/** - * @brief GUID type, something you can also find in CFKit. - * @author Amlal El Mahrouss - */ -typedef struct GUID -{ - DWordType Data1; - WordType Data2; - WordType Data3; - ByteType Data4[8]; -} GUIDType, *PtrGUIDType; - -/// \brief Application Interface. -/// \author Amlal El Mahrouss -typedef struct ApplicationInterface -{ - VoidType (*Release)(struct ApplicationInterface* Self, DWordType ExitCode); - IntPtrType (*Invoke)(struct ApplicationInterface* Self, DWordType Sel, ...); - VoidType (*Query)(struct ApplicationInterface* Self, PtrVoidType* Dst, SizeType SzDst, struct GUID* GuidOf); -} ApplicationInterface, *ApplicationInterfaceRef; - -#ifdef __cplusplus - -#define CA_COPY_DELETE(KLASS) \ - KLASS& operator=(const KLASS&) = delete; \ - KLASS(const KLASS&) = delete; - -#define CA_COPY_DEFAULT(KLASS) \ - KLASS& operator=(const KLASS&) = default; \ - KLASS(const KLASS&) = default; - -#define CA_MOVE_DELETE(KLASS) \ - KLASS& operator=(KLASS&&) = delete; \ - KLASS(KLASS&&) = delete; - -#define CA_MOVE_DEFAULT(KLASS) \ - KLASS& operator=(KLASS&&) = default; \ - KLASS(KLASS&&) = default; - -#define app_cast reinterpret_cast - -template -using StrType = CharacterTypeUTF8[N]; - -#else - -#define app_cast (ApplicationInterfaceRef) - -#endif // ifdef C++ - -/// @brief Get app singleton. -/// @param -/// @return -CA_EXTERN_C ApplicationInterfaceRef RtGetAppPointer(VoidType); - -/// @brief Get argument count -/// @param -/// @return -CA_EXTERN_C SizeType RtGetAppArgumentsCount(VoidType); - -/// @brief Get argument pointer. -/// @param -/// @return -CA_EXTERN_C CharacterTypeUTF8** RtGetAppArgumentsPtr(VoidType); - -CA_EXTERN_C ApplicationInterfaceRef kSharedApplication; - -typedef CharacterTypeUTF8 StrType255[255]; - -#define True 1 -#define False 0 -#define Bool BooleanType - -#define NullPtr ((PtrVoidType)0) - -#ifndef kInvalidRef -#define kInvalidRef 0 -#endif - -#include diff --git a/SDK/Developer/CoreSystem/Headers/File.h b/SDK/Developer/CoreSystem/Headers/File.h deleted file mode 100644 index 09cd0b88..00000000 --- a/SDK/Developer/CoreSystem/Headers/File.h +++ /dev/null @@ -1,52 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#pragma once - -#include - -/// @brief Filesystem wrapper. - -typedef QWordType FSRef; - -/// @brief Opens a new file. -/// @param path where to find it. -/// @param rest the restrict (rw, rwe, r+, w+, r, w) -/// @return FSRef the file. -CA_EXTERN_C FSRef FsOpenFile(const CharacterTypeUTF8* path, const CharacterTypeUTF8* r); - -/// @brief Closes the file and flushes it to the said file. -/// @param refFs the filesystem reference. -/// @return -CA_EXTERN_C VoidType FsCloseFile(FSRef refFs); - -#define kMaxForkNameLength 256 /* long fork names. */ - -/// @brief A fork information header. -typedef struct _Fork -{ - PtrVoidType forkData; - SizeType forkSize; - Int32Type forkFlags; - Int32Type forkKind; - CharacterTypeUTF8 forkName[kMaxForkNameLength]; -} ForkType; - -typedef ForkType* FSForkRef; - -/// @brief Gets the fork inside a file. -/// @param refFs the filesystem ref -/// @param forkName the fork's name -/// @return the fork data. -CA_EXTERN_C FSForkRef FsGetFork(FSRef refFs, const CharacterTypeUTF8* forkName); - -/// @brief Check if the filesystem path is valid. -/// @return if not return false, or true. -CA_EXTERN_C BooleanType FsIsValidPath(const CharacterTypeUTF8* path); - -/// @note not only limited to, there is code forks, icon forks... -#define FsGetDataFork(refFs) FsGetFork(refFs, "data") -#define FsGetRsrcFork(refFs) FsGetFork(refFs, "rsrc") diff --git a/SDK/Developer/CoreSystem/Headers/Heap.h b/SDK/Developer/CoreSystem/Headers/Heap.h deleted file mode 100644 index 09cb15ee..00000000 --- a/SDK/Developer/CoreSystem/Headers/Heap.h +++ /dev/null @@ -1,39 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#pragma once - -#include - -#define kAllocationTypes 2 - -enum RtAllocationKind -{ - kStandardAllocation = 0xC, - kArrayAllocation = 0xD, -}; - -/// @brief Allocates a new pointer from process pool. -/// @param sz the size -/// @param flags the allocation flags. -/// @return -CA_EXTERN_C PtrVoidType RtTlsAllocate(QWordType sz, - DWordType flags); - -/// @brief Check if the pointer exists. -/// @param ptr the pointer to free. -/// @return -CA_EXTERN_C BooleanType RtTlsPtrExists(PtrVoidType ptr); - -/// @brief Gets the size of the process' pointer. -/// @param ptr the pointer to free. -/// @return -CA_EXTERN_C QWordType RtTlsGetSize(PtrVoidType ptr); - -/// @brief Frees the process pointer. -/// @param ptr the pointer to free. -/// @return -CA_EXTERN_C VoidType RtTlsFree(PtrVoidType ptr); diff --git a/SDK/Developer/CoreSystem/Headers/Hint.h b/SDK/Developer/CoreSystem/Headers/Hint.h deleted file mode 100644 index d775f52d..00000000 --- a/SDK/Developer/CoreSystem/Headers/Hint.h +++ /dev/null @@ -1,20 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#pragma once - -#pragma compiler(hint_manifest) - -#define _Input -#define _Output - -#define _Optional - -#define _StrictCheckInput -#define _StrictCheckOutput - -#define _InOut -#define _StrictInOut diff --git a/SDK/Developer/CoreSystem/Headers/Intl.h b/SDK/Developer/CoreSystem/Headers/Intl.h deleted file mode 100644 index 5e4ef49e..00000000 --- a/SDK/Developer/CoreSystem/Headers/Intl.h +++ /dev/null @@ -1,24 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#pragma once - -/// @brief Intlization primitives. - -#include - -typedef UInt64Type IntlRef; - -/// @brief locale getter and setters. - -IntlRef IntlGetLocale(const char* name); -BooleanType IntlSetLocale(const IntlRef intl); - -/// @brief locale helpers. - -/// @brief translate a string from a locale. -const CharacterTypeUTF8* Intl(const CharacterTypeUTF8* input, - const IntlRef locale); diff --git a/SDK/Developer/CoreSystem/Headers/Math.h b/SDK/Developer/CoreSystem/Headers/Math.h deleted file mode 100644 index 87c792eb..00000000 --- a/SDK/Developer/CoreSystem/Headers/Math.h +++ /dev/null @@ -1,27 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#pragma once - -#include - -/////////////////////////////////////////////////////////////////////// -/// Random functions /// -/////////////////////////////////////////////////////////////////////// - -/// @brief Number generator helper. -/// @return Random generated number. -CA_EXTERN_C SizeType MathRand(VoidType); - -/////////////////////////////////////////////////////////////////////// -/// Mathematical functions /// -/////////////////////////////////////////////////////////////////////// - -CA_EXTERN_C FloatType Sqrt(FloatType number); - -CA_EXTERN_C FloatType Cosine(FloatType number); -CA_EXTERN_C FloatType Sine(FloatType number); -CA_EXTERN_C FloatType Tangent(FloatType number); \ No newline at end of file diff --git a/SDK/Developer/CoreSystem/Headers/Rsrc.h b/SDK/Developer/CoreSystem/Headers/Rsrc.h deleted file mode 100644 index 7d76f50d..00000000 --- a/SDK/Developer/CoreSystem/Headers/Rsrc.h +++ /dev/null @@ -1,9 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#pragma once - -#include diff --git a/SDK/Developer/CoreSystem/Headers/Thread.h b/SDK/Developer/CoreSystem/Headers/Thread.h deleted file mode 100644 index f0360b63..00000000 --- a/SDK/Developer/CoreSystem/Headers/Thread.h +++ /dev/null @@ -1,47 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -// -// Created by Amlal on 3/18/24 -// - -#ifndef __THREAD__ -#define __THREAD__ - -#include - -#define kThreadErrorExit (-33) - -/// @brief Thread reference. -typedef QWordType ThreadRef; - -/// @brief Main application thread. -CA_EXTERN_C ThreadRef kMainThread; - -typedef VoidType (*ThreadEntrypointKind)(VoidType); - -/// @brief Creates a new thread, and runs the code. -/// @param threadName the thread's name. -/// @param threadStart where to start. -/// @return -CA_EXTERN_C ThreadRef CTCreate(const CharacterTypeUTF8* threadName, ThreadEntrypointKind threadStart); - -/// @brief Dispoes the thread, and exits with code kThreadErrorExit -/// @param ref the thread reference. -/// @return nothing. -CA_EXTERN_C VoidType CTRelease(ThreadRef ref); - -/// @brief Waits for the thread to complete. -/// @param ref the thread reference. -/// @return nothing. -CA_EXTERN_C VoidType CTJoin(ThreadRef ref); - -/// @brief Yields the current thread. -/// @param ref the thead reference. -/// @return -CA_EXTERN_C VoidType CTYield(ThreadRef ref); - -#endif // __THREAD__ diff --git a/SDK/Developer/CoreSystem/POWER/CoreAssembly.s b/SDK/Developer/CoreSystem/POWER/CoreAssembly.s deleted file mode 100644 index e7919f23..00000000 --- a/SDK/Developer/CoreSystem/POWER/CoreAssembly.s +++ /dev/null @@ -1,23 +0,0 @@ -; /* ------------------------------------------- -; -; Copyright SoftwareLabs -; -; Purpose: POWER low level I/O -; -; ------------------------------------------- */ - -/* @brief Application getter */ -/* @throws: ApptError: appartement error. */ -export .code64 RtGetAppPointer: - mflr r3 - stw 0x10, 0(r3) /* sysGetProcessObject */ - sc - - blr - -export .code64 RtAssertTriggerInterrupt: - mflr r3 - stw 0x11, 0(r3) /* sysTerminateCurrentProcess */ - sc - - blr diff --git a/SDK/Developer/CoreSystem/RISCV/.gitkeep b/SDK/Developer/CoreSystem/RISCV/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/SDK/Developer/CoreSystem/ReadMe.md b/SDK/Developer/CoreSystem/ReadMe.md deleted file mode 100644 index c7c4d390..00000000 --- a/SDK/Developer/CoreSystem/ReadMe.md +++ /dev/null @@ -1,14 +0,0 @@ -# CoreSystem -## System API. - -Currently contains: -- Heap API. -- File API. -- Window Manager API. -- Dialogs API. -- Data types. -- Threading API. - -Needs: -- Device API -- Drive API. \ No newline at end of file diff --git a/SDK/Developer/CoreSystem/Sources/App.c b/SDK/Developer/CoreSystem/Sources/App.c deleted file mode 100644 index 6c6f22f3..00000000 --- a/SDK/Developer/CoreSystem/Sources/App.c +++ /dev/null @@ -1,31 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#include - -/// @brief Main Application object, retrieved from the RtGetAppPointer symbol. -ApplicationInterfaceRef kSharedApplication = NullPtr; - -/// @brief Gets the app arguments count. -/// @param void no arguments. -/// @return The number of arguments given to the application. -CA_EXTERN_C SizeType RtGetAppArgumentsCount(VoidType) -{ - CA_MUST_PASS(kSharedApplication); - - return kSharedApplication->Invoke(kSharedApplication, kCallGetArgsCount); -} - -/// @brief Gets the app arguments pointer. -/// @param void no arguments. -/// @return -CA_EXTERN_C CharacterTypeUTF8** RtGetAppArgumentsPtr(VoidType) -{ - CA_MUST_PASS(kSharedApplication); - - return (CharacterTypeUTF8**)kSharedApplication->Invoke(kSharedApplication, - kCallGetArgsPtr); -} diff --git a/SDK/Developer/CoreSystem/Sources/File.c b/SDK/Developer/CoreSystem/Sources/File.c deleted file mode 100644 index 6488bccf..00000000 --- a/SDK/Developer/CoreSystem/Sources/File.c +++ /dev/null @@ -1,43 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#include -#include - -enum FileOp -{ - kFlushFile, - kReadFork, - kWriteFork, - kOpenFork, - kCloseFork, -}; - -/// @brief Opens a new file. -/// @param path where to find it. -/// @param rest the restrict (rw, rwe, r+, w+, r, w) -/// @return FSRef the file. -CA_EXTERN_C FSRef FsOpenFile(const CharacterTypeUTF8* path, - const CharacterTypeUTF8* rest) -{ - CA_MUST_PASS(kSharedApplication); - CA_MUST_PASS(path && FsIsValidPath(path) == Yes); - CA_MUST_PASS(rest); - - return kSharedApplication->Invoke(kSharedApplication, kCallOpenFile, path, - rest); -} - -/// @brief Closes the file and flushes it to the said file. -/// @param refFs the filesystem reference. -/// @return -CA_EXTERN_C VoidType FsCloseFile(FSRef refFs) -{ - CA_MUST_PASS(kSharedApplication); - - kSharedApplication->Invoke(kSharedApplication, refFs, kFlushFile); - kSharedApplication->Invoke(kSharedApplication, kCallCloseFile, refFs); -} diff --git a/SDK/Developer/CoreSystem/Sources/Heap.c b/SDK/Developer/CoreSystem/Sources/Heap.c deleted file mode 100644 index 546384e2..00000000 --- a/SDK/Developer/CoreSystem/Sources/Heap.c +++ /dev/null @@ -1,55 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#include -#include - -/// @brief Allocate from the user's heap. -/// @param sz size of object. -/// @param flags flags. -/// @return -CA_EXTERN_C PtrVoidType RtTlsAllocate(QWordType sz, DWordType flags) -{ - CA_MUST_PASS(kSharedApplication); - CA_MUST_PASS(sz); - CA_MUST_PASS(flags); - - return (PtrVoidType)kSharedApplication->Invoke(kSharedApplication, - kCallAllocPtr, sz, flags); -} - -/// @brief Free pointer from the user's heap. -/// @param ptr the pointer to free. -CA_EXTERN_C VoidType RtTlsFree(PtrVoidType ptr) -{ - CA_MUST_PASS(kSharedApplication); - CA_MUST_PASS(ptr); - - CA_UNREFERENCED_PARAMETER( - kSharedApplication->Invoke(kSharedApplication, kCallFreePtr, ptr)); -} - -/// @brief Get pointer size. -/// @param ptr the pointer to find. -/// @return the size. -CA_EXTERN_C QWordType RtTlsGetSize(PtrVoidType ptr) -{ - CA_MUST_PASS(kSharedApplication); - - CA_MUST_PASS(ptr); - return kSharedApplication->Invoke(kSharedApplication, kCallSizePtr, ptr); -} - -/// @brief Check if the pointer exists. -/// @param ptr the pointer to check. -/// @return if it exists -CA_EXTERN_C BooleanType RtTlsPtrExists(PtrVoidType ptr) -{ - CA_MUST_PASS(kSharedApplication); - - CA_MUST_PASS(ptr); - return kSharedApplication->Invoke(kSharedApplication, kCallCheckPtr, ptr); -} diff --git a/SDK/Developer/CoreSystem/Sources/Math.c b/SDK/Developer/CoreSystem/Sources/Math.c deleted file mode 100644 index b41f8a54..00000000 --- a/SDK/Developer/CoreSystem/Sources/Math.c +++ /dev/null @@ -1,14 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#include - -/// @brief Number generator helper. -/// @return Random generated number. -CA_EXTERN_C SizeType MathRand(VoidType) -{ - return kSharedApplication->Invoke(kSharedApplication, kCallRandomNumberGenerator); -} \ No newline at end of file diff --git a/SDK/Developer/CoreSystem/amd64.mk b/SDK/Developer/CoreSystem/amd64.mk deleted file mode 100644 index 33303430..00000000 --- a/SDK/Developer/CoreSystem/amd64.mk +++ /dev/null @@ -1,22 +0,0 @@ -################################################## -# (C) SoftwareLabs, all rights reserved. -# This is the CoreSystem Makefile. -################################################## - -CC=x86_64-w64-mingw32-gcc -AR=x86_64-w64-mingw32-ar -CCINC=-I./ -CCFLAGS=-D__SINGLE_PRECISION__ -nostdlib -std=c17 -ffreestanding -Xlinker --subsystem=17 -shared -OUTPUT=CoreSystem.lib - -.PHONY: all -all: build-core-amd64 - @echo "[CoreSystem.lib] Build done." - -.PHONY: build-core-amd64 -build-core-amd64: - $(CC) $(CCINC) $(CCFLAGS) $(wildcard Sources/*.c) $(wildcard AMD64/*.s) -o $(OUTPUT) - -.PHONY: clean -clean: - rm -f $(wildcard *.lib) diff --git a/SDK/Developer/CoreSystem/compile_flags.txt b/SDK/Developer/CoreSystem/compile_flags.txt deleted file mode 100644 index 3be985d1..00000000 --- a/SDK/Developer/CoreSystem/compile_flags.txt +++ /dev/null @@ -1,4 +0,0 @@ --I./ --I../ --I../../../Private --std=c17 diff --git a/SDK/Library/.gitkeep b/SDK/Library/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/SDK/Library/CoreCxxRuntime/.gitkeep b/SDK/Library/CoreCxxRuntime/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/SDK/Library/CoreCxxRuntime/Sources/New+Delete.cxx b/SDK/Library/CoreCxxRuntime/Sources/New+Delete.cxx new file mode 100644 index 00000000..6ed8fecf --- /dev/null +++ b/SDK/Library/CoreCxxRuntime/Sources/New+Delete.cxx @@ -0,0 +1,33 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#include + +typedef SizeType size_t; + +void* operator new[](size_t sz) +{ + if (sz == 0) + ++sz; + + return RtTlsAllocate(sz, kStandardAllocation); +} + +void* operator new(size_t sz) +{ + if (sz == 0) + ++sz; + + return RtTlsAllocate(sz, kArrayAllocation); +} + +void operator delete[](void* ptr) +{ + if (ptr == nullptr) + return; + + RtTlsFree(ptr); +} \ No newline at end of file diff --git a/SDK/Library/CorePEFRuntime/.gitkeep b/SDK/Library/CorePEFRuntime/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/SDK/Library/CorePEFRuntime/Sources/PEFStart.c b/SDK/Library/CorePEFRuntime/Sources/PEFStart.c new file mode 100644 index 00000000..0dd6c3b7 --- /dev/null +++ b/SDK/Library/CorePEFRuntime/Sources/PEFStart.c @@ -0,0 +1,23 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#include + +/// @brief Application entrypoint. +/// @param void +/// @return void +CA_EXTERN_C VoidType AppMain(VoidType); + +/// @brief Process entrypoint. +/// @param void +/// @return void +CA_EXTERN_C VoidType __ImageStart(VoidType) +{ + kSharedApplication = RtGetAppPointer(); + CA_MUST_PASS(kSharedApplication); + + AppMain(); +} diff --git a/SDK/Library/CoreSystem/.gitkeep b/SDK/Library/CoreSystem/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/SDK/Library/CoreSystem/AMD64/CoreAssembly.s b/SDK/Library/CoreSystem/AMD64/CoreAssembly.s new file mode 100644 index 00000000..5d1484cf --- /dev/null +++ b/SDK/Library/CoreSystem/AMD64/CoreAssembly.s @@ -0,0 +1,28 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + + Purpose: AMD64 low level I/O + +------------------------------------------- */ + +.text + +.globl RtGetAppPointer +.globl RtAssertTriggerInterrupt + +/* @brief Application getter */ +/* @throws: ApptError: appartement error. */ +RtGetAppPointer: + mov $0x10, %rcx /* sysGetProcessObject */ + int $0x32 + + /* rax gets saved and returned. */ + ret + +RtAssertTriggerInterrupt: + mov $0x11, %rcx /* sysTerminateCurrentProcess */ + int $0x32 + + ret + diff --git a/SDK/Library/CoreSystem/ARM64/.gitkeep b/SDK/Library/CoreSystem/ARM64/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/SDK/Library/CoreSystem/Headers/Alert.h b/SDK/Library/CoreSystem/Headers/Alert.h new file mode 100644 index 00000000..57c9afeb --- /dev/null +++ b/SDK/Library/CoreSystem/Headers/Alert.h @@ -0,0 +1,21 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +/************************************************************* + * + * File: Alert.h + * Purpose: New OS alert dialog. + * Date: 3/26/24 + * + * Copyright SoftwareLabs, all rights reserved. + * + *************************************************************/ + +#pragma once + +#include + +CA_EXTERN_C VoidType Alert(const CharacterTypeUTF8* fmt, ...); diff --git a/SDK/Library/CoreSystem/Headers/Defines.h b/SDK/Library/CoreSystem/Headers/Defines.h new file mode 100644 index 00000000..600e9ab6 --- /dev/null +++ b/SDK/Library/CoreSystem/Headers/Defines.h @@ -0,0 +1,230 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#pragma once + +#ifdef CA_MUST_PASS +#undef CA_MUST_PASS +#endif + +#ifdef _DEBUG +#define CA_MUST_PASS(e) \ + { \ + if (!e) \ + { \ + Alert("Sorry, an assertion failed.\nFile: %s\nLine: %i", __FILE__, __LINE__) RtAssertTriggerInterrupt() \ + } \ + } +#else +#define CA_MUST_PASS(e) CA_UNREFERENCED_PARAMETER(e) +#endif + +#ifdef __cplusplus + +#define CA_EXTERN_C extern "C" + +#else + +#define CA_EXTERN_C extern + +#endif + +struct ApplicationInterface; +struct GUID; + +CA_EXTERN_C void RtAssertTriggerInterrupt(void); + +#define CA_STDCALL __attribute__((stdcall)) +#define CA_CDECL __attribute__((cdecl)) +#define CA_MSCALL __attribute__((ms_abi)) + +#define PACKED __attribute__((packed)) + +#define CA_PASCAL CA_STDCALL + +#include + +typedef __UINT8_TYPE__ ByteType; +typedef __UINT16_TYPE__ WordType; +typedef __UINT32_TYPE__ DWordType; +typedef __UINT64_TYPE__ QWordType; +typedef __SIZE_TYPE__ SizeType; + +typedef char CharacterTypeUTF8; +typedef CharacterTypeUTF8* PtrCharacterType; + +typedef void* PtrVoidType; +typedef void VoidType; + +#ifdef __SINGLE_PRECISION__ +typedef float FloatType; +typedef float PositionType; +#else +typedef double FloatType; +typedef double PositionType; +#endif + +typedef __UINTPTR_TYPE__ UIntPtrType; +typedef __INTPTR_TYPE__ IntPtrType; +typedef __UINT64_TYPE__ UInt64Type; +typedef __INT64_TYPE__ Int64Type; +typedef __UINT32_TYPE__ UInt32Type; +typedef __INT32_TYPE__ Int32Type; + +typedef CharacterTypeUTF8 BooleanType; + +#define Yes 1 +#define No 0 + +#define CA_PTR * + +#define CA_UNREFERENCED_PARAMETER(e) ((VoidType)(e)) + +#ifdef __x86_64__ + +#define CA_FAR __far +#define CA_NEAR __near + +#define _M_AMD64 2 +#else + +#define CA_FAR +#define CA_NEAR + +#endif + +#ifdef __aarch64__ +#define _M_AARCH64 3 +#endif + +#ifdef __powerpc64__ +#define _M_PPC64 4 +#endif + +#ifdef __64x0__ +#define _M_64000 5 +#endif + +#ifdef __riscv__ +#define _M_RISCV 6 +#endif + +#define CA_STATIC static +#define CA_INLINE inline +#define CA_CONST const + +#ifdef __cplusplus +#define CA_CONSTEXPR constexpr +#else +#define CA_CONSTEXPR +#endif // __cplusplus + +enum RtProcessCall +{ + kCallAllocPtr = 1, + kCallFreePtr, + kCallSizePtr, + kCallCheckPtr, + kCallAllocStack, + /// @brief Open a specific handle + /// (can be used as sel to call methods related to it.) + kCallOpenFile, + kCallCloseFile, + kCallOpenDir, + kCallCloseDir, + kCallOpenDevice, + kCallCloseDevice, + kCallCreateWindow, + kCallCloseWindow, + kCallCreateMenu, + kCallCloseMenu, + kCallRandomNumberGenerator, + kCallGetArgsCount, + kCallGetArgsPtr, + /// @brief Number of process calls. + kCallsCount, +}; + +/** + * @brief GUID type, something you can also find in CFKit. + * @author Amlal El Mahrouss + */ +typedef struct GUID +{ + DWordType Data1; + WordType Data2; + WordType Data3; + ByteType Data4[8]; +} GUIDType, *PtrGUIDType; + +/// \brief Application Interface. +/// \author Amlal El Mahrouss +typedef struct ApplicationInterface +{ + VoidType (*Release)(struct ApplicationInterface* Self, DWordType ExitCode); + IntPtrType (*Invoke)(struct ApplicationInterface* Self, DWordType Sel, ...); + VoidType (*Query)(struct ApplicationInterface* Self, PtrVoidType* Dst, SizeType SzDst, struct GUID* GuidOf); +} ApplicationInterface, *ApplicationInterfaceRef; + +#ifdef __cplusplus + +#define CA_COPY_DELETE(KLASS) \ + KLASS& operator=(const KLASS&) = delete; \ + KLASS(const KLASS&) = delete; + +#define CA_COPY_DEFAULT(KLASS) \ + KLASS& operator=(const KLASS&) = default; \ + KLASS(const KLASS&) = default; + +#define CA_MOVE_DELETE(KLASS) \ + KLASS& operator=(KLASS&&) = delete; \ + KLASS(KLASS&&) = delete; + +#define CA_MOVE_DEFAULT(KLASS) \ + KLASS& operator=(KLASS&&) = default; \ + KLASS(KLASS&&) = default; + +#define app_cast reinterpret_cast + +template +using StrType = CharacterTypeUTF8[N]; + +#else + +#define app_cast (ApplicationInterfaceRef) + +#endif // ifdef C++ + +/// @brief Get app singleton. +/// @param +/// @return +CA_EXTERN_C ApplicationInterfaceRef RtGetAppPointer(VoidType); + +/// @brief Get argument count +/// @param +/// @return +CA_EXTERN_C SizeType RtGetAppArgumentsCount(VoidType); + +/// @brief Get argument pointer. +/// @param +/// @return +CA_EXTERN_C CharacterTypeUTF8** RtGetAppArgumentsPtr(VoidType); + +CA_EXTERN_C ApplicationInterfaceRef kSharedApplication; + +typedef CharacterTypeUTF8 StrType255[255]; + +#define True 1 +#define False 0 +#define Bool BooleanType + +#define NullPtr ((PtrVoidType)0) + +#ifndef kInvalidRef +#define kInvalidRef 0 +#endif + +#include diff --git a/SDK/Library/CoreSystem/Headers/File.h b/SDK/Library/CoreSystem/Headers/File.h new file mode 100644 index 00000000..09cd0b88 --- /dev/null +++ b/SDK/Library/CoreSystem/Headers/File.h @@ -0,0 +1,52 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#pragma once + +#include + +/// @brief Filesystem wrapper. + +typedef QWordType FSRef; + +/// @brief Opens a new file. +/// @param path where to find it. +/// @param rest the restrict (rw, rwe, r+, w+, r, w) +/// @return FSRef the file. +CA_EXTERN_C FSRef FsOpenFile(const CharacterTypeUTF8* path, const CharacterTypeUTF8* r); + +/// @brief Closes the file and flushes it to the said file. +/// @param refFs the filesystem reference. +/// @return +CA_EXTERN_C VoidType FsCloseFile(FSRef refFs); + +#define kMaxForkNameLength 256 /* long fork names. */ + +/// @brief A fork information header. +typedef struct _Fork +{ + PtrVoidType forkData; + SizeType forkSize; + Int32Type forkFlags; + Int32Type forkKind; + CharacterTypeUTF8 forkName[kMaxForkNameLength]; +} ForkType; + +typedef ForkType* FSForkRef; + +/// @brief Gets the fork inside a file. +/// @param refFs the filesystem ref +/// @param forkName the fork's name +/// @return the fork data. +CA_EXTERN_C FSForkRef FsGetFork(FSRef refFs, const CharacterTypeUTF8* forkName); + +/// @brief Check if the filesystem path is valid. +/// @return if not return false, or true. +CA_EXTERN_C BooleanType FsIsValidPath(const CharacterTypeUTF8* path); + +/// @note not only limited to, there is code forks, icon forks... +#define FsGetDataFork(refFs) FsGetFork(refFs, "data") +#define FsGetRsrcFork(refFs) FsGetFork(refFs, "rsrc") diff --git a/SDK/Library/CoreSystem/Headers/Heap.h b/SDK/Library/CoreSystem/Headers/Heap.h new file mode 100644 index 00000000..09cb15ee --- /dev/null +++ b/SDK/Library/CoreSystem/Headers/Heap.h @@ -0,0 +1,39 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#pragma once + +#include + +#define kAllocationTypes 2 + +enum RtAllocationKind +{ + kStandardAllocation = 0xC, + kArrayAllocation = 0xD, +}; + +/// @brief Allocates a new pointer from process pool. +/// @param sz the size +/// @param flags the allocation flags. +/// @return +CA_EXTERN_C PtrVoidType RtTlsAllocate(QWordType sz, + DWordType flags); + +/// @brief Check if the pointer exists. +/// @param ptr the pointer to free. +/// @return +CA_EXTERN_C BooleanType RtTlsPtrExists(PtrVoidType ptr); + +/// @brief Gets the size of the process' pointer. +/// @param ptr the pointer to free. +/// @return +CA_EXTERN_C QWordType RtTlsGetSize(PtrVoidType ptr); + +/// @brief Frees the process pointer. +/// @param ptr the pointer to free. +/// @return +CA_EXTERN_C VoidType RtTlsFree(PtrVoidType ptr); diff --git a/SDK/Library/CoreSystem/Headers/Hint.h b/SDK/Library/CoreSystem/Headers/Hint.h new file mode 100644 index 00000000..d775f52d --- /dev/null +++ b/SDK/Library/CoreSystem/Headers/Hint.h @@ -0,0 +1,20 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#pragma once + +#pragma compiler(hint_manifest) + +#define _Input +#define _Output + +#define _Optional + +#define _StrictCheckInput +#define _StrictCheckOutput + +#define _InOut +#define _StrictInOut diff --git a/SDK/Library/CoreSystem/Headers/Intl.h b/SDK/Library/CoreSystem/Headers/Intl.h new file mode 100644 index 00000000..5e4ef49e --- /dev/null +++ b/SDK/Library/CoreSystem/Headers/Intl.h @@ -0,0 +1,24 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#pragma once + +/// @brief Intlization primitives. + +#include + +typedef UInt64Type IntlRef; + +/// @brief locale getter and setters. + +IntlRef IntlGetLocale(const char* name); +BooleanType IntlSetLocale(const IntlRef intl); + +/// @brief locale helpers. + +/// @brief translate a string from a locale. +const CharacterTypeUTF8* Intl(const CharacterTypeUTF8* input, + const IntlRef locale); diff --git a/SDK/Library/CoreSystem/Headers/Math.h b/SDK/Library/CoreSystem/Headers/Math.h new file mode 100644 index 00000000..87c792eb --- /dev/null +++ b/SDK/Library/CoreSystem/Headers/Math.h @@ -0,0 +1,27 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#pragma once + +#include + +/////////////////////////////////////////////////////////////////////// +/// Random functions /// +/////////////////////////////////////////////////////////////////////// + +/// @brief Number generator helper. +/// @return Random generated number. +CA_EXTERN_C SizeType MathRand(VoidType); + +/////////////////////////////////////////////////////////////////////// +/// Mathematical functions /// +/////////////////////////////////////////////////////////////////////// + +CA_EXTERN_C FloatType Sqrt(FloatType number); + +CA_EXTERN_C FloatType Cosine(FloatType number); +CA_EXTERN_C FloatType Sine(FloatType number); +CA_EXTERN_C FloatType Tangent(FloatType number); \ No newline at end of file diff --git a/SDK/Library/CoreSystem/Headers/Rsrc.h b/SDK/Library/CoreSystem/Headers/Rsrc.h new file mode 100644 index 00000000..7d76f50d --- /dev/null +++ b/SDK/Library/CoreSystem/Headers/Rsrc.h @@ -0,0 +1,9 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#pragma once + +#include diff --git a/SDK/Library/CoreSystem/Headers/Thread.h b/SDK/Library/CoreSystem/Headers/Thread.h new file mode 100644 index 00000000..f0360b63 --- /dev/null +++ b/SDK/Library/CoreSystem/Headers/Thread.h @@ -0,0 +1,47 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +// +// Created by Amlal on 3/18/24 +// + +#ifndef __THREAD__ +#define __THREAD__ + +#include + +#define kThreadErrorExit (-33) + +/// @brief Thread reference. +typedef QWordType ThreadRef; + +/// @brief Main application thread. +CA_EXTERN_C ThreadRef kMainThread; + +typedef VoidType (*ThreadEntrypointKind)(VoidType); + +/// @brief Creates a new thread, and runs the code. +/// @param threadName the thread's name. +/// @param threadStart where to start. +/// @return +CA_EXTERN_C ThreadRef CTCreate(const CharacterTypeUTF8* threadName, ThreadEntrypointKind threadStart); + +/// @brief Dispoes the thread, and exits with code kThreadErrorExit +/// @param ref the thread reference. +/// @return nothing. +CA_EXTERN_C VoidType CTRelease(ThreadRef ref); + +/// @brief Waits for the thread to complete. +/// @param ref the thread reference. +/// @return nothing. +CA_EXTERN_C VoidType CTJoin(ThreadRef ref); + +/// @brief Yields the current thread. +/// @param ref the thead reference. +/// @return +CA_EXTERN_C VoidType CTYield(ThreadRef ref); + +#endif // __THREAD__ diff --git a/SDK/Library/CoreSystem/POWER/CoreAssembly.s b/SDK/Library/CoreSystem/POWER/CoreAssembly.s new file mode 100644 index 00000000..e7919f23 --- /dev/null +++ b/SDK/Library/CoreSystem/POWER/CoreAssembly.s @@ -0,0 +1,23 @@ +; /* ------------------------------------------- +; +; Copyright SoftwareLabs +; +; Purpose: POWER low level I/O +; +; ------------------------------------------- */ + +/* @brief Application getter */ +/* @throws: ApptError: appartement error. */ +export .code64 RtGetAppPointer: + mflr r3 + stw 0x10, 0(r3) /* sysGetProcessObject */ + sc + + blr + +export .code64 RtAssertTriggerInterrupt: + mflr r3 + stw 0x11, 0(r3) /* sysTerminateCurrentProcess */ + sc + + blr diff --git a/SDK/Library/CoreSystem/RISCV/.gitkeep b/SDK/Library/CoreSystem/RISCV/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/SDK/Library/CoreSystem/ReadMe.md b/SDK/Library/CoreSystem/ReadMe.md new file mode 100644 index 00000000..be075a59 --- /dev/null +++ b/SDK/Library/CoreSystem/ReadMe.md @@ -0,0 +1,13 @@ +# CoreSystem +## System Core framework. + +Currently contains: + +- Heap API. +- File API. +- Data API. +- Threading API. + +Needs: +- Device API +- Drive API. \ No newline at end of file diff --git a/SDK/Library/CoreSystem/Sources/App.c b/SDK/Library/CoreSystem/Sources/App.c new file mode 100644 index 00000000..6c6f22f3 --- /dev/null +++ b/SDK/Library/CoreSystem/Sources/App.c @@ -0,0 +1,31 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#include + +/// @brief Main Application object, retrieved from the RtGetAppPointer symbol. +ApplicationInterfaceRef kSharedApplication = NullPtr; + +/// @brief Gets the app arguments count. +/// @param void no arguments. +/// @return The number of arguments given to the application. +CA_EXTERN_C SizeType RtGetAppArgumentsCount(VoidType) +{ + CA_MUST_PASS(kSharedApplication); + + return kSharedApplication->Invoke(kSharedApplication, kCallGetArgsCount); +} + +/// @brief Gets the app arguments pointer. +/// @param void no arguments. +/// @return +CA_EXTERN_C CharacterTypeUTF8** RtGetAppArgumentsPtr(VoidType) +{ + CA_MUST_PASS(kSharedApplication); + + return (CharacterTypeUTF8**)kSharedApplication->Invoke(kSharedApplication, + kCallGetArgsPtr); +} diff --git a/SDK/Library/CoreSystem/Sources/File.c b/SDK/Library/CoreSystem/Sources/File.c new file mode 100644 index 00000000..6488bccf --- /dev/null +++ b/SDK/Library/CoreSystem/Sources/File.c @@ -0,0 +1,43 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#include +#include + +enum FileOp +{ + kFlushFile, + kReadFork, + kWriteFork, + kOpenFork, + kCloseFork, +}; + +/// @brief Opens a new file. +/// @param path where to find it. +/// @param rest the restrict (rw, rwe, r+, w+, r, w) +/// @return FSRef the file. +CA_EXTERN_C FSRef FsOpenFile(const CharacterTypeUTF8* path, + const CharacterTypeUTF8* rest) +{ + CA_MUST_PASS(kSharedApplication); + CA_MUST_PASS(path && FsIsValidPath(path) == Yes); + CA_MUST_PASS(rest); + + return kSharedApplication->Invoke(kSharedApplication, kCallOpenFile, path, + rest); +} + +/// @brief Closes the file and flushes it to the said file. +/// @param refFs the filesystem reference. +/// @return +CA_EXTERN_C VoidType FsCloseFile(FSRef refFs) +{ + CA_MUST_PASS(kSharedApplication); + + kSharedApplication->Invoke(kSharedApplication, refFs, kFlushFile); + kSharedApplication->Invoke(kSharedApplication, kCallCloseFile, refFs); +} diff --git a/SDK/Library/CoreSystem/Sources/Heap.c b/SDK/Library/CoreSystem/Sources/Heap.c new file mode 100644 index 00000000..546384e2 --- /dev/null +++ b/SDK/Library/CoreSystem/Sources/Heap.c @@ -0,0 +1,55 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#include +#include + +/// @brief Allocate from the user's heap. +/// @param sz size of object. +/// @param flags flags. +/// @return +CA_EXTERN_C PtrVoidType RtTlsAllocate(QWordType sz, DWordType flags) +{ + CA_MUST_PASS(kSharedApplication); + CA_MUST_PASS(sz); + CA_MUST_PASS(flags); + + return (PtrVoidType)kSharedApplication->Invoke(kSharedApplication, + kCallAllocPtr, sz, flags); +} + +/// @brief Free pointer from the user's heap. +/// @param ptr the pointer to free. +CA_EXTERN_C VoidType RtTlsFree(PtrVoidType ptr) +{ + CA_MUST_PASS(kSharedApplication); + CA_MUST_PASS(ptr); + + CA_UNREFERENCED_PARAMETER( + kSharedApplication->Invoke(kSharedApplication, kCallFreePtr, ptr)); +} + +/// @brief Get pointer size. +/// @param ptr the pointer to find. +/// @return the size. +CA_EXTERN_C QWordType RtTlsGetSize(PtrVoidType ptr) +{ + CA_MUST_PASS(kSharedApplication); + + CA_MUST_PASS(ptr); + return kSharedApplication->Invoke(kSharedApplication, kCallSizePtr, ptr); +} + +/// @brief Check if the pointer exists. +/// @param ptr the pointer to check. +/// @return if it exists +CA_EXTERN_C BooleanType RtTlsPtrExists(PtrVoidType ptr) +{ + CA_MUST_PASS(kSharedApplication); + + CA_MUST_PASS(ptr); + return kSharedApplication->Invoke(kSharedApplication, kCallCheckPtr, ptr); +} diff --git a/SDK/Library/CoreSystem/Sources/Math.c b/SDK/Library/CoreSystem/Sources/Math.c new file mode 100644 index 00000000..b41f8a54 --- /dev/null +++ b/SDK/Library/CoreSystem/Sources/Math.c @@ -0,0 +1,14 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#include + +/// @brief Number generator helper. +/// @return Random generated number. +CA_EXTERN_C SizeType MathRand(VoidType) +{ + return kSharedApplication->Invoke(kSharedApplication, kCallRandomNumberGenerator); +} \ No newline at end of file diff --git a/SDK/Library/CoreSystem/amd64.mk b/SDK/Library/CoreSystem/amd64.mk new file mode 100644 index 00000000..33303430 --- /dev/null +++ b/SDK/Library/CoreSystem/amd64.mk @@ -0,0 +1,22 @@ +################################################## +# (C) SoftwareLabs, all rights reserved. +# This is the CoreSystem Makefile. +################################################## + +CC=x86_64-w64-mingw32-gcc +AR=x86_64-w64-mingw32-ar +CCINC=-I./ +CCFLAGS=-D__SINGLE_PRECISION__ -nostdlib -std=c17 -ffreestanding -Xlinker --subsystem=17 -shared +OUTPUT=CoreSystem.lib + +.PHONY: all +all: build-core-amd64 + @echo "[CoreSystem.lib] Build done." + +.PHONY: build-core-amd64 +build-core-amd64: + $(CC) $(CCINC) $(CCFLAGS) $(wildcard Sources/*.c) $(wildcard AMD64/*.s) -o $(OUTPUT) + +.PHONY: clean +clean: + rm -f $(wildcard *.lib) diff --git a/SDK/Library/CoreSystem/compile_flags.txt b/SDK/Library/CoreSystem/compile_flags.txt new file mode 100644 index 00000000..749a500e --- /dev/null +++ b/SDK/Library/CoreSystem/compile_flags.txt @@ -0,0 +1,4 @@ +-I./ +-I../ +-I../../../Kernel +-std=c17 diff --git a/SDK/Tools/.gitkeep b/SDK/Tools/.gitkeep new file mode 100644 index 00000000..e69de29b -- cgit v1.2.3