Skip to content

Language Overview

KDAL splits driver development into two complementary file types. This page introduces the concepts; the following pages dive into each format.

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.

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.”

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 constant N; 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.

flowchart LR SRC[/".kdc driver<br/>importing .kdh headers"/] READ["Read<br/>source.c"] LEX["Lexer<br/>lexer.c<br/>characters to tokens"] PARSE["Parser<br/>parser.c<br/>recursive descent, tokens to AST"] SEMA["Semantic analysis<br/>sema.c<br/>types, register access,<br/>scopes, backends"] GEN["Codegen<br/>codegen.c<br/>AST to C"] OUT[/".c and Makefile.kbuild"/] KO[/"kbuild: .ko<br/>fails today: open finding O7"/] SRC --> READ --> LEX --> PARSE --> SEMA --> GEN --> OUT --> KO classDef observed stroke:#0ca30c,stroke-width:2px class READ,LEX,PARSE,SEMA,GEN observed

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).

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)