From 38cddd5dc02f886e5cb3a0e386f0f7a1e6c8da86 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sun, 1 Mar 2026 05:48:35 +0100 Subject: feat: ddk!: Breaking changes, the DDK has been reworked in C++ instead. chore: public, kernel: fixes and important patches. Signed-off-by: Amlal El Mahrouss --- src/libDDK/DriverKit/Device.h | 47 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/libDDK/DriverKit/Device.h (limited to 'src/libDDK/DriverKit/Device.h') diff --git a/src/libDDK/DriverKit/Device.h b/src/libDDK/DriverKit/Device.h new file mode 100644 index 00000000..6511b452 --- /dev/null +++ b/src/libDDK/DriverKit/Device.h @@ -0,0 +1,47 @@ +// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org) +// Licensed under the Apache License, Version 2.0 (see LICENSE file) +// Official repository: https://github.com/nekernel-org/nekernel + +#ifndef DRIVERKIT_DEV_H +#define DRIVERKIT_DEV_H + +#include + +struct _DDK_DEVICE; + +#define DDK_DEVICE_NAME_LEN (255) + +#define DDK_TYPE_SOCKET (1) +#define DDK_TYPE_FILE (2) +#define DDK_TYPE_DEVICE (3) + +#define DDK_SUB_TYPE_TCP (1) +#define DDK_SUB_TYPE_UDP (2) +#define DDK_SUB_TYPE_BT (3) + +/// @brief Kernel Device driver. +typedef struct _DDK_DEVICE DDK_FINAL { + char d_name[DDK_DEVICE_NAME_LEN]; // the device name. Could be /./DEVICE_NAME/ + int d_type; + int d_subtype; + 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; + +#define kopen kopen_dev +#define kclose kclose_dev + +/// @brief Open a new device from path. +/// @param path the device's path. +DDK_EXTERN DDK_DEVICE_PTR kopen_dev(const char* path); + +/// @brief Close any device. +/// @param device valid device. +DDK_EXTERN BOOL kclose_dev(DDK_DEVICE_PTR device); + +#endif -- cgit v1.2.3