diff options
| author | Amlal <amlal@el-mahrouss-logic.com> | 2024-10-25 16:52:55 +0200 |
|---|---|---|
| committer | Amlal <amlal@el-mahrouss-logic.com> | 2024-10-25 16:52:55 +0200 |
| commit | bde40a348877ff33649c5335a9ebe0502a606d7c (patch) | |
| tree | 0aaf2821c8436afd9ba7f74a28b6e97ae2a795d2 | |
| parent | 5c319a1b4d08ce784f164aa5d073af71336e1547 (diff) | |
IMP: Cleanup source code.
Signed-off-by: Amlal <amlal@el-mahrouss-logic.com>
42 files changed, 11 insertions, 1295 deletions
diff --git a/dev/comm/xpcom_sms.idl b/dev/comm/xpcom_sms.idl deleted file mode 100644 index 6c9e46fa..00000000 --- a/dev/comm/xpcom_sms.idl +++ /dev/null @@ -1,33 +0,0 @@ -/* -------------------------------------------
-
-Copyright ZKA Web Services Co.
-
-File: xpcom_sms.idl
-Purpose: SMS XPCOM interface
-
-------------------------------------------- */
-
-#ifndef __TOOLCHAINKIT__
-#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 ToolchainKit, please be cautious that some features mayn't be present. !!
-#endif // ifndef __TOOLCHAINKIT__
-
-interface("0943A614-0201-4107-8F8D-E909DF7F53C9") ISMS
-{
-interface_public:
- 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/crt/ReadMe.md b/dev/crt/ReadMe.md deleted file mode 100644 index 055650b0..00000000 --- a/dev/crt/ReadMe.md +++ /dev/null @@ -1,5 +0,0 @@ -# ZKA C++ RunTime Kit.
-
-This is the public interface of ZKA' C++ RunTime.
-
-###### (c) ZKA Web Services Co, all rights reserved.
diff --git a/dev/crt/alloca.h b/dev/crt/alloca.h deleted file mode 100644 index 35e742d8..00000000 --- a/dev/crt/alloca.h +++ /dev/null @@ -1,19 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Web Services Co. - - File: alloca.h - Purpose: Stack allocation functions. - -------------------------------------------- */ - -#pragma once - -#include <crt/defines.h> - -inline ptr_type __rt_alloca(size_type sz) -{ - return __builtin_alloca(sz); -} - -#define alloca __rt_alloca diff --git a/dev/crt/base_alloc.h b/dev/crt/base_alloc.h deleted file mode 100644 index 97826d80..00000000 --- a/dev/crt/base_alloc.h +++ /dev/null @@ -1,49 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Web Services Co. - -------------------------------------------- */ - -#pragma once - -#include <crt/defines.h> - -namespace std::base_alloc -{ - /// @brief allocate a new class. - /// @tparam KindClass the class type to allocate. - template <typename KindClass, typename... Args> - inline KindClass* allocate(Args&&... args) - { - return new KindClass(forward(args)...); - } - - /// @brief allocate a new class. - /// @note aborts on error. - /// @tparam KindClass the class type to allocate. - template <typename KindClass, typename... Args> - inline KindClass* allocate_nothrow(Args&&... args) noexcept - { - return allocate(forward(args)...); - } - - /// @brief free a class. - /// @tparam KindClass the class type to allocate. - template <typename KindClass> - inline void release(KindClass ptr) - { - if (!ptr) - return; - - delete ptr; - } - - /// @brief destroy and free a class. - /// @note aborts on error. - /// @tparam KindClass the class type to allocate. - template <typename KindClass> - inline void release_nothrow(KindClass ptr) noexcept - { - release(ptr); - } -} // namespace std::base_alloc diff --git a/dev/crt/base_exception.h b/dev/crt/base_exception.h deleted file mode 100644 index 3b95f400..00000000 --- a/dev/crt/base_exception.h +++ /dev/null @@ -1,36 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Web Services Co. - -------------------------------------------- */ - -#pragma once - -#include <crt/defines.h> -#include <crt/exit.h> - -namespace std -{ - inline void __throw_general(void) - { - exit(33); - } - - inline void __throw_domain_error(const char* error) - { - __throw_general(); - __builtin_unreachable(); // prevent from continuing. - } - - inline void __throw_bad_alloc(void) - { - __throw_general(); - __builtin_unreachable(); // prevent from continuing. - } - - inline void __throw_bad_array_new_length(void) - { - __throw_general(); - __builtin_unreachable(); // prevent from continuing. - } -} // namespace std diff --git a/dev/crt/crtx64.json b/dev/crt/crtx64.json deleted file mode 100644 index b8e99385..00000000 --- a/dev/crt/crtx64.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compiler_path": "x86_64-w64-mingw32-g++", - "compiler_std": "c++20", - "headers_path": ["../", "./"], - "sources_path": ["src/*.cc", "src/hal/x86/*.cc"], - "output_name": "crtx64.dll", - "compiler_flags": [ - "-ffreestanding", - "-shared", - "-fno-rtti", - "-fno-exceptions", - "-Wl,--subsystem=17" - ], - "cpp_macros": [ - "__CRT_AMD64__", - "cCRTVersion=0x0100", - "cEFSVersionHighest=0x0100", - "cEFSVersionLowest=0x0100" - ] -} diff --git a/dev/crt/defines.h b/dev/crt/defines.h deleted file mode 100644 index f9c85387..00000000 --- a/dev/crt/defines.h +++ /dev/null @@ -1,106 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Web Services Co. - -------------------------------------------- */ - -#ifndef __TOOLCHAINKIT_DEFINES_H__ -#define __TOOLCHAINKIT_DEFINES_H__ - -#include <stdint.h> -#include <stddef.h> - -#ifdef __GNUC__ - -typedef void* ptr_type; -typedef __SIZE_TYPE__ size_type; - -typedef void* voidptr_t; -typedef void* any_t; -typedef char* caddr_t; - -#ifndef NULL -#define NULL ((voidptr_t)0) -#endif // !null - -#ifdef __GNUC__ -#include <crt/alloca.h> -#elif defined(__TOOLCHAINKIT__) -#define __alloca(sz) __rt_alloca(sz) -#endif - -#define __deref(ptr) (*(ptr)) - -#ifdef __cplusplus -#define __init_decl() \ - extern "C" \ - { -#define __fini_decl() \ - } \ - ; -#else -#define __init_decl() -#define __fini_decl() -#endif - -typedef long long off_t; -typedef unsigned long long uoff_t; - -typedef union float_cast { - struct - { - unsigned int mantissa : 23; - unsigned int exponent : 8; - unsigned int sign : 1; - }; - - float f; -} __attribute__((packed)) float_cast_t; - -typedef union double_cast { - struct - { - unsigned long long int mantissa : 52; - unsigned int exponent : 11; - unsigned int sign : 1; - }; - - double f; -} __attribute__((packed)) double_cast_t; - -#endif // ifndef __GNUC__ - -/// Include these helpers as well. - -#ifdef __STD_CXX__ - -#include <crt/base_exception.h> -#include <crt/base_alloc.h> - -#endif // ifdef __STD_CXX__ - -/// @brief Standard C++ namespace. -namespace std -{ - /// @brief Forward object. - /// @tparam Args the object type. - /// @param arg the object. - /// @return object's rvalue - template <typename Args> - inline Args&& forward(Args& arg) - { - return static_cast<Args&&>(arg); - } - - /// @brief Move object. - /// @tparam Args the object type. - /// @param arg the object. - /// @return object's rvalue - template <typename Args> - inline Args&& move(Args&& arg) - { - return static_cast<Args&&>(arg); - } -} // namespace std - -#endif /* __TOOLCHAINKIT_DEFINES_H__ */ diff --git a/dev/crt/exit.h b/dev/crt/exit.h deleted file mode 100644 index 9bf9928f..00000000 --- a/dev/crt/exit.h +++ /dev/null @@ -1,20 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Web Services Co. - -------------------------------------------- */ - -#pragma once - -#include <crt/defines.h> - -extern "C" int exit(int code); - -/// @brief Standard C++ namespace -namespace std -{ - inline int exit(int code) - { - return exit(code); - } -} // namespace std diff --git a/dev/crt/math.h b/dev/crt/math.h deleted file mode 100644 index fd948d63..00000000 --- a/dev/crt/math.h +++ /dev/null @@ -1,62 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Web Services Co. - -------------------------------------------- */ - -#pragma once - -#include <crt/defines.h> - -/// @file Math.h -/// @brief Math functions. - -#ifdef __ZKA_USE_DOUBLE__ -typedef double real_type; -#else -typedef float real_type; -#endif - -namespace std::math -{ - /// @brief Power function, with Repeat argument. - template <size_t Exponent> - inline real_type pow(real_type in) - { - if (Exponent == 0) - return 1; // Any number to the power of 0 is 1. - - if (Exponent == 1) - return in; // Any number to the power of 1 is itself. - - size_t cnt = Exponent; - - real_type result = 1; - - for (auto i = 0; i < cnt; ++i) - result *= in; - - return result; - } - - /// @brief Square of function, with Base template argument. - /// @param of Base argument to find sqquare of - template <size_t Base> - inline real_type sqr(real_type in) - { - if (in == 0) - return 0; - - return pow<1 / Base>(in); - } - - /// @brief Linear interpolation equation solver. - /// @param from where? - /// @param to to? - /// @param Updated diff value according to difference. - inline real_type lerp(real_type to, real_type from, real_type stat) - { - real_type diff = (to - from); - return from + (diff * stat); - } -} // namespace std::math diff --git a/dev/crt/src/alloca.cc b/dev/crt/src/alloca.cc deleted file mode 100644 index ccee07a7..00000000 --- a/dev/crt/src/alloca.cc +++ /dev/null @@ -1,9 +0,0 @@ -/* -------------------------------------------
-
- Copyright ZKA Web Services Co.
-
-------------------------------------------- */
-
-#include <crt/alloca.h>
-
-/// @note Just here for building.
diff --git a/dev/crt/src/base_exception.cc b/dev/crt/src/base_exception.cc deleted file mode 100644 index 75699f64..00000000 --- a/dev/crt/src/base_exception.cc +++ /dev/null @@ -1,9 +0,0 @@ -/* -------------------------------------------
-
- Copyright ZKA Web Services Co.
-
-------------------------------------------- */
-
-#include <crt/base_exception.h>
-
-/// @note Just here for building.
diff --git a/dev/crt/src/hal/x86/base_alloc.cc b/dev/crt/src/hal/x86/base_alloc.cc deleted file mode 100644 index 10690d4b..00000000 --- a/dev/crt/src/hal/x86/base_alloc.cc +++ /dev/null @@ -1,55 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Web Services Co. - -------------------------------------------- */ - -#include <crt/base_alloc.h> -#include <crt/base_exception.h> - -#define kAllocSyscallId "mov $10, %%r9\n\t" -#define kFreeSyscallId "mov $11, %%r9\n\t" - -void* operator new(size_t length) -{ - void* ptr = nullptr; - - // do syscall according to PEF convention. - asm("mov %0, %%r8\n\t" kAllocSyscallId - "syscall" - : "=r"(ptr)); - - if (!ptr) - std::__throw_bad_alloc(); - - return ptr; -} - -void* operator new[](size_t length) -{ - ptr_type ptr = nullptr; - - // do syscall according to PEF convention. - asm("mov %0, %%r8\n\t" kAllocSyscallId - "syscall" - : "=r"(ptr)); - - if (!ptr) - std::__throw_bad_alloc(); - - return ptr; -} - -void operator delete(void* ptr) noexcept -{ - asm("mov %0, %%r8\n\t" kFreeSyscallId - "syscall" - : "=r"(ptr)); -} - -void operator delete[](void* ptr) noexcept -{ - asm("mov %0, %%r8\n\t" kFreeSyscallId - "syscall" - : "=r"(ptr)); -} diff --git a/dev/crt/src/hal/x86/exit.cc b/dev/crt/src/hal/x86/exit.cc deleted file mode 100644 index 8ee6744b..00000000 --- a/dev/crt/src/hal/x86/exit.cc +++ /dev/null @@ -1,19 +0,0 @@ -/* -------------------------------------------
-
- Copyright ZKA Web Services Co.
-
-------------------------------------------- */
-
-#include <crt/exit.h>
-
-#define kAllocSyscallId "mov $12, %%r9\n\t"
-
-/// @note Just here for building.
-extern "C" int exit(int code)
-{
- asm("mov 0, %%r8\n\t" kAllocSyscallId
- "syscall"
- : "=r"(code));
-
- return 1;
-}
diff --git a/dev/ddk/ReadMe.md b/dev/ddk/ReadMe.md deleted file mode 100644 index ac103ce8..00000000 --- a/dev/ddk/ReadMe.md +++ /dev/null @@ -1,9 +0,0 @@ -# ZKA's Device Driver Kit. - -A kit used to write Kernel HALs, using the NDK compiler suite. - -## How to use it - -Simply link against ddk.dll. - -###### Copyright 2024 ZKA Web Services Co, all rights reserved. diff --git a/dev/ddk/ddk.h b/dev/ddk/ddk.h deleted file mode 100644 index 002dfe0c..00000000 --- a/dev/ddk/ddk.h +++ /dev/null @@ -1,117 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Web Services Co. - - FILE: ddk.h - PURPOSE: DDK Driver model base header. - -------------------------------------------- */ - -#pragma once - -#include <stdint.h> -#include <stddef.h> - -#if defined(__cplusplus) -#define DK_EXTERN extern "C" __declspec(dllexport) -#define nil nullptr -#undef NULL -#define NULL 0 -#define DK_FINAL final -#else -#define DK_EXTERN extern __declspec(dllexport) -#define nil ((void*)0) -#undef NULL -#define NULL ((void*)0) -#define DK_FINAL -#endif // defined(__cplusplus) - -#ifndef __DDK__ -#undef DK_EXTERN -#if defined(__cplusplus) -#define DK_EXTERN extern "C" __declspec(dllimport) -#else -#define DK_EXTERN __declspec(dllimport) -#endif -#endif - -#define ATTRIBUTE(X) __attribute__((X)) - -#define DDK_SMS_MAX_SZ 128 - -#ifndef __NEWOSKRNL__ -#error !!! including header in l0/ring-3 mode !!! -#endif // __NEWOSKRNL__ - -struct DDK_STATUS_STRUCT; -struct DDK_OBJECT_MANIFEST; - -/// \brief manifest structure, represents a structure with methods and fields. -struct DDK_OBJECT_MANIFEST DK_FINAL -{ - char* p_name; - int32_t p_kind; - void* p_object; -}; - -/// \brief DDK status ping structure. -struct DDK_STATUS_STRUCT DK_FINAL -{ - int32_t s_action_id; - int32_t s_issuer_id; - int32_t s_group_id; - void* s_object; -}; - -/// \brief Simple Message Struct structure. -struct DDK_SMS_STRUCT DK_FINAL -{ - char s_msg[DDK_SMS_MAX_SZ]; - int32_t s_type; - int64_t s_sender; - int64_t s_receiver; -}; - -/// @brief Call Kernel procedure. -/// @param name the procedure name. -/// @param cnt number of elements in **dat** -/// @param dat data argument pointer. -/// @param sz sz of whole data argument pointer. -/// @return result of call -DK_EXTERN void* KernelCall(const char* name, int32_t cnt, void* dat, size_t sz); - -/// @brief add a system call. -/// @param slot system call slot id. -/// @param slotFn, syscall slot. -DK_EXTERN void KernelAddSyscall(const int32_t slot, void (*slotFn)(void* a0)); - -/// @brief Allocates an heap ptr. -/// @param sz size of the allocated struct/type. -/// @return the pointer allocated or **nil**. -DK_EXTERN void* KernelAlloc(size_t sz); - -/// @brief Frees an heap ptr. -/// @param pointer kernel pointer to free. -DK_EXTERN void KernelFree(void* the_ptr); - -/// @brief Gets a Kernel object. -/// @param slot object id (can be 0) -/// @param name the property's name. -/// @return DDK_OBJECT_MANIFEST. -DK_EXTERN struct DDK_OBJECT_MANIFEST* KernelGetObject(const int slot, const char* name); - -/// @brief Set a Kernel object. -/// @param slot object id (can be 0) -/// @param name the property's name. -/// @param ddk_pr pointer to a object's DDK_OBJECT_MANIFEST. -/// @return returned object. -DK_EXTERN void* KernelSetObject(const int32_t slot, const struct DDK_OBJECT_MANIFEST* ddk_pr); - -/// @brief The highest API version of the DDK. -DK_EXTERN int32_t c_api_version_highest; - -/// @brief The lowest API version of the DDK. -DK_EXTERN int32_t c_api_version_least; - -/// @brief c_api_version_least+c_api_version_highest combined version. -DK_EXTERN int32_t c_api_version; diff --git a/dev/ddk/ddk.json b/dev/ddk/ddk.json deleted file mode 100644 index 3a19eef8..00000000 --- a/dev/ddk/ddk.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "compiler_path": "x86_64-w64-mingw32-gcc", - "compiler_std": "c++20", - "headers_path": ["../", "./"], - "sources_path": ["src/*.c", "src/*.cc", "src/*.S"], - "output_name": "ddk.dll", - "compiler_flags": [ - "-ffreestanding", - "-shared", - "-std=c17", - "-std=c++20", - "-fno-rtti", - "-fno-exceptions", - " -Wl,--subsystem=17" - ], - "cpp_macros": [ - "__NEWOSKRNL__", - "__DDK_AMD64__", - "__DDK__", - "cDDKVersionHighest=0x0100", - "cDDKVersionLowest=0x0100", - "cDDKVersion=0x0100" - ] -} diff --git a/dev/ddk/dev.h b/dev/ddk/dev.h deleted file mode 100644 index 26105ff4..00000000 --- a/dev/ddk/dev.h +++ /dev/null @@ -1,33 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Web Services Co. - - File: dev.h - Purpose: DDK device support. - -------------------------------------------- */ - -#pragma once - -#include <ddk/ddk.h> - -struct _DDK_DEVICE; - -/// @brief Kernel Device driver. -typedef struct _DDK_DEVICE DK_FINAL -{ - char d_name[255]; // the device name. Could be /./DEVICE_NAME/ - void* (*d_read)(void* arg, int len); // read from device. - void (*d_write)(void* arg, int len); - void (*d_wait)(void); // write to device. - struct _DDK_DEVICE* (*d_open)(const char* path); // open device. - void (*d_close)(struct _DDK_DEVICE* dev); // close device. -} KERNEL_DEVICE, *KERNEL_DEVICE_PTR; - -/// @brief Open a new device from path. -/// @param devicePath the device's path. -DK_EXTERN KERNEL_DEVICE_PTR KernelOpenDevice(const char* devicePath); - -/// @brief Close any device. -/// @param device valid device. -DK_EXTERN void KernelCloseDevice(KERNEL_DEVICE_PTR device); diff --git a/dev/ddk/io.h b/dev/ddk/io.h deleted file mode 100644 index 3dcea20b..00000000 --- a/dev/ddk/io.h +++ /dev/null @@ -1,18 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Web Services Co. - - Purpose: DDK Text I/O. - -------------------------------------------- */ - -#pragma once - -#include <ddk/str.h> - -/// @brief print character into UART. -DK_EXTERN void KernelPrintChar(const char ch); - -/// @brief print string to UART. -/// @param message string to transmit to UART. -DK_EXTERN void KernelPrintStr(const char* message); diff --git a/dev/ddk/src/ddk_alloc.c b/dev/ddk/src/ddk_alloc.c deleted file mode 100644 index 441c2c83..00000000 --- a/dev/ddk/src/ddk_alloc.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Web Services Co. - - Purpose: DDK allocator. - -------------------------------------------- */ - -#include <ddk/ddk.h> - -/** - \brief Allocates a new heap on the Kernel's side. - \param sz the size of the heap block. - \return the newly allocated pointer. -*/ -DK_EXTERN void* KernelAlloc(size_t sz) -{ - if (!sz) - ++sz; - - void* ptr = KernelCall("MmNew", 1, &sz, sizeof(size_t)); - - return ptr; -} - -/** - \brief Frees a pointer from the heap. - \param ptr the pointer to free. -*/ -DK_EXTERN void KernelFree(void* ptr) -{ - if (!ptr) - return; - - KernelCall("MmDelete", 1, ptr, 0); -} diff --git a/dev/ddk/src/ddk_dev.c b/dev/ddk/src/ddk_dev.c deleted file mode 100644 index 3cc28117..00000000 --- a/dev/ddk/src/ddk_dev.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Web Services Co. - - Purpose: DDK Text I/O. - -------------------------------------------- */ - -#include <ddk/dev.h> -#include <ddk/str.h> - -/// @brief Open a new binary device from path. -DK_EXTERN KERNEL_DEVICE_PTR KernelOpenDevice(const char* devicePath) -{ - if (!devicePath) - return nil; - - return KernelCall("RtlOpenDevice", 1, (void*)devicePath, KernelStringLength(devicePath)); -} - -/// @brief Close any device. -/// @param device valid device. -DK_EXTERN void KernelCloseDevice(KERNEL_DEVICE_PTR device) -{ - if (!device) - return; - - KernelCall("RtlCloseDevice", 1, device, sizeof(KERNEL_DEVICE)); -} diff --git a/dev/ddk/src/ddk_io.c b/dev/ddk/src/ddk_io.c deleted file mode 100644 index 84d08e2e..00000000 --- a/dev/ddk/src/ddk_io.c +++ /dev/null @@ -1,42 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Web Services Co. - - Purpose: DDK Text I/O. - -------------------------------------------- */ - -#include <ddk/io.h> - -DK_EXTERN void KernelPrintChar(const char msg_ch) -{ - char assembled[2] = {0}; - - assembled[0] = msg_ch; - - if (msg_ch != 0) - { - assembled[1] = 0; - } - - KernelCall("SrWriteCharacter", 1, assembled, 1); -} - -/// @brief print string to UART. -/// @param message UART to transmit. -DK_EXTERN void KernelPrintStr(const char* message) -{ - if (!message) - return; - if (*message == 0) - return; - - size_t index = 0; - size_t len = KernelStringLength(message); - - while (index < len) - { - KernelPrintChar(message[index]); - ++index; - } -} diff --git a/dev/ddk/src/ddk_kernel_call.c b/dev/ddk/src/ddk_kernel_call.c deleted file mode 100644 index 2a310dc6..00000000 --- a/dev/ddk/src/ddk_kernel_call.c +++ /dev/null @@ -1,60 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Web Services Co. - - Purpose: DDK Kernel call. - -------------------------------------------- */ - -#include <ddk/ddk.h> -#include <stdarg.h> - -/// @brief this is an internal call, do not use it. -DK_EXTERN ATTRIBUTE(naked) void* __KernelCallDispatch(const char* name, int32_t cnt, void* data, size_t sz); - -/// @brief Interupt Kernel -/// @param KernelRpcName RPC name -/// @param cnt number of elements in **data** pointer. -/// @param data data pointer. -/// @param sz The size of the whole data pointer. -/// @retval void* Kernel call was successful. -/// @retval nil Kernel call failed, call KernelLastError(void) -DK_EXTERN void* KernelCall(const char* name, int32_t cnt, void* data, size_t sz) -{ - if (!name || *name == 0 || cnt == 0) - return nil; - - return __KernelCallDispatch(name, cnt, data, sz); -} - -/// @brief Add system call. -/// @param slot system call slot -/// @param slotFn, syscall slot. -DK_EXTERN void KernelAddSyscall(const int slot, void (*slotFn)(void* a0)) -{ - KernelCall("IntAddSyscall", slot, slotFn, 1); -} - -/// @brief Get a Kernel property. -/// @param slot property id (always 0) -/// @param name the object's name. -/// @return The manifest structure. -DK_EXTERN struct DDK_OBJECT_MANIFEST* KernelGetObject(const int slot, const char* name) -{ - struct DDK_OBJECT_MANIFEST* manifest = (struct DDK_OBJECT_MANIFEST*)KernelCall("RtlGetObject", slot, (void*)name, 1); - - if (!manifest) - return nil; - - return manifest; -} - -/// @brief Set a Kernel property. -/// @param slot property id (always 0) -/// @param name the object's name. -/// @param ddk_pr pointer to a object's DDK_OBJECT_MANIFEST. -/// @return property's object. -DK_EXTERN void* KernelSetObject(const int slot, const struct DDK_OBJECT_MANIFEST* ddk_pr) -{ - return KernelCall("RtlSetObject", slot, (void*)ddk_pr, 1); -} diff --git a/dev/ddk/src/ddk_kernel_call_dispatch.S b/dev/ddk/src/ddk_kernel_call_dispatch.S deleted file mode 100644 index 3a9a57b5..00000000 --- a/dev/ddk/src/ddk_kernel_call_dispatch.S +++ /dev/null @@ -1,36 +0,0 @@ -/** - lang: asm - compiler: gnu - */ - -.globl __KernelCallDispatch - -.text - -/* Really simple function, takes our va-list, - and brings it to the trap handler in the Kernel. */ - -#ifdef __DDK_AMD64__ - -/* args rcx, rdx, r8, r9 */ -__KernelCallDispatch: - int $0x33 - ret - -#elif defined(__DDK_POWER64__) - -/* args r8, r9, r10, r11 */ -__KernelCallDispatch: - /* There is no specific interrupt request id for a system call in POWER. */ - sc - blr - -#elif defined(__DDK_ARM64__) - -/* args x0, x8, x9, x10, x11 is kept to tell that this is a Kernel call */ -__KernelCallDispatch: - /* There is no specific interrupt request id for a system call in ARM64 as well. */ - mov x9, #0x33 - svc #0 - -#endif diff --git a/dev/ddk/src/ddk_rt_cxx.cc b/dev/ddk/src/ddk_rt_cxx.cc deleted file mode 100644 index 8ca2464c..00000000 --- a/dev/ddk/src/ddk_rt_cxx.cc +++ /dev/null @@ -1,29 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Web Services Co. - - Purpose: DDK C++ runtime. - -------------------------------------------- */ - -#include <ddk/ddk.h> - -void* operator new(size_t sz) -{ - return KernelAlloc(sz); -} - -void operator delete(void* ptr) -{ - KernelFree(ptr); -} - -void* operator new[](size_t sz) -{ - return KernelAlloc(sz); -} - -void operator delete[](void* ptr) -{ - KernelFree(ptr); -} diff --git a/dev/ddk/src/ddk_str.c b/dev/ddk/src/ddk_str.c deleted file mode 100644 index 5b368d39..00000000 --- a/dev/ddk/src/ddk_str.c +++ /dev/null @@ -1,39 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Web Services Co. - - Purpose: DDK Strings. - -------------------------------------------- */ - -#include <ddk/str.h> - -DK_EXTERN size_t KernelStringLength(const char* in) -{ - if (in == nil) - return 0; - if (*in == 0) - return 0; - - size_t index = 0; - - while (in[index] != 0) - { - ++index; - } - - return index; -} - -DK_EXTERN int KernelStringCopy(char* dst, const char* src, size_t len) -{ - size_t index = 0; - - while (index != len) - { - dst[index] = src[index]; - ++index; - } - - return index; -} diff --git a/dev/ddk/src/ddk_ver.c b/dev/ddk/src/ddk_ver.c deleted file mode 100644 index 826cd3f8..00000000 --- a/dev/ddk/src/ddk_ver.c +++ /dev/null @@ -1,25 +0,0 @@ -/* -------------------------------------------
-
- Copyright ZKA Web Services Co.
-
- Purpose: DDK versioning.
-
-------------------------------------------- */
-
-#include <ddk/ddk.h>
-
-#ifndef cDDKVersionHighest
-#define cDDKVersionHighest 1
-#endif // !cDDKVersionHighest
-
-#ifndef cDDKVersionLowest
-#define cDDKVersionLowest 1
-#endif // !cDDKVersionLowest
-
-#ifndef cDDKVersion
-#define cDDKVersion 1
-#endif // !cDDKVersion
-
-int32_t c_api_version_highest = cDDKVersionHighest;
-int32_t c_api_version_least = cDDKVersionLowest;
-int32_t c_api_version = cDDKVersion;
diff --git a/dev/ddk/str.h b/dev/ddk/str.h deleted file mode 100644 index 5e55aa59..00000000 --- a/dev/ddk/str.h +++ /dev/null @@ -1,17 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Web Services Co. - - Purpose: DDK Strings. - -------------------------------------------- */ - -#pragma once - -#include <ddk/ddk.h> - -/// @brief DDK equivalent of POSIX's string.h -/// @file KernelString.h - -DK_EXTERN size_t KernelStringLength(const char* in); -DK_EXTERN int KernelStringCopy(char* dst, const char* src, size_t len); diff --git a/dev/ddk/x86_64.make b/dev/ddk/x86_64.make deleted file mode 100644 index b976427a..00000000 --- a/dev/ddk/x86_64.make +++ /dev/null @@ -1,14 +0,0 @@ -##################################################
-# (C) ZKA Web Services Co, all rights reserved.
-# This is the DDK's makefile.
-##################################################
-
-CC=x86_64-w64-mingw32-gcc
-INC=-I./ -I../
-FLAGS=-ffreestanding -shared -std=c17 -std=c++20 -D__NEWOSKRNL__ -fno-rtti -fno-exceptions -D__DDK_AMD64__ -Wl,--subsystem=17
-VERSION=-DcDDKVersionLowest=1 -DcDDKVersionHighest=1
-OUTPUT=ddk.dll
-
-.PHONY: x86_64-build
-x86_64-build:
- $(CC) $(INC) $(FLAGS) $(VERSION) $(wildcard *.c) $(wildcard *.S) $(wildcard .cc) -o $(OUTPUT)
diff --git a/dev/hpfs/.gitignore b/dev/hpfs/.gitignore deleted file mode 100644 index 6f675898..00000000 --- a/dev/hpfs/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.sys -*.exe -*.dll
\ No newline at end of file diff --git a/dev/hpfs/ReadMe.md b/dev/hpfs/ReadMe.md deleted file mode 100644 index 53778988..00000000 --- a/dev/hpfs/ReadMe.md +++ /dev/null @@ -1,9 +0,0 @@ -# High Performance File System. - -Filesystem driver for the HPFS specification. - -## Installation - -- Use BTB to build filesystem and partition blobs. - -###### Copyright ZKA Web Services Co. All rights reserved. diff --git a/dev/hpfs/epm/blob.json b/dev/hpfs/epm/blob.json deleted file mode 100644 index 4b1905b5..00000000 --- a/dev/hpfs/epm/blob.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "compiler_path": "nasm", - "sources_path": ["epm.asm"], - "output_name": "bl.bin", - "compiler_flags": ["-f bin"] -} diff --git a/dev/hpfs/epm/ebs.i b/dev/hpfs/epm/ebs.i deleted file mode 100644 index c486f463..00000000 --- a/dev/hpfs/epm/ebs.i +++ /dev/null @@ -1,29 +0,0 @@ -;; FILE: EBS.asm -;; PURPOSE: EXPLICIT BOOT SECTOR STRUCTURE (HPFS RELATED). -;; AUTHOR: AMLAL EL MAHROUSS - -[bits 64] - -;; DUMP THIS BLOB TO DISK, WHEN FORMATTING THE SSD. - -HPFS_EBS_HEADER: - db " HPFS", 0 ;; MAGIC NUMBER OF FILESYSTEM - dw 8 ;; MAGIC NUMBER LENGTH. - dq 0 ;; RESERVED 4 - dw 0x0100 ;; VERSION - dw 0 ;; PARTITION TYPE - dq 0 ;; RESERVED 3 - dw 0 ;; DISK TYPE (INVALID = 0, CDROM = 1, SSD = 2, USB = 3) - dw 0 ;; CHECKSUM OF PARTITION - dw 0 ;; IS IT LOCKED? (DISK ENCRYPTION ON?) - dq 0 ;; SECTOR COUNT - dq 0 ;; RESERVED 2 - dq 512 ;; SECTOR SZ - dq 0 ;; DISK SIZE - dq 0 ;; RESERVED 1 SLOT - dq 1 ;; LOCKER ON? - dq 1 ;; PARTITION MAP TYPE (GPT, MBR, EPM) - dq 16 ;; MASTER FILE TABLE - dq 80 ;; MASTER TRACE TABLE - dq 144 ;; MASTER DIRECTORY TABLE - dw 0xFFFF ;; END OF HEADER WORD diff --git a/dev/hpfs/epm/epm.asm b/dev/hpfs/epm/epm.asm deleted file mode 100644 index 2197d2cd..00000000 --- a/dev/hpfs/epm/epm.asm +++ /dev/null @@ -1,37 +0,0 @@ -;; FILE: EBS.asm -;; PURPOSE: EXPLICIT PARTITION MAP BOOT STRUCTURE (HPFS RELATED). -;; AUTHOR: AMLAL EL MAHROUSS - -[bits 64] - -HPFS_EPM_HEADER: - db "EPMAM", 0 - db "HPFS ", 0 -HPFS_EPM_UUID: - dd 0 - dw 0 - db 0 - db 0 - db 0 - db 0 - db 0 - db 0 - db 0 - db 0 - dd 0xAD ;; EPM revision - dd 0 ;; Number of blocks, set to 0 by default. - dd 512 ;; Sector size, HPFS was made with drives in mind, so 512. - dd 0 - dd 0 - dw 0x1f ;; NewOS (ZKA) present on partition. - dd 1 - db "FileSystem (A:)", 0 - times 401 db 0 -HPFS_EPM_HEADER_END: - - -%include "EBS.i" - -times 16 db 0 - -;; Here the partition starts diff --git a/dev/hpfs/hpfs.json b/dev/hpfs/hpfs.json deleted file mode 100644 index a6f20f66..00000000 --- a/dev/hpfs/hpfs.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "compiler_path": "x86_64-w64-mingw32-g++", - "compiler_std": "c++20", - "headers_path": ["../"], - "sources_path": ["src/*.cc"], - "output_name": "hpfs.sys", - "compiler_flags": [ - "-fPIC", - "-ffreestanding", - "-shared", - "-fno-rtti", - "-fno-exceptions", - "-Wl,--subsystem=17" - ], - "cpp_macros": [ - "__HPFS_IMPL__", - "__NEWOSKRNL__", - "cHPFSVersion=0x0100", - "cHPFSVersionHighest=0x0100", - "cHPFSVersionLowest=0x0100" - ] -} diff --git a/dev/hpfs/hpfs_specs.h b/dev/hpfs/hpfs_specs.h deleted file mode 100644 index 3a6ef582..00000000 --- a/dev/hpfs/hpfs_specs.h +++ /dev/null @@ -1,31 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Web Services Co. - - FILE: Defines.h - PURPOSE: HPFS IFS defines. - -------------------------------------------- */ - -#pragma once - -#include <ddk/ddk.h> - -#define kHPFSVersion 0x01000 -#define kHPFSMagic " HPFS" -#define kHPFSMagicLen 8 - -#define kHPFSMinimumDiskSize (gib_cast(64)) - -/** @brief Drive type enum. */ -enum -{ - kHPFSInvalidDrive, - kHPFSCDROMDrive, - kHPFSHDDDrive, - kHPFSSSDDrive, - kHPFSUSBDrive, -}; - -/** @brief Explicit Boot Sector structure. */ -struct HPFS_EXPLICIT_BOOT_SECTOR; diff --git a/dev/hpfs/src/hpfs_main.cc b/dev/hpfs/src/hpfs_main.cc deleted file mode 100644 index e65b03dc..00000000 --- a/dev/hpfs/src/hpfs_main.cc +++ /dev/null @@ -1,29 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Web Services Co. - - FILE: hpfs_main.cxx - PURPOSE: HPFS IFS entrypoint. - -------------------------------------------- */ - -#include <hpfs/hpfs_specs.h> - -static DDK_OBJECT_MANIFEST* kIfsObject = nullptr; - -/** @brief HPFS IFS main module function. */ -DK_EXTERN int32_t ModuleMain(void) -{ - auto ifs_handle = KernelGetObject(0, "IFS_OBJECT"); - - if (ifs_handle == nil) - { - return 1; - } - - /// TODO: Register this IFS with necessary I/O functions... - - kIfsObject = ifs_handle; - - return 0; -} diff --git a/dev/sci/sci_base.h b/dev/sci/sci_base.h index eca69595..0860e72f 100644 --- a/dev/sci/sci_base.h +++ b/dev/sci/sci_base.h @@ -10,8 +10,6 @@ Purpose: SCI core header file (C++ only). #ifndef __SCI_BASE_H__
#define __SCI_BASE_H__
-#include <sci/sci_hint.h>
-
#define ATTRIBUTE(X) __attribute__((X))
#define IMPORT_XPCOM extern "XPCOM"
#define IMPORT_CXX extern "C++"
@@ -35,46 +33,12 @@ typedef __INT8_TYPE__ SInt8; typedef void* VoidPtr;
typedef __UINTPTR_TYPE__ UIntPtr;
typedef char Char;
-#include <sci/sci_lpc.h>
-#ifdef __XPCOM_IMPL__
-#include <sci/xpcom_core.h>
-#else
-class IUnknown; // Refrenced from an IDB entry.
-class ICLSID; // From the IDB, the constructor of the object, e.g: IAppCLSID.
-class UUID;
-class ATTRIBUTE(uuid("d7c144b6-0792-44b8-b06b-02b227b547df")) IUnknown
-{
-public:
- explicit IUnknown() = default;
- virtual ~IUnknown() = default;
-
- IUnknown& operator=(const IUnknown&) = default;
- IUnknown(const IUnknown&) = default;
-
- virtual SInt32 Release() = 0;
- virtual void RemoveRef() = 0;
- virtual IUnknown* AddRef() = 0;
- virtual VoidPtr QueryClass(UUID* p_uuid) = 0;
-};
-template <typename FnSign, typename ClsID>
-class IEventListener : public ClsID
-{
- friend ClsID;
-
- explicit IEventListener() = default;
- virtual ~IEventListener() = default;
-
- IEventListener& operator=(const IEventListener&) = default;
- IEventListener(const IEventListener&) = default;
-
- virtual IEventListener& operator-=(const Char* event_name);
- virtual IEventListener& operator+=(FnSign arg) = 0;
-};
-#endif
+#include <sci/sci_hint.h>
+#include <sci/sci_lpc.h>
// ------------------------------------------------------------------------------------------ //
-/// @note Handle typedefs.
+/// @brief Handle Type Definitions.
// ------------------------------------------------------------------------------------------ //
typedef VoidPtr SCIObject;
@@ -88,9 +52,7 @@ typedef SCIObject ShellObject; typedef SCIObject UIObject;
// ------------------------------------------------------------------------------------------ //
-
-// ------------------------------------------------------------------------------------------ //
-/// @note Dynamic Loader API.
+/// @brief Dynamic Loader API.
// ------------------------------------------------------------------------------------------ //
/// @brief Get function which is part of the DLL.
diff --git a/dev/sci/xpcom_core.h b/dev/sci/xpcom_core.h deleted file mode 100644 index 45c13d1f..00000000 --- a/dev/sci/xpcom_core.h +++ /dev/null @@ -1,99 +0,0 @@ -/* -------------------------------------------
-
-Copyright ZKA Web Services Co.
-
-File: rt.internal.inl
-Purpose: Base code of XPCOM.
-
-------------------------------------------- */
-
-/// @internal Reserved for internal definitions only.
-
-#ifndef __TOOLCHAINKIT__
-#define object class
-#define protocol class
-#define clsid(X)
-
-#warning ! You may be using the clang compiler, please be cautious that some features mayn't be present. !
-#endif // !__TOOLCHAINKIT__
-
-protocol IUnknown; // Refrenced from an IDB entry.
-protocol ICLSID; // From the IDB, the constructor of the object, e.g: TextUCLSID.
-object UUID;
-object IStr;
-
-/// @brief Unknown XPCOM interface
-protocol clsid("d7c144b6-0792-44b8-b06b-02b227b547df") IUnknown
-{
-public:
- explicit IUnknown() = default;
- virtual ~IUnknown() = default;
-
- IUnknown& operator=(const IUnknown&) = default;
- IUnknown(const IUnknown&) = default;
-
- virtual SInt32 Release() = 0;
- virtual Void RemoveRef() = 0;
- virtual IUnknown* AddRef() = 0;
- virtual VoidPtr QueryClass(UUID * p_uuid) = 0;
-};
-
-/// @brief Allocate new XPCOM 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* XPCOMQueryInterface(UCLSID* uclsidOfCls, Args&&... args)
-{
- if (uclsidOfCls == nullptr)
- return nullptr;
-
- uclsidOfCls->AddRef();
- return uclsidOfCls->QueryInterfaceWithArgs(args...);
-}
-
-/// @brief Release XPCOM object.
-/// @tparam TCLS the class type.
-/// @param cls the class to release.
-/// @return status code.
-template <typename TCLS>
-inline SInt32 XPCOMReleaseClass(TCLS** cls)
-{
- if (!*cls)
- return -kErrorInvalidData;
-
- (*cls)->RemoveRef();
- (*cls)->Release();
-
- *cls = nullptr;
-
- return kErrorSuccess;
-}
-
-/// @brief Event listener interface.
-/// @tparam FnSign the event listener function type.
-/// @tparam ClsID the event listener class ID.
-template <typename FnSign, typename ClsID>
-protocol IEventListener : public ClsID
-{
- friend ClsID;
-
- explicit IEventListener() = default;
- virtual ~IEventListener() = default;
-
- IEventListener& operator=(const IEventListener&) = default;
- IEventListener(const IEventListener&) = default;
-
- virtual IEventListener& operator-=(const IStr* event_name)
- {
- this->RemoveEventListener(event_name);
- return *this;
- }
-
- virtual IEventListener& operator+=(FnSign arg)
- {
- this->AddEventListener(arg);
- return *this;
- }
-};
diff --git a/dev/zba/amd64-efi.make b/dev/zba/amd64-efi.make index 24ffeb95..aa071913 100644 --- a/dev/zba/amd64-efi.make +++ b/dev/zba/amd64-efi.make @@ -49,12 +49,9 @@ FLAG_GNU=-fshort-wchar -D__EFI_x86_64__ -mno-red-zone -D__NEWOSKRNL__ -D__NEWOSL -DEFI_FUNCTION_WRAPPER -I./ -I../zka -I../ -c -nostdlib -fno-rtti -fno-exceptions \ -std=c++20 -D__HAVE_ZKA_APIS__ -D__ZKA_USE_FB__ -D__ZKA_AMD64__ -D__ZKA__ -BOOT_LOADER=zbaosldr.exe +BOOTLOADER=zbaosldr.exe KERNEL=minoskrnl.exe -DDK=ddk.dll -SCI=sci.dll -CRT=crtx64.dll -SYS_CHK=syschk.sys +SYSCHK=syschk.sys STARTUP=startup.sys .PHONY: invalid-recipe @@ -65,15 +62,13 @@ invalid-recipe: all: compile-amd64 mkdir -p src/Root/EFI/BOOT $(LD_GNU) $(OBJ) $(LD_FLAGS) -o src/$(BOOT_LOADER) - $(COPY) src/$(BOOT_LOADER) src/Root/EFI/BOOT/BOOTX64.EFI - $(COPY) src/$(BOOT_LOADER) src/Root/EFI/BOOT/ZBA.EFI + $(COPY) src/$(BOOTLOADER) src/Root/EFI/BOOT/BOOTX64.EFI + $(COPY) src/$(BOOTLOADER) src/Root/EFI/BOOT/ZBAOSLDR.EFI $(COPY) ../zka/$(KERNEL) src/Root/$(KERNEL) - $(COPY) ../sci/$(SCI) src/Root/$(SCI) - $(COPY) ../ddk/$(DDK) src/Root/$(DDK) - $(COPY) ./Modules/SysChk/$(SYS_CHK) src/Root/$(SYS_CHK) - $(COPY) ./Modules/SysChk/$(SYS_CHK) src/Root/zka/$(STARTUP) + $(COPY) ./Modules/SysChk/$(SYSCHK) src/Root/$(SYSCHK) + $(COPY) ./Modules/SysChk/$(STARTUP) src/Root/zka/$(STARTUP) $(COPY) ../crt/$(CRT) src/Root/$(CRT) - $(COPY) src/$(BOOT_LOADER) src/Root/$(BOOT_LOADER) + $(COPY) src/$(BOOTLOADER) src/Root/$(BOOTLOADER) ifneq ($(DEBUG_SUPPORT), ) DEBUG = -D__DEBUG__ diff --git a/dev/zba/arm64-efi.make b/dev/zba/arm64-efi.make index 7ef77e72..dd7efc1f 100644 --- a/dev/zba/arm64-efi.make +++ b/dev/zba/arm64-efi.make @@ -50,9 +50,6 @@ FLAG_GNU=-fshort-wchar -c -ffreestanding -MMD -mno-red-zone -D__ZKA_ARM64__ -fno BOOT_LOADER=zbaosldr.exe KERNEL=minoskrnl.exe -DDK=ddk.dll -SCI=sci.dll -CRT=crt.dll SYS_CHK=syschk.sys STARTUP=startup.sys diff --git a/dev/zwm/.keepme b/dev/zwm/.keepme deleted file mode 100644 index e69de29b..00000000 --- a/dev/zwm/.keepme +++ /dev/null diff --git a/dev/zwm/ReadMe.md b/dev/zwm/ReadMe.md deleted file mode 100644 index 026d801f..00000000 --- a/dev/zwm/ReadMe.md +++ /dev/null @@ -1,3 +0,0 @@ -# ZKA Wireless Module. - -A DDK driver used to communicate with Wireless protocols. |
