+#include <lunaix/ds/mutex.h>
+#include <lunaix/iopoll.h>
+#include <lunaix/types.h>
+
+#include <usr/lunaix/device.h>
+
+/**
+ * @brief Export a device definition (i.e., device driver metadata)
+ *
+ */
+#define EXPORT_DEVICE(id, devdef, load_order) \
+ export_ldga_el(devdefs, id, ptr_t, devdef); \
+ export_ldga_el_sfx(devdefs, id##_ldorder, ptr_t, devdef, load_order);
+
+/**
+ * @brief Mark the device definition can be loaded on demand, all other loading
+ * options are extended from this
+ */
+#define load_on_demand ld_ondemand
+
+/**
+ * @brief Mark the device definition to be loaded as system configuration
+ * device. These kind of devices are defined to be the devices that talk to the
+ * system firmware to do config, or collecting crucial information about the
+ * system. For instances, ACPI, SoC components, and other **interconnection**
+ * buese (not USB!). Such device driver must only rely on basic memory
+ * management service, and must not try accessing subsystems other than the mm
+ * unit, for example, timer, interrupt, file-system, must not assumed exist.
+ *
+ */
+#define load_sysconf ld_sysconf
+
+/**
+ * @brief Mark the device definition should be loaded as time device, for
+ * example a real time clock device. Such device will be loaded and managed by
+ * clock subsystem
+ */
+#define load_timedev ld_timedev
+
+/**
+ * @brief Mark the device definition should be loaded automatically during the
+ * bootstrapping stage. Most of the driver do load there.
+ *
+ */
+#define load_onboot ld_kboot
+
+/**
+ * @brief Mark the device definition should be loaded automatically in
+ * the post boostrapping stage (i.e., the start up of proc0), where most of
+ * kernel sub-system are became ready to use. Do your load there if your driver
+ * depends on such condition
+ *
+ */
+#define load_postboot ld_post
+
+#define __foreach_exported_device_of(stage, index, pos) \
+ ldga_foreach(dev_##stage, struct device_def*, index, pos)
+#define foreach_exported_device_of(stage, index, pos) \
+ __foreach_exported_device_of(stage, index, pos)
+
+/**
+ * @brief Declare a device class
+ *
+ */
+#define DEVCLASS(devif, devfn, dev) \
+ (struct devclass) \
+ { \
+ .fn_grp = DEV_FNGRP(devif, devfn), .device = (dev), .variant = 0 \
+ }
+
+#define DEVCLASSV(devif, devfn, dev, devvar) \
+ (struct devclass) \
+ { \
+ .fn_grp = DEV_FNGRP(devif, devfn), .device = (dev), \
+ .variant = (devvar) \
+ }
+
+#define DEV_STRUCT_MAGIC 0x5645444c
+
+#define DEV_MSKIF 0x00000003
+
+#define DEV_IFVOL 0x0 // volumetric (block) device
+#define DEV_IFSEQ 0x1 // sequential (character) device
+#define DEV_IFCAT 0x2 // a device category (as device groupping)
+#define DEV_IFSYS 0x3 // a system device