From 650fee520f526d9cd5ffa75735bd94d5140dd247 Mon Sep 17 00:00:00 2001 From: Amlal Date: Sat, 20 Jul 2024 08:43:16 +0200 Subject: [IMP] See below. - Revoke OTA flag for now inside bootloader (newosldr #4) - Rework Comm as SCI (System Call Interface) (newoskrnl #3) - Rework and fix some parts of the scheduler (newoskrnl #2) - Return from thread when region is zero (newosldr #1) - Separate allocation functions and c++ runtime from each other. (DDK #5) - Rename kHartStandard to kStandard (newoskrnl #6) Signed-off-by: Amlal --- SCI/ErrorTypes.hxx | 52 ++++++++++++++++++++ SCI/Hint.hxx | 23 +++++++++ SCI/StandardInterface.hxx | 123 ++++++++++++++++++++++++++++++++++++++++++++++ SCI/compile_flags.txt | 4 ++ 4 files changed, 202 insertions(+) create mode 100644 SCI/ErrorTypes.hxx create mode 100644 SCI/Hint.hxx create mode 100644 SCI/StandardInterface.hxx create mode 100644 SCI/compile_flags.txt (limited to 'SCI') diff --git a/SCI/ErrorTypes.hxx b/SCI/ErrorTypes.hxx new file mode 100644 index 00000000..7ab31215 --- /dev/null +++ b/SCI/ErrorTypes.hxx @@ -0,0 +1,52 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies + +------------------------------------------- */ + +#pragma once + +#include + +#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 kErrorUnimplemented = 0; + +inline HError kLastError = 0; diff --git a/SCI/Hint.hxx b/SCI/Hint.hxx new file mode 100644 index 00000000..fd91ece9 --- /dev/null +++ b/SCI/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/SCI/StandardInterface.hxx b/SCI/StandardInterface.hxx new file mode 100644 index 00000000..9e792546 --- /dev/null +++ b/SCI/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/SCI/compile_flags.txt b/SCI/compile_flags.txt new file mode 100644 index 00000000..509e3eed --- /dev/null +++ b/SCI/compile_flags.txt @@ -0,0 +1,4 @@ +-I./ +-I../Kernel +-I../ +-std=c++20 -- cgit v1.2.3