+device_alloc(struct device_meta* parent, u32_t type, void* underlay);
+
+#ifdef CONFIG_USE_DEVICETREE
+static inline void
+device_set_devtree_node(struct device* dev, devtree_link_t node)
+{
+ dev->devtree_node = node;
+}
+#endif
+
+static inline struct device* must_inline
+device_allocsys(struct device_meta* parent, void* underlay)
+{
+ return device_alloc(parent, DEV_IFSYS, underlay);
+}
+
+static inline struct device* must_inline
+device_allocseq(struct device_meta* parent, void* underlay)
+{
+ return device_alloc(parent, DEV_IFSEQ, underlay);
+}
+
+static inline struct device* must_inline
+device_allocvol(struct device_meta* parent, void* underlay)
+{
+ return device_alloc(parent, DEV_IFVOL, underlay);
+}
+
+struct device_alias*
+device_addalias(struct device_meta* parent, struct device_meta* aliased,
+ char* name_fmt, ...);
+
+struct device_cat*
+device_addcat(struct device_meta* parent, char* name_fmt, ...);
+
+void
+device_remove(struct device_meta* dev);
+
+struct hbucket*
+device_definitions_byif(int if_type);
+
+struct device_def*
+devdef_byident(struct devident* class);
+
+void
+device_populate_info(struct device* dev, struct dev_info* devinfo);
+
+void
+device_scan_drivers();
+
+/*------ Capability ------*/
+
+struct potens_meta*
+alloc_potens(int cap, unsigned int size);
+
+#define new_potens(pot_type, pot_struct)\
+ ((pot_struct*)alloc_potens((pot_type), sizeof(pot_struct)))
+
+#define new_potens_marker(pot_type)\
+ (alloc_potens((pot_type), sizeof(struct potens_meta)))
+
+void
+device_grant_potens(struct device* dev, struct potens_meta* cap);
+
+struct potens_meta*
+device_get_potens(struct device* dev, unsigned int pot_type);
+
+/*------ Load hooks ------*/
+
+void
+device_onboot_load();
+
+void
+device_postboot_load();
+
+void
+device_sysconf_load();
+
+/**
+ * @brief Add the loader to the chain, used by device domain
+ * to inject their custom loading logic to the hook
+ */
+void
+device_chain_loader(struct device_def* def, devdef_ldfn fn);
+
+/**
+ * @brief Walk the chain and load in a use-and-burnt fashion.
+ * the chain will be deleted and freed after loading,
+ * regardless successful or not.
+ */
+void
+device_chain_load_once(struct device_def* def);
+
+static inline void
+device_lock(struct device* dev)
+{
+ mutex_lock(&dev->lock);
+}
+
+static inline void
+device_unlock(struct device* dev)
+{
+ mutex_unlock(&dev->lock);
+}
+
+static inline int
+device_locked(struct device* dev)
+{
+ return mutex_on_hold(&dev->lock);
+}
+
+#define devprintf_expand(devident) (devident)->fn_grp, (devident)->unique
+
+
+/**
+ *
+ * Device def hooks extern
+ *
+ */
+
+static int
+default_onregister_hook(struct device_def* def)
+{
+ return 0;
+}
+
+static int
+default_onload_hook(struct device_def* def)
+{
+ return 0;
+}
+
+static int
+default_oncreate_hook(struct device_def* def, morph_t* morphed)
+{
+ return 0;
+}
+
+#define extern_hook_register(name) \
+ int weak_alias("default_onregister_hook") \
+ name(struct device_def* def)
+
+#define extern_hook_load(name) \
+ int weak_alias("default_onload_hook") \
+ name(struct device_def* def)
+
+#define extern_hook_create(name) \
+ int weak_alias("default_oncreate_hook") \
+ name(struct device_def* def, morph_t* morphed)
+