summaryrefslogtreecommitdiffhomepage
path: root/dev/SCIKit
diff options
context:
space:
mode:
authorAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-08-15 18:35:34 +0200
committerAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-08-15 18:35:34 +0200
commitf3d931aa7cfaf96baef8383b59a8938779541ee7 (patch)
treefdb9fc51badb3dbd03e46ab0766a49d9522e13e2 /dev/SCIKit
parent86640816e8b1d3595365f1fcc8a2a9e61fb40ff1 (diff)
[IMP] Moved source code into dev/ folder.
Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'dev/SCIKit')
-rw-r--r--dev/SCIKit/Hint.hxx23
-rw-r--r--dev/SCIKit/ReadMe.md3
-rw-r--r--dev/SCIKit/SCIBase.cxx7
-rw-r--r--dev/SCIKit/SCIBase.hxx185
-rw-r--r--dev/SCIKit/SCIErr.cxx9
-rw-r--r--dev/SCIKit/SCIErr.hxx49
-rw-r--r--dev/SCIKit/SCM.drawio28
-rw-r--r--dev/SCIKit/build.json10
-rw-r--r--dev/SCIKit/compile_flags.txt4
-rw-r--r--dev/SCIKit/makefile12
-rw-r--r--dev/SCIKit/scm.idlparser.inl21
-rw-r--r--dev/SCIKit/scm.internal.inl84
-rw-r--r--dev/SCIKit/source_deploy.xml7
13 files changed, 442 insertions, 0 deletions
diff --git a/dev/SCIKit/Hint.hxx b/dev/SCIKit/Hint.hxx
new file mode 100644
index 00000000..c785f953
--- /dev/null
+++ b/dev/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/dev/SCIKit/ReadMe.md b/dev/SCIKit/ReadMe.md
new file mode 100644
index 00000000..b5f76a9f
--- /dev/null
+++ b/dev/SCIKit/ReadMe.md
@@ -0,0 +1,3 @@
+# Official SCM implementation for New OS
+
+Read the specs for + information... \ No newline at end of file
diff --git a/dev/SCIKit/SCIBase.cxx b/dev/SCIKit/SCIBase.cxx
new file mode 100644
index 00000000..628bfd67
--- /dev/null
+++ b/dev/SCIKit/SCIBase.cxx
@@ -0,0 +1,7 @@
+/* -------------------------------------------
+
+ Copyright ZKA Technologies.
+
+------------------------------------------- */
+
+#include <SCIKit/SCIBase.hxx> \ No newline at end of file
diff --git a/dev/SCIKit/SCIBase.hxx b/dev/SCIKit/SCIBase.hxx
new file mode 100644
index 00000000..b902b5fa
--- /dev/null
+++ b/dev/SCIKit/SCIBase.hxx
@@ -0,0 +1,185 @@
+/* -------------------------------------------
+
+Copyright ZKA Technologies.
+
+File: SCIBase.hxx
+Purpose: SCI/M core header file (C++)
+
+------------------------------------------- */
+
+#ifndef __SCI_BASE_HXX__
+#define __SCI_BASE_HXX__
+
+#ifdef __cplusplus
+
+#include <SCIKit/Hint.hxx>
+
+#define IMPORT_CXX extern "C++"
+#define IMPORT_C extern "C"
+
+#define OBJECT_PATH "::\\"
+
+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 void* VoidPtr;
+typedef __UINTPTR_TYPE__ UIntPtr;
+typedef char Char;
+
+#ifdef __SCI_IMPL__
+#include <SCIKit/scm.internal.inl>
+#else
+class UnknownInterface; // Refrenced from an IDB entry.
+class UnknownUCLSID; // From the IDB, the constructor of the object, e.g: WordUCLSID.
+class UUID;
+
+/// @brief Allocate new SCM class.
+/// @tparam TCLS
+/// @tparam UCLSID
+/// @param uclsidOfCls
+/// @return
+template <typename TCLS, typename UCLSID, typename... Args>
+TCLS* RtlQueryInterface(UCLSID uclsidOfCls, Args... args);
+
+/// @brief Release SCM class.
+/// @tparam TCLS
+/// @param cls
+/// @return
+template <typename TCLS>
+SInt32 RtlReleaseClass(TCLS* cls);
+
+class __attribute__((uuid("d7c144b6-0792-44b8-b06b-02b227b547df"))) UnknownInterface
+{
+public:
+ explicit UnknownInterface() = default;
+ virtual ~UnknownInterface() = default;
+
+ UnknownInterface& operator=(const UnknownInterface&) = default;
+ UnknownInterface(const UnknownInterface&) = default;
+
+ virtual SInt32 Release() = 0;
+ virtual void RemoveRef() = 0;
+ virtual UnknownInterface* AddRef() = 0;
+ virtual VoidPtr QueryInterface(UUID* p_uuid) = 0;
+};
+
+template <typename FnSign, typename ClsID>
+class EventListenerInterface final : public ClsID
+{
+public:
+ explicit EventListenerInterface() = default;
+ virtual ~EventListenerInterface() = default;
+
+ EventListenerInterface& operator=(const EventListenerInterface&) = default;
+ EventListenerInterface(const EventListenerInterface&) = default;
+
+ virtual EventListenerInterface& operator +=(FnSign arg) = 0;
+};
+#endif
+
+// ------------------------------------------------------------------------------------------ //
+/// @note Handle types.
+// ------------------------------------------------------------------------------------------ //
+
+typedef VoidPtr NEW_OBJECT;
+
+typedef NEW_OBJECT DLL_OBJECT;
+typedef NEW_OBJECT IO_OBJECT;
+typedef NEW_OBJECT COMP_OBJECT;
+
+// ------------------------------------------------------------------------------------------ //
+
+// ------------------------------------------------------------------------------------------ //
+/// @note Part of NK loader API.
+// ------------------------------------------------------------------------------------------ //
+
+
+/// @brief Get function which is part of the DLL.
+/// @param symbol the symbol to look for
+/// @param dll_handle the DLL handle.
+/// @return the proc pointer.
+IMPORT_C VoidPtr RtlGetDLLProc(_Input const Char* symbol, _Input NEW_OBJECT dll_handle);
+
+/// @brief Open DLL handle.
+/// @param path
+/// @param drv
+/// @return
+IMPORT_C NEW_OBJECT RtlOpenDLL(_Input const Char* path, _Input const Char* drive_letter);
+
+/// @brief Close DLL handle
+/// @param dll_handle
+/// @return
+IMPORT_C UInt0 RtlCloseDLL(_Input NEW_OBJECT dll_handle);
+
+/// @note Part of NK file API.
+
+/// @brief Opens a file from a drive.
+/// @param fs_path the filesystem path.
+/// @param drive_letter drive name, use NULL to use default one.
+/// @return the file descriptor of the file.
+IMPORT_C NEW_OBJECT RtlOpenFile(const Char* fs_path, const Char* drive_letter);
+
+/// @brief Closes a file and flushes its content.
+/// @param file_desc the file descriptor.
+/// @return
+IMPORT_C UInt0 RtlCloseFile(_Input NEW_OBJECT file_desc);
+
+/// @brief Installs the TIB and GIB inside the current process.
+/// @param none
+/// @return > 0 error ocurred or already present, = 0 success.
+IMPORT_C UInt32 RtlInstallInfoBlocks(UInt0);
+
+/// @brief Allocate new SCM object.
+/// @tparam TCLS the class type.
+/// @tparam UCLSID UCLS factory class type.
+/// @param uclsidOfCls UCLS factory class
+/// @return TCLS interface
+template <typename TCLS, typename UCLSID, typename... Args>
+TCLS* ScmQueryInterface(_Input UCLSID* uclsidOfCls, _Input Args&&... args);
+
+/// @brief Release SCM object.
+/// @tparam TCLS the class type.
+/// @param cls the class to release.
+/// @return status code.
+template <typename TCLS>
+SInt32 ScmReleaseClass(_Input TCLS* cls);
+
+/// @brief Creates an SCM instance in the process.
+/// @param handle_instance the SCM handle.
+/// @param flags the SCM flags.
+SInt32 ScmCreateInstance(_Input UInt32 flags, _Output VoidPtr* handle_instance);
+
+/// @brief Destroys an SCM instance of the process.
+/// @param handle_instance the SCM handle.
+UInt0 ScmDestroyInstance(_Input VoidPtr handle_instance);
+
+/// @brief Creates a new heap from the process's address space.
+/// @param len the length of it.
+/// @param flags the flags of it.
+/// @return heap pointer.
+VoidPtr RtlCreateHeap(_Input SizeT len, _Input UInt32 flags);
+
+/// @brief Destroys the pointer
+/// @param heap the heap itself.
+/// @return void.
+UInt0 RtlDestroyHeap(_Input VoidPtr heap);
+
+#else
+
+#include <SCIKit/SCIBase.h>
+
+#endif // ifdef __cplusplus
+
+#endif // ifndef __SCI_BASE_HXX__ \ No newline at end of file
diff --git a/dev/SCIKit/SCIErr.cxx b/dev/SCIKit/SCIErr.cxx
new file mode 100644
index 00000000..b0766944
--- /dev/null
+++ b/dev/SCIKit/SCIErr.cxx
@@ -0,0 +1,9 @@
+/* -------------------------------------------
+
+ Copyright ZKA Technologies.
+
+------------------------------------------- */
+
+#include <SCIKit/SCIErr.hxx>
+
+NEW_ERROR_TYPE kLastError = 0; \ No newline at end of file
diff --git a/dev/SCIKit/SCIErr.hxx b/dev/SCIKit/SCIErr.hxx
new file mode 100644
index 00000000..aa3e72e4
--- /dev/null
+++ b/dev/SCIKit/SCIErr.hxx
@@ -0,0 +1,49 @@
+/* -------------------------------------------
+
+ Copyright ZKA Technologies.
+
+------------------------------------------- */
+
+#pragma once
+
+#include <SCIKit/SCIBase.hxx>
+
+#define ErrLocalIsOk() (kLastError == kErrorSuccess)
+#define ErrLocalFailed() (kLastError != kErrorSuccess)
+#define ErrLocal() (kLastError)
+
+typedef SInt32 NEW_ERROR_TYPE;
+
+inline constexpr NEW_ERROR_TYPE kErrorSuccess = 0;
+inline constexpr NEW_ERROR_TYPE kErrorExecutable = 33;
+inline constexpr NEW_ERROR_TYPE kErrorExecutableLib = 34;
+inline constexpr NEW_ERROR_TYPE kErrorFileNotFound = 35;
+inline constexpr NEW_ERROR_TYPE kErrorDirectoryNotFound = 36;
+inline constexpr NEW_ERROR_TYPE kErrorDiskReadOnly = 37;
+inline constexpr NEW_ERROR_TYPE kErrorDiskIsFull = 38;
+inline constexpr NEW_ERROR_TYPE kErrorProcessFault = 39;
+inline constexpr NEW_ERROR_TYPE kErrorSocketHangUp = 40;
+inline constexpr NEW_ERROR_TYPE kErrorThreadLocalStorage = 41;
+inline constexpr NEW_ERROR_TYPE kErrorMath = 42;
+inline constexpr NEW_ERROR_TYPE kErrorNoNetwork = 43;
+inline constexpr NEW_ERROR_TYPE kErrorHeapOutOfMemory = 44;
+inline constexpr NEW_ERROR_TYPE kErrorNoSuchDisk = 45;
+inline constexpr NEW_ERROR_TYPE kErrorFileExists = 46;
+inline constexpr NEW_ERROR_TYPE kErrorFormatFailed = 47;
+inline constexpr NEW_ERROR_TYPE kErrorNetworkTimeout = 48;
+inline constexpr NEW_ERROR_TYPE kErrorInternal = 49;
+inline constexpr NEW_ERROR_TYPE kErrorForkAlreadyExists = 50;
+inline constexpr NEW_ERROR_TYPE kErrorOutOfTeamSlot = 51;
+inline constexpr NEW_ERROR_TYPE kErrorHeapNotPresent = 52;
+inline constexpr NEW_ERROR_TYPE kErrorNoEntrypoint = 53;
+inline constexpr NEW_ERROR_TYPE kErrorDiskIsCorrupted = 54;
+inline constexpr NEW_ERROR_TYPE kErrorDisk = 55;
+inline constexpr NEW_ERROR_TYPE kErrorInvalidData = 56;
+inline constexpr NEW_ERROR_TYPE kErrorAsync = 57;
+inline constexpr NEW_ERROR_TYPE kErrorNonBlocking = 58;
+inline constexpr NEW_ERROR_TYPE kErrorIPC = 59;
+inline constexpr NEW_ERROR_TYPE kErrorSign = 60;
+inline constexpr NEW_ERROR_TYPE kErrorInvalidCreds = 61;
+inline constexpr NEW_ERROR_TYPE kErrorUnimplemented = 0;
+
+IMPORT_C NEW_ERROR_TYPE kLastError;
diff --git a/dev/SCIKit/SCM.drawio b/dev/SCIKit/SCM.drawio
new file mode 100644
index 00000000..403d6642
--- /dev/null
+++ b/dev/SCIKit/SCM.drawio
@@ -0,0 +1,28 @@
+<mxfile host="65bd71144e">
+ <diagram name="Page-1" id="_vc7fxBdNKI2W8YhI8VA">
+ <mxGraphModel dx="774" dy="581" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
+ <root>
+ <mxCell id="0"/>
+ <mxCell id="1" parent="0"/>
+ <mxCell id="eRehIIeIVOPW1y23kRkx-9" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="eRehIIeIVOPW1y23kRkx-2" target="eRehIIeIVOPW1y23kRkx-8" edge="1">
+ <mxGeometry relative="1" as="geometry"/>
+ </mxCell>
+ <mxCell id="eRehIIeIVOPW1y23kRkx-2" value="User level interfaces and events." style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
+ <mxGeometry x="200" y="450" width="226" height="60" as="geometry"/>
+ </mxCell>
+ <mxCell id="eRehIIeIVOPW1y23kRkx-4" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="eRehIIeIVOPW1y23kRkx-3" target="eRehIIeIVOPW1y23kRkx-2" edge="1">
+ <mxGeometry relative="1" as="geometry"/>
+ </mxCell>
+ <mxCell id="eRehIIeIVOPW1y23kRkx-3" value="IDB" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=15;" parent="1" vertex="1">
+ <mxGeometry x="283" y="290" width="60" height="80" as="geometry"/>
+ </mxCell>
+ <mxCell id="eRehIIeIVOPW1y23kRkx-8" value="Program #2&lt;div&gt;Is a web browser, it uses an HTML parser component.&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
+ <mxGeometry x="253" y="570" width="120" height="60" as="geometry"/>
+ </mxCell>
+ <mxCell id="eRehIIeIVOPW1y23kRkx-10" value="&lt;h1 style=&quot;margin-top: 0px;&quot;&gt;System Component/Call Model/Interface&lt;/h1&gt;&lt;p&gt;SCM is a standardized way of sharing code within DLLs in NewOS.&lt;/p&gt;&lt;p&gt;All classes are based upon&amp;nbsp;&lt;span style=&quot;color: rgb(78, 201, 176); background-color: rgb(31, 31, 31); font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px;&quot;&gt;UnknownInterface&lt;/span&gt;&lt;/p&gt;&lt;p&gt;It is also used to register and call code using&amp;nbsp;&lt;span style=&quot;color: rgb(78, 201, 176); background-color: rgb(31, 31, 31); font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px;&quot;&gt;EventListenerInterface&lt;/span&gt;&lt;/p&gt;" style="text;html=1;whiteSpace=wrap;overflow=hidden;rounded=0;" parent="1" vertex="1">
+ <mxGeometry x="450" y="240" width="320" height="240" as="geometry"/>
+ </mxCell>
+ </root>
+ </mxGraphModel>
+ </diagram>
+</mxfile> \ No newline at end of file
diff --git a/dev/SCIKit/build.json b/dev/SCIKit/build.json
new file mode 100644
index 00000000..9bc72bfa
--- /dev/null
+++ b/dev/SCIKit/build.json
@@ -0,0 +1,10 @@
+{
+ "compiler_path": "x86_64-w64-mingw32-g++.exe",
+ "compiler_std": "c++20",
+ "headers_path": ["../"],
+ "sources_path": ["*.cxx"],
+ "output_name": "sci.dll",
+ "compiler_flags": ["-fPIC", "-ffreestanding", "-shared", "-fno-rtti", "-fno-exceptions", "-Wl,--subsystem=17"],
+ "cpp_macros": ["__SCI_IMPL__", "cSCIVersion=0x0100", "cSCIVersionHighest=0x0100", "cSCIVersionLowest=0x0100"]
+ }
+ \ No newline at end of file
diff --git a/dev/SCIKit/compile_flags.txt b/dev/SCIKit/compile_flags.txt
new file mode 100644
index 00000000..509e3eed
--- /dev/null
+++ b/dev/SCIKit/compile_flags.txt
@@ -0,0 +1,4 @@
+-I./
+-I../Kernel
+-I../
+-std=c++20
diff --git a/dev/SCIKit/makefile b/dev/SCIKit/makefile
new file mode 100644
index 00000000..63753422
--- /dev/null
+++ b/dev/SCIKit/makefile
@@ -0,0 +1,12 @@
+######################
+# (C) ZKA
+# SCM/SCI kit makefile.
+######################
+
+CC=g++
+FLAGS=-I../ -shared -fPIC -D__NEWOS_SYMS__
+OUTPUT=sci.dll
+
+.PHONY: build-sci
+build-sci:
+ $(CC) $(wildcard *.cxx) $(FLAGS) -o $(OUTPUT) \ No newline at end of file
diff --git a/dev/SCIKit/scm.idlparser.inl b/dev/SCIKit/scm.idlparser.inl
new file mode 100644
index 00000000..6189eab6
--- /dev/null
+++ b/dev/SCIKit/scm.idlparser.inl
@@ -0,0 +1,21 @@
+/* -------------------------------------------
+
+Copyright ZKA Technologies.
+
+File: rt.internal.inl
+Purpose: Base code of SCM.
+
+------------------------------------------- */
+
+/// @internal
+
+#ifndef __NDK__
+#define object class
+#define protocol class
+#define clsid(X) __attribute__((uuid(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 IDLParserInterface;
+protocol IDLInterface; \ No newline at end of file
diff --git a/dev/SCIKit/scm.internal.inl b/dev/SCIKit/scm.internal.inl
new file mode 100644
index 00000000..8a5a85fa
--- /dev/null
+++ b/dev/SCIKit/scm.internal.inl
@@ -0,0 +1,84 @@
+/* -------------------------------------------
+
+Copyright ZKA Technologies.
+
+File: rt.internal.inl
+Purpose: Base code of SCM.
+
+------------------------------------------- */
+
+/// @internal
+
+#ifndef __NDK__
+#define object class
+#define protocol class
+#define clsid(X) __attribute__((uuid(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__
+
+// Interfaces are divided between classes.
+// So that they aren't too big.
+
+protocol UnknownInterface; // Refrenced from an IDB entry.
+class UnknownUCLSID; // From the IDB, the constructor of the object, e.g: TextUCLSID.
+object UUID;
+
+protocol clsid("d7c144b6-0792-44b8-b06b-02b227b547df") UnknownInterface
+{
+public:
+ explicit UnknownInterface() = default;
+ virtual ~UnknownInterface() = default;
+
+ UnknownInterface& operator=(const UnknownInterface&) = default;
+ UnknownInterface(const UnknownInterface&) = default;
+
+ virtual SInt32 Release() = 0;
+ virtual void RemoveRef() = 0;
+ virtual UnknownInterface* AddRef() = 0;
+ virtual VoidPtr QueryInterface(UUID* p_uuid) = 0;
+};
+
+/// @brief Allocate new SCM object.
+/// @tparam TCLS the class type.
+/// @tparam UCLSID UCLS factory class type.
+/// @param uclsidOfCls UCLS factory class
+/// @return TCLS interface
+template <typename TCLS, typename UCLSID, typename... Args>
+inline TCLS* ScmQueryInterface(UCLSID* uclsidOfCls, Args&&... args)
+{
+ return uclsidOfCls->QueryInterfaceWithArgs(args...);
+}
+
+/// @brief Release SCM object.
+/// @tparam TCLS the class type.
+/// @param cls the class to release.
+/// @return status code.
+template <typename TCLS>
+inline SInt32 ScmReleaseClass(TCLS* cls)
+{
+ if (!cls)
+ return -1;
+
+ cls->DecrementRef();
+ cls->Release();
+
+ return 0;
+}
+
+template <typename FnSign, typename ClsID>
+protocol EventListenerInterface final : public ClsID
+{
+public:
+ explicit EventListenerInterface() = default;
+ virtual ~EventListenerInterface() = default;
+
+ EventListenerInterface& operator=(const EventListenerInterface&) = default;
+ EventListenerInterface(const EventListenerInterface&) = default;
+
+ virtual EventListenerInterface& operator +=(FnSign arg)
+ {
+ this->AddEventListener(arg);
+ return *this;
+ }
+};
diff --git a/dev/SCIKit/source_deploy.xml b/dev/SCIKit/source_deploy.xml
new file mode 100644
index 00000000..7873c49f
--- /dev/null
+++ b/dev/SCIKit/source_deploy.xml
@@ -0,0 +1,7 @@
+<SourceDeploy>
+<HiddenFiles>
+ <SourceFile>*.cxx</SourceFile>
+ <SourceFile>*.drawio</SourceFile>
+ <SourceFile>*.internal.inl</SourceFile>
+</HiddenFiles>
+</SourceDeploy>