From c4870d08fa4bfb2613bf22a0b7cf306b388f58a4 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sat, 29 Mar 2025 05:03:14 +0100 Subject: ddk: refactor: reorganize kit into a standard kernel kit. sched: refactor: refactor scheduler file names, for future additions. xcoff: refactor: document and improve XCOFF for NeFS (regarding Ne's FW) codemgr: refactor: make a difference between kernel and user processes. refactor: document project overall. Signed-off-by: Amlal El Mahrouss --- dev/ddk/DDKKit/ddk.h | 112 ++++++++++++++++++++++++++++++++++++++++++ dev/ddk/DDKKit/dev.h | 35 +++++++++++++ dev/ddk/DDKKit/io.h | 18 +++++++ dev/ddk/DDKKit/str.h | 17 +++++++ dev/ddk/ddk.h | 112 ------------------------------------------ dev/ddk/dev.h | 35 ------------- dev/ddk/io.h | 18 ------- dev/ddk/obj/.gitkeep | 0 dev/ddk/src/ddk_alloc.c | 2 +- dev/ddk/src/ddk_dev.c | 4 +- dev/ddk/src/ddk_io.c | 2 +- dev/ddk/src/ddk_kernel_call.c | 2 +- dev/ddk/src/ddk_rt_cxx.cc | 2 +- dev/ddk/src/ddk_str.c | 2 +- dev/ddk/src/ddk_ver.c | 2 +- dev/ddk/str.h | 17 ------- 16 files changed, 190 insertions(+), 190 deletions(-) create mode 100644 dev/ddk/DDKKit/ddk.h create mode 100644 dev/ddk/DDKKit/dev.h create mode 100644 dev/ddk/DDKKit/io.h create mode 100644 dev/ddk/DDKKit/str.h delete mode 100644 dev/ddk/ddk.h delete mode 100644 dev/ddk/dev.h delete mode 100644 dev/ddk/io.h create mode 100644 dev/ddk/obj/.gitkeep delete mode 100644 dev/ddk/str.h (limited to 'dev/ddk') diff --git a/dev/ddk/DDKKit/ddk.h b/dev/ddk/DDKKit/ddk.h new file mode 100644 index 00000000..f6f8d48e --- /dev/null +++ b/dev/ddk/DDKKit/ddk.h @@ -0,0 +1,112 @@ +/* ------------------------------------------- + + Copyright Amlal EL Mahrouss. + + FILE: ddk.h + PURPOSE: DDK Driver model base header. + +------------------------------------------- */ + +#pragma once + +#include +#include + +#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 // __MINOSKRNL__ + +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; + void* 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(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_add_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 int32_t kApiVersionHighest; + +/// @brief The lowest API version of the DDK. +DDK_EXTERN int32_t kApiVersionLowest; + +/// @brief API version in BCD. +DDK_EXTERN int32_t kApiVersion; diff --git a/dev/ddk/DDKKit/dev.h b/dev/ddk/DDKKit/dev.h new file mode 100644 index 00000000..929aafa4 --- /dev/null +++ b/dev/ddk/DDKKit/dev.h @@ -0,0 +1,35 @@ +/* ------------------------------------------- + + Copyright Amlal EL Mahrouss. + + File: dev.h + Purpose: DDK device support. + +------------------------------------------- */ + +#pragma once + +#include + +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. +} 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/DDKKit/io.h b/dev/ddk/DDKKit/io.h new file mode 100644 index 00000000..a5ab93f1 --- /dev/null +++ b/dev/ddk/DDKKit/io.h @@ -0,0 +1,18 @@ +/* ------------------------------------------- + + Copyright Amlal EL Mahrouss. + + Purpose: DDK Text I/O. + +------------------------------------------- */ + +#pragma once + +#include + +/// @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/DDKKit/str.h b/dev/ddk/DDKKit/str.h new file mode 100644 index 00000000..49aeb45f --- /dev/null +++ b/dev/ddk/DDKKit/str.h @@ -0,0 +1,17 @@ +/* ------------------------------------------- + + Copyright Amlal EL Mahrouss. + + Purpose: DDK Strings. + +------------------------------------------- */ + +#pragma once + +#include + +/// @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); diff --git a/dev/ddk/ddk.h b/dev/ddk/ddk.h deleted file mode 100644 index f6f8d48e..00000000 --- a/dev/ddk/ddk.h +++ /dev/null @@ -1,112 +0,0 @@ -/* ------------------------------------------- - - Copyright Amlal EL Mahrouss. - - FILE: ddk.h - PURPOSE: DDK Driver model base header. - -------------------------------------------- */ - -#pragma once - -#include -#include - -#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 // __MINOSKRNL__ - -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; - void* 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(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_add_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 int32_t kApiVersionHighest; - -/// @brief The lowest API version of the DDK. -DDK_EXTERN int32_t kApiVersionLowest; - -/// @brief API version in BCD. -DDK_EXTERN int32_t kApiVersion; diff --git a/dev/ddk/dev.h b/dev/ddk/dev.h deleted file mode 100644 index 98979e52..00000000 --- a/dev/ddk/dev.h +++ /dev/null @@ -1,35 +0,0 @@ -/* ------------------------------------------- - - Copyright Amlal EL Mahrouss. - - File: dev.h - Purpose: DDK device support. - -------------------------------------------- */ - -#pragma once - -#include - -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. -} 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/io.h b/dev/ddk/io.h deleted file mode 100644 index cfd6d2d2..00000000 --- a/dev/ddk/io.h +++ /dev/null @@ -1,18 +0,0 @@ -/* ------------------------------------------- - - Copyright Amlal EL Mahrouss. - - Purpose: DDK Text I/O. - -------------------------------------------- */ - -#pragma once - -#include - -/// @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/obj/.gitkeep b/dev/ddk/obj/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/dev/ddk/src/ddk_alloc.c b/dev/ddk/src/ddk_alloc.c index 9d0ac0db..e0bd8ad2 100644 --- a/dev/ddk/src/ddk_alloc.c +++ b/dev/ddk/src/ddk_alloc.c @@ -6,7 +6,7 @@ ------------------------------------------- */ -#include +#include /** \brief Allocates a new heap on the Kernel's side. diff --git a/dev/ddk/src/ddk_dev.c b/dev/ddk/src/ddk_dev.c index 7514bf84..b4bbeae7 100644 --- a/dev/ddk/src/ddk_dev.c +++ b/dev/ddk/src/ddk_dev.c @@ -6,8 +6,8 @@ ------------------------------------------- */ -#include -#include +#include +#include /// @brief Open a new binary device from path. DDK_EXTERN DDK_DEVICE_PTR open(const char* devicePath) diff --git a/dev/ddk/src/ddk_io.c b/dev/ddk/src/ddk_io.c index 0e10a0ad..5405a0e3 100644 --- a/dev/ddk/src/ddk_io.c +++ b/dev/ddk/src/ddk_io.c @@ -6,7 +6,7 @@ ------------------------------------------- */ -#include +#include DDK_EXTERN void kputc(const char ch) { diff --git a/dev/ddk/src/ddk_kernel_call.c b/dev/ddk/src/ddk_kernel_call.c index 71dbebeb..5c3c051a 100644 --- a/dev/ddk/src/ddk_kernel_call.c +++ b/dev/ddk/src/ddk_kernel_call.c @@ -6,7 +6,7 @@ ------------------------------------------- */ -#include +#include #include /// @brief this is an internal call, do not use it. diff --git a/dev/ddk/src/ddk_rt_cxx.cc b/dev/ddk/src/ddk_rt_cxx.cc index 1ac66457..f3c332dc 100644 --- a/dev/ddk/src/ddk_rt_cxx.cc +++ b/dev/ddk/src/ddk_rt_cxx.cc @@ -6,7 +6,7 @@ ------------------------------------------- */ -#include +#include void* operator new(size_t sz) { diff --git a/dev/ddk/src/ddk_str.c b/dev/ddk/src/ddk_str.c index 1558e636..a2918815 100644 --- a/dev/ddk/src/ddk_str.c +++ b/dev/ddk/src/ddk_str.c @@ -6,7 +6,7 @@ ------------------------------------------- */ -#include +#include DDK_EXTERN size_t kstrlen(const char* in) { diff --git a/dev/ddk/src/ddk_ver.c b/dev/ddk/src/ddk_ver.c index 9641fb34..5cce1c3d 100644 --- a/dev/ddk/src/ddk_ver.c +++ b/dev/ddk/src/ddk_ver.c @@ -6,7 +6,7 @@ ------------------------------------------- */ -#include +#include #ifndef kDDKVersionHighest #define kDDKVersionHighest 1 diff --git a/dev/ddk/str.h b/dev/ddk/str.h deleted file mode 100644 index e1e206a8..00000000 --- a/dev/ddk/str.h +++ /dev/null @@ -1,17 +0,0 @@ -/* ------------------------------------------- - - Copyright Amlal EL Mahrouss. - - Purpose: DDK Strings. - -------------------------------------------- */ - -#pragma once - -#include - -/// @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); -- cgit v1.2.3