summaryrefslogtreecommitdiffhomepage
path: root/SCIKit
diff options
context:
space:
mode:
authorAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-07-30 08:49:23 +0200
committerAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-07-30 08:49:23 +0200
commitbf642edd6c77d405637f0695452460640b8e540d (patch)
treee8e78f658e5eac62790a0fb8129a491183db92d5 /SCIKit
parent60902ec5fc462128d264f63f279c7fc362a72e1d (diff)
[Refactor] SCIKit and DDKit.
[IMP} Prevent DDK from being included when we aren't in kernel mode. Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'SCIKit')
-rw-r--r--SCIKit/ErrorTypes.hxx53
-rw-r--r--SCIKit/Hint.hxx23
-rw-r--r--SCIKit/StandardInterface.hxx123
-rw-r--r--SCIKit/compile_flags.txt4
-rw-r--r--SCIKit/source_deploy.xml5
5 files changed, 208 insertions, 0 deletions
diff --git a/SCIKit/ErrorTypes.hxx b/SCIKit/ErrorTypes.hxx
new file mode 100644
index 00000000..041786ba
--- /dev/null
+++ b/SCIKit/ErrorTypes.hxx
@@ -0,0 +1,53 @@
+/* -------------------------------------------
+
+ Copyright ZKA Technologies
+
+------------------------------------------- */
+
+#pragma once
+
+#include <SCI/StandardInterface.hxx>
+
+#ifdef __KERNEL__
+#error !!! including header in kernel mode !!!
+#endif // __KERNEL__
+
+#define ErrLocalIsOk() (kLastError == kErrorSuccess)
+#define ErrLocalFailed() (kLastError != kErrorSuccess)
+#define ErrLocal() (kLastError)
+
+typedef SInt32 HError;
+
+inline constexpr HError kErrorSuccess = 0;
+inline constexpr HError kErrorExecutable = 33;
+inline constexpr HError kErrorExecutableLib = 34;
+inline constexpr HError kErrorFileNotFound = 35;
+inline constexpr HError kErrorDirectoryNotFound = 36;
+inline constexpr HError kErrorDiskReadOnly = 37;
+inline constexpr HError kErrorDiskIsFull = 38;
+inline constexpr HError kErrorProcessFault = 39;
+inline constexpr HError kErrorSocketHangUp = 40;
+inline constexpr HError kErrorThreadLocalStorage = 41;
+inline constexpr HError kErrorMath = 42;
+inline constexpr HError kErrorNoNetwork = 43;
+inline constexpr HError kErrorHeapOutOfMemory = 44;
+inline constexpr HError kErrorNoSuchDisk = 45;
+inline constexpr HError kErrorFileExists = 46;
+inline constexpr HError kErrorFormatFailed = 47;
+inline constexpr HError kErrorNetworkTimeout = 48;
+inline constexpr HError kErrorInternal = 49;
+inline constexpr HError kErrorForkAlreadyExists = 50;
+inline constexpr HError kErrorOutOfTeamSlot = 51;
+inline constexpr HError kErrorHeapNotPresent = 52;
+inline constexpr HError kErrorNoEntrypoint = 53;
+inline constexpr HError kErrorDiskIsCorrupted = 54;
+inline constexpr HError kErrorDisk = 55;
+inline constexpr HError kErrorInvalidData = 56;
+inline constexpr HError kErrorAsync = 57;
+inline constexpr HError kErrorNonBlocking = 58;
+inline constexpr HError kErrorIPC = 59;
+inline constexpr HError kErrorSign = 60;
+inline constexpr HError kErrorInvalidCreds = 61;
+inline constexpr HError kErrorUnimplemented = 0;
+
+inline HError kLastError = 0;
diff --git a/SCIKit/Hint.hxx b/SCIKit/Hint.hxx
new file mode 100644
index 00000000..fd91ece9
--- /dev/null
+++ b/SCIKit/Hint.hxx
@@ -0,0 +1,23 @@
+/* -------------------------------------------
+
+ Copyright ZKA Technologies
+
+------------------------------------------- */
+
+#ifndef __SCI_HINT_HXX__
+#define __SCI_HINT_HXX__
+
+#pragma compiler(hint_manifest)
+
+#define _Input
+#define _Output
+
+#define _Optional
+
+#define _StrictCheckInput
+#define _StrictCheckOutput
+
+#define _InOut
+#define _StrictInOut
+
+#endif // ifndef __SCI_HINT_HXX__
diff --git a/SCIKit/StandardInterface.hxx b/SCIKit/StandardInterface.hxx
new file mode 100644
index 00000000..9e792546
--- /dev/null
+++ b/SCIKit/StandardInterface.hxx
@@ -0,0 +1,123 @@
+/* -------------------------------------------
+
+Copyright ZKA Technologies.
+
+File: newstd.hxx.
+Purpose: System Call Interface.
+
+------------------------------------------- */
+
+#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;
+
+/**
+ @brief System call class.
+*/
+class SCISharedInterface
+{
+public:
+ explicit SCISharedInterface() = default;
+ virtual ~SCISharedInterface() = default;
+
+ SCISharedInterface& operator=(const SCISharedInterface&) = default;
+ SCISharedInterface(const SCISharedInterface&) = default;
+
+public:
+ /// @brief disable device.
+ virtual UInt0 PowerOff(PowerID) = 0;
+
+ /// @brief enable device.
+ virtual UInt0 PowerOn(PowerID) = 0;
+
+ /// @brief reboot device.
+ virtual UInt0 PowerReboot(PowerID) = 0;
+
+ /// @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;
+
+ // THOSE DOESNT REQUIRE PERMISSIONS FROM THE USER. //
+
+ /// @brief terminate app.
+ virtual UInt0 Terminate() = 0;
+
+ /// @brief exit thread.
+ virtual Bool Exit(FD code) = 0;
+
+ /// @brief alloc pointer.
+ virtual UInt0* New(long long sz) = 0;
+
+ /// @brief free pointer.
+ virtual UInt0 Delete(void* ptr) = 0;
+
+ // THOSE MAY REQUIRE PERMISSIONS FROM THE USER. //
+
+ /// @brief Open descriptor.
+ virtual FD OpenStorage(const char* path, const char* restr) = 0;
+
+ /// @brief Close descriptor.
+ virtual UInt0 CloseStorage(FD descriptorType) = 0;
+
+ /// @brief Execute from shell.
+ virtual FD URLExecute(const UTFChar* shellLink) = 0;
+
+ /// @brief Read descriptor.
+ virtual UInt0* ReadStorage(const UTFChar* cmdNameOrData, SizeT cmdSize, FD descriptorType) = 0;
+
+ /// @brief Seek in storage file
+ virtual UInt64 SeekStorage(FD descriptorType, UInt64 offset) = 0;
+
+ /// @brief Tell storage cursor.
+ virtual UInt64 TellStorage(FD descriptorType) = 0;
+
+ /// @brief Remove stored file.
+ virtual UInt64 RemoveStorage(FD descriptorType) = 0;
+
+ /// @brief Create stored file.
+ virtual FD CreateStorage(const UTFChar* fileName, UInt64 flags) = 0;
+
+ /// @brief Write descriptor.
+ 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/compile_flags.txt b/SCIKit/compile_flags.txt
new file mode 100644
index 00000000..509e3eed
--- /dev/null
+++ b/SCIKit/compile_flags.txt
@@ -0,0 +1,4 @@
+-I./
+-I../Kernel
+-I../
+-std=c++20
diff --git a/SCIKit/source_deploy.xml b/SCIKit/source_deploy.xml
new file mode 100644
index 00000000..088bbb75
--- /dev/null
+++ b/SCIKit/source_deploy.xml
@@ -0,0 +1,5 @@
+<SourceDeploy>
+<HiddenFiles>
+ <SourceFile>*.cxx</SourceFile>
+</HiddenFiles>
+</SourceDeploy>