diff options
| author | Amlal <amlal@nekernel.org> | 2025-08-13 23:56:41 +0200 |
|---|---|---|
| committer | Amlal <amlal@nekernel.org> | 2025-08-13 23:56:41 +0200 |
| commit | bb432453ab609ca7e8dc8e991775329d10a29e7b (patch) | |
| tree | cea449ab68c412e6bd33ef4aedf8c912b55b3ade /dev/ddk/DriverKit | |
| parent | d720fa31aaf728b63c95575843f42a575c63765f (diff) | |
feat! Breaking changes in the DDK.
Signed-off-by: Amlal <amlal@nekernel.org>
Diffstat (limited to 'dev/ddk/DriverKit')
| -rw-r--r-- | dev/ddk/DriverKit/ddk.h | 74 | ||||
| -rw-r--r-- | dev/ddk/DriverKit/dev.h | 36 | ||||
| -rw-r--r-- | dev/ddk/DriverKit/io.h | 18 | ||||
| -rw-r--r-- | dev/ddk/DriverKit/macros.h | 48 | ||||
| -rw-r--r-- | dev/ddk/DriverKit/net.h | 16 | ||||
| -rw-r--r-- | dev/ddk/DriverKit/str.h | 17 |
6 files changed, 209 insertions, 0 deletions
diff --git a/dev/ddk/DriverKit/ddk.h b/dev/ddk/DriverKit/ddk.h new file mode 100644 index 00000000..254137f9 --- /dev/null +++ b/dev/ddk/DriverKit/ddk.h @@ -0,0 +1,74 @@ +/* ------------------------------------------- + + Copyright Amlal El Mahrouss. + + FILE: ddk.h + PURPOSE: DDK Driver model base header. + +------------------------------------------- */ + +#pragma once + +#include <DriverKit/macros.h> + +struct DDK_STATUS_STRUCT; +struct DDK_OBJECT_MANIFEST; + +/// \brief Object handle manifest. +struct DDK_OBJECT_MANIFEST DDK_FINAL { + char* p_name; + int32_t p_kind; + void* p_object; +}; + +/// \brief DDK status ping structure. +struct DDK_STATUS_STRUCT DDK_FINAL { + int32_t s_action_id; + int32_t s_issuer_id; + int32_t s_group_id; + struct DDK_OBJECT_MANIFEST* s_object; +}; + +/// @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 +DDK_EXTERN void* ke_call_dispatch(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. +DDK_EXTERN void ke_set_syscall(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**. +DDK_EXTERN void* kalloc(size_t sz); + +/// @brief Frees an heap ptr. +/// @param pointer kernel pointer to free. +DDK_EXTERN void kfree(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. +DDK_EXTERN struct DDK_OBJECT_MANIFEST* ke_get_obj(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. +DDK_EXTERN void* ke_set_obj(const int32_t slot, const struct DDK_OBJECT_MANIFEST* ddk_pr); + +/// @brief The highest API version of the DDK. +DDK_EXTERN uint32_t kApiVersionHighest; + +/// @brief The lowest API version of the DDK. +DDK_EXTERN uint32_t kApiVersionLowest; + +/// @brief API version in BCD. +DDK_EXTERN uint32_t kApiVersion; diff --git a/dev/ddk/DriverKit/dev.h b/dev/ddk/DriverKit/dev.h new file mode 100644 index 00000000..adb1c1d0 --- /dev/null +++ b/dev/ddk/DriverKit/dev.h @@ -0,0 +1,36 @@ +/* ------------------------------------------- + + Copyright Amlal El Mahrouss. + + File: dev.h + Purpose: DDK device support. + +------------------------------------------- */ + +#pragma once + +#include <DriverKit/ddk.h> + +struct _DDK_DEVICE; + +#define DDK_DEVICE_NAME_LEN (255) + +/// @brief Kernel Device driver. +typedef struct _DDK_DEVICE DDK_FINAL { + char d_name[DDK_DEVICE_NAME_LEN]; // 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. + void (*d_seek)(struct _DDK_DEVICE* dev, size_t off); + size_t (*d_tell)(struct _DDK_DEVICE* dev); +} DDK_DEVICE, *DDK_DEVICE_PTR; + +/// @brief Open a new device from path. +/// @param path the device's path. +DDK_EXTERN DDK_DEVICE_PTR open(const char* path); + +/// @brief Close any device. +/// @param device valid device. +DDK_EXTERN BOOL close(DDK_DEVICE_PTR device); diff --git a/dev/ddk/DriverKit/io.h b/dev/ddk/DriverKit/io.h new file mode 100644 index 00000000..805696e6 --- /dev/null +++ b/dev/ddk/DriverKit/io.h @@ -0,0 +1,18 @@ +/* ------------------------------------------- + + Copyright Amlal El Mahrouss. + + Purpose: DDK Text I/O. + +------------------------------------------- */ + +#pragma once + +#include <DriverKit/str.h> + +/// @brief print character into UART. +DDK_EXTERN void kputc(const char ch); + +/// @brief print string to UART. +/// @param message string to transmit to UART. +DDK_EXTERN void kprint(const char* message); diff --git a/dev/ddk/DriverKit/macros.h b/dev/ddk/DriverKit/macros.h new file mode 100644 index 00000000..9b7b3d50 --- /dev/null +++ b/dev/ddk/DriverKit/macros.h @@ -0,0 +1,48 @@ +/* ------------------------------------------- + + Copyright 2025 Amlal El Mahrouss. + + FILE: ddk.h + PURPOSE: DDK Driver model base header. + +------------------------------------------- */ + +#pragma once + +#include <stddef.h> +#include <stdint.h> + +#if defined(__cplusplus) +#define BOOL bool +#define YES true +#define NO false +#define DDK_EXTERN extern "C" __declspec(dllexport) +#define nil nullptr +#undef NULL +#define NULL 0 +#define DDK_FINAL final +#else +#define BOOL char +#define YES 1 +#define NO 0 +#define DDK_EXTERN extern __declspec(dllexport) +#define nil ((void*) 0) +#undef NULL +#define NULL ((void*) 0) +#define DDK_FINAL +#endif // defined(__cplusplus) + +#ifndef __DDK__ +#undef DDK_EXTERN +#if defined(__cplusplus) +#define DDK_EXTERN extern "C" __declspec(dllimport) +#else +#define DDK_EXTERN __declspec(dllimport) +#endif +#endif + +#define ATTRIBUTE(X) __attribute__((X)) + +#ifndef __NEOSKRNL__ +#error !!! Do not include header in EL0/Ring 3 mode !!! +#endif // __NEOSKRNL__
\ No newline at end of file diff --git a/dev/ddk/DriverKit/net.h b/dev/ddk/DriverKit/net.h new file mode 100644 index 00000000..63f89367 --- /dev/null +++ b/dev/ddk/DriverKit/net.h @@ -0,0 +1,16 @@ +/* ------------------------------------------- + + Copyright Amlal El Mahrouss. + + FILE: net.h + PURPOSE: Network model base header. + +------------------------------------------- */ + +#pragma once + +#include <DriverKit/macros.h> + +struct DDK_NET_MANIFEST; + +/// @brief IFS hooks to plug into the FileMgr. diff --git a/dev/ddk/DriverKit/str.h b/dev/ddk/DriverKit/str.h new file mode 100644 index 00000000..b2c0ce72 --- /dev/null +++ b/dev/ddk/DriverKit/str.h @@ -0,0 +1,17 @@ +/* ------------------------------------------- + + Copyright Amlal El Mahrouss. + + Purpose: DDK Strings. + +------------------------------------------- */ + +#pragma once + +#include <DriverKit/ddk.h> + +/// @brief DDK equivalent of POSIX's string.h +/// @file str.h + +DDK_EXTERN size_t kstrlen(const char* in); +DDK_EXTERN int kstrncpy(char* dst, const char* src, size_t len); |
