PatchworkOS
Loading...
Searching...
No Matches
ctl.h
Go to the documentation of this file.
1#pragma once
2
3#include <kernel/fs/file.h>
4
5#include <stdint.h>
6
25#define CTL_STANDARD_WRITE_DEFINE(name, ...) \
26 static ctl_t name##ctls[] = __VA_ARGS__; \
27 static uint64_t name(file_t* file, const void* buffer, uint64_t count, uint64_t* offset) \
28 { \
29 (void)offset; \
30 return ctl_dispatch(name##ctls, file, buffer, count); \
31 }
32
41#define CTL_STANDARD_OPS_DEFINE(name, ...) \
42 CTL_STANDARD_WRITE_DEFINE(name##write, __VA_ARGS__) \
43 static file_ops_t name = (file_ops_t){ \
44 .write = name##write, \
45 };
46
55typedef uint64_t (*ctl_func_t)(file_t* file, uint64_t, const char**);
56
61typedef struct
62{
63 const char* name;
67} ctl_t;
68
73
84
uint64_t ctl_dispatch(ctl_array_t ctls, file_t *file, const void *buffer, uint64_t count)
Dispatch a ctl command.
Definition ctl.c:9
ctl_t ctl_array_t[]
Type definition for an array of ctl commands.
Definition ctl.h:72
uint64_t(* ctl_func_t)(file_t *file, uint64_t, const char **)
Type definition for a ctl function.
Definition ctl.h:55
static dentry_t * file
Definition log_file.c:17
EFI_PHYSICAL_ADDRESS buffer
Definition mem.c:15
static atomic_long count
Definition main.c:9
__UINT64_TYPE__ uint64_t
Definition stdint.h:17
Structure defining a ctl command.
Definition ctl.h:62
uint64_t argcMin
The minimum number of arguments accepted by func.
Definition ctl.h:65
ctl_func_t func
The function to call for the command.
Definition ctl.h:64
uint64_t argcMax
The maximum number of arguments accepted by func.
Definition ctl.h:66
const char * name
The name of the command.
Definition ctl.h:63
File structure.
Definition file.h:37