summaryrefslogtreecommitdiffhomepage
path: root/dev/sci
diff options
context:
space:
mode:
authorAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-10-09 13:06:53 +0200
committerAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-10-09 13:06:53 +0200
commit122681ad5bc13ceece505e030a1141d2ae76c252 (patch)
tree92a3647489f17d51d62344233bb91b61e15270f1 /dev/sci
parent2a51866f3f39d4ebf0fd2d132cfad1e2962d1236 (diff)
IMP: Implemented SCI Memory Manager following functions: MmFillMemory
and MmCopyMemory. Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'dev/sci')
-rw-r--r--dev/sci/sci_base.hxx15
-rw-r--r--dev/sci/src/sci_base.cxx7
-rw-r--r--dev/sci/src/sci_mm.cxx52
3 files changed, 62 insertions, 12 deletions
diff --git a/dev/sci/sci_base.hxx b/dev/sci/sci_base.hxx
index 70a0f7f4..f0eff474 100644
--- a/dev/sci/sci_base.hxx
+++ b/dev/sci/sci_base.hxx
@@ -208,8 +208,11 @@ IMPORT_C VoidPtr MmCreateHeap(_Input SizeT len, _Input UInt32 flags);
/// @return void.
IMPORT_C Void MmDestroyHeap(_Input VoidPtr heap);
-/// @brief Change protection flags of memory region.
-IMPORT_C UInt32 MmChangeHeapFlags(_Input VoidPtr heap, _Input UInt32 flags);
+/// @brief Change protection flags of a memory region.
+IMPORT_C Void MmSetHeapFlags(_Input VoidPtr heap, _Input UInt32 flags);
+
+/// @brief Change protection flags of a memory region.
+IMPORT_C UInt32 MmGetHeapFlags(_Input VoidPtr heap);
/// @brief Fill memory region with CRC32.
IMPORT_C UInt32 MmFillCRC32Heap(_Input VoidPtr heap);
@@ -243,12 +246,14 @@ IMPORT_C Void ThrExitMainThread(_Input SInt32 exit_code);
/// @param exit_code the exit code.
IMPORT_C Void ThrExitThread(_Input ThreadObject thread, _Input SInt32 exit_code);
-typedef Void(*GenericThreadFn)(Void);
+typedef Void(*ThreadProc)(Void);
/// @brief Create a thread.
-/// @param proc the thread procedure.
+/// @param procedure the thread procedure.
+/// @param argument_count number of arguments inside that thread.
+/// @param flags Thread flags.
/// @return the thread object.
-IMPORT_C ThreadObject ThrCreateThread(GenericThreadFn proc);
+IMPORT_C ThreadObject ThrCreateThread(ThreadProc procedure, SInt32 argument_count, SInt32 flags);
/// @brief Yield the current thread.
/// @param thread the thread to yield.
diff --git a/dev/sci/src/sci_base.cxx b/dev/sci/src/sci_base.cxx
deleted file mode 100644
index d2897cb3..00000000
--- a/dev/sci/src/sci_base.cxx
+++ /dev/null
@@ -1,7 +0,0 @@
-/* -------------------------------------------
-
- Copyright ZKA Technologies.
-
-------------------------------------------- */
-
-#include <sci/sci_base.hxx>
diff --git a/dev/sci/src/sci_mm.cxx b/dev/sci/src/sci_mm.cxx
new file mode 100644
index 00000000..eff54501
--- /dev/null
+++ b/dev/sci/src/sci_mm.cxx
@@ -0,0 +1,52 @@
+/* -------------------------------------------
+
+ Copyright ZKA Technologies.
+
+------------------------------------------- */
+
+#include <sci/sci_base.hxx>
+
+/// @file sci_base.cxx
+/// @brief Base Memory Manager functions for SCI.dll
+
+/// @brief Debug error prompt, when a function misbehaves.
+/// @param msg
+/// @return
+IMPORT_C Void __RtlRaiseSoftError(const char* msg);
+
+/// @brief Copy memory region.
+IMPORT_C VoidPtr MmCopyMemory(_Input VoidPtr dest, _Input VoidPtr src, _Input SizeT len)
+{
+ if (!len ||
+ !dest ||
+ !src)
+ {
+ __RtlRaiseSoftError("Debug Error, MmCopyMemory contains one or more invalid arguments.");
+ return nullptr;
+ }
+
+ for (SizeT i = 0; i < len; i++)
+ {
+ ((Char*)dest)[i] = ((Char*)src)[i];
+ }
+
+ return dest;
+}
+
+/// @brief Fill memory region with **value**.
+IMPORT_C VoidPtr MmFillMemory(_Input VoidPtr dest, _Input SizeT len, _Input UInt8 value)
+{
+ if (!len ||
+ !dest)
+ {
+ __RtlRaiseSoftError("Debug Error, MmFillMemory contains one or more invalid arguments.");
+ return nullptr;
+ }
+
+ for (SizeT i = 0; i < len; i++)
+ {
+ ((Char*)dest)[i] = value;
+ }
+
+ return dest;
+}