summaryrefslogtreecommitdiffhomepage
path: root/Public/Developer/System.Core
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-03-26 20:00:41 +0100
committerAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-03-26 20:01:41 +0100
commit5ab8bb9c497f673a81da693e9aacc78210718000 (patch)
tree3ae1d5fe040c2c09e92e121436a54650b0adcd35 /Public/Developer/System.Core
parent9a0c2664b0ca5634aa557b0761139cccfb0fe753 (diff)
Kernel: Implement more API calls.
Signed-off-by: Amlal El Mahrouss <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'Public/Developer/System.Core')
-rw-r--r--Public/Developer/System.Core/AMD64/HCoreAssemblyRoutines.s4
-rw-r--r--Public/Developer/System.Core/Headers/Defines.hxx11
-rw-r--r--Public/Developer/System.Core/Headers/Dialog.hxx7
-rw-r--r--Public/Developer/System.Core/Headers/Heap.hxx10
-rw-r--r--Public/Developer/System.Core/Headers/Thread.hxx15
-rw-r--r--Public/Developer/System.Core/Headers/TrueType.hxx12
-rw-r--r--Public/Developer/System.Core/Headers/Window.hxx4
-rw-r--r--Public/Developer/System.Core/Makefile2
-rw-r--r--Public/Developer/System.Core/Sources/CRT0.cxx2
-rw-r--r--Public/Developer/System.Core/Sources/Heap.cxx8
-rw-r--r--Public/Developer/System.Core/Sources/New+Delete.cxx10
11 files changed, 58 insertions, 27 deletions
diff --git a/Public/Developer/System.Core/AMD64/HCoreAssemblyRoutines.s b/Public/Developer/System.Core/AMD64/HCoreAssemblyRoutines.s
index 3876175b..58bb1260 100644
--- a/Public/Developer/System.Core/AMD64/HCoreAssemblyRoutines.s
+++ b/Public/Developer/System.Core/AMD64/HCoreAssemblyRoutines.s
@@ -4,12 +4,12 @@
.section .text
-.globl HcGetAppObject
+.globl RtGetAppObject
.globl __assert_chk_fail
/* @brief Process object getter */
/* @throws: ApptError: appartement error. */
-HcGetAppObject:
+RtGetAppObject:
mov $0x10, %rcx /* sysGetProcessObject */
int $0x21
diff --git a/Public/Developer/System.Core/Headers/Defines.hxx b/Public/Developer/System.Core/Headers/Defines.hxx
index 55810d9d..9932298e 100644
--- a/Public/Developer/System.Core/Headers/Defines.hxx
+++ b/Public/Developer/System.Core/Headers/Defines.hxx
@@ -117,7 +117,7 @@ typedef CharacterTypeUTF8 BooleanType;
#define CA_CONSTEXPR
#endif // __cplusplus
-enum HcProcessCall {
+enum RtProcessCall {
kProcessCallAllocPtr = 1,
kProcessCallFreePtr,
kProcessCallSizePtr,
@@ -181,15 +181,8 @@ using StrType = CharacterTypeUTF8[N];
#endif // ifdef C++
-CA_EXTERN_C ObjectRef HcGetAppObject(VoidType);
+CA_EXTERN_C ObjectRef RtGetAppObject(VoidType);
CA_INLINE ObjectRef kApplicationObject;
typedef CharacterTypeUTF8 Str255Type[255];
-
-/// @brief Shows an message box with a formatting.
-/// @param title the message box title
-/// @param format the format
-/// @param va_list the va args, that goes along with it.
-/// @return void
-CA_EXTERN_C VoidType MsgBox(CharacterTypeUTF8* title, CharacterTypeUTF8* format, ...);
diff --git a/Public/Developer/System.Core/Headers/Dialog.hxx b/Public/Developer/System.Core/Headers/Dialog.hxx
index 0fc4e738..1cc97a6e 100644
--- a/Public/Developer/System.Core/Headers/Dialog.hxx
+++ b/Public/Developer/System.Core/Headers/Dialog.hxx
@@ -7,3 +7,10 @@
#pragma once
#include <System.Core/Headers/Window.hxx>
+
+/// @brief Shows an message box with a formatting.
+/// @param title the message box title
+/// @param format the format
+/// @param va_list the va args, that goes along with it.
+/// @return void
+CA_EXTERN_C VoidType MsgBox(CharacterTypeUTF8* title, CharacterTypeUTF8* format, ...);
diff --git a/Public/Developer/System.Core/Headers/Heap.hxx b/Public/Developer/System.Core/Headers/Heap.hxx
index 98ee5bd2..c6252c04 100644
--- a/Public/Developer/System.Core/Headers/Heap.hxx
+++ b/Public/Developer/System.Core/Headers/Heap.hxx
@@ -10,7 +10,7 @@
#define kAllocationTypes 2
-enum HcAllocationKind {
+enum RtAllocationKind {
kStandardAllocation = 0xC,
kArrayAllocation = 0xD,
};
@@ -20,13 +20,13 @@ enum HcAllocationKind {
/// @param sz
/// @param flags
/// @return
-CA_EXTERN_C PtrVoidType HcAllocateProcessHeap(ObjectRef refObj, QWordType sz,
+CA_EXTERN_C PtrVoidType RtAllocateProcessHeap(ObjectRef refObj, QWordType sz,
DWordType flags);
/// @brief Check if pointer exists.
/// @param refObj
/// @param ptr
/// @return
-CA_EXTERN_C BooleanType HcProcessHeapExists(ObjectRef refObj, PtrVoidType ptr);
-CA_EXTERN_C QWordType HcProcessHeapSize(ObjectRef refObj, PtrVoidType ptr);
-CA_EXTERN_C VoidType HcFreeProcessHeap(ObjectRef refObj, PtrVoidType ptr);
+CA_EXTERN_C BooleanType RtProcessHeapExists(ObjectRef refObj, PtrVoidType ptr);
+CA_EXTERN_C QWordType RtProcessHeapSize(ObjectRef refObj, PtrVoidType ptr);
+CA_EXTERN_C VoidType RtFreeProcessHeap(ObjectRef refObj, PtrVoidType ptr);
diff --git a/Public/Developer/System.Core/Headers/Thread.hxx b/Public/Developer/System.Core/Headers/Thread.hxx
index df803860..a441041d 100644
--- a/Public/Developer/System.Core/Headers/Thread.hxx
+++ b/Public/Developer/System.Core/Headers/Thread.hxx
@@ -13,6 +13,8 @@
#include <System.Core/Headers/Defines.hxx>
+#define kThreadErrorExit -33
+
/// @brief Thread Information Block, which holds information about the running
/// thread.
typedef QWordType ThreadRef;
@@ -20,4 +22,17 @@ typedef QWordType ThreadRef;
/// @brief Main application thread.
CA_EXTERN_C ThreadRef kMainThread;
+typedef VoidType(*ThreadEntrypointKind)(VoidType);
+
+/// @brief Creates a new thread, and runs the code.
+/// @param threadName the thread's name.
+/// @param threadStart where to start.
+/// @return
+CA_EXTERN_C ThreadRef CreateThread(const CharacterTypeUTF8* threadName, ThreadEntrypointKind threadStart);
+
+/// @brief Dispoes the thread, and exits with code kThreadErrorExit
+/// @param ref
+/// @return
+CA_EXTERN_C VoidType DisposeThread(ThreadRef ref);
+
#endif // __THREAD_API__
diff --git a/Public/Developer/System.Core/Headers/TrueType.hxx b/Public/Developer/System.Core/Headers/TrueType.hxx
index 14a85823..001d986e 100644
--- a/Public/Developer/System.Core/Headers/TrueType.hxx
+++ b/Public/Developer/System.Core/Headers/TrueType.hxx
@@ -17,3 +17,15 @@
* Copyright Mahrouss Logic, all rights reserved.
*
*************************************************************/
+
+typedef QWordType TTFFontRef;
+
+/// @brief Loads a new font into app's memory.
+/// @param name
+/// @return
+CA_EXTERN_C TTFFontRef CreateFont(const char* name);
+
+/// @brief Dispose an allocated font.
+/// @param fon
+/// @return
+CA_EXTERN_C VoidType DisposeFont(TTFFontRef fon); \ No newline at end of file
diff --git a/Public/Developer/System.Core/Headers/Window.hxx b/Public/Developer/System.Core/Headers/Window.hxx
index 02be0681..b7671661 100644
--- a/Public/Developer/System.Core/Headers/Window.hxx
+++ b/Public/Developer/System.Core/Headers/Window.hxx
@@ -21,7 +21,11 @@
struct _GraphicsPoint;
struct _GraphicsPort;
+#ifdef __SINGLE_PRECISION__
typedef float PositionType;
+#else
+typedef double PositionType;
+#endif
/// @brief A point, can represent the size, position of a window.
typedef struct _GraphicsPoint {
diff --git a/Public/Developer/System.Core/Makefile b/Public/Developer/System.Core/Makefile
index c4a97c30..11e4760f 100644
--- a/Public/Developer/System.Core/Makefile
+++ b/Public/Developer/System.Core/Makefile
@@ -4,7 +4,7 @@
##################################################
CC=x86_64-w64-mingw32-g++
-CCFLAGS=-shared -ffreestanding -nostdlib -fno-rtti -fno-exceptions -std=c++20 -Xlinker --subsystem=17
+CCFLAGS=-shared -ffreestanding -D__SINGLE_PRECISION__ -nostdlib -fno-rtti -fno-exceptions -std=c++20 -Xlinker --subsystem=17
OUTPUT=System.Core.lib
.PHONY: build-core-amd64
diff --git a/Public/Developer/System.Core/Sources/CRT0.cxx b/Public/Developer/System.Core/Sources/CRT0.cxx
index b6fb9de1..244e62d5 100644
--- a/Public/Developer/System.Core/Sources/CRT0.cxx
+++ b/Public/Developer/System.Core/Sources/CRT0.cxx
@@ -7,7 +7,7 @@
/// @brief Inits the library.
/// @return if it was succesful or not.
CA_EXTERN_C DWordType __start(VoidType) {
- kApplicationObject = HcGetAppObject();
+ kApplicationObject = RtGetAppObject();
CA_MUST_PASS(kApplicationObject);
return 0;
diff --git a/Public/Developer/System.Core/Sources/Heap.cxx b/Public/Developer/System.Core/Sources/Heap.cxx
index fcd80a7f..991987ca 100644
--- a/Public/Developer/System.Core/Sources/Heap.cxx
+++ b/Public/Developer/System.Core/Sources/Heap.cxx
@@ -11,7 +11,7 @@
/// @param sz size of object.
/// @param flags flags.
/// @return
-CA_EXTERN_C PtrVoidType HcAllocateProcessHeap(ObjectRef refObj, QWordType sz,
+CA_EXTERN_C PtrVoidType RtAllocateProcessHeap(ObjectRef refObj, QWordType sz,
DWordType flags) {
CA_MUST_PASS(sz);
CA_MUST_PASS(flags);
@@ -22,7 +22,7 @@ CA_EXTERN_C PtrVoidType HcAllocateProcessHeap(ObjectRef refObj, QWordType sz,
/// @brief Free pointer from the user's heap.
/// @param refObj Process object.
/// @param ptr the pointer to free.
-CA_EXTERN_C VoidType HcFreeProcessHeap(ObjectRef refObj, PtrVoidType ptr) {
+CA_EXTERN_C VoidType RtFreeProcessHeap(ObjectRef refObj, PtrVoidType ptr) {
CA_MUST_PASS(ptr);
CA_UNREFERENCED_PARAMETER(refObj->Invoke(refObj, kProcessCallFreePtr, ptr));
}
@@ -31,7 +31,7 @@ CA_EXTERN_C VoidType HcFreeProcessHeap(ObjectRef refObj, PtrVoidType ptr) {
/// @param refObj Process object.
/// @param ptr the pointer to find.
/// @return the size.
-CA_EXTERN_C QWordType HcProcessHeapSize(ObjectRef refObj, PtrVoidType ptr) {
+CA_EXTERN_C QWordType RtProcessHeapSize(ObjectRef refObj, PtrVoidType ptr) {
CA_MUST_PASS(ptr);
return refObj->Invoke(refObj, kProcessCallSizePtr, ptr);
}
@@ -40,7 +40,7 @@ CA_EXTERN_C QWordType HcProcessHeapSize(ObjectRef refObj, PtrVoidType ptr) {
/// @param refObj Process object.
/// @param ptr the pointer to check.
/// @return if it exists
-CA_EXTERN_C BooleanType HcProcessHeapExists(ObjectRef refObj, PtrVoidType ptr) {
+CA_EXTERN_C BooleanType RtProcessHeapExists(ObjectRef refObj, PtrVoidType ptr) {
CA_MUST_PASS(ptr);
return refObj->Invoke(refObj, kProcessCallCheckPtr, ptr);
}
diff --git a/Public/Developer/System.Core/Sources/New+Delete.cxx b/Public/Developer/System.Core/Sources/New+Delete.cxx
index 6e40aa06..3901aed1 100644
--- a/Public/Developer/System.Core/Sources/New+Delete.cxx
+++ b/Public/Developer/System.Core/Sources/New+Delete.cxx
@@ -11,25 +11,25 @@ typedef SizeType size_t;
void* operator new[](size_t sz) {
if (sz == 0) ++sz;
- return HcAllocateProcessHeap(kApplicationObject, sz, kStandardAllocation);
+ return RtAllocateProcessHeap(kApplicationObject, sz, kStandardAllocation);
}
void* operator new(size_t sz) {
if (sz == 0) ++sz;
- return HcAllocateProcessHeap(kApplicationObject, sz, kArrayAllocation);
+ return RtAllocateProcessHeap(kApplicationObject, sz, kArrayAllocation);
}
void operator delete[](void* ptr) {
if (ptr == nullptr) return;
- HcFreeProcessHeap(kApplicationObject, ptr);
+ RtFreeProcessHeap(kApplicationObject, ptr);
}
void operator delete(void* ptr) {
if (ptr == nullptr) return;
- HcFreeProcessHeap(kApplicationObject, ptr);
+ RtFreeProcessHeap(kApplicationObject, ptr);
}
void operator delete(void* ptr, size_t sz) {
@@ -37,5 +37,5 @@ void operator delete(void* ptr, size_t sz) {
(void)sz;
- HcFreeProcessHeap(kApplicationObject, ptr);
+ RtFreeProcessHeap(kApplicationObject, ptr);
}