summaryrefslogtreecommitdiffhomepage
path: root/dev/libDDK/src
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-11-24 03:02:43 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2025-11-24 03:02:43 +0100
commit83d870e58457a1d335a1d9b9966a6a1887cc297b (patch)
tree72888f88c7728c82f3f6df1f4f70591de15eab36 /dev/libDDK/src
parentab37adbacf0f33845804c788b39680cd754752a8 (diff)
feat! breaking changes on kernel sources.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/libDDK/src')
-rw-r--r--dev/libDDK/src/ddk_abi_cxx.cc27
-rw-r--r--dev/libDDK/src/ddk_alloc.c32
-rw-r--r--dev/libDDK/src/ddk_dev.c27
-rw-r--r--dev/libDDK/src/ddk_io.c36
-rw-r--r--dev/libDDK/src/ddk_kernel_call.c76
-rw-r--r--dev/libDDK/src/ddk_kernel_call_dispatch.S47
-rw-r--r--dev/libDDK/src/ddk_str.c36
-rw-r--r--dev/libDDK/src/ddk_ver.c25
8 files changed, 0 insertions, 306 deletions
diff --git a/dev/libDDK/src/ddk_abi_cxx.cc b/dev/libDDK/src/ddk_abi_cxx.cc
deleted file mode 100644
index 196f7f6a..00000000
--- a/dev/libDDK/src/ddk_abi_cxx.cc
+++ /dev/null
@@ -1,27 +0,0 @@
-/* ========================================
-
- DDK
- Copyright Amlal El Mahrouss.
-
- Author: Amlal El Mahrouss
- Purpose: DDK C++ ABI.
-
-======================================== */
-
-#include <DriverKit/ddk.h>
-
-void* operator new(size_t sz) {
- return ::kalloc(sz);
-}
-
-void operator delete(void* ptr) {
- ::kfree(ptr);
-}
-
-void* operator new[](size_t sz) {
- return ::kalloc(sz);
-}
-
-void operator delete[](void* ptr) {
- ::kfree(ptr);
-}
diff --git a/dev/libDDK/src/ddk_alloc.c b/dev/libDDK/src/ddk_alloc.c
deleted file mode 100644
index 09f3034f..00000000
--- a/dev/libDDK/src/ddk_alloc.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/* ========================================
-
- Copyright Amlal El Mahrouss.
-
- Purpose: DDK allocator.
-
-======================================== */
-
-#include <DriverKit/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.
-*/
-DDK_EXTERN void* kalloc(size_t sz) {
- if (!sz) ++sz;
-
- void* ptr = ke_call_dispatch("mm_alloc_ptr", 1, &sz, sizeof(size_t));
-
- return ptr;
-}
-
-/**
- \brief Frees a pointer from the heap.
- \param ptr the pointer to free.
-*/
-DDK_EXTERN void kfree(void* ptr) {
- if (!ptr) return;
-
- ke_call_dispatch("mm_free_ptr", 1, ptr, 0);
-}
diff --git a/dev/libDDK/src/ddk_dev.c b/dev/libDDK/src/ddk_dev.c
deleted file mode 100644
index 64ecefb6..00000000
--- a/dev/libDDK/src/ddk_dev.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* ========================================
-
- Copyright Amlal El Mahrouss.
-
- Purpose: DDK Text I/O.
-
-======================================== */
-
-#include <DriverKit/dev.h>
-#include <DriverKit/str.h>
-
-/// @brief Open a new binary device from path.
-DDK_EXTERN DDK_DEVICE_PTR kopen_dev(const char* devicePath) {
- if (nil == devicePath) return nil;
-
- return (DDK_DEVICE_PTR) ke_call_dispatch("dk_open_dev", 1, (void*) devicePath,
- kstrlen(devicePath));
-}
-
-/// @brief Close any device.
-/// @param device valid device.
-DDK_EXTERN BOOL kclose_dev(DDK_DEVICE_PTR device) {
- if (nil == device) return NO;
-
- ke_call_dispatch("dk_close_dev", 1, device, sizeof(DDK_DEVICE));
- return YES;
-}
diff --git a/dev/libDDK/src/ddk_io.c b/dev/libDDK/src/ddk_io.c
deleted file mode 100644
index 07287b91..00000000
--- a/dev/libDDK/src/ddk_io.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/* ========================================
-
- libDDK - Device Driver Kit
- Copyright 2025 - Amlal El Mahrouss and NeKernel contributors.
-
- File: ddk_io.c
- Purpose: DDK Text I/O.
-
-======================================== */
-
-#include <DriverKit/io.h>
-
-DDK_EXTERN void kputc(const char ch) {
- if (!ch) return;
-
- char assembled[2] = {0};
- assembled[0] = ch;
- assembled[1] = 0;
-
- ke_call_dispatch("ke_put_string", 1, assembled, 1);
-}
-
-/// @brief print string to UART.
-/// @param message UART to transmit.
-DDK_EXTERN void kprint(const char* message) {
- if (nil == message) return;
- if (*message == '\0') return;
-
- size_t index = 0;
- size_t len = kstrlen(message);
-
- while (index < len) {
- kputc(message[index]);
- ++index;
- }
-}
diff --git a/dev/libDDK/src/ddk_kernel_call.c b/dev/libDDK/src/ddk_kernel_call.c
deleted file mode 100644
index 92662ea5..00000000
--- a/dev/libDDK/src/ddk_kernel_call.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/* ========================================
-
- DDK
- Copyright Amlal El Mahrouss.
-
- Author: Amlal El Mahrouss
- Purpose: DDK kernel dispatch system.
-
-======================================== */
-
-#include <DriverKit/ddk.h>
-#include <stdarg.h>
-
-/// @brief this is an internal call, do not use it.
-DDK_EXTERN ATTRIBUTE(naked) ptr_t
- __ke_call_dispatch(const int32_t name, int32_t cnt, void* data, size_t sz);
-/// @brief This function hashes the path into a FNV symbol.
-/// @param path the path to hash.
-/// @retval 0 symbol wasn't hashed.
-/// @retval > 0 hashed symbol.
-static uint64_t ddk_fnv_64(const char* path) {
- if (path == nil || *path == 0) return 0;
-
- const uint64_t kFnvOffsetBase = 0xcbf29ce484222325ULL;
- const uint64_t kFnvPrime64 = 0x100000001b3ULL;
-
- uint64_t hash = kFnvOffsetBase;
-
- while (*path) {
- hash ^= (char) (*path++);
- hash *= kFnvPrime64;
- }
-
- return hash;
-}
-
-/// @brief Interrupt Kernel and call it's RPC.
-/// @param name 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)
-DDK_EXTERN void* ke_call_dispatch(const char* name, int32_t cnt, void* data, size_t sz) {
- if (name == nil || *name == 0 || data == nil || cnt == 0) return nil;
- return __ke_call_dispatch(ddk_fnv_64(name), cnt, data, sz);
-}
-
-/// @brief Add system call.
-/// @param slot system call slot
-/// @param slotFn, syscall slot.
-DDK_EXTERN void ke_set_syscall(const int slot, void (*slotFn)(void* a0)) {
- ke_call_dispatch("ke_set_syscall", slot, slotFn, 1);
-}
-
-/// @brief Get a Kernel object.
-/// @param slot property id (always 0)
-/// @param name the object's name.
-/// @return Object manifest.
-DDK_EXTERN struct DDK_OBJECT_MANIFEST* ke_get_obj(const int slot, const char* name) {
- struct DDK_OBJECT_MANIFEST* manifest =
- (struct DDK_OBJECT_MANIFEST*) ke_call_dispatch("cfkit_get_kobj", slot, (void*) name, 1);
-
- if (!manifest) return nil;
-
- return manifest;
-}
-
-/// @brief Set a Kernel object.
-/// @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.
-DDK_EXTERN void* ke_set_obj(const int slot, const struct DDK_OBJECT_MANIFEST* ddk_pr) {
- return ke_call_dispatch("cfkit_set_kobj", slot, (void*) ddk_pr, 1);
-}
diff --git a/dev/libDDK/src/ddk_kernel_call_dispatch.S b/dev/libDDK/src/ddk_kernel_call_dispatch.S
deleted file mode 100644
index a607fe40..00000000
--- a/dev/libDDK/src/ddk_kernel_call_dispatch.S
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- lang: asm
- compiler: gnu
- */
-
-#define kKernelCallTrapId 51
-
-.globl __ke_call_dispatch
-
-.text
-
-/* Really simple function, takes our va-list,
- and brings it to the trap handler in the Kernel. */
-
-#if defined(__DDK_AMD64__)
-
- .intel_syntax noprefix
-
-/* args rcx, rdx, r8, r9 */
-__ke_call_dispatch:
- push rbp
- mov rbp, rsp
-
- /* registers have already been pushed. */
-
- int kKernelCallTrapId
-
- pop rbp
- ret
-
-#elif defined(__DDK_POWER64__)
-
-/* args r8, r9, r10, r11 */
-__ke_call_dispatch:
- /* 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 */
-__ke_call_dispatch:
- /* There is no specific interrupt request id for a system call in ARM64 as well. */
- mov x9, #kKernelCallTrapId
- svc #0
-
-#endif
diff --git a/dev/libDDK/src/ddk_str.c b/dev/libDDK/src/ddk_str.c
deleted file mode 100644
index 3021f84a..00000000
--- a/dev/libDDK/src/ddk_str.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/* ========================================
-
- Copyright Amlal El Mahrouss.
-
- Purpose: DDK String API.
-
-======================================== */
-
-#include <DriverKit/str.h>
-
-DDK_EXTERN size_t kstrlen(const char* in) {
- if (in == nil) return 0;
-
- if (*in == 0) return 0;
-
- size_t index = 0;
-
- while (in[index] != 0) {
- ++index;
- }
-
- return index;
-}
-
-DDK_EXTERN int kstrncpy(char* dst, const char* src, size_t len) {
- if (nil == dst || nil == src) return 0;
-
- size_t index = 0;
-
- while (index != len) {
- dst[index] = src[index];
- ++index;
- }
-
- return index;
-}
diff --git a/dev/libDDK/src/ddk_ver.c b/dev/libDDK/src/ddk_ver.c
deleted file mode 100644
index 3679bdef..00000000
--- a/dev/libDDK/src/ddk_ver.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/* ========================================
-
- Copyright Amlal El Mahrouss.
-
- Purpose: DDK version system.
-
-======================================== */
-
-#include <DriverKit/ddk.h>
-
-#ifndef kDDKVersionHighest
-#define kDDKVersionHighest 1
-#endif // !kDDKVersionHighest
-
-#ifndef kDDKVersionLowest
-#define kDDKVersionLowest 1
-#endif // !kDDKVersionLowest
-
-#ifndef kDDKVersion
-#define kDDKVersion 1
-#endif // !kDDKVersion
-
-uint32_t kApiVersionHighest = kDDKVersionHighest;
-uint32_t kApiVersionLowest = kDDKVersionLowest;
-uint32_t kApiVersion = kDDKVersion;