summaryrefslogtreecommitdiffhomepage
path: root/Public/Developer/SystemLib/Sources
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-03-29 17:01:55 +0100
committerAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-03-29 17:06:28 +0100
commit7e5be1572c043484293ee0cdd840dd41f54e87ee (patch)
tree171427b27eb240d4006fda89e485ce6da28fd749 /Public/Developer/SystemLib/Sources
parentd7eb7affee3733dfeee6864045da4c2f5df2e919 (diff)
Kernel and SystemLib: See below.
What has been done: - Rename most System.Core to SystemLib. - Reworked it's API and the concept of ObjectRef to become the ApplicationRef object. - Remove unused ODF and XIFF file format from tree, ODF will be part of the text editing program. - Update Readme for SystemLib. - Add Support folder on NewFS partitions. What is next: - NewFS filesystem support. - Program loading. - Preemptive scheduler on non-SMP systems using timers. Signed-off-by: Amlal El Mahrouss <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'Public/Developer/SystemLib/Sources')
-rw-r--r--Public/Developer/SystemLib/Sources/Application.c25
-rw-r--r--Public/Developer/SystemLib/Sources/ApplicationStart.c14
-rw-r--r--Public/Developer/SystemLib/Sources/Heap.c42
-rw-r--r--Public/Developer/SystemLib/Sources/Window.c70
4 files changed, 151 insertions, 0 deletions
diff --git a/Public/Developer/SystemLib/Sources/Application.c b/Public/Developer/SystemLib/Sources/Application.c
new file mode 100644
index 00000000..d7a83d3e
--- /dev/null
+++ b/Public/Developer/SystemLib/Sources/Application.c
@@ -0,0 +1,25 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#include <Headers/Defines.h>
+
+/// @brief Main Application object, retrieved from the RtGetAppObject symbol.
+ApplicationRef kSharedApplication = NullPtr;
+
+/// @brief Gets the app arguments count.
+/// @param void no arguments.
+/// @return
+CA_EXTERN_C SizeType RtGetAppArgumentsCount(VoidType) {
+ return kSharedApplication->Invoke(kSharedApplication, kCallGetArgsCount);
+}
+
+/// @brief Gets the app arguments pointer.
+/// @param void no arguments.
+/// @return
+CA_EXTERN_C CharacterTypeUTF8* RtGetAppArgumentsPtr(VoidType) {
+ return (CharacterTypeUTF8*)kSharedApplication->Invoke(kSharedApplication,
+ kCallGetArgsPtr);
+} \ No newline at end of file
diff --git a/Public/Developer/SystemLib/Sources/ApplicationStart.c b/Public/Developer/SystemLib/Sources/ApplicationStart.c
new file mode 100644
index 00000000..5b91ba18
--- /dev/null
+++ b/Public/Developer/SystemLib/Sources/ApplicationStart.c
@@ -0,0 +1,14 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#include <Headers/Defines.h>
+
+/// @brief Inits the system library.
+/// @return if it was succesful or not.
+CA_EXTERN_C VoidType __start(VoidType) {
+ kSharedApplication = RtGetAppObject();
+ CA_MUST_PASS(kSharedApplication);
+}
diff --git a/Public/Developer/SystemLib/Sources/Heap.c b/Public/Developer/SystemLib/Sources/Heap.c
new file mode 100644
index 00000000..c9b2b938
--- /dev/null
+++ b/Public/Developer/SystemLib/Sources/Heap.c
@@ -0,0 +1,42 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#include <Headers/Heap.h>
+
+/// @brief Allocate from the user's heap.
+/// @param sz size of object.
+/// @param flags flags.
+/// @return
+CA_EXTERN_C PtrVoidType RtAllocateProcessPtr(QWordType sz,
+ DWordType flags) {
+ 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 RtFreeProcessPtr(PtrVoidType ptr) {
+ 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 RtProcessPtrSize(PtrVoidType ptr) {
+ 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 RtProcessPtrExists(PtrVoidType ptr) {
+ CA_MUST_PASS(ptr);
+ return kSharedApplication->Invoke(kSharedApplication, kCallCheckPtr, ptr);
+}
diff --git a/Public/Developer/SystemLib/Sources/Window.c b/Public/Developer/SystemLib/Sources/Window.c
new file mode 100644
index 00000000..2527e041
--- /dev/null
+++ b/Public/Developer/SystemLib/Sources/Window.c
@@ -0,0 +1,70 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#include <Headers/Window.h>
+
+/// invalid resource handle, they always start from 1.
+#define kInvalidRsrc (0U)
+
+/////////////////////////////////////////////////////////////////////////
+
+CA_EXTERN_C WindowPort* WmCreateWindow(const CharacterTypeUTF8* name,
+ const DWordType rsrcId) {
+ CA_MUST_PASS(name);
+ CA_MUST_PASS(rsrcId != kInvalidRsrc);
+
+ return (WindowPort*)kSharedApplication->Invoke(
+ kSharedApplication, kCallCreateWindow, name, rsrcId);
+}
+
+/////////////////////////////////////////////////////////////////////////
+
+CA_EXTERN_C VoidType WmReleaseWindow(WindowPort* winPort) {
+ CA_MUST_PASS(winPort);
+
+ kSharedApplication->Invoke(kSharedApplication, kCallCloseWindow, winPort);
+}
+
+/////////////////////////////////////////////////////////////////////////
+
+CA_EXTERN_C WindowPort* WmCreateMenu(const CharacterTypeUTF8* name,
+ const DWordType rsrcId) {
+ CA_MUST_PASS(name);
+ CA_MUST_PASS(rsrcId != kInvalidRsrc);
+
+ return (WindowPort*)kSharedApplication->Invoke(kSharedApplication,
+ kCallCreateMenu, name, rsrcId);
+}
+
+/////////////////////////////////////////////////////////////////////////
+
+CA_EXTERN_C VoidType WmReleaseMenu(WindowPort* winPort) {
+ CA_MUST_PASS(winPort);
+
+ kSharedApplication->Invoke(kSharedApplication, 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;
+}
+
+/// @brief Color refs.
+
+const ColorRef kRgbRed = 0x000000FF;
+const ColorRef kRgbGreen = 0x0000FF00;
+const ColorRef kRgbBlue = 0x00FF0000;
+const ColorRef kRgbBlack = 0x00000000;
+const ColorRef kRgbWhite = 0xFFFFFFFF;