From bf642edd6c77d405637f0695452460640b8e540d Mon Sep 17 00:00:00 2001 From: Amlal EL Mahrouss Date: Tue, 30 Jul 2024 08:49:23 +0200 Subject: [Refactor] SCIKit and DDKit. [IMP} Prevent DDK from being included when we aren't in kernel mode. Signed-off-by: Amlal EL Mahrouss --- DDK/DispatchKernelCall.S | 36 ----------- DDK/KernelAlloc.c | 34 ---------- DDK/KernelCall.c | 36 ----------- DDK/KernelCxxRt.cxx | 29 --------- DDK/KernelDev.c | 29 --------- DDK/KernelDev.h | 32 ---------- DDK/KernelPrint.c | 37 ----------- DDK/KernelPrint.h | 18 ------ DDK/KernelStd.h | 63 ------------------ DDK/KernelString.c | 39 ------------ DDK/KernelString.h | 17 ----- DDK/KernelVersion.c | 21 ------ DDK/ReadMe.md | 9 --- DDK/compile_flags.txt | 2 - DDK/x86_64.make | 14 ---- DDKit/DispatchKernelCall.S | 36 +++++++++++ DDKit/KernelAlloc.c | 34 ++++++++++ DDKit/KernelCall.c | 36 +++++++++++ DDKit/KernelCxxRt.cxx | 29 +++++++++ DDKit/KernelDev.c | 29 +++++++++ DDKit/KernelDev.h | 32 ++++++++++ DDKit/KernelPrint.c | 37 +++++++++++ DDKit/KernelPrint.h | 18 ++++++ DDKit/KernelStd.h | 67 ++++++++++++++++++++ DDKit/KernelString.c | 39 ++++++++++++ DDKit/KernelString.h | 17 +++++ DDKit/KernelVersion.c | 21 ++++++ DDKit/ReadMe.md | 9 +++ DDKit/compile_flags.txt | 2 + DDKit/source_deploy.xml | 5 ++ DDKit/x86_64.make | 14 ++++ SCI/ErrorTypes.hxx | 53 ---------------- SCI/Hint.hxx | 23 ------- SCI/StandardInterface.hxx | 123 ------------------------------------ SCI/compile_flags.txt | 4 -- SCIKit/ErrorTypes.hxx | 53 ++++++++++++++++ SCIKit/Hint.hxx | 23 +++++++ SCIKit/StandardInterface.hxx | 123 ++++++++++++++++++++++++++++++++++++ SCIKit/compile_flags.txt | 4 ++ SCIKit/source_deploy.xml | 5 ++ Samples/.gitkeep | 0 Samples/SampleHAL/CheckStck.c | 11 ---- Samples/SampleHAL/DriverRsrc.rsrc | 25 -------- Samples/SampleHAL/Main.c | 20 ------ Samples/SampleHAL/compile_flags.txt | 3 - Samples/SampleHAL/x86_64.mk | 51 --------------- 46 files changed, 633 insertions(+), 729 deletions(-) delete mode 100644 DDK/DispatchKernelCall.S delete mode 100644 DDK/KernelAlloc.c delete mode 100644 DDK/KernelCall.c delete mode 100644 DDK/KernelCxxRt.cxx delete mode 100644 DDK/KernelDev.c delete mode 100644 DDK/KernelDev.h delete mode 100644 DDK/KernelPrint.c delete mode 100644 DDK/KernelPrint.h delete mode 100644 DDK/KernelStd.h delete mode 100644 DDK/KernelString.c delete mode 100644 DDK/KernelString.h delete mode 100644 DDK/KernelVersion.c delete mode 100644 DDK/ReadMe.md delete mode 100644 DDK/compile_flags.txt delete mode 100644 DDK/x86_64.make create mode 100644 DDKit/DispatchKernelCall.S create mode 100644 DDKit/KernelAlloc.c create mode 100644 DDKit/KernelCall.c create mode 100644 DDKit/KernelCxxRt.cxx create mode 100644 DDKit/KernelDev.c create mode 100644 DDKit/KernelDev.h create mode 100644 DDKit/KernelPrint.c create mode 100644 DDKit/KernelPrint.h create mode 100644 DDKit/KernelStd.h create mode 100644 DDKit/KernelString.c create mode 100644 DDKit/KernelString.h create mode 100644 DDKit/KernelVersion.c create mode 100644 DDKit/ReadMe.md create mode 100644 DDKit/compile_flags.txt create mode 100644 DDKit/source_deploy.xml create mode 100644 DDKit/x86_64.make delete mode 100644 SCI/ErrorTypes.hxx delete mode 100644 SCI/Hint.hxx delete mode 100644 SCI/StandardInterface.hxx delete mode 100644 SCI/compile_flags.txt create mode 100644 SCIKit/ErrorTypes.hxx create mode 100644 SCIKit/Hint.hxx create mode 100644 SCIKit/StandardInterface.hxx create mode 100644 SCIKit/compile_flags.txt create mode 100644 SCIKit/source_deploy.xml delete mode 100644 Samples/.gitkeep delete mode 100644 Samples/SampleHAL/CheckStck.c delete mode 100644 Samples/SampleHAL/DriverRsrc.rsrc delete mode 100644 Samples/SampleHAL/Main.c delete mode 100644 Samples/SampleHAL/compile_flags.txt delete mode 100644 Samples/SampleHAL/x86_64.mk diff --git a/DDK/DispatchKernelCall.S b/DDK/DispatchKernelCall.S deleted file mode 100644 index b6ce8004..00000000 --- a/DDK/DispatchKernelCall.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 x11, #0x33 - svc #0 - -#endif diff --git a/DDK/KernelAlloc.c b/DDK/KernelAlloc.c deleted file mode 100644 index 1eadd4e2..00000000 --- a/DDK/KernelAlloc.c +++ /dev/null @@ -1,34 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies - - Purpose: DDK allocator. - -------------------------------------------- */ - -#include - -/** - \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("NewHeap", 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("DeleteHeap", 1, ptr, 0); -} diff --git a/DDK/KernelCall.c b/DDK/KernelCall.c deleted file mode 100644 index ffc2ded6..00000000 --- a/DDK/KernelCall.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies - - Purpose: DDK kernel call. - -------------------------------------------- */ - -#include -#include - -/// @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* kernelRpcName, int32_t cnt, void* data, size_t sz) -{ - if (!kernelRpcName || cnt == 0) - return nil; - - return __kernelCallDispatch(kernelRpcName, 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("AddSyscall", slot, slotFn, 0); -} diff --git a/DDK/KernelCxxRt.cxx b/DDK/KernelCxxRt.cxx deleted file mode 100644 index 08fab7b9..00000000 --- a/DDK/KernelCxxRt.cxx +++ /dev/null @@ -1,29 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies - - Purpose: DDK C++ runtime. - -------------------------------------------- */ - -#include - -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/DDK/KernelDev.c b/DDK/KernelDev.c deleted file mode 100644 index 07a64bdd..00000000 --- a/DDK/KernelDev.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies - - Purpose: DDK Text I/O. - -------------------------------------------- */ - -#include -#include - -/// @brief Open a new binary device from path. -DK_EXTERN kernelDeviceRef kernelOpenDevice(const char* devicePath) -{ - if (!devicePath) - return nil; - - return kernelCall("OpenDevice", 1, (void*)devicePath, kernelStringLength(devicePath)); -} - -/// @brief Close any device. -/// @param device valid device. -DK_EXTERN void kernelCloseDevice(kernelDeviceRef device) -{ - if (!device) - return; - - kernelCall("CloseDevice", 1, device, sizeof(kernelDevice)); -} diff --git a/DDK/KernelDev.h b/DDK/KernelDev.h deleted file mode 100644 index d7c13a13..00000000 --- a/DDK/KernelDev.h +++ /dev/null @@ -1,32 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies - - Purpose: DDK Devices. - -------------------------------------------- */ - -#pragma once - -#include - -struct _kernelDevice; - -/// @brief Kernel Device driver. -typedef struct _kernelDevice -{ - char name[255]; // the device name. Could be /./DEVICE_NAME/ - void* (*read)(void* arg, int len); // read from device. - void (*write)(void* arg, int len); - void (*wait)(void); // write to device. - struct _kernelDevice* (*open)(const char* path); // open device. - void (*close)(struct _kernelDevice* dev); // close device. -} kernelDevice, *kernelDeviceRef; - -/// @brief Open a new device from path. -/// @param devicePath the device's path. -DK_EXTERN kernelDeviceRef kernelOpenDevice(const char* devicePath); - -/// @brief Close any device. -/// @param device valid device. -DK_EXTERN void kernelCloseDevice(kernelDeviceRef device); diff --git a/DDK/KernelPrint.c b/DDK/KernelPrint.c deleted file mode 100644 index eee90e3c..00000000 --- a/DDK/KernelPrint.c +++ /dev/null @@ -1,37 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies - - Purpose: DDK Text I/O. - -------------------------------------------- */ - -#include - -DK_EXTERN void kernelPrintChar(const char ch) -{ - char assembled[2] = {0}; - assembled[0] = ch; - assembled[1] = 0; - - kernelCall("WriteCharacter", 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/DDK/KernelPrint.h b/DDK/KernelPrint.h deleted file mode 100644 index 25b702e1..00000000 --- a/DDK/KernelPrint.h +++ /dev/null @@ -1,18 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies - - Purpose: DDK Text I/O. - -------------------------------------------- */ - -#pragma once - -#include - -/// @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/DDK/KernelStd.h b/DDK/KernelStd.h deleted file mode 100644 index 5d8af8cd..00000000 --- a/DDK/KernelStd.h +++ /dev/null @@ -1,63 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies - - Purpose: DDK Definitions. - -------------------------------------------- */ - -#pragma once - -#if defined(__cplusplus) -#define DK_EXTERN extern "C" -#define nil nullptr -#define DK_FINAL final -#else -#define DK_EXTERN extern -#define nil ((void*)0) -#define DK_FINAL -#endif // defined(__cplusplus) - -#include -#include - -struct DDK_STATUS_STRUCT; - -/// \brief DDK status structure (__at_enable, __at_disable...) -struct DDK_STATUS_STRUCT DK_FINAL -{ - int32_t action_id; - int32_t issuer_id; - int32_t group_id; -}; - -/// @brief Call kernel (interrupt 0x33) -/// @param kernelRpcName -/// @param cnt number of elements in **dat** -/// @param dat data ptr -/// @param sz sz of whole data ptr. -/// @return result of call -DK_EXTERN void* kernelCall(const char* kernelRpcName, int32_t cnt, void* dat, size_t 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)); - -/// @brief allocate heap ptr. -/// @param sz size of ptr. -/// @return the pointer allocated or **nil**. -DK_EXTERN void* kernelAlloc(size_t sz); - -/// @brief free heap ptr. -/// @param pointer to free -DK_EXTERN void kernelFree(void*); - -/// @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; \ No newline at end of file diff --git a/DDK/KernelString.c b/DDK/KernelString.c deleted file mode 100644 index 2cb6adcc..00000000 --- a/DDK/KernelString.c +++ /dev/null @@ -1,39 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies - - Purpose: DDK Strings. - -------------------------------------------- */ - -#include - -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/DDK/KernelString.h b/DDK/KernelString.h deleted file mode 100644 index dd6fdce6..00000000 --- a/DDK/KernelString.h +++ /dev/null @@ -1,17 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies - - Purpose: DDK Strings. - -------------------------------------------- */ - -#pragma once - -#include - -/// @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/DDK/KernelVersion.c b/DDK/KernelVersion.c deleted file mode 100644 index 0f27d345..00000000 --- a/DDK/KernelVersion.c +++ /dev/null @@ -1,21 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies - - Purpose: DDK versioning. - -------------------------------------------- */ - -#include - -#ifndef cDDKVersionHighest -#define cDDKVersionHighest 1 -#endif // cDDKVersionHighest - -#ifndef cDDKVersionLowest -#define cDDKVersionLowest 1 -#endif // cDDKVersionLowest - -int32_t c_api_version_highest = cDDKVersionHighest; -int32_t c_api_version_least = cDDKVersionLowest; -int32_t c_api_version = cDDKVersionHighest | cDDKVersionLowest; \ No newline at end of file diff --git a/DDK/ReadMe.md b/DDK/ReadMe.md deleted file mode 100644 index cde81cf7..00000000 --- a/DDK/ReadMe.md +++ /dev/null @@ -1,9 +0,0 @@ -# DDK (Device Driver Kit) - -A kit used to write kernel HALs, using the NDK compiler suite. - -## How to use it - -Simply link against libDDK. - -###### Copyright 2024 ZKA Technologies, all rights reserved. diff --git a/DDK/compile_flags.txt b/DDK/compile_flags.txt deleted file mode 100644 index 48dfa8fe..00000000 --- a/DDK/compile_flags.txt +++ /dev/null @@ -1,2 +0,0 @@ --std=c17 --I../ diff --git a/DDK/x86_64.make b/DDK/x86_64.make deleted file mode 100644 index 61cafeee..00000000 --- a/DDK/x86_64.make +++ /dev/null @@ -1,14 +0,0 @@ -################################################## -# (C) ZKA Technologies, 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 -fno-rtti -fno-exceptions -D__DDK_AMD64__ -Wl,--subsystem=17 -VERSION=-DcDDKVersionLowest=1 -DcDDKVersionHighest=1 -OUTPUT=libDDK.dll - -.PHONY: all -all: - $(CC) $(INC) $(FLAGS) $(VERSION) $(wildcard *.c) $(wildcard *.S) $(wildcard *.cxx) -o $(OUTPUT) \ No newline at end of file diff --git a/DDKit/DispatchKernelCall.S b/DDKit/DispatchKernelCall.S new file mode 100644 index 00000000..b6ce8004 --- /dev/null +++ b/DDKit/DispatchKernelCall.S @@ -0,0 +1,36 @@ +/** + 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 x11, #0x33 + svc #0 + +#endif diff --git a/DDKit/KernelAlloc.c b/DDKit/KernelAlloc.c new file mode 100644 index 00000000..f1044324 --- /dev/null +++ b/DDKit/KernelAlloc.c @@ -0,0 +1,34 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies + + Purpose: DDK allocator. + +------------------------------------------- */ + +#include + +/** + \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("NewHeap", 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("DeleteHeap", 1, ptr, 0); +} diff --git a/DDKit/KernelCall.c b/DDKit/KernelCall.c new file mode 100644 index 00000000..fb29fc6a --- /dev/null +++ b/DDKit/KernelCall.c @@ -0,0 +1,36 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies + + Purpose: DDK kernel call. + +------------------------------------------- */ + +#include +#include + +/// @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* kernelRpcName, int32_t cnt, void* data, size_t sz) +{ + if (!kernelRpcName || cnt == 0) + return nil; + + return __kernelCallDispatch(kernelRpcName, 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("AddSyscall", slot, slotFn, 0); +} diff --git a/DDKit/KernelCxxRt.cxx b/DDKit/KernelCxxRt.cxx new file mode 100644 index 00000000..93980532 --- /dev/null +++ b/DDKit/KernelCxxRt.cxx @@ -0,0 +1,29 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies + + Purpose: DDK C++ runtime. + +------------------------------------------- */ + +#include + +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/DDKit/KernelDev.c b/DDKit/KernelDev.c new file mode 100644 index 00000000..d0c7570d --- /dev/null +++ b/DDKit/KernelDev.c @@ -0,0 +1,29 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies + + Purpose: DDK Text I/O. + +------------------------------------------- */ + +#include +#include + +/// @brief Open a new binary device from path. +DK_EXTERN kernelDeviceRef kernelOpenDevice(const char* devicePath) +{ + if (!devicePath) + return nil; + + return kernelCall("OpenDevice", 1, (void*)devicePath, kernelStringLength(devicePath)); +} + +/// @brief Close any device. +/// @param device valid device. +DK_EXTERN void kernelCloseDevice(kernelDeviceRef device) +{ + if (!device) + return; + + kernelCall("CloseDevice", 1, device, sizeof(kernelDevice)); +} diff --git a/DDKit/KernelDev.h b/DDKit/KernelDev.h new file mode 100644 index 00000000..4e640d9d --- /dev/null +++ b/DDKit/KernelDev.h @@ -0,0 +1,32 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies + + Purpose: DDK Devices. + +------------------------------------------- */ + +#pragma once + +#include + +struct _kernelDevice; + +/// @brief Kernel Device driver. +typedef struct _kernelDevice +{ + char name[255]; // the device name. Could be /./DEVICE_NAME/ + void* (*read)(void* arg, int len); // read from device. + void (*write)(void* arg, int len); + void (*wait)(void); // write to device. + struct _kernelDevice* (*open)(const char* path); // open device. + void (*close)(struct _kernelDevice* dev); // close device. +} kernelDevice, *kernelDeviceRef; + +/// @brief Open a new device from path. +/// @param devicePath the device's path. +DK_EXTERN kernelDeviceRef kernelOpenDevice(const char* devicePath); + +/// @brief Close any device. +/// @param device valid device. +DK_EXTERN void kernelCloseDevice(kernelDeviceRef device); diff --git a/DDKit/KernelPrint.c b/DDKit/KernelPrint.c new file mode 100644 index 00000000..b7e20d24 --- /dev/null +++ b/DDKit/KernelPrint.c @@ -0,0 +1,37 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies + + Purpose: DDK Text I/O. + +------------------------------------------- */ + +#include + +DK_EXTERN void kernelPrintChar(const char ch) +{ + char assembled[2] = {0}; + assembled[0] = ch; + assembled[1] = 0; + + kernelCall("WriteCharacter", 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/DDKit/KernelPrint.h b/DDKit/KernelPrint.h new file mode 100644 index 00000000..0556923a --- /dev/null +++ b/DDKit/KernelPrint.h @@ -0,0 +1,18 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies + + Purpose: DDK Text I/O. + +------------------------------------------- */ + +#pragma once + +#include + +/// @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/DDKit/KernelStd.h b/DDKit/KernelStd.h new file mode 100644 index 00000000..bdd8ce3d --- /dev/null +++ b/DDKit/KernelStd.h @@ -0,0 +1,67 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies + + Purpose: DDK Definitions. + +------------------------------------------- */ + +#pragma once + +#include +#include + +#if defined(__cplusplus) +#define DK_EXTERN extern "C" +#define nil nullptr +#define DK_FINAL final +#else +#define DK_EXTERN extern +#define nil ((void*)0) +#define DK_FINAL +#endif // defined(__cplusplus) + +#ifndef __KERNEL__ +#error !!! including header in kernel mode !!! +#endif // __KERNEL__ + +struct DDK_STATUS_STRUCT; + +/// \brief DDK status structure (__at_enable, __at_disable...) +struct DDK_STATUS_STRUCT DK_FINAL +{ + int32_t action_id; + int32_t issuer_id; + int32_t group_id; +}; + +/// @brief Call kernel (interrupt 0x33) +/// @param kernelRpcName +/// @param cnt number of elements in **dat** +/// @param dat data ptr +/// @param sz sz of whole data ptr. +/// @return result of call +DK_EXTERN void* kernelCall(const char* kernelRpcName, int32_t cnt, void* dat, size_t 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)); + +/// @brief allocate heap ptr. +/// @param sz size of ptr. +/// @return the pointer allocated or **nil**. +DK_EXTERN void* kernelAlloc(size_t sz); + +/// @brief free heap ptr. +/// @param pointer to free +DK_EXTERN void kernelFree(void*); + +/// @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; \ No newline at end of file diff --git a/DDKit/KernelString.c b/DDKit/KernelString.c new file mode 100644 index 00000000..3ef65cf2 --- /dev/null +++ b/DDKit/KernelString.c @@ -0,0 +1,39 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies + + Purpose: DDK Strings. + +------------------------------------------- */ + +#include + +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/DDKit/KernelString.h b/DDKit/KernelString.h new file mode 100644 index 00000000..07d33c7e --- /dev/null +++ b/DDKit/KernelString.h @@ -0,0 +1,17 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies + + Purpose: DDK Strings. + +------------------------------------------- */ + +#pragma once + +#include + +/// @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/DDKit/KernelVersion.c b/DDKit/KernelVersion.c new file mode 100644 index 00000000..0f27d345 --- /dev/null +++ b/DDKit/KernelVersion.c @@ -0,0 +1,21 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies + + Purpose: DDK versioning. + +------------------------------------------- */ + +#include + +#ifndef cDDKVersionHighest +#define cDDKVersionHighest 1 +#endif // cDDKVersionHighest + +#ifndef cDDKVersionLowest +#define cDDKVersionLowest 1 +#endif // cDDKVersionLowest + +int32_t c_api_version_highest = cDDKVersionHighest; +int32_t c_api_version_least = cDDKVersionLowest; +int32_t c_api_version = cDDKVersionHighest | cDDKVersionLowest; \ No newline at end of file diff --git a/DDKit/ReadMe.md b/DDKit/ReadMe.md new file mode 100644 index 00000000..cde81cf7 --- /dev/null +++ b/DDKit/ReadMe.md @@ -0,0 +1,9 @@ +# DDK (Device Driver Kit) + +A kit used to write kernel HALs, using the NDK compiler suite. + +## How to use it + +Simply link against libDDK. + +###### Copyright 2024 ZKA Technologies, all rights reserved. diff --git a/DDKit/compile_flags.txt b/DDKit/compile_flags.txt new file mode 100644 index 00000000..48dfa8fe --- /dev/null +++ b/DDKit/compile_flags.txt @@ -0,0 +1,2 @@ +-std=c17 +-I../ diff --git a/DDKit/source_deploy.xml b/DDKit/source_deploy.xml new file mode 100644 index 00000000..6a03fdf8 --- /dev/null +++ b/DDKit/source_deploy.xml @@ -0,0 +1,5 @@ + + + *.cxx, *.c, *.S + + diff --git a/DDKit/x86_64.make b/DDKit/x86_64.make new file mode 100644 index 00000000..f261d432 --- /dev/null +++ b/DDKit/x86_64.make @@ -0,0 +1,14 @@ +################################################## +# (C) ZKA Technologies, 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__KERNEL__ -fno-rtti -fno-exceptions -D__DDK_AMD64__ -Wl,--subsystem=17 +VERSION=-DcDDKVersionLowest=1 -DcDDKVersionHighest=1 +OUTPUT=libDDK.so + +.PHONY: x86_64-build +x86_64-build: + $(CC) $(INC) $(FLAGS) $(VERSION) $(wildcard *.c) $(wildcard *.S) $(wildcard *.cxx) -o $(OUTPUT) \ No newline at end of file diff --git a/SCI/ErrorTypes.hxx b/SCI/ErrorTypes.hxx deleted file mode 100644 index 041786ba..00000000 --- a/SCI/ErrorTypes.hxx +++ /dev/null @@ -1,53 +0,0 @@ -/* ------------------------------------------- - - 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 kErrorInvalidCreds = 61; -inline constexpr HError kErrorUnimplemented = 0; - -inline HError kLastError = 0; diff --git a/SCI/Hint.hxx b/SCI/Hint.hxx deleted file mode 100644 index fd91ece9..00000000 --- a/SCI/Hint.hxx +++ /dev/null @@ -1,23 +0,0 @@ -/* ------------------------------------------- - - 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 deleted file mode 100644 index 9e792546..00000000 --- a/SCI/StandardInterface.hxx +++ /dev/null @@ -1,123 +0,0 @@ -/* ------------------------------------------- - -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 deleted file mode 100644 index 509e3eed..00000000 --- a/SCI/compile_flags.txt +++ /dev/null @@ -1,4 +0,0 @@ --I./ --I../Kernel --I../ --std=c++20 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 + +#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 @@ + + + *.cxx + + diff --git a/Samples/.gitkeep b/Samples/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/Samples/SampleHAL/CheckStck.c b/Samples/SampleHAL/CheckStck.c deleted file mode 100644 index 54b6bc5d..00000000 --- a/Samples/SampleHAL/CheckStck.c +++ /dev/null @@ -1,11 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies - -------------------------------------------- */ - -///! @brief Use this to check your stack, if using MinGW/MSVC/CodeTools. -void ___chkstk_ms(void) -{ - (void)0; -} diff --git a/Samples/SampleHAL/DriverRsrc.rsrc b/Samples/SampleHAL/DriverRsrc.rsrc deleted file mode 100644 index 45caf4db..00000000 --- a/Samples/SampleHAL/DriverRsrc.rsrc +++ /dev/null @@ -1,25 +0,0 @@ -1 ICON "../../Icons/default.ico" - -1 VERSIONINFO -FILEVERSION 1,0,0,0 -PRODUCTVERSION 1,0,0,0 -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "080904E4" - BEGIN - VALUE "CompanyName", "ZKA Technologies" - VALUE "FileDescription", "ZKA HAL." - VALUE "FileVersion", "1.00" - VALUE "InternalName", "SampleHAL" - VALUE "LegalCopyright", "Copyright ZKA Technologies, all rights reserved." - VALUE "OriginalFilename", "SampleHAL.exe" - VALUE "ProductName", "SampleHAL" - VALUE "ProductVersion", "1.00" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x809, 1252 - END -END diff --git a/Samples/SampleHAL/Main.c b/Samples/SampleHAL/Main.c deleted file mode 100644 index 9d1510ea..00000000 --- a/Samples/SampleHAL/Main.c +++ /dev/null @@ -1,20 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies - -------------------------------------------- */ - -#include -#include - -int __at_enter(void) -{ - kernelPrintStr("SampleHAL: Starting up...\r"); - return 0; -} - -int __at_exit(void) -{ - kernelPrintStr("SampleHAL: Shutting down...\r"); - return 0; -} diff --git a/Samples/SampleHAL/compile_flags.txt b/Samples/SampleHAL/compile_flags.txt deleted file mode 100644 index 10bdb71e..00000000 --- a/Samples/SampleHAL/compile_flags.txt +++ /dev/null @@ -1,3 +0,0 @@ --I../../ --I../../Kernel --std=c++20 diff --git a/Samples/SampleHAL/x86_64.mk b/Samples/SampleHAL/x86_64.mk deleted file mode 100644 index 2fa20d1a..00000000 --- a/Samples/SampleHAL/x86_64.mk +++ /dev/null @@ -1,51 +0,0 @@ -################################################## -# (C) ZKA Technologies, all rights reserved. -# This is the sample driver makefile. -################################################## - -CC_GNU=x86_64-w64-mingw32-gcc -LD_GNU=x86_64-w64-mingw32-ld - -WINDRES=x86_64-w64-mingw32-windres - -ADD_FILE=touch -COPY=cp -HTTP_GET=wget - -LD_FLAGS=-e __at_enter --subsystem=17 - -OBJ=*.o - - -REM=rm -REM_FLAG=-f - -FLAG_ASM=-f win64 -FLAG_GNU=-fshort-wchar -D__EFI_x86_64__ -mgeneral-regs-only -mno-red-zone -D__KERNEL__ -DEFI_FUNCTION_WRAPPER -I../ -I../../ -I./ -c -ffreestanding -std=c17 -D__HAVE_MAHROUSS_APIS__ -D__MAHROUSS__ -D__BOOTLOADER__ -I./ - -.PHONY: invalid-recipe -invalid-recipe: - @echo "invalid-recipe: Use make all instead." - -.PHONY: all -all: compile-amd64 - $(LD_GNU) $(OBJ) $(LD_FLAGS) -o SampleHAL.exe - -ifneq ($(DEBUG_SUPPORT), ) -DEBUG = -D__DEBUG__ -endif - -.PHONY: compile-amd64 -compile-amd64: - $(WINDRES) DriverRsrc.rsrc -O coff -o DriverRsrc.o - $(CC_GNU) $(FLAG_GNU) $(DEBUG) $(wildcard *.c) $(wildcard ../../DDK/*.c) $(wildcard ../../DDK/*.S) - -.PHONY: clean -clean: - $(REM) $(REM_FLAG) $(OBJ) SampleHAL.exe - -.PHONY: help -help: - @echo "=== HELP ===" - @echo "clean: Clean driver." - @echo "compile-amd64: Build driver." -- cgit v1.2.3