diff options
| author | Amlal EL Mahrouss <amlalelmahrouss@icloud.com> | 2024-07-30 10:01:42 +0200 |
|---|---|---|
| committer | Amlal EL Mahrouss <amlalelmahrouss@icloud.com> | 2024-07-30 10:01:42 +0200 |
| commit | 6ea68d219dc3a1bcc0deef1683e8442082025940 (patch) | |
| tree | 5a6879105a374bb4353959790d85c5de88de6be8 | |
| parent | bf642edd6c77d405637f0695452460640b8e540d (diff) | |
[IMP] SCIKit: SharedInterface1 and UnknownInterface, both are defined in foreign SOs.
[REFACTOR] IPCEP is just now IPC.
Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
| -rw-r--r-- | .vscode/c_cpp_properties.json | 6 | ||||
| -rw-r--r-- | Kernel/HALKit/AMD64/HalKernelMain.cxx | 4 | ||||
| -rw-r--r-- | Kernel/HALKit/ARM64/HalKernelMain.cxx | 4 | ||||
| -rw-r--r-- | Kernel/KernelKit/User.hxx | 1 | ||||
| -rw-r--r-- | Kernel/NetworkKit/IPC.hxx (renamed from Kernel/NetworkKit/IPCEP.hxx) | 25 | ||||
| -rw-r--r-- | Kernel/NetworkKit/NetworkDevice.hpp | 2 | ||||
| -rw-r--r-- | Kernel/Sources/Network/IPC.cxx (renamed from Kernel/Sources/Network/IPCEP.cxx) | 6 | ||||
| -rw-r--r-- | SCIKit/ErrorTypes.cxx | 9 | ||||
| -rw-r--r-- | SCIKit/ErrorTypes.hxx | 8 | ||||
| -rw-r--r-- | SCIKit/SharedInterface1.hxx (renamed from SCIKit/StandardInterface.hxx) | 58 | ||||
| -rw-r--r-- | SCIKit/Types.hxx | 69 | ||||
| -rw-r--r-- | SCIKit/makefile | 7 |
12 files changed, 122 insertions, 77 deletions
diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 1c195e89..2cb9e3a7 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -1,10 +1,9 @@ { "configurations": [ { - "name": "MicroKernel (Macintosh)", + "name": "Kernel (Macintosh)", "includePath": [ "${workspaceFolder}/Kernel/**", - "${workspaceFolder}/Drv/**", "${workspaceFolder}/Boot/**", "${workspaceFolder}/**" ], @@ -25,9 +24,8 @@ "intelliSenseMode": "gcc-x64" }, { - "name": "MicroKernel (Windows)", + "name": "Kernel (Windows)", "includePath": [ - "${workspaceFolder}/Drv/**", "${workspaceFolder}/Kernel/**", "${workspaceFolder}/Boot/**", "${workspaceFolder}/**" diff --git a/Kernel/HALKit/AMD64/HalKernelMain.cxx b/Kernel/HALKit/AMD64/HalKernelMain.cxx index 1628e5e9..a4067c84 100644 --- a/Kernel/HALKit/AMD64/HalKernelMain.cxx +++ b/Kernel/HALKit/AMD64/HalKernelMain.cxx @@ -17,7 +17,7 @@ #include <Modules/CoreCG/Accessibility.hxx> #include <KernelKit/CodeManager.hpp> #include <Modules/ACPI/ACPIFactoryInterface.hxx> -#include <NetworkKit/IPCEP.hxx> +#include <NetworkKit/IPC.hxx> #include <CFKit/Property.hpp> #define mInitKernel(X) \ @@ -141,7 +141,7 @@ EXTERN_C void hal_init_platform( }; kSyscalls[cLPCSanitizeMsg].Leak().Leak()->fProc = [](Kernel::VoidPtr rdx) -> void { - Kernel::ipc_sanitize_packet(reinterpret_cast<Kernel::IPCEPMessageHeader*>(rdx)); + Kernel::ipc_sanitize_packet(reinterpret_cast<Kernel::IPC_MESSAGE_STRUCT*>(rdx)); }; kSyscalls[cNewInterrupt].Leak().Leak()->fProc = [](Kernel::VoidPtr rdx) -> void { diff --git a/Kernel/HALKit/ARM64/HalKernelMain.cxx b/Kernel/HALKit/ARM64/HalKernelMain.cxx index a2d215f6..a5285f0f 100644 --- a/Kernel/HALKit/ARM64/HalKernelMain.cxx +++ b/Kernel/HALKit/ARM64/HalKernelMain.cxx @@ -17,7 +17,7 @@ #include <Modules/CoreCG/Accessibility.hxx> #include <KernelKit/CodeManager.hpp> #include <Modules/ACPI/ACPIFactoryInterface.hxx> -#include <NetworkKit/IPCEP.hxx> +#include <NetworkKit/IPC.hxx> #define KERNEL_INIT(X) \ X; \ @@ -99,7 +99,7 @@ EXTERN_C void hal_init_platform( }; kSyscalls[cLPCSanitizeMsg].Leak().Leak()->fProc = [](Kernel::VoidPtr rdx) -> void { - Kernel::ipc_sanitize_packet(reinterpret_cast<Kernel::IPCEPMessageHeader*>(rdx)); + Kernel::ipc_sanitize_packet(reinterpret_cast<Kernel::IPC_MESSAGE_STRUCT*>(rdx)); }; kSyscalls[cNewInterrupt].Leak().Leak()->fProc = [](Kernel::VoidPtr rdx) -> void { diff --git a/Kernel/KernelKit/User.hxx b/Kernel/KernelKit/User.hxx index 861fd17a..c84910c5 100644 --- a/Kernel/KernelKit/User.hxx +++ b/Kernel/KernelKit/User.hxx @@ -57,6 +57,7 @@ namespace Kernel public: /// @brief Get software ring const RingKind& Ring() noexcept; + /// @brief Get user name StringView& Name() noexcept; diff --git a/Kernel/NetworkKit/IPCEP.hxx b/Kernel/NetworkKit/IPC.hxx index 7a7d8fc9..e53d8f1c 100644 --- a/Kernel/NetworkKit/IPCEP.hxx +++ b/Kernel/NetworkKit/IPC.hxx @@ -2,7 +2,7 @@ Copyright ZKA Technologies. - File: IPCEP.hxx. + File: IPC.hxx. Purpose: IPC protocol. ------------------------------------------- */ @@ -13,7 +13,8 @@ #include <NewKit/Defines.hpp> #include <NewKit/String.hpp> -/// @brief IPC Endpoint Protocol (IPCEP for short). +/// @file IPC.hxx +/// @brief IPC protocol. /// IA separator. #define cRemoteSeparator "." @@ -26,7 +27,7 @@ namespace Kernel { /// @brief 128-bit IPC address. - struct PACKED IPCEPAddress final + struct PACKED IPC_ADDRESS_STRUCT final { UInt64 ProcessID; UInt64 ProcessTeam; @@ -35,18 +36,18 @@ namespace Kernel // some operators. //////////////////////////////////// - bool operator==(const IPCEPAddress& addr) noexcept + bool operator==(const IPC_ADDRESS_STRUCT& addr) noexcept { return addr.ProcessID == this->ProcessID && addr.ProcessTeam == this->ProcessTeam; } - bool operator==(IPCEPAddress& addr) noexcept + bool operator==(IPC_ADDRESS_STRUCT& addr) noexcept { return addr.ProcessID == this->ProcessID && addr.ProcessTeam == this->ProcessTeam; } }; - typedef struct IPCEPAddress IPCEPAddressType; + typedef struct IPC_ADDRESS_STRUCT IPCEPAddressKind; enum { @@ -56,24 +57,24 @@ namespace Kernel constexpr auto cIPCEPMsgSize = 6094U; - /// @brief IPCEP connection header, message cannot be greater than 6K. - typedef struct IPCEPMessageHeader final + /// @brief IPC connection header, message cannot be greater than 6K. + typedef struct IPC_MESSAGE_STRUCT final { UInt32 IpcHeaderMagic; // cRemoteHeaderMagic UInt8 IpcEndianess; // 0 : LE, 1 : BE SizeT IpcPacketSize; - IPCEPAddressType IpcFrom; - IPCEPAddressType IpcTo; + IPCEPAddressKind IpcFrom; + IPCEPAddressKind IpcTo; UInt32 IpcCRC32; UInt32 IpcMsg; UInt32 IpcMsgSz; UInt8 IpcData[cIPCEPMsgSize]; - } PACKED IPCEPMessageHeader; + } PACKED IPC_MESSAGE_STRUCT; /// @brief Sanitize packet function /// @retval true packet is correct. /// @retval false packet is incorrect and process has crashed. - Bool ipc_sanitize_packet(IPCEPMessageHeader* pckt); + Bool ipc_sanitize_packet(IPC_MESSAGE_STRUCT* pckt); } // namespace Kernel #endif // _INC_IPC_ENDPOINT_HXX_ diff --git a/Kernel/NetworkKit/NetworkDevice.hpp b/Kernel/NetworkKit/NetworkDevice.hpp index 956475aa..eed5f071 100644 --- a/Kernel/NetworkKit/NetworkDevice.hpp +++ b/Kernel/NetworkKit/NetworkDevice.hpp @@ -62,7 +62,7 @@ namespace Kernel /// @brief PPP device. using PPPNetworkDevice = NetworkDevice; - /// @brief IPCEP device. + /// @brief IPC device. using IPCEPNetworkDevice = NetworkDevice; /// @brief GRPS device. diff --git a/Kernel/Sources/Network/IPCEP.cxx b/Kernel/Sources/Network/IPC.cxx index 5271be05..12ec6c1a 100644 --- a/Kernel/Sources/Network/IPCEP.cxx +++ b/Kernel/Sources/Network/IPC.cxx @@ -4,7 +4,7 @@ ------------------------------------------- */ -#include <NetworkKit/IPCEP.hxx> +#include <NetworkKit/IPC.hxx> #include <KernelKit/LPC.hxx> #include <KernelKit/ProcessScheduler.hxx> @@ -12,7 +12,7 @@ using namespace Kernel; /// @internal /// @brief The internal sanitize function. -Bool ipc_int_sanitize_packet(IPCEPMessageHeader* pckt) +Bool ipc_int_sanitize_packet(IPC_MESSAGE_STRUCT* pckt) { auto endian = DEDUCE_ENDIAN(pckt, ((char*)pckt)[0]); @@ -54,7 +54,7 @@ namespace Kernel /// @brief Sanitize packet function /// @retval true packet is correct. /// @retval false packet is incorrect and process has crashed. - Bool ipc_sanitize_packet(IPCEPMessageHeader* pckt) + Bool ipc_sanitize_packet(IPC_MESSAGE_STRUCT* pckt) { if (!pckt || !ipc_int_sanitize_packet(pckt)) diff --git a/SCIKit/ErrorTypes.cxx b/SCIKit/ErrorTypes.cxx new file mode 100644 index 00000000..7bd4146a --- /dev/null +++ b/SCIKit/ErrorTypes.cxx @@ -0,0 +1,9 @@ +/* -------------------------------------------
+
+ Copyright ZKA Technologies
+
+------------------------------------------- */
+
+#include <SCIKit/ErrorTypes.hxx>
+
+HError kLastError = 0;
\ No newline at end of file diff --git a/SCIKit/ErrorTypes.hxx b/SCIKit/ErrorTypes.hxx index 041786ba..4473722a 100644 --- a/SCIKit/ErrorTypes.hxx +++ b/SCIKit/ErrorTypes.hxx @@ -6,11 +6,7 @@ #pragma once -#include <SCI/StandardInterface.hxx> - -#ifdef __KERNEL__ -#error !!! including header in kernel mode !!! -#endif // __KERNEL__ +#include <SCIKit/Types.hxx> #define ErrLocalIsOk() (kLastError == kErrorSuccess) #define ErrLocalFailed() (kLastError != kErrorSuccess) @@ -50,4 +46,4 @@ inline constexpr HError kErrorSign = 60; inline constexpr HError kErrorInvalidCreds = 61; inline constexpr HError kErrorUnimplemented = 0; -inline HError kLastError = 0; +IMPORT_C HError kLastError; diff --git a/SCIKit/StandardInterface.hxx b/SCIKit/SharedInterface1.hxx index 9e792546..b1f7ce9d 100644 --- a/SCIKit/StandardInterface.hxx +++ b/SCIKit/SharedInterface1.hxx @@ -2,59 +2,27 @@ Copyright ZKA Technologies.
-File: newstd.hxx.
-Purpose: System Call Interface.
+File: StandardInterface1.hxx.
+Purpose: System Call Interface Version 1.
------------------------------------------- */
#ifndef __SCI_STD_HXX__
#define __SCI_STD_HXX__
-#ifdef __KERNEL__
-#error !!! including header in kernel mode !!!
-#endif // __KERNEL__
-
-#define IMPORT_CXX extern "C++"
-#define IMPORT_C extern "C"
-
-#define cRestrictR "r"
-#define cRestrictRB "rb"
-#define cRestrictW "w"
-#define cRestrictRW "rw"
-
-class SCISharedInterface; /// @brief System call class.
-
-typedef long long int FD;
-typedef bool Bool;
-typedef void UInt0;
-
-typedef __UINT64_TYPE__ UInt64;
-typedef __UINT32_TYPE__ UInt32;
-typedef __UINT16_TYPE__ UInt16;
-typedef __UINT8_TYPE__ UInt8;
-
-typedef __SIZE_TYPE__ SizeT;
-
-typedef __INT64_TYPE__ SInt64;
-typedef __INT32_TYPE__ SInt32;
-typedef __INT16_TYPE__ SInt16;
-typedef __INT8_TYPE__ SInt8;
-
-typedef char UTFChar;
-
-typedef UInt32 PowerID;
+#include <SCIKit/Types.hxx>
/**
@brief System call class.
*/
-class SCISharedInterface
+class __attribute__((uuid_of(SharedInterface1))) SharedInterface1 : public UnknownInterface
{
public:
- explicit SCISharedInterface() = default;
- virtual ~SCISharedInterface() = default;
+ explicit SharedInterface1() = default;
+ virtual ~SharedInterface1() = default;
- SCISharedInterface& operator=(const SCISharedInterface&) = default;
- SCISharedInterface(const SCISharedInterface&) = default;
+ SharedInterface1& operator=(const SharedInterface1&) = default;
+ SharedInterface1(const SharedInterface1&) = default;
public:
/// @brief disable device.
@@ -69,8 +37,8 @@ public: /// @brief check if MBCI device is wokeup.
virtual Bool PowerIsWokeup(PowerID) = 0;
- /// @brief probe MBCI/ACPI device from phone.
- virtual PowerID PowerProbeDevice(const char* namepace, const int index) = 0;
+ /// @brief probe MBCI/ACPI device from device.
+ virtual PowerID PowerProbeDevice(const char* namezpace, const int index) = 0;
// THOSE DOESNT REQUIRE PERMISSIONS FROM THE USER. //
@@ -89,7 +57,7 @@ public: // THOSE MAY REQUIRE PERMISSIONS FROM THE USER. //
/// @brief Open descriptor.
- virtual FD OpenStorage(const char* path, const char* restr) = 0;
+ virtual FD OpenStorage(const char* path, const UInt32 restr) = 0;
/// @brief Close descriptor.
virtual UInt0 CloseStorage(FD descriptorType) = 0;
@@ -116,8 +84,4 @@ public: virtual UInt0* WriteStorage(const UTFChar* cmdNameOrData, SizeT cmdSize, FD descriptorType) = 0;
};
-/// @brief Get shared syscall object.
-/// @return Syscall implementation.
-IMPORT_C SCISharedInterface* SCIGetSharedInterface(UInt0);
-
#endif // ifndef __SCI_STD_HXX__
diff --git a/SCIKit/Types.hxx b/SCIKit/Types.hxx new file mode 100644 index 00000000..c6c93fdc --- /dev/null +++ b/SCIKit/Types.hxx @@ -0,0 +1,69 @@ +/* -------------------------------------------
+
+Copyright ZKA Technologies.
+
+File: Types.hxx.
+Purpose: System Call types.
+
+------------------------------------------- */
+
+
+#pragma once
+
+#define IMPORT_CXX extern "C++"
+#define IMPORT_C extern "C"
+
+#define cRestrictR 1
+#define cRestrictRB 2
+#define cRestrictW 4
+#define cRestrictRW 6
+
+typedef long long int FD;
+typedef bool Bool;
+typedef void UInt0;
+
+typedef __UINT64_TYPE__ UInt64;
+typedef __UINT32_TYPE__ UInt32;
+typedef __UINT16_TYPE__ UInt16;
+typedef __UINT8_TYPE__ UInt8;
+
+typedef __SIZE_TYPE__ SizeT;
+
+typedef __INT64_TYPE__ SInt64;
+typedef __INT32_TYPE__ SInt32;
+typedef __INT16_TYPE__ SInt16;
+typedef __INT8_TYPE__ SInt8;
+
+typedef char UTFChar;
+
+typedef UInt32 PowerID;
+
+// Interfaces are divided between classes.
+// So that they aren't too big.
+
+class SharedInterface1;
+class SharedInterface2;
+class SharedInterface3;
+class UnknownInterface;
+class EncodingInterface;
+
+class __attribute__((uuid_of(UnknownInterface))) UnknownInterface
+{
+public:
+ explicit UnknownInterface() = default;
+ virtual ~UnknownInterface() = default;
+
+ UnknownInterface& operator=(const UnknownInterface&) = default;
+ UnknownInterface(const UnknownInterface&) = default;
+
+ SInt32 Release() { return -1; }
+
+ template <typename TCLS>
+ SInt32 Release(TCLS* cls) { return -1; }
+
+ template <typename TCLS, typename UCLSID>
+ TCLS* QueryInterface(UCLSID uclsidOfCls) { return nullptr; }
+};
+
+template <typename TCLS, typename UCLSID>
+TCLS* SciGetClassFromCLSID(UCLSID uclsidOfCls);
\ No newline at end of file diff --git a/SCIKit/makefile b/SCIKit/makefile new file mode 100644 index 00000000..2989d18c --- /dev/null +++ b/SCIKit/makefile @@ -0,0 +1,7 @@ +######################
+# (C) ZKA
+######################
+
+.PHONY: build-sci
+build-sci:
+ g++ *.cxx -I../ -shared -fPIC -o libSCI.so
\ No newline at end of file |
