summaryrefslogtreecommitdiffhomepage
path: root/SDK/Library
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-05-21 09:10:57 +0200
committerAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-05-21 09:10:57 +0200
commit0c211cca4d7a4d836f4cb685345e44f3f2814fd1 (patch)
treef08901e67cdabe025d8ad40c18c62b27b32c5517 /SDK/Library
parentf022a2afeb7af04ce3ef256ef617d19f07d84d9a (diff)
MHR-23: New CoreSystem calls and refactors.
Signed-off-by: Amlal El Mahrouss <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'SDK/Library')
-rw-r--r--SDK/Library/CoreCxxRuntime/Private.xml3
-rw-r--r--SDK/Library/CorePEFRuntime/Private.xml3
-rw-r--r--SDK/Library/CoreSystem/Headers/Alert.h2
-rw-r--r--SDK/Library/CoreSystem/Headers/Defines.h7
-rw-r--r--SDK/Library/CoreSystem/Headers/File.h16
-rw-r--r--SDK/Library/CoreSystem/Headers/Heap.h12
-rw-r--r--SDK/Library/CoreSystem/Headers/Intl.h9
-rw-r--r--SDK/Library/CoreSystem/Headers/Transport.h29
-rw-r--r--SDK/Library/CoreSystem/Private.xml4
-rw-r--r--SDK/Library/CoreSystem/Sources/CRTStartup.c12
-rw-r--r--SDK/Library/CoreSystem/Sources/File.c27
-rw-r--r--SDK/Library/CoreSystem/Sources/Heap.c9
-rw-r--r--SDK/Library/CoreSystem/amd64.mk2
13 files changed, 105 insertions, 30 deletions
diff --git a/SDK/Library/CoreCxxRuntime/Private.xml b/SDK/Library/CoreCxxRuntime/Private.xml
new file mode 100644
index 00000000..08a95273
--- /dev/null
+++ b/SDK/Library/CoreCxxRuntime/Private.xml
@@ -0,0 +1,3 @@
+<Private>
+ <Ignore/>
+</Private> \ No newline at end of file
diff --git a/SDK/Library/CorePEFRuntime/Private.xml b/SDK/Library/CorePEFRuntime/Private.xml
new file mode 100644
index 00000000..08a95273
--- /dev/null
+++ b/SDK/Library/CorePEFRuntime/Private.xml
@@ -0,0 +1,3 @@
+<Private>
+ <Ignore/>
+</Private> \ No newline at end of file
diff --git a/SDK/Library/CoreSystem/Headers/Alert.h b/SDK/Library/CoreSystem/Headers/Alert.h
index a09a5d57..7decd4ca 100644
--- a/SDK/Library/CoreSystem/Headers/Alert.h
+++ b/SDK/Library/CoreSystem/Headers/Alert.h
@@ -22,4 +22,4 @@
/// @param fmt The alert formating.
/// @param
/// @return
-CS_EXTERN_C VoidType Alert(const CharacterTypeUTF8* fmt, ...);
+CS_EXTERN_C VoidType UiAlert(const CharacterTypeUTF8* fmt, ...);
diff --git a/SDK/Library/CoreSystem/Headers/Defines.h b/SDK/Library/CoreSystem/Headers/Defines.h
index 1b6a27c6..a7e46234 100644
--- a/SDK/Library/CoreSystem/Headers/Defines.h
+++ b/SDK/Library/CoreSystem/Headers/Defines.h
@@ -15,7 +15,7 @@
{ \
if (!e) \
{ \
- Alert("Sorry, an assertion failed.\nFile: %s\nLine: %i", __FILE__, __LINE__) RtAssertTriggerInterrupt() \
+ UiAlert("Assertion failed.\nExpression :%s\nFile: %s\nLine: %i", #e, __FILE__, __LINE__) RtAssertTriggerInterrupt() \
} \
}
#else
@@ -144,6 +144,11 @@ enum RtProcessCall
kCallRandomNumberGenerator,
kCallGetArgsCount,
kCallGetArgsPtr,
+ kCallFileExists,
+ kCallDirectoryExists,
+ kCallSymlinkExists,
+ kCallDeviceExists,
+ kCallDriveExists,
/// @brief Number of process calls.
kCallsCount,
};
diff --git a/SDK/Library/CoreSystem/Headers/File.h b/SDK/Library/CoreSystem/Headers/File.h
index da88ecbc..594b4edb 100644
--- a/SDK/Library/CoreSystem/Headers/File.h
+++ b/SDK/Library/CoreSystem/Headers/File.h
@@ -8,6 +8,8 @@
#include <Headers/Defines.h>
+struct _Fork;
+
/// @brief Filesystem wrapper.
typedef QWordType FSRef;
@@ -16,14 +18,14 @@ typedef QWordType FSRef;
/// @param path where to find it.
/// @param rest the restrict (rw, rwe, r+, w+, r, w)
/// @return FSRef the file.
-CS_EXTERN_C FSRef FsOpenFile(const CharacterTypeUTF8* path, const CharacterTypeUTF8* r);
+CS_EXTERN_C FSRef CSOpenFile(const CharacterTypeUTF8* path, const CharacterTypeUTF8* r);
/// @brief Closes the file and flushes it to the said file.
-/// @param refFs the filesystem reference.
+/// @param refCS the filesystem reference.
/// @return
-CS_EXTERN_C VoidType FsCloseFile(FSRef refFs);
+CS_EXTERN_C VoidType CSCloseFile(FSRef refCS);
-#define kMaxForkNameLength 256 /* long fork names. */
+#define kMaxForkNameLength (256U) /* long fork names. */
/// @brief A fork information header.
typedef struct _Fork
@@ -38,13 +40,13 @@ typedef struct _Fork
typedef ForkType* FSForkRef;
/// @brief Gets the fork inside a file.
-/// @param refFs the filesystem ref
+/// @param refCS the filesystem ref
/// @param forkName the fork's name
/// @return the fork data.
-CS_EXTERN_C FSForkRef FsGetFork(FSRef refFs, const CharacterTypeUTF8* forkName);
+CS_EXTERN_C FSForkRef CSGetFork(FSRef refCS, const CharacterTypeUTF8* forkName);
/// @brief Check if the filesystem path is valid.
/// @return if not return false, or true.
-CS_EXTERN_C BooleanType FsIsValidPath(const CharacterTypeUTF8* path);
+CS_EXTERN_C BooleanType CSIsValidPath(const CharacterTypeUTF8* path);
/// END OF FILE
diff --git a/SDK/Library/CoreSystem/Headers/Heap.h b/SDK/Library/CoreSystem/Headers/Heap.h
index 87b356e2..b2ad6e74 100644
--- a/SDK/Library/CoreSystem/Headers/Heap.h
+++ b/SDK/Library/CoreSystem/Headers/Heap.h
@@ -8,9 +8,9 @@
#include <Headers/Defines.h>
-#define kAllocationKindCount (2)
+#define cAllocationKindCount (2U)
-enum RtAllocationKind
+enum CsAllocationKind
{
kStandardAllocation = 0xC,
kArrayAllocation = 0xD,
@@ -20,20 +20,20 @@ enum RtAllocationKind
/// @param sz the size
/// @param flags the allocation flags.
/// @return
-CS_EXTERN_C PtrVoidType RtHeapAllocate(QWordType sz,
+CS_EXTERN_C PtrVoidType CSAllocateHeap(QWordType sz,
DWordType flags);
/// @brief Check if the pointer exists.
/// @param ptr the pointer to free.
/// @return
-CS_EXTERN_C BooleanType RtHeapPtrExists(PtrVoidType ptr);
+CS_EXTERN_C BooleanType CSIsHeapValid(PtrVoidType ptr);
/// @brief Gets the size of the process' pointer.
/// @param ptr the pointer to free.
/// @return
-CS_EXTERN_C QWordType RtHeapGetSize(PtrVoidType ptr);
+CS_EXTERN_C QWordType CSGetHeapSize(PtrVoidType ptr);
/// @brief Frees the process pointer.
/// @param ptr the pointer to free.
/// @return
-CS_EXTERN_C VoidType RtHeapFree(PtrVoidType ptr);
+CS_EXTERN_C VoidType CSFreeHeap(PtrVoidType ptr);
diff --git a/SDK/Library/CoreSystem/Headers/Intl.h b/SDK/Library/CoreSystem/Headers/Intl.h
index 9a06fdfe..b868adca 100644
--- a/SDK/Library/CoreSystem/Headers/Intl.h
+++ b/SDK/Library/CoreSystem/Headers/Intl.h
@@ -12,9 +12,14 @@
typedef UInt64Type IntlRef;
-/// @brief locale getter and setters.
-
+/// @brief Get app locale.
+/// @param name locale name.
+/// @return
IntlRef IntlGetLocale(const char* name);
+
+/// @brief Set app locale.
+/// @param intl the locale
+/// @return
BooleanType IntlSetLocale(const IntlRef intl);
/// @brief locale helpers.
diff --git a/SDK/Library/CoreSystem/Headers/Transport.h b/SDK/Library/CoreSystem/Headers/Transport.h
index aed20e96..3f6db3f1 100644
--- a/SDK/Library/CoreSystem/Headers/Transport.h
+++ b/SDK/Library/CoreSystem/Headers/Transport.h
@@ -16,6 +16,33 @@
#include <Headers/Defines.h>
-typedef QWordType CSStreamType;
+typedef QWordType TrStreamType;
+
+/// @brief Opens a new socket
+/// @param afType address family
+/// @param sockType type of socket
+/// @param sockProto socket protocol.
+/// @return The STREAMS socket.
+/// @note return is const.
+CS_EXTERN_C CS_CONST TrStreamType CSOpenSocket(UInt32Type afType, UInt32Type sockType, UInt32Type sockProto);
+
+/// @brief Close a STREAMS socket.
+/// @param streams The streams socket.
+/// @return
+CS_EXTERN_C VoidType CSCloseSocket(CS_CONST TrStreamType streams);
+
+/// @brief Get OpenTransport version.
+/// @param void
+/// @return
+CS_EXTERN_C CS_CONST Int32Type CSGetVersion(VoidType);
+
+enum
+{
+ TrSocketProtoTCP, /// TCP socket
+ TrSocketProtoUDP, /// UDP socket
+ TrSocketProtoUN, /// IPC socket
+ TrSocketProtoRaw, /// Raw socket
+ TrSocketProtoCount,
+};
#endif // __TRANSPORT__ \ No newline at end of file
diff --git a/SDK/Library/CoreSystem/Private.xml b/SDK/Library/CoreSystem/Private.xml
new file mode 100644
index 00000000..55b0ba71
--- /dev/null
+++ b/SDK/Library/CoreSystem/Private.xml
@@ -0,0 +1,4 @@
+<Private>
+ <File name="Headers/Hint.h" hidden="true"/>
+ <Directory name="Sources/" hidden="true"/>
+</Private> \ No newline at end of file
diff --git a/SDK/Library/CoreSystem/Sources/CRTStartup.c b/SDK/Library/CoreSystem/Sources/CRTStartup.c
new file mode 100644
index 00000000..1cfad65d
--- /dev/null
+++ b/SDK/Library/CoreSystem/Sources/CRTStartup.c
@@ -0,0 +1,12 @@
+/* -------------------------------------------
+
+ Copyright SoftwareLabs
+
+------------------------------------------- */
+
+#include <Headers/Defines.h>
+
+VoidType __DllMainCRTStartup(VoidType)
+{
+ kSharedApplication = RtGetAppPointer();
+} \ No newline at end of file
diff --git a/SDK/Library/CoreSystem/Sources/File.c b/SDK/Library/CoreSystem/Sources/File.c
index 485500ab..7547e7f2 100644
--- a/SDK/Library/CoreSystem/Sources/File.c
+++ b/SDK/Library/CoreSystem/Sources/File.c
@@ -20,11 +20,11 @@ enum FileOp
/// @param path where to find it.
/// @param rest the restrict (rw, rwe, r+, w+, r, w)
/// @return FSRef the file.
-CS_EXTERN_C FSRef FsOpenFile(const CharacterTypeUTF8* path,
+CS_EXTERN_C FSRef CSOpenFile(const CharacterTypeUTF8* path,
const CharacterTypeUTF8* rest)
{
CS_MUST_PASS(kSharedApplication);
- CS_MUST_PASS(path && FsIsValidPath(path) == Yes);
+ CS_MUST_PASS(path && CSIsValidPath(path) == Yes);
CS_MUST_PASS(rest);
return kSharedApplication->Invoke(kSharedApplication, kCallOpenFile, path,
@@ -32,12 +32,27 @@ CS_EXTERN_C FSRef FsOpenFile(const CharacterTypeUTF8* path,
}
/// @brief Closes the file and flushes it to the said file.
-/// @param refFs the filesystem reference.
+/// @param refCS the filesystem reference.
/// @return
-CS_EXTERN_C VoidType FsCloseFile(FSRef refFs)
+CS_EXTERN_C VoidType CSCloseFile(FSRef refCS)
{
CS_MUST_PASS(kSharedApplication);
- kSharedApplication->Invoke(kSharedApplication, refFs, kFlushFile);
- kSharedApplication->Invoke(kSharedApplication, kCallCloseFile, refFs);
+ kSharedApplication->Invoke(kSharedApplication, refCS, kFlushFile);
+ kSharedApplication->Invoke(kSharedApplication, kCallCloseFile, refCS);
}
+
+/// @brief Check if filesystem path is valid.
+/// @param path
+/// @return
+CS_EXTERN_C BooleanType CSIsValidPath(const CharacterTypeUTF8* path)
+{
+ CS_MUST_PASS(kSharedApplication);
+ CS_MUST_PASS(path);
+
+ return kSharedApplication->Invoke(kSharedApplication, kCallFileExists, path) ||
+ kSharedApplication->Invoke(kSharedApplication, kCallDirectoryExists, path) ||
+ kSharedApplication->Invoke(kSharedApplication, kCallSymlinkExists, path) ||
+ kSharedApplication->Invoke(kSharedApplication, kCallDriveExists, path) ||
+ kSharedApplication->Invoke(kSharedApplication, kCallDeviceExists, path);
+} \ No newline at end of file
diff --git a/SDK/Library/CoreSystem/Sources/Heap.c b/SDK/Library/CoreSystem/Sources/Heap.c
index e359aded..e7a77ba5 100644
--- a/SDK/Library/CoreSystem/Sources/Heap.c
+++ b/SDK/Library/CoreSystem/Sources/Heap.c
@@ -11,7 +11,7 @@
/// @param sz size of object.
/// @param flags flags.
/// @return
-CS_EXTERN_C PtrVoidType RtHeapAllocate(QWordType sz, DWordType flags)
+CS_EXTERN_C PtrVoidType CSAllocateHeap(QWordType sz, DWordType flags)
{
CS_MUST_PASS(kSharedApplication);
CS_MUST_PASS(sz);
@@ -23,7 +23,7 @@ CS_EXTERN_C PtrVoidType RtHeapAllocate(QWordType sz, DWordType flags)
/// @brief Free pointer from the user's heap.
/// @param ptr the pointer to free.
-CS_EXTERN_C VoidType RtHeapFree(PtrVoidType ptr)
+CS_EXTERN_C VoidType CSFreeHeap(PtrVoidType ptr)
{
CS_MUST_PASS(kSharedApplication);
CS_MUST_PASS(ptr);
@@ -35,7 +35,7 @@ CS_EXTERN_C VoidType RtHeapFree(PtrVoidType ptr)
/// @brief Get pointer size.
/// @param ptr the pointer to find.
/// @return the size.
-CS_EXTERN_C QWordType RtHeapGetSize(PtrVoidType ptr)
+CS_EXTERN_C QWordType CSGetHeapSize(PtrVoidType ptr)
{
CS_MUST_PASS(kSharedApplication);
@@ -46,10 +46,9 @@ CS_EXTERN_C QWordType RtHeapGetSize(PtrVoidType ptr)
/// @brief Check if the pointer exists.
/// @param ptr the pointer to check.
/// @return if it exists
-CS_EXTERN_C BooleanType RtHeapPtrExists(PtrVoidType ptr)
+CS_EXTERN_C BooleanType CSIsHeapValid(PtrVoidType ptr)
{
CS_MUST_PASS(kSharedApplication);
-
CS_MUST_PASS(ptr);
return kSharedApplication->Invoke(kSharedApplication, kCallCheckPtr, ptr);
}
diff --git a/SDK/Library/CoreSystem/amd64.mk b/SDK/Library/CoreSystem/amd64.mk
index 33303430..e64de90f 100644
--- a/SDK/Library/CoreSystem/amd64.mk
+++ b/SDK/Library/CoreSystem/amd64.mk
@@ -6,7 +6,7 @@
CC=x86_64-w64-mingw32-gcc
AR=x86_64-w64-mingw32-ar
CCINC=-I./
-CCFLAGS=-D__SINGLE_PRECISION__ -nostdlib -std=c17 -ffreestanding -Xlinker --subsystem=17 -shared
+CCFLAGS=-D__SINGLE_PRECISION__ -nostdlib -std=c17 -ffreestanding -Xlinker --subsystem=17 -e __DllMainCRTStartup -shared
OUTPUT=CoreSystem.lib
.PHONY: all