summaryrefslogtreecommitdiffhomepage
path: root/Public/Developer/SystemLib
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-04-03 09:20:28 +0200
committerAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-04-03 09:20:28 +0200
commit3facc32b746a44b0e3a91cbe1897127194396d1b (patch)
tree0725ebbf35a18e6933596ea5c765ac81adf7834f /Public/Developer/SystemLib
parentefc6b5d169d2b6eaabe7384141cec6054ae622a0 (diff)
MHR-3: See main changes below.
Kernel: Improve Disk interfaces regarding the struct they're using (all of them are using MountpountInterface now) SystemLib: Start adding PowerPC code to the SystemLib to be cross compiled as a PEF FAT binary. Kernel: Adding new builtins to support a wide range of hardware. Signed-off-by: Amlal El Mahrouss <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'Public/Developer/SystemLib')
-rw-r--r--Public/Developer/SystemLib/AMD64/CoreAssembly.s10
-rw-r--r--Public/Developer/SystemLib/Headers/Defines.h23
-rw-r--r--Public/Developer/SystemLib/Headers/File.h4
-rw-r--r--Public/Developer/SystemLib/Makefile1
-rw-r--r--Public/Developer/SystemLib/PowerPC/CoreAssembly.s26
-rw-r--r--Public/Developer/SystemLib/Sources/Application.c6
-rw-r--r--Public/Developer/SystemLib/Sources/ApplicationStart.c2
-rw-r--r--Public/Developer/SystemLib/Sources/File.c38
-rw-r--r--Public/Developer/SystemLib/Sources/Heap.c10
9 files changed, 100 insertions, 20 deletions
diff --git a/Public/Developer/SystemLib/AMD64/CoreAssembly.s b/Public/Developer/SystemLib/AMD64/CoreAssembly.s
index 58bb1260..1d361621 100644
--- a/Public/Developer/SystemLib/AMD64/CoreAssembly.s
+++ b/Public/Developer/SystemLib/AMD64/CoreAssembly.s
@@ -4,19 +4,19 @@
.section .text
-.globl RtGetAppObject
-.globl __assert_chk_fail
+.globl RtGetApp
+.globl RtAssertTriggerInterrupt
-/* @brief Process object getter */
+/* @brief Application getter */
/* @throws: ApptError: appartement error. */
-RtGetAppObject:
+RtGetApp:
mov $0x10, %rcx /* sysGetProcessObject */
int $0x21
/* rax gets saved and returned. */
ret
-__assert_chk_fail:
+RtAssertTriggerInterrupt:
mov $0x11, %rcx /* sysTerminateCurrentProcess */
int $0x21
diff --git a/Public/Developer/SystemLib/Headers/Defines.h b/Public/Developer/SystemLib/Headers/Defines.h
index 6ab27497..d3b6b793 100644
--- a/Public/Developer/SystemLib/Headers/Defines.h
+++ b/Public/Developer/SystemLib/Headers/Defines.h
@@ -11,7 +11,7 @@
#endif
#ifdef _DEBUG
-#define CA_MUST_PASS(e) { if (!e) { DlgMsgBox("Sorry, an assertion failed.\nFile: %s\nLine: %i", __FILE__, __LINE__) __assert_chk_fail() } }
+#define CA_MUST_PASS(e) { if (!e) { DlgMsgBox("Sorry, an assertion failed.\nFile: %s\nLine: %i", __FILE__, __LINE__) RtAssertTriggerInterrupt() } }
#else
#define CA_MUST_PASS(e) CA_UNREFERENCED_PARAMETER(e)
#endif
@@ -29,7 +29,7 @@
struct Application;
struct GUID;
-CA_EXTERN_C void __assert_chk_fail(void);
+CA_EXTERN_C void RtAssertTriggerInterrupt(void);
#define CA_STDCALL __attribute__((stdcall))
#define CA_CDECL __attribute__((cdecl))
@@ -115,6 +115,10 @@ enum RtProcessCall {
/// @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,
@@ -180,9 +184,20 @@ using StrType = CharacterTypeUTF8[N];
#endif // ifdef C++
-CA_EXTERN_C ApplicationRef RtGetAppObject(VoidType);
+/// @brief Get app singleton.
+/// @param
+/// @return
+CA_EXTERN_C ApplicationRef RtGetApp(VoidType);
+
+/// @brief Get argument count
+/// @param
+/// @return
CA_EXTERN_C SizeType RtGetAppArgumentsCount(VoidType);
-CA_EXTERN_C CharacterTypeUTF8* RtGetAppArgumentsPtr(VoidType);
+
+/// @brief Get argument pointer.
+/// @param
+/// @return
+CA_EXTERN_C CharacterTypeUTF8** RtGetAppArgumentsPtr(VoidType);
CA_EXTERN_C ApplicationRef kSharedApplication;
diff --git a/Public/Developer/SystemLib/Headers/File.h b/Public/Developer/SystemLib/Headers/File.h
index 6333bf6a..5e58d104 100644
--- a/Public/Developer/SystemLib/Headers/File.h
+++ b/Public/Developer/SystemLib/Headers/File.h
@@ -23,8 +23,6 @@ CA_EXTERN_C FSRef FsOpenFile(const CharacterTypeUTF8* path, const CharacterTypeU
/// @return
CA_EXTERN_C VoidType FsCloseFile(FSRef refFs);
-typedef QWordType FSForkRef;
-
/// @brief A fork information header.
typedef struct _Fork {
PtrVoidType forkData;
@@ -34,6 +32,8 @@ typedef struct _Fork {
CharacterTypeUTF8 forkName[256];
} ForkType;
+typedef ForkType* FSForkRef;
+
/// @brief Gets the fork inside a file.
/// @param refFs the filesystem ref
/// @param forkName the fork's name
diff --git a/Public/Developer/SystemLib/Makefile b/Public/Developer/SystemLib/Makefile
index f7a30572..a753ccc8 100644
--- a/Public/Developer/SystemLib/Makefile
+++ b/Public/Developer/SystemLib/Makefile
@@ -5,7 +5,6 @@
CC=x86_64-w64-mingw32-gcc
AR=x86_64-w64-mingw32-ar
-ARFLAGS=-rcs
CCINC=-I./
CCFLAGS=-D__SINGLE_PRECISION__ -nostdlib -std=c17 -ffreestanding -Xlinker --subsystem=17 -shared
OUTPUT=SystemLib.lib
diff --git a/Public/Developer/SystemLib/PowerPC/CoreAssembly.s b/Public/Developer/SystemLib/PowerPC/CoreAssembly.s
new file mode 100644
index 00000000..7fef98e3
--- /dev/null
+++ b/Public/Developer/SystemLib/PowerPC/CoreAssembly.s
@@ -0,0 +1,26 @@
+/** ===========================================
+ (C) Mahrouss Logic
+ Purpose: PowerPC low-level routines.
+ ===========================================*/
+
+.section .text
+
+.globl RtGetApp
+.globl RtAssertTriggerInterrupt
+.balign 4
+
+/* @brief Application getter */
+/* @throws: ApptError: appartement error. */
+RtGetApp:
+ stw 0x10, 0(3) /* sysGetProcessObject */
+ sc
+
+ blr
+
+RtAssertTriggerInterrupt:
+ stw 0x11, 0(3) /* sysTerminateCurrentProcess */
+ stw 0x3, 0(4)
+ sc
+
+ blr
+
diff --git a/Public/Developer/SystemLib/Sources/Application.c b/Public/Developer/SystemLib/Sources/Application.c
index d7a83d3e..f1391975 100644
--- a/Public/Developer/SystemLib/Sources/Application.c
+++ b/Public/Developer/SystemLib/Sources/Application.c
@@ -6,7 +6,7 @@
#include <Headers/Defines.h>
-/// @brief Main Application object, retrieved from the RtGetAppObject symbol.
+/// @brief Main Application object, retrieved from the RtGetApp symbol.
ApplicationRef kSharedApplication = NullPtr;
/// @brief Gets the app arguments count.
@@ -19,7 +19,7 @@ CA_EXTERN_C SizeType RtGetAppArgumentsCount(VoidType) {
/// @brief Gets the app arguments pointer.
/// @param void no arguments.
/// @return
-CA_EXTERN_C CharacterTypeUTF8* RtGetAppArgumentsPtr(VoidType) {
- return (CharacterTypeUTF8*)kSharedApplication->Invoke(kSharedApplication,
+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
index 5b91ba18..0960388e 100644
--- a/Public/Developer/SystemLib/Sources/ApplicationStart.c
+++ b/Public/Developer/SystemLib/Sources/ApplicationStart.c
@@ -9,6 +9,6 @@
/// @brief Inits the system library.
/// @return if it was succesful or not.
CA_EXTERN_C VoidType __start(VoidType) {
- kSharedApplication = RtGetAppObject();
+ kSharedApplication = RtGetApp();
CA_MUST_PASS(kSharedApplication);
}
diff --git a/Public/Developer/SystemLib/Sources/File.c b/Public/Developer/SystemLib/Sources/File.c
new file mode 100644
index 00000000..1432e7e0
--- /dev/null
+++ b/Public/Developer/SystemLib/Sources/File.c
@@ -0,0 +1,38 @@
+/* -------------------------------------------
+
+ 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 r the restrict (rw, rwe, r+, w+, r, w)
+/// @return
+CA_EXTERN_C FSRef FsOpenFile(const CharacterTypeUTF8* path, const CharacterTypeUTF8* r) {
+ CA_MUST_PASS(kSharedApplication);
+ CA_MUST_PASS(path);
+ CA_MUST_PASS(r);
+
+ return kSharedApplication->Invoke(kSharedApplication, kCallOpenFile, path, 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) {
+ CA_MUST_PASS(kSharedApplication);
+
+ kSharedApplication->Invoke(kSharedApplication, refFs, kFlushFile);
+ kSharedApplication->Invoke(kSharedApplication, kCallCloseFile, refFs);
+} \ No newline at end of file
diff --git a/Public/Developer/SystemLib/Sources/Heap.c b/Public/Developer/SystemLib/Sources/Heap.c
index c866ef5d..041c5764 100644
--- a/Public/Developer/SystemLib/Sources/Heap.c
+++ b/Public/Developer/SystemLib/Sources/Heap.c
@@ -4,25 +4,27 @@
------------------------------------------- */
+#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_EXTERN_C PtrVoidType RtTlsAllocate(QWordType sz, DWordType flags) {
CA_MUST_PASS(sz);
CA_MUST_PASS(flags);
- return (PtrVoidType)kSharedApplication->Invoke(kSharedApplication, kCallAllocPtr, sz, 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(ptr);
- CA_UNREFERENCED_PARAMETER(kSharedApplication->Invoke(kSharedApplication, kCallFreePtr, ptr));
+ CA_UNREFERENCED_PARAMETER(
+ kSharedApplication->Invoke(kSharedApplication, kCallFreePtr, ptr));
}
/// @brief Get pointer size.