Kernel: Implemented banos - a WIP C driver API
Banos is a stable WIP C driver API that is supposed to provide a simple interface to interact with the kernel and load the modules dynamically. It is WIP and atm this just implements module loading with a custom banos_install syscall. Banos will not try to substitute parts of the kernel instead it will just expose kernel functionality via a stable BINARY API. Meaning binaries (should) remain forward and backward compatible on a binary level. Banos modules work similarly to those in linux, you expose symbols via BANOS_EXPORT which allows you to export a name + addr paired symbol. It puts it in the .banos-export section. Drivers provide metadata about themselves in the REQUIRED .banos-driver section. Symbols are resolved at runtime. The kernel exposes the driver functionality via the same .banos-export export mechanism. Banos modules are elf RELOCATABLE files (object files) which have partial linking (only banos symbols should remain). Modules will eventually define dependencies, will export symbols and will allow you to build a complex object hierarchy. This patch adds the banos_install syscall which takes in the driver image to install and may only be executed by super users. The API doesn't validate already loaded modules, as thats something the userspace MAY choose to keep track of. Multi-instance functionality shall be implemented via driver specific behaviuor (exposed in the dev filesystem or some other means). Modules are supposed to allow you to alter kernel behavior and extend it, allowing you to create filesystems, drivers, networking modifications, schedulers, probers, and more (hopefully) whilst remaining binary compatible with any version of the kernel (again, hopefully).
This commit is contained in:
15
kernel/include/banos/export.h
Normal file
15
kernel/include/banos/export.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
// Copyright (c) 2026 Dcraftbg
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
typedef struct Banos_Symbol {
|
||||
const char* name;
|
||||
void* arg;
|
||||
} Banos_Symbol;
|
||||
#define BANOS_EXPORT_SYMBOL(symname, str, ptr) \
|
||||
static __attribute__((section(".banos-export"), used, aligned(8))) Banos_Symbol __symbol_##symname = {\
|
||||
.name = str, \
|
||||
.arg = ptr \
|
||||
};
|
||||
#define BANOS_EXPORT(name) BANOS_EXPORT_SYMBOL(name, #name, (void*)&name)
|
||||
Reference in New Issue
Block a user