KDAL - Kernel Device Abstraction Layer
A hardware-agnostic, pluggable abstraction framework inside the Linux kernel that lets developers write portable device drivers and accelerator backends once and run them on any embedded platform.
Master thesis project - Computer Engineering
Features
Section titled “Features”- Single control device (
/dev/kdal) with per-fd device selection - 4 example drivers over the backends: UART, I2C, SPI, GPU (with accelerator ops)
- Pluggable backends: QEMU ring-buffer, generic platform device, Device Tree
- 6 ioctl commands defined: GET_VERSION, GET_INFO, SET_POWER, LIST_DEVICES, SELECT_DEV, and POLL_EVENT (defined, not yet dispatched by the character device)
- debugfs interface:
/sys/kernel/debug/kdal/for introspection - Event system: circular buffer with waitqueue-based notification
- Power management: per-device power state transitions
- KUnit tests: 40 in-kernel test cases in 6 suites
- Userspace tools: CLI tool, smoke test, integration suite, throughput benchmark
- QEMU-first workflow: fully reproducible on Mac M4 Pro → aarch64 guest
Language Ecosystem
Section titled “Language Ecosystem”- KDAL DSL:
.kdhdevice headers +.kdcdriver implementations - Compiler (
kdalc): hand-written lexer → parser → sema → codegen; produces kernel C + Kbuild - Standard library: 7 device headers (UART, I2C, SPI, GPIO, GPU, NPU, common)
- Unified toolchain (
kdality): compile, init, lint, simulate, dt-gen, test-gen - VS Code extension: syntax highlighting + snippets for
.kdh/.kdc - CMake modules (7 installed): FindKDAL, Config, Targets, CompileKDC, Toolchain, Testing, Packaging
Quick Start
Section titled “Quick Start”# Install dependencies (macOS or Linux)./scripts/env/dependencies.sh
# Prepare QEMU workspace./scripts/env/prepare.sh
# Build kernel with KDAL support./scripts/env/kernel.sh
# Build everything (compiler + CLI + VS Code extension)./scripts/dev/build.sh --variant release all
# Launch QEMU guest./scripts/env/run.sh
# Inside guest: load module and testinsmod /mnt/shared/kdal.ko/mnt/shared/kdality version/mnt/shared/kdality listArchitecture
Section titled “Architecture”Green: built into kdal.ko, which CI loads and tests with its KUnit suites
(and which loads inside HAVEN’s partition A on HAVEN’s pull requests). Amber: the user-space
programs build, but CI does not run them against the module (it runs
kdality only to compile the examples). Key: Reading the
diagrams.
See the architecture page for full details.
Scope in the HAVEN thesis
Section titled “Scope in the HAVEN thesis”KDAL is one of three components of the HAVEN Master’s thesis. Its role is the
device-access driver inside HAVEN’s Linux partition: the kernel module
(src/, include/) and the kdality runtime CLI are active. The KDAL
language, the kdalc compiler (compiler/, lang/) and the editor plugins
(editor/) are frozen as of 2026-11-01: kept, still built and checked by CI,
but not developed further unless the thesis needs them.
Repository Layout
Section titled “Repository Layout”Where to work:
- Maintained: the kernel module (
src/,include/,tests/with kunit, integration and userspace tests,scripts/ci/) and thekdalityruntime CLI (tools/). New work, fixes and reviews go here. - Frozen since 2026-11-01:
lang/,compiler/andeditor/(the KDAL language, thekdalccompiler and the editor plugins). They are kept and still built by CI, but take no new work unless the thesis needs them. Known limit, parked with the freeze:kdality compilewrites C that does not build as a module yet (it includes<linux/kdal.h>and calls a register API KDAL does not provide;docs/open-findings-20261121.md, F1 and F4). The language,simulate,lint,test-genanddt-genwork. Three more limits, found on 2026-12-03 and parked with the freeze: the compiler checksro/woonly for registers declared in the file it compiles, so for a driver and its imported header the check iskdality lint(W003, W004); a.kdhwith semantic errors (for example a bitfield range written high to low) prints them but still lints “OK” with exit 0, becausekdal_semareturns 0 for a header; andkdality compiledoes not parse the imported headers, so it exits 0 when one is broken. Read the messages, not only the exit status.
include/kdal/ Public API headers (types, ioctl, driver, accel, backend)src/core/ Core runtime (lifecycle, registry, events, chardev, debugfs)src/drivers/ Device drivers (UART, I2C, SPI, GPU)src/backends/ Hardware backends (QEMU, generic)compiler/ KDAL compiler (kdalc): lexer, parser, sema, codegenlang/grammar/ EBNF grammars for .kdh and .kdclang/stdlib/ Standard device headers (7 .kdh files)lang/ Language specification + design docstools/kdality/ Unified CLI + compiler frontend (kdality)editor/vscode/ VS Code extension for .kdh/.kdceditor/vim/ Vim/Neovim plugin for .kdh/.kdccmake/ CMake modules for build integrationtests/kunit/ In-kernel tests (40 test cases, 6 suites)tests/userspace/ Userspace smoke test + benchmarktests/integration/ Multi-device integration suitescripts/dev/ Development scripts (build, run, test)scripts/e2e/ End-to-end test suitesscripts/ci/ CI/CD helper scriptsscripts/installer/ SDK installer (kdalup)docs/ release workflow, open findings, CI SDK, evidence (the guides are on the documentation site)examples/ Driver examples (.kdc, plain C, accel demos)build/ Variant-specific build trees and generated outputsBuilding
Section titled “Building”The project uses CMake 3.20+ as its build system, wrapped by convenience
scripts under scripts/dev/.
Development Scripts
Section titled “Development Scripts”./scripts/dev/build.sh --variant <name> <target> # Build targets./scripts/dev/run.sh --variant <name> <target> # Run targets (auto-builds if needed)./scripts/dev/test.sh --variant <name> <target> # Test targets with PASS/FAIL reportingBuild Variants
Section titled “Build Variants”release: optimized local SDK build inbuild/release/; use for packaging, install checks, and normal local use.debug: symbols + assertions inbuild/debug/; use for compiler or CLI debugging.asan: AddressSanitizer-enabled build inbuild/asan/; use for memory-safety investigations.
Use --variant for normal local development. Use --preset only for automation-oriented trees such as ci-release, nightly, and release-matrix.
Build Targets
Section titled “Build Targets”./scripts/dev/build.sh --variant release kdalc # Compiler (kdalc + libkdalc.a)./scripts/dev/build.sh --variant release kdality # CLI toolchain./scripts/dev/build.sh --variant release vscode # VS Code extension → build/release/editor/vscode/./scripts/dev/build.sh --variant debug module # Kernel module iteration build./scripts/dev/build.sh --variant release all # Everything above./scripts/dev/build.sh --variant asan clean # Remove the asan build tree./scripts/dev/build.sh --variant release install # Install to system (cmake --install)Kernel Module (cross-compile for aarch64)
Section titled “Kernel Module (cross-compile for aarch64)”export KDAL_KERNEL_DIR=/path/to/linux-6.6export CROSS_COMPILE=aarch64-linux-gnu-export ARCH=arm64./scripts/dev/build.sh --variant debug module# Run all tests (mirrors CI stages locally)./scripts/dev/test.sh --variant release all
# Test specific targets./scripts/dev/test.sh --variant release kdalc # Compiler binary + sample compilation./scripts/dev/test.sh --variant release kdality # CLI subcommands./scripts/dev/test.sh --variant release vscode # VS Code extension packaging./scripts/dev/test.sh --variant release cppcheck # C static analysis (mirrors CI)./scripts/dev/test.sh --variant release shellcheck # Shell script linting (mirrors CI)./scripts/dev/test.sh --variant release structure # Project structure validation./scripts/dev/test.sh --variant release e2e # End-to-end test suites./scripts/dev/test.sh help # List all testable targetsTest reports are saved under the selected variant tree, for example build/debug/test/<target>_<date>.log.
Build Output Layout
Section titled “Build Output Layout”build/├── release/ Optimized local build and install validation│ ├── compiler/ kdalc, libkdalc.a│ ├── editor/vscode/ .vsix package│ └── test/ Test reports├── debug/ Debuggable local build with symbols├── asan/ AddressSanitizer build├── ci/release/ CI-only verification build└── nightly/<os-arch>/ Nightly matrix builds per target host/archDocumentation
Section titled “Documentation”The KDAL documentation site is part of the ecosystem’s site, docs-haven.vercel.app/kdal (its pages are in the haven-docs repository). The repository’s own documents:
| Document | Description |
|---|---|
| Architecture | 6-layer design, data flow, init cascade |
| API Reference | All functions, ioctl commands, types |
| Language Overview | Tutorial: .kdh/.kdc from scratch |
| Language Spec | Formal language specification |
| Language Design | Design rationale and comparison table |
| Installation | Setup guide for macOS and Linux |
| Porting Guide | How to add a new backend |
| Performance | Benchmarking methodology and metrics |
| FAQ | Common questions answered |
| Upstreaming | Path to Linux kernel mainline |
| Thesis | Chapter mapping to repository artifacts |
Target Platforms
Section titled “Target Platforms”| Platform | Status | Backend |
|---|---|---|
QEMU aarch64 virt |
Implemented | qemu (ring buffer) |
| CIX P1: Orange Pi 6 Plus | Planned (thesis board, end of 2026) | generic (MMIO + DT) |
| CIX P1: Radxa Orion O6 / O6N, Orange Pi 6 | Reference variants | generic (MMIO + DT) |
The HAVEN thesis targets the CIX P1 SoC only. In QEMU, KDAL’s module runs in
Linux inside HAVEN’s partition A: HAVEN’s CI job “Linux in partition A”
builds kdal.ko at the KDAL commit HAVEN pins and checks the device demand
it prints.
Testing Without Hardware
Section titled “Testing Without Hardware”KDAL v0.2.0 is QEMU-validated only - no real hardware is required.
QEMU workflow
Section titled “QEMU workflow”./scripts/env/dependencies.sh # Install host tools./scripts/env/prepare.sh # Download Ubuntu cloud image + create QEMU workspace./scripts/env/kernel.sh # Cross-compile Linux 6.6 with KUnit + virtio./scripts/env/run.sh # Boot QEMU aarch64 virt machine# Inside guest: insmod /mnt/shared/kdal.koDocker (zero-setup)
Section titled “Docker (zero-setup)”docker build -t kdal-dev -f Dockerfile.dev .docker run -it -v $(pwd):/workspace kdal-dev# Inside container: cmake --preset ci-release && cmake --build --preset ci-releaseThe container includes cmake, gcc, aarch64 cross-compiler, QEMU, cppcheck, shellcheck, and Node.js.
License
Section titled “License”GPL-2.0-only - see LICENSE. Every C source carries its SPDX
line; the userspace ABI header include/kdal/ioctl.h is
GPL-2.0-only WITH Linux-syscall-note, as the kernel’s own UAPI headers
are, so programs that include it are not bound by the GPL. Until
2026-12-03 the repository said GPLv3 while the module declared
MODULE_LICENSE("GPL") (GPL version 2) and the compiler’s files said
GPL-2.0-only; a GPLv3 module cannot be loaded into the GPLv2 kernel
consistently, so KDAL is GPL-2.0-only throughout.
Contributing
Section titled “Contributing”See CONTRIBUTING.md for guidelines.