Language Overview
KDAL splits driver development into two complementary file types. This page introduces the concepts; the following pages dive into each format.
Two-File Model
Section titled “Two-File Model”| File type | Extension | Purpose |
|---|---|---|
| Device Header | .kdh |
Declares what the device is - registers, signals, capabilities, power states |
| Driver Code | .kdc |
Implements how the driver behaves - event handlers for probe, read, write, signal, power |
The compiler (kdalc, or kdality compile) reads both files and generates the C source of a
Linux kernel module and a kbuild fragment. That module does not build yet (open finding O7,
below). The language and compiler are frozen since 2026-11-01.
Design Philosophy
Section titled “Design Philosophy”Declarative at the top, imperative at the edges
Section titled “Declarative at the top, imperative at the edges”A .kdh file is purely declarative: it describes hardware registers, signal lines, capabilities,
and power states. No executable logic.
A .kdc driver is mostly declarative (config, annotations) but contains imperative event
handlers where real work happens. This mirrors how hardware engineers think: “the device has
these registers; when this event occurs, do this sequence.”
Intentionally not Turing-complete
Section titled “Intentionally not Turing-complete”KDAL rejects:
- Recursion - call depth bounded at 1 (handler calls built-ins only)
- Heap allocation - driver state lives in a C struct allocated once by
probe - Unbounded loops - only
for i in 0..N, meant for a compile-time constantN; the frozen compiler warns, without stopping, when it cannot tell - Pointer arithmetic - register access uses typed paths; the generated C calls the runtime’s
register accessors (
kdal_reg_read,kdal_reg_write), which do not exist yet (O7) - Inline assembly - no escape hatch to machine code
The aim is generated code that can be audited, and whole classes of kernel bugs that cannot be written.
Compilation Flow
Section titled “Compilation Flow”The same diagram as KDAL’s lang/DESIGN.md: the five phases run
(kdality compile succeeds on every example); the generated module does
not build yet (finding O7 in KDAL’s docs/open-findings-20261121.md).
Comparison with Alternatives
Section titled “Comparison with Alternatives”| Feature | C + Kbuild | Arduino | Zephyr RTOS | KDAL |
|---|---|---|---|---|
| Target | Linux .ko |
Bare-metal | RTOS firmware image | Linux .ko (not yet built: O7) |
| Register access | Manual | Manual | Manual | ro/wo checked by kdality lint |
| Backend abstraction | Manual | None | DTS + Kconfig | backend declaration |
| Signal/IRQ model | Manual | attachInterrupt |
gpio_callback |
on signal handler |
| Power management | PM framework | None | pm_device |
on power handler |
| Turing-complete | Yes | Yes | Yes | No (by design) |
Next Steps
Section titled “Next Steps”- Device Headers (.kdh) - the declarative format
- Driver Code (.kdc) - the imperative format
- Standard Library - pre-built device headers