summaryrefslogtreecommitdiffhomepage
path: root/dev
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-08-28 08:00:52 +0200
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-08-28 08:00:52 +0200
commit3c233e380524d6842d396fd0a1fb9aeacf34d35f (patch)
tree30ea7f65f614c96e60cb514d8402c352cdc05879 /dev
parentcdaf8e9379f1756a9416f455ff5552fb8871c16d (diff)
[IMP] Add ipc_construct_packet function to IPC protocol implementation.
[IMP] Update Endian enum to match the one from the IPC protocol. [IMP] MUST_PASS works in debug only now. Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev')
-rw-r--r--dev/EFS/EncryptFS.hxx6
-rw-r--r--dev/SCI/scm_core.hxx2
-rw-r--r--dev/SCI/scm_xpcom.idl36
-rw-r--r--dev/SCI/scm_xpcom.inl30
-rw-r--r--dev/SIGG/SIGG.hxx (renamed from dev/SIGG/Format.hxx)0
-rw-r--r--dev/SYSDRV/.keep (renamed from dev/ZGM/.keep)0
-rw-r--r--dev/SYSDRV/Sources/WindowMgr.cxx10
-rw-r--r--dev/SYSDRV/WindowMgr.hxx (renamed from dev/ZGM/Sources/WindowCompositor.cxx)20
-rw-r--r--dev/SYSDRV/build.json (renamed from dev/ZGM/build.json)2
-rw-r--r--dev/ZBA/Sources/Thread.cxx2
-rw-r--r--dev/ZKA/Modules/CoreCG/WindowRenderer.hxx4
-rw-r--r--dev/ZKA/NetworkKit/IPC.hxx23
-rw-r--r--dev/ZKA/NewKit/Defines.hxx5
-rw-r--r--dev/ZKA/NewKit/KernelCheck.hxx7
-rw-r--r--dev/ZKA/Sources/Network/IPC.cxx45
15 files changed, 137 insertions, 55 deletions
diff --git a/dev/EFS/EncryptFS.hxx b/dev/EFS/EncryptFS.hxx
index 4348027b..4aa82666 100644
--- a/dev/EFS/EncryptFS.hxx
+++ b/dev/EFS/EncryptFS.hxx
@@ -14,3 +14,9 @@
#pragma once
#include <FSKit/NewFS.hxx>
+
+namespace EncryptFS
+{
+ using namespace Kernel;
+
+} \ No newline at end of file
diff --git a/dev/SCI/scm_core.hxx b/dev/SCI/scm_core.hxx
index 5b4c26f4..ef0a8b5b 100644
--- a/dev/SCI/scm_core.hxx
+++ b/dev/SCI/scm_core.hxx
@@ -14,7 +14,7 @@ Purpose: Base code of SCM.
#define protocol class
#define clsid(X)
-#warning ! you may be using the clang version of the newos kit, please be cautious that some thing mayn't be present. !
+#warning ! You may be using the clang version of the ZKA kit, please be cautious that some thing mayn't be present. !
#endif // !__NDK__
// Interfaces are divided between classes.
diff --git a/dev/SCI/scm_xpcom.idl b/dev/SCI/scm_xpcom.idl
new file mode 100644
index 00000000..1fdbd6c9
--- /dev/null
+++ b/dev/SCI/scm_xpcom.idl
@@ -0,0 +1,36 @@
+/* -------------------------------------------
+
+Copyright ZKA Technologies.
+
+File: rt.internal.inl
+Purpose: Base code of SCM.
+
+------------------------------------------- */
+
+/// @internal
+
+#ifndef __NDK__
+#define object class
+#define protocol class
+#define interface private
+#define interface_method
+#define CONST const
+#define CHAR char
+#define INT32 __INT32_TYPE__
+#define SIZE_T __SIZE_TYPE__
+#define _Output
+#define _Input
+#define clsid(X)
+
+#warning ! You may be using the clang version of the ZKA kit, please be cautious that some thing mayn't be present. !
+#endif // !__NDK__
+
+protocol IPXCOMSocket;
+
+clsid("0943A614-0201-4107-8F8D-E909DF7F53C9")
+protocol IPXCOMSocket
+{
+interface:
+ interface_method INT32 SendMessage(_Input CONST CHAR* bytes, _Input SIZE_T bytes_size);
+ interface_method INT32 RecvMessage(_Output CONST CHAR** bytes_in, _Input SIZE_T bytes_size);
+};
diff --git a/dev/SCI/scm_xpcom.inl b/dev/SCI/scm_xpcom.inl
deleted file mode 100644
index 9c63f041..00000000
--- a/dev/SCI/scm_xpcom.inl
+++ /dev/null
@@ -1,30 +0,0 @@
-/* -------------------------------------------
-
-Copyright ZKA Technologies.
-
-File: rt.internal.inl
-Purpose: Base code of SCM.
-
-------------------------------------------- */
-
-/// @internal
-
-#ifndef __NDK__
-#define object class
-#define protocol class
-#define interface private
-#define method
-#define clsid(X)
-
-#warning ! you may be using the clang version of the newos kit, please be cautious that some thing mayn't be present. !
-#endif // !__NDK__
-
-protocol IPXCOMSocket;
-
-clsid("0943A614-0201-4107-8F8D-E909DF7F53C9")
-protocol IPXCOMSocket
-{
-interface:
- method SInt32 SendMessage(const Char* bytes, SizeT bytes_size);
- method SInt32 RecvMessage(_Output const Char** bytes_in, _Input SizeT bytes_size);
-};
diff --git a/dev/SIGG/Format.hxx b/dev/SIGG/SIGG.hxx
index e7d9f60b..e7d9f60b 100644
--- a/dev/SIGG/Format.hxx
+++ b/dev/SIGG/SIGG.hxx
diff --git a/dev/ZGM/.keep b/dev/SYSDRV/.keep
index e69de29b..e69de29b 100644
--- a/dev/ZGM/.keep
+++ b/dev/SYSDRV/.keep
diff --git a/dev/SYSDRV/Sources/WindowMgr.cxx b/dev/SYSDRV/Sources/WindowMgr.cxx
new file mode 100644
index 00000000..e39bf733
--- /dev/null
+++ b/dev/SYSDRV/Sources/WindowMgr.cxx
@@ -0,0 +1,10 @@
+/* -------------------------------------------
+
+ Copyright ZKA Technologies.
+
+------------------------------------------- */
+
+#include <WindowMgr.hxx>
+
+/// @file WindowMgr.cxx
+/// @brief Window manager of system driver. \ No newline at end of file
diff --git a/dev/ZGM/Sources/WindowCompositor.cxx b/dev/SYSDRV/WindowMgr.hxx
index da9a0935..ed40285a 100644
--- a/dev/ZGM/Sources/WindowCompositor.cxx
+++ b/dev/SYSDRV/WindowMgr.hxx
@@ -1,10 +1,10 @@
-/* -------------------------------------------
-
- Copyright ZKA Technologies.
-
-------------------------------------------- */
-
-#include <Modules/CoreCG/FbRenderer.hxx>
-
-/// @file WindowCompositor.cxx
-/// @brief Window compoistor, takes care of video regions. \ No newline at end of file
+/* -------------------------------------------
+
+ Copyright ZKA Technologies.
+
+------------------------------------------- */
+
+#pragma once
+
+#include <Modules/CoreCG/FbRenderer.hxx>
+#include <Modules/CoreCG/WindowRenderer.hxx>
diff --git a/dev/ZGM/build.json b/dev/SYSDRV/build.json
index cd8fbe63..d8b1e941 100644
--- a/dev/ZGM/build.json
+++ b/dev/SYSDRV/build.json
@@ -3,7 +3,7 @@
"compiler_std": "c++20",
"headers_path": ["../"],
"sources_path": ["Sources/*.cxx"],
- "output_name": "sgm.sys",
+ "output_name": "sysdrv.sys",
"compiler_flags": [
"-fPIC",
"-ffreestanding",
diff --git a/dev/ZBA/Sources/Thread.cxx b/dev/ZBA/Sources/Thread.cxx
index c850b6ae..2f662f0d 100644
--- a/dev/ZBA/Sources/Thread.cxx
+++ b/dev/ZBA/Sources/Thread.cxx
@@ -15,7 +15,7 @@
#include <CFKit/LoaderUtils.hxx>
#include <Modules/CoreCG/TextRenderer.hxx>
-#include <SIGG/Format.hxx>
+#include <SIGG/SIGG.hxx>
EXTERN_C{
#include <string.h>
diff --git a/dev/ZKA/Modules/CoreCG/WindowRenderer.hxx b/dev/ZKA/Modules/CoreCG/WindowRenderer.hxx
index 1a7d1660..580e2197 100644
--- a/dev/ZKA/Modules/CoreCG/WindowRenderer.hxx
+++ b/dev/ZKA/Modules/CoreCG/WindowRenderer.hxx
@@ -34,6 +34,8 @@ namespace CG
struct UI_WINDOW_STRUCT final
{
+ static constexpr auto cChildElementCount = 255;
+
Char w_window_name[255]{0};
Char w_class_name[255]{0};
Int32 w_type{0};
@@ -43,7 +45,7 @@ namespace CG
Int32 w_w{0};
Int32 w_h{0};
Size w_child_count{0};
- struct UI_WINDOW_STRUCT* w_child_elements[255]{0};
+ struct UI_WINDOW_STRUCT* w_child_elements[cChildElementCount]{0};
struct UI_WINDOW_STRUCT* w_parent{nullptr};
UInt32* display_ptr{nullptr};
Bool w_needs_repaint{false};
diff --git a/dev/ZKA/NetworkKit/IPC.hxx b/dev/ZKA/NetworkKit/IPC.hxx
index eb62f433..069a2c66 100644
--- a/dev/ZKA/NetworkKit/IPC.hxx
+++ b/dev/ZKA/NetworkKit/IPC.hxx
@@ -12,22 +12,25 @@
#include <NewKit/Defines.hxx>
#include <NewKit/String.hxx>
-
+#include <HintKit/CompilerHint.hxx>
#include <CompressKit/RLE.hxx>
/// @file IPC.hxx
-/// @brief IPC protocol.
+/// @brief IPC EP protocol.
/// IA separator.
-#define cRemoteSeparator "."
+#define cIPCEPRemoteSeparator ":"
/// Interchange address, consists of PID:TEAM.
-#define cRemoteInvalid "00:00"
+#define cIPCEPRemoteInvalid "00:00"
-#define cRemoteHeaderMagic (0x4950434)
+#define cIPCEPHeaderMagic (0x4950434)
namespace Kernel
{
+ struct IPC_ADDRESS_STRUCT;
+ struct IPC_MESSAGE_STRUCT;
+
/// @brief 128-bit IPC address.
struct PACKED IPC_ADDRESS_STRUCT final
{
@@ -54,7 +57,8 @@ namespace Kernel
enum
{
eIPCEPLittleEndian = 0,
- eIPCEPBigEndian = 1
+ eIPCEPBigEndian = 1,
+ eIPCEPMixedEndian = 2,
};
constexpr auto cIPCEPMsgSize = 6094U;
@@ -76,7 +80,12 @@ namespace Kernel
/// @brief Sanitize packet function
/// @retval true packet is correct.
/// @retval false packet is incorrect and process has crashed.
- Bool ipc_sanitize_packet(IPC_MESSAGE_STRUCT* pckt);
+ Bool ipc_sanitize_packet(_Input IPC_MESSAGE_STRUCT* pckt_in);
+
+ /// @brief Construct packet function
+ /// @retval true packet is correct.
+ /// @retval false packet is incorrect and process has crashed.
+ Bool ipc_construct_packet(_Output IPC_MESSAGE_STRUCT** pckt_in);
} // namespace Kernel
#endif // _INC_IPC_ENDPOINT_HXX_
diff --git a/dev/ZKA/NewKit/Defines.hxx b/dev/ZKA/NewKit/Defines.hxx
index 47381368..c83ec782 100644
--- a/dev/ZKA/NewKit/Defines.hxx
+++ b/dev/ZKA/NewKit/Defines.hxx
@@ -74,10 +74,11 @@ namespace Kernel
using Lba = UInt64;
- enum class Endian : UChar
+ enum class Endian : UInt8
{
- kEndianLittle,
+ kEndianInvalid,
kEndianBig,
+ kEndianLittle,
kEndianMixed,
kCount
};
diff --git a/dev/ZKA/NewKit/KernelCheck.hxx b/dev/ZKA/NewKit/KernelCheck.hxx
index 30f66ee5..58a76acb 100644
--- a/dev/ZKA/NewKit/KernelCheck.hxx
+++ b/dev/ZKA/NewKit/KernelCheck.hxx
@@ -15,10 +15,17 @@ namespace Kernel
}
#define MUST_PASS_COMPILER(EXPR, MSG) static_assert(EXPR, MSG)
+
#define __MUST_PASS(EXPR, FILE, LINE) \
Kernel::ke_runtime_check(EXPR, FILE, STRINGIFY(LINE))
+
+#ifdef __DEBUG__
#define MUST_PASS(EXPR) __MUST_PASS(EXPR, __FILE__, __LINE__)
#define assert(EXPR) MUST_PASS(EXPR, RUNTIME_CHECK_EXPRESSION)
+#else
+#define MUST_PASS(EXPR) (Kernel::Void)(EXPR)
+#define assert(EXPR) (Kernel::Void)(EXPR)
+#endif
enum RUNTIME_CHECK
{
diff --git a/dev/ZKA/Sources/Network/IPC.cxx b/dev/ZKA/Sources/Network/IPC.cxx
index 926224d9..2ec50892 100644
--- a/dev/ZKA/Sources/Network/IPC.cxx
+++ b/dev/ZKA/Sources/Network/IPC.cxx
@@ -30,8 +30,12 @@ Bool ipc_int_sanitize_packet(IPC_MESSAGE_STRUCT* pckt)
break;
}
- case Endian::kEndianMixed:
+ case Endian::kEndianMixed: {
+ if (pckt->IpcEndianess == eIPCEPMixedEndian)
+ goto ipc_check_failed;
+
break;
+ }
default:
goto ipc_check_failed;
}
@@ -42,7 +46,7 @@ Bool ipc_int_sanitize_packet(IPC_MESSAGE_STRUCT* pckt)
goto ipc_check_failed;
}
- return pckt->IpcPacketSize > 1 && pckt->IpcHeaderMagic == cRemoteHeaderMagic;
+ return pckt->IpcPacketSize > 1 && pckt->IpcHeaderMagic == cIPCEPHeaderMagic;
ipc_check_failed:
ErrLocal() = kErrorIPC;
@@ -65,4 +69,41 @@ namespace Kernel
return true;
}
+
+ /// @brief Construct packet function
+ /// @retval true packet is correct.
+ /// @retval false packet is incorrect and process has crashed.
+ Bool ipc_construct_packet(_Output IPC_MESSAGE_STRUCT** pckt_in)
+ {
+ // don't do anything if it's valid already.
+ if (*pckt_in)
+ return true;
+
+ // crash process if the packet pointer of pointer is NULL.
+ if (!pckt_in)
+ {
+ ProcessScheduler::The().Leak().TheCurrent().Leak().Crash();
+ return false;
+ }
+
+ *pckt_in = new IPC_MESSAGE_STRUCT();
+
+ MUST_PASS((*pckt_in));
+
+ if (*pckt_in)
+ {
+ (*pckt_in)->IpcHeaderMagic = cIPCEPHeaderMagic;
+
+ auto endian = DEDUCE_ENDIAN((*pckt_in), ((Char*)(*pckt_in))[0]);
+
+ (*pckt_in)->IpcEndianess = static_cast<UInt8>(endian);
+ (*pckt_in)->IpcPacketSize = sizeof(IPC_MESSAGE_STRUCT);
+ (*pckt_in)->IpcFrom.ProcessID = Kernel::ProcessScheduler::The().Leak().TheCurrent().Leak().ProcessId;
+ (*pckt_in)->IpcFrom.ProcessTeam = Kernel::ProcessScheduler::The().Leak().CurrentTeam().mTeamId;
+ return true;
+ }
+
+ ProcessScheduler::The().Leak().TheCurrent().Leak().Crash();
+ return false;
+ }
} // namespace Kernel