Porting Guide
Porting KDAL to a new platform means implementing a backend adapter; the driver layer and the userspace interface are meant to stay unchanged. KDAL runs on QEMU only so far: no port to real hardware has been done, so this page describes the intended path.
Step-by-Step
Section titled “Step-by-Step”1. Create a Backend
Section titled “1. Create a Backend”Create a new directory under src/backends/<platform>/ with a backend source
file implementing struct kdal_backend_ops:
static const struct kdal_backend_ops myplatform_ops = { .init = myplatform_init, .exit = myplatform_exit, .enumerate = myplatform_enumerate, .read = myplatform_read, .write = myplatform_write, .ioctl = myplatform_ioctl,};
static struct kdal_backend myplatform_backend = { .name = "my-platform", .feature_flags = KDAL_FEAT_POWER_MGMT, .ops = &myplatform_ops,};2. Implement Transport
Section titled “2. Implement Transport”The read/write ops provide the data transport path. On real hardware these
access MMIO registers, DMA buffers, or a bus controller:
static ssize_t myplatform_read(struct kdal_device *device, char *buf, size_t count){ void __iomem *base = device->priv; size_t i;
for (i = 0; i < count; i++) buf[i] = kdal_mmio_read8(base, 0x00); /* a data register */ return i;}The MMIO helpers (kdal_mmio_read8/16/32, kdal_mmio_write8/16/32) are
declared in include/kdal/core/internal.h and defined in
src/backends/qemu/mmio.c; there is no bulk helper.
3. Device Enumeration
Section titled “3. Device Enumeration”During enumerate(), scan platform resources (Device Tree, ACPI, PCI) and
create kdal_device instances:
static int myplatform_enumerate(struct kdal_backend *backend){ /* create and register this platform's kdal_device instances */ return 0;}Device Tree nodes with compatible = "kdal,device" are already scanned by
the core (kdal_devicetree_scan(), src/backends/generic/devicetree.c,
called from kdal_core_init), so a DT-described platform may need no
enumeration of its own.
4. Register the Backend
Section titled “4. Register the Backend”Add init/exit functions and call them from kdal_core_init() and
kdal_core_exit() in src/core/kdal.c, next to the backends already there:
int kdal_myplatform_backend_init(void);void kdal_myplatform_backend_exit(void);5. Add to Build
Section titled “5. Add to Build”Add the new .o files to the kdal-y list in Makefile (the QEMU backend
and the example drivers are in kdal-$(CONFIG_KDAL_QEMU_BACKEND) and
kdal-$(CONFIG_KDAL_EXAMPLE_DRIVERS), both y by default); CMake’s
module target runs the same kbuild Makefile.
6. Test
Section titled “6. Test”- Build with the new backend
- Load module on target hardware
- Verify
cat /sys/kernel/debug/kdal/devicesshows enumerated devices - Test with
kdality listandkdality info <device> - Run write/read loopback verification
Porting Checklist
Section titled “Porting Checklist”- Backend ops fully implemented (no NULL function pointers)
- Backend registered with unique name
-
enumerate()creates correctly typedkdal_deviceinstances - Devices have
backendpointer set before driver attachment -
privpointer holds per-device hardware state - Read/write ops handle partial transfers correctly
- Error codes follow Linux kernel conventions (negative errno)
- No platform-specific types in public headers
- KUnit tests added for new backend
- Documentation updated with platform notes
Reference: QEMU Backend
Section titled “Reference: QEMU Backend”The QEMU backend (src/backends/qemu/qemubackend.c) serves as the reference
implementation. It uses a software ring buffer to emulate hardware I/O:
init()- logs and returns 0enumerate()- logs and returns 0: the example drivers create their own devicesread()/write()- go through the device’sqemu_dev_ring(inpriv) under its spinlockexit()- logs
Planned: CIX P1
Section titled “Planned: CIX P1”The thesis board is the Orange Pi 6 Plus (CIX P1 SoC), planned for the end
of 2026; the Radxa Orion O6 / O6N and Orange Pi 6 are reference variants of
the same SoC (KDAL’s README, Target Platforms). The intended path is the
generic backend: Device Tree enumeration and MMIO register access through
the kernel’s platform_driver framework. KDAL does not yet run inside a
HAVEN partition: that needs a Linux guest under HAVEN on the board.