diff options
Diffstat (limited to 'dev/ddk')
| -rw-r--r-- | dev/ddk/ReadMe.md | 9 | ||||
| -rw-r--r-- | dev/ddk/ddk.h | 117 | ||||
| -rw-r--r-- | dev/ddk/ddk.json | 24 | ||||
| -rw-r--r-- | dev/ddk/dev.h | 33 | ||||
| -rw-r--r-- | dev/ddk/io.h | 18 | ||||
| -rw-r--r-- | dev/ddk/src/ddk_alloc.c | 36 | ||||
| -rw-r--r-- | dev/ddk/src/ddk_dev.c | 29 | ||||
| -rw-r--r-- | dev/ddk/src/ddk_io.c | 42 | ||||
| -rw-r--r-- | dev/ddk/src/ddk_kernel_call.c | 60 | ||||
| -rw-r--r-- | dev/ddk/src/ddk_kernel_call_dispatch.S | 36 | ||||
| -rw-r--r-- | dev/ddk/src/ddk_rt_cxx.cc | 29 | ||||
| -rw-r--r-- | dev/ddk/src/ddk_str.c | 39 | ||||
| -rw-r--r-- | dev/ddk/src/ddk_ver.c | 25 | ||||
| -rw-r--r-- | dev/ddk/str.h | 17 | ||||
| -rw-r--r-- | dev/ddk/x86_64.make | 14 |
15 files changed, 0 insertions, 528 deletions
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)
|
