From 3facc32b746a44b0e3a91cbe1897127194396d1b Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Wed, 3 Apr 2024 09:20:28 +0200 Subject: 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 --- Public/Developer/SystemLib/Sources/Application.c | 6 ++-- .../Developer/SystemLib/Sources/ApplicationStart.c | 2 +- Public/Developer/SystemLib/Sources/File.c | 38 ++++++++++++++++++++++ Public/Developer/SystemLib/Sources/Heap.c | 10 +++--- 4 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 Public/Developer/SystemLib/Sources/File.c (limited to 'Public/Developer/SystemLib/Sources') 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 -/// @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 +#include + +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 #include /// @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. -- cgit v1.2.3