summaryrefslogtreecommitdiffhomepage
path: root/Public/Developer/System.Core/Sources
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-03-28 20:54:33 +0100
committerAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-03-28 20:54:33 +0100
commitb2c7b8604ed3a4c209a15a9ffd718a43163dd9b4 (patch)
tree851d79e3a9b1c676b48ec8dfcd2b989f4da45c9b /Public/Developer/System.Core/Sources
parent215518ae55a54973a1ae18f572ca5bf0ac2a499e (diff)
NewKernel: Add PowerPC partition type inside EPM, add Leak() FileStream method. and documentation.
SystemLib: Start implementing the API. Signed-off-by: Amlal El Mahrouss <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'Public/Developer/System.Core/Sources')
-rw-r--r--Public/Developer/System.Core/Sources/App.c20
-rw-r--r--Public/Developer/System.Core/Sources/Heap.c22
-rw-r--r--Public/Developer/System.Core/Sources/New+Delete.cxx13
-rw-r--r--Public/Developer/System.Core/Sources/Start.c (renamed from Public/Developer/System.Core/Sources/CRT0.c)2
-rw-r--r--Public/Developer/System.Core/Sources/Window.c62
5 files changed, 98 insertions, 21 deletions
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 <System.Core/Headers/Defines.h>
+
+/// @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/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 <System.Core/Headers/Heap.h>
/// @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/CRT0.c b/Public/Developer/System.Core/Sources/Start.c
index 03aa62b8..25a29e18 100644
--- a/Public/Developer/System.Core/Sources/CRT0.c
+++ b/Public/Developer/System.Core/Sources/Start.c
@@ -11,4 +11,4 @@ CA_EXTERN_C DWordType __start(VoidType) {
CA_MUST_PASS(kApplicationObject);
return 0;
-} \ No newline at end of file
+}
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 <System.Core/Headers/Window.h>
+
+/// 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