diff options
Diffstat (limited to 'SDK')
28 files changed, 760 insertions, 0 deletions
diff --git a/SDK/.gitkeep b/SDK/.gitkeep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/SDK/.gitkeep diff --git a/SDK/Developer/.gitkeep b/SDK/Developer/.gitkeep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/SDK/Developer/.gitkeep diff --git a/SDK/Developer/CoreCxxRuntime/.gitkeep b/SDK/Developer/CoreCxxRuntime/.gitkeep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/SDK/Developer/CoreCxxRuntime/.gitkeep diff --git a/SDK/Developer/CoreCxxRuntime/Sources/New+Delete.cxx b/SDK/Developer/CoreCxxRuntime/Sources/New+Delete.cxx new file mode 100644 index 00000000..5ff3612f --- /dev/null +++ b/SDK/Developer/CoreCxxRuntime/Sources/New+Delete.cxx @@ -0,0 +1,33 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#include <Headers/Heap.h> + +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 new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/SDK/Developer/CorePEFRuntime/.gitkeep diff --git a/SDK/Developer/CorePEFRuntime/Sources/PEFStart.c b/SDK/Developer/CorePEFRuntime/Sources/PEFStart.c new file mode 100644 index 00000000..31b0d7bd --- /dev/null +++ b/SDK/Developer/CorePEFRuntime/Sources/PEFStart.c @@ -0,0 +1,23 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#include <Headers/Defines.h> + +/// @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 new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/SDK/Developer/CoreSystem/.gitkeep diff --git a/SDK/Developer/CoreSystem/AMD64/CoreAssembly.s b/SDK/Developer/CoreSystem/AMD64/CoreAssembly.s new file mode 100644 index 00000000..58fa3c28 --- /dev/null +++ b/SDK/Developer/CoreSystem/AMD64/CoreAssembly.s @@ -0,0 +1,28 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + + 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 new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/SDK/Developer/CoreSystem/ARM64/.gitkeep diff --git a/SDK/Developer/CoreSystem/Headers/Alert.h b/SDK/Developer/CoreSystem/Headers/Alert.h new file mode 100644 index 00000000..443b6829 --- /dev/null +++ b/SDK/Developer/CoreSystem/Headers/Alert.h @@ -0,0 +1,21 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +/************************************************************* + * + * File: Alert.h + * Purpose: New OS alert dialog. + * Date: 3/26/24 + * + * Copyright Mahrouss Logic, all rights reserved. + * + *************************************************************/ + +#pragma once + +#include <Headers/Defines.h> + +CA_EXTERN_C VoidType Alert(const CharacterTypeUTF8* fmt, ...); diff --git a/SDK/Developer/CoreSystem/Headers/Defines.h b/SDK/Developer/CoreSystem/Headers/Defines.h new file mode 100644 index 00000000..07e0cfeb --- /dev/null +++ b/SDK/Developer/CoreSystem/Headers/Defines.h @@ -0,0 +1,230 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#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 <Headers/Hint.h> + +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<ApplicationInterfaceRef> + +template <SizeType N> +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 <Headers/Alert.h> diff --git a/SDK/Developer/CoreSystem/Headers/File.h b/SDK/Developer/CoreSystem/Headers/File.h new file mode 100644 index 00000000..6b0bb29b --- /dev/null +++ b/SDK/Developer/CoreSystem/Headers/File.h @@ -0,0 +1,52 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#include <Headers/Defines.h> + +/// @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 new file mode 100644 index 00000000..511eaa1b --- /dev/null +++ b/SDK/Developer/CoreSystem/Headers/Heap.h @@ -0,0 +1,39 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#include <Headers/Defines.h> + +#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 new file mode 100644 index 00000000..843407e0 --- /dev/null +++ b/SDK/Developer/CoreSystem/Headers/Hint.h @@ -0,0 +1,20 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#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 new file mode 100644 index 00000000..2e91812e --- /dev/null +++ b/SDK/Developer/CoreSystem/Headers/Intl.h @@ -0,0 +1,24 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +/// @brief Intlization primitives. + +#include <Headers/Defines.h> + +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 new file mode 100644 index 00000000..4f54563b --- /dev/null +++ b/SDK/Developer/CoreSystem/Headers/Math.h @@ -0,0 +1,27 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#include <Headers/Defines.h> + +/////////////////////////////////////////////////////////////////////// +/// 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 new file mode 100644 index 00000000..1ff71332 --- /dev/null +++ b/SDK/Developer/CoreSystem/Headers/Rsrc.h @@ -0,0 +1,9 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#include <Headers/Defines.h> diff --git a/SDK/Developer/CoreSystem/Headers/Thread.h b/SDK/Developer/CoreSystem/Headers/Thread.h new file mode 100644 index 00000000..9562003e --- /dev/null +++ b/SDK/Developer/CoreSystem/Headers/Thread.h @@ -0,0 +1,47 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +// +// Created by Amlal on 3/18/24 +// + +#ifndef __THREAD__ +#define __THREAD__ + +#include <Headers/Defines.h> + +#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 new file mode 100644 index 00000000..99605870 --- /dev/null +++ b/SDK/Developer/CoreSystem/POWER/CoreAssembly.s @@ -0,0 +1,23 @@ +; /* ------------------------------------------- +; +; Copyright Mahrouss Logic +; +; 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 new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/SDK/Developer/CoreSystem/RISCV/.gitkeep diff --git a/SDK/Developer/CoreSystem/ReadMe.md b/SDK/Developer/CoreSystem/ReadMe.md new file mode 100644 index 00000000..c7c4d390 --- /dev/null +++ b/SDK/Developer/CoreSystem/ReadMe.md @@ -0,0 +1,14 @@ +# 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 new file mode 100644 index 00000000..7778c064 --- /dev/null +++ b/SDK/Developer/CoreSystem/Sources/App.c @@ -0,0 +1,31 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#include <Headers/Defines.h> + +/// @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 new file mode 100644 index 00000000..40cbd515 --- /dev/null +++ b/SDK/Developer/CoreSystem/Sources/File.c @@ -0,0 +1,43 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#include <Headers/Defines.h> +#include <Headers/File.h> + +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 new file mode 100644 index 00000000..6c5e381e --- /dev/null +++ b/SDK/Developer/CoreSystem/Sources/Heap.c @@ -0,0 +1,55 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#include <Headers/Defines.h> +#include <Headers/Heap.h> + +/// @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 new file mode 100644 index 00000000..6797166a --- /dev/null +++ b/SDK/Developer/CoreSystem/Sources/Math.c @@ -0,0 +1,14 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#include <Headers/Math.h> + +/// @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 new file mode 100644 index 00000000..a2ce70df --- /dev/null +++ b/SDK/Developer/CoreSystem/amd64.mk @@ -0,0 +1,22 @@ +################################################## +# (C) Mahrouss Logic, 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 new file mode 100644 index 00000000..3be985d1 --- /dev/null +++ b/SDK/Developer/CoreSystem/compile_flags.txt @@ -0,0 +1,4 @@ +-I./ +-I../ +-I../../../Private +-std=c17 diff --git a/SDK/Root b/SDK/Root new file mode 120000 index 00000000..418b1c64 --- /dev/null +++ b/SDK/Root @@ -0,0 +1 @@ +../Private/Root
\ No newline at end of file |
