From b2c7b8604ed3a4c209a15a9ffd718a43163dd9b4 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 28 Mar 2024 20:54:33 +0100 Subject: NewKernel: Add PowerPC partition type inside EPM, add Leak() FileStream method. and documentation. SystemLib: Start implementing the API. Signed-off-by: Amlal El Mahrouss --- Public/Developer/System.Core/Sources/App.c | 20 +++++++ Public/Developer/System.Core/Sources/CRT0.c | 14 ----- Public/Developer/System.Core/Sources/Heap.c | 22 ++++---- .../Developer/System.Core/Sources/New+Delete.cxx | 13 +++-- Public/Developer/System.Core/Sources/Start.c | 14 +++++ Public/Developer/System.Core/Sources/Window.c | 62 ++++++++++++++++++++++ 6 files changed, 111 insertions(+), 34 deletions(-) create mode 100644 Public/Developer/System.Core/Sources/App.c delete mode 100644 Public/Developer/System.Core/Sources/CRT0.c create mode 100644 Public/Developer/System.Core/Sources/Start.c create mode 100644 Public/Developer/System.Core/Sources/Window.c (limited to 'Public/Developer/System.Core/Sources') diff --git a/Public/Developer/System.Core/Sources/App.c b/Public/Developer/System.Core/Sources/App.c new file mode 100644 index 00000000..0bd7fd03 --- /dev/null +++ b/Public/Developer/System.Core/Sources/App.c @@ -0,0 +1,20 @@ +/** =========================================== + (C) Mahrouss Logic + ===========================================*/ + +#include + +/// @brief Gets the app arguments count. +/// @param +/// @return +CA_EXTERN_C SizeType RtGetAppArgumentsCount(VoidType) { + return kApplicationObject->Invoke(kApplicationObject, kCallGetArgsCount); +} + +/// @brief Gets the app arguments pointer. +/// @param +/// @return +CA_EXTERN_C CharacterTypeUTF8* RtGetAppArgumentsPtr(VoidType) { + return (CharacterTypeUTF8*)kApplicationObject->Invoke(kApplicationObject, + kCallGetArgsPtr); +} \ No newline at end of file diff --git a/Public/Developer/System.Core/Sources/CRT0.c b/Public/Developer/System.Core/Sources/CRT0.c deleted file mode 100644 index 03aa62b8..00000000 --- a/Public/Developer/System.Core/Sources/CRT0.c +++ /dev/null @@ -1,14 +0,0 @@ -/** =========================================== - (C) Mahrouss Logic - ===========================================*/ - -#include - -/// @brief Inits the library. -/// @return if it was succesful or not. -CA_EXTERN_C DWordType __start(VoidType) { - kApplicationObject = RtGetAppObject(); - CA_MUST_PASS(kApplicationObject); - - return 0; -} \ No newline at end of file diff --git a/Public/Developer/System.Core/Sources/Heap.c b/Public/Developer/System.Core/Sources/Heap.c index 390ae072..db4a16bf 100644 --- a/Public/Developer/System.Core/Sources/Heap.c +++ b/Public/Developer/System.Core/Sources/Heap.c @@ -7,40 +7,36 @@ #include /// @brief Allocate from the user's heap. -/// @param refObj Process object. /// @param sz size of object. /// @param flags flags. /// @return -CA_EXTERN_C PtrVoidType RtAllocateProcessHeap(ObjectRef refObj, QWordType sz, - DWordType flags) { +CA_EXTERN_C PtrVoidType RtAllocateProcessPtr(QWordType sz, + DWordType flags) { CA_MUST_PASS(sz); CA_MUST_PASS(flags); - return (PtrVoidType)refObj->Invoke(refObj, kProcessCallAllocPtr, sz, flags); + return (PtrVoidType)kApplicationObject->Invoke(kApplicationObject, kCallAllocPtr, sz, flags); } /// @brief Free pointer from the user's heap. -/// @param refObj Process object. /// @param ptr the pointer to free. -CA_EXTERN_C VoidType RtFreeProcessHeap(ObjectRef refObj, PtrVoidType ptr) { +CA_EXTERN_C VoidType RtFreeProcessPtr(PtrVoidType ptr) { CA_MUST_PASS(ptr); - CA_UNREFERENCED_PARAMETER(refObj->Invoke(refObj, kProcessCallFreePtr, ptr)); + CA_UNREFERENCED_PARAMETER(kApplicationObject->Invoke(kApplicationObject, kCallFreePtr, ptr)); } /// @brief Get pointer size. -/// @param refObj Process object. /// @param ptr the pointer to find. /// @return the size. -CA_EXTERN_C QWordType RtProcessHeapSize(ObjectRef refObj, PtrVoidType ptr) { +CA_EXTERN_C QWordType RtProcessPtrSize(PtrVoidType ptr) { CA_MUST_PASS(ptr); - return refObj->Invoke(refObj, kProcessCallSizePtr, ptr); + return kApplicationObject->Invoke(kApplicationObject, kCallSizePtr, ptr); } /// @brief Check if the pointer exists. -/// @param refObj Process object. /// @param ptr the pointer to check. /// @return if it exists -CA_EXTERN_C BooleanType RtProcessHeapExists(ObjectRef refObj, PtrVoidType ptr) { +CA_EXTERN_C BooleanType RtProcessPtrExists(PtrVoidType ptr) { CA_MUST_PASS(ptr); - return refObj->Invoke(refObj, kProcessCallCheckPtr, ptr); + return kApplicationObject->Invoke(kApplicationObject, kCallCheckPtr, ptr); } diff --git a/Public/Developer/System.Core/Sources/New+Delete.cxx b/Public/Developer/System.Core/Sources/New+Delete.cxx index 3e2942c5..0800da22 100644 --- a/Public/Developer/System.Core/Sources/New+Delete.cxx +++ b/Public/Developer/System.Core/Sources/New+Delete.cxx @@ -11,31 +11,30 @@ typedef SizeType size_t; void* operator new[](size_t sz) { if (sz == 0) ++sz; - return RtAllocateProcessHeap(kApplicationObject, sz, kStandardAllocation); + return RtAllocateProcessPtr(sz, kStandardAllocation); } void* operator new(size_t sz) { if (sz == 0) ++sz; - return RtAllocateProcessHeap(kApplicationObject, sz, kArrayAllocation); + return RtAllocateProcessPtr(sz, kArrayAllocation); } void operator delete[](void* ptr) { if (ptr == nullptr) return; - RtFreeProcessHeap(kApplicationObject, ptr); + RtFreeProcessPtr(ptr); } void operator delete(void* ptr) { if (ptr == nullptr) return; - RtFreeProcessHeap(kApplicationObject, ptr); + RtFreeProcessPtr(ptr); } void operator delete(void* ptr, size_t sz) { if (ptr == nullptr) return; + CA_UNREFERENCED_PARAMETER(sz); - (void)sz; - - RtFreeProcessHeap(kApplicationObject, ptr); + RtFreeProcessPtr(ptr); } diff --git a/Public/Developer/System.Core/Sources/Start.c b/Public/Developer/System.Core/Sources/Start.c new file mode 100644 index 00000000..25a29e18 --- /dev/null +++ b/Public/Developer/System.Core/Sources/Start.c @@ -0,0 +1,14 @@ +/** =========================================== + (C) Mahrouss Logic + ===========================================*/ + +#include + +/// @brief Inits the library. +/// @return if it was succesful or not. +CA_EXTERN_C DWordType __start(VoidType) { + kApplicationObject = RtGetAppObject(); + CA_MUST_PASS(kApplicationObject); + + return 0; +} diff --git a/Public/Developer/System.Core/Sources/Window.c b/Public/Developer/System.Core/Sources/Window.c new file mode 100644 index 00000000..2b589402 --- /dev/null +++ b/Public/Developer/System.Core/Sources/Window.c @@ -0,0 +1,62 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#include + +/// invalid resource handle, they always start from 1. +#define kInvalidRsrc 0 + +///////////////////////////////////////////////////////////////////////// + +CA_EXTERN_C WindowPort* WmCreateWindow(const CharacterTypeUTF8* name, + const DWordType rsrcId) { + CA_MUST_PASS(name); + CA_MUST_PASS(rsrcId != kInvalidRsrc); + + return (WindowPort*)kApplicationObject->Invoke( + kApplicationObject, kCallCreateWindow, name, rsrcId); +} + +///////////////////////////////////////////////////////////////////////// + +CA_EXTERN_C VoidType WmReleaseWindow(WindowPort* winPort) { + CA_MUST_PASS(winPort); + + kApplicationObject->Invoke(kApplicationObject, kCallCloseWindow, winPort); +} + +///////////////////////////////////////////////////////////////////////// + +CA_EXTERN_C WindowPort* WmCreateMenu(const CharacterTypeUTF8* name, + const DWordType rsrcId) { + CA_MUST_PASS(name); + CA_MUST_PASS(rsrcId != kInvalidRsrc); + + return (WindowPort*)kApplicationObject->Invoke(kApplicationObject, + kCallCreateMenu, name, rsrcId); +} + +///////////////////////////////////////////////////////////////////////// + +CA_EXTERN_C VoidType WmReleaseMenu(WindowPort* winPort) { + CA_MUST_PASS(winPort); + + kApplicationObject->Invoke(kApplicationObject, kCallCloseMenu, winPort); +} + +///////////////////////////////////////////////////////////////////////// + +CA_EXTERN_C Int32Type WmMoveWindow(WindowPort* id, WmPoint where) { + if (!id) { + return kWmErrInvalidArg; + } + + id->windowPosition.X = where.X; + id->windowPosition.Y = where.Y; + id->windowMoving = True; + + return 0; +} \ No newline at end of file -- cgit v1.2.3