Device-Driver-Environment Kit API

The Device-Driver-Environment (DDE) Kit provides a C API for developing device drivers. In principle, device drivers can be implemented directly using Genode's base API. But because most existing device drivers are implemented in C rather than C++, a C API such as DDE Kit facilitates the porting of existing device drivers. The functionality comprised in the DDE Kit covers all typical functions needed by device drivers and normally found in the kernel of a monolithic OS. The DDE Kit library translates the C API calls to Genode's Base API.

Initialization and types

For initialization purposes, os/include/dde_kit/initcall.h provides a mechanism to mark certain functions for initialization calls. These functions must be executed before the driver program starts it's normal execution. For example, in Linux 2.6, kernel modules always provide functions for module initialization via module_init() (linux/init.h). The mechanism is implemented as the pre-processor macro

 DDE_KIT_INITCALL(function, id)

function is the name of the initialization function and id is an user-defined identifier concatenated with the function name. The marked function is exported via a non-static symbol called dde_kit_initcall_<id>_<fn>. On driver startup, the driver environment has to explicitly call these functions. The signature of initialization functions is

 extern int initcall_func(void);

For convenience, the os/tool/dde_kit_find_initcalls tool can be used to print all inititalization symbols in a list of binaries, e.g.

 dde_kit_find_initcalls test-dde_linux26_net

A demonstrative example for the usage of initcalls can be found in linux_drivers/src/test/dde_linux26_net/main.cc.

Memory management

The memory subsystem provides slab caches and large-block allocators backed by physically contiguous RAM prepared for DMA operations. Memory allocated from the provided simple memory allocator cannot be used for DMA and is intended for meta-data memory blocks. A virtual page table implementation supports the bookkeeping of physical memory mappings into the drivers virtual address space. Note, slab cache and large-memory allocations are automatically added to the virtual page table.

Device access

The DDE kit supports registration of one handler function per interrupt. If any specific DDE implementation needs to register more than one handler, multiplexing has to be implemented there. Furthermore, the driver is supplied with a virtual PCI bus, where accessible PCI devices are connected.

Timing

The timer subsystem provides a generic timer implementation that enables users to execute a callback function after a certain period of time. Therefore, DDE kit starts a timer thread that executes callbacks and keeps track of the currently running timers. Moreover, the system tick can be accessed via the dde_kit_timer_ticks and jiffies symbols.

Threads and synchronization

Utilities