rewrite the device subsystem interfaces (#48)
[lunaix-os.git] / lunaix-os / hal / devtree / devtree.h
index 3b1df0803bb4c12d0530d98025d5f26eef07ef45..c2374c82820d05d2352b28e12d0038d8ab455432 100644 (file)
@@ -3,6 +3,44 @@
 
 #include <hal/devtree.h>
 
+#include <klibc/string.h>
+
+static inline bool
+propeq(struct fdt_iter* it, const char* key)
+{
+    return streq(fdtit_prop_key(it), key);
+}
+
+static inline void
+__mkprop_val32(struct fdt_iter* it, struct dt_prop_val* val)
+{
+    val->u32_val = le(*(u32_t*)&it->prop[1]);
+    val->size = le(it->prop->len);
+}
+
+static inline void
+__mkprop_val64(struct fdt_iter* it, struct dt_prop_val* val)
+{
+    val->u64_val = le64(*(u64_t*)&it->prop[1]);
+    val->size = le(it->prop->len);
+}
+
+static inline void
+__mkprop_ptr(struct fdt_iter* it, struct dt_prop_val* val)
+{
+    val->ptr_val = __ptr(&it->prop[1]);
+    val->size = le(it->prop->len);
+}
+
+static inline u32_t
+__prop_getu32(struct fdt_iter* it)
+{
+    return le(*(u32_t*)&it->prop[1]);
+}
+
+bool
+parse_stdintr_prop(struct fdt_iter* it, struct dt_intr_node* node);
+
 bool
 parse_stdintr_prop(struct fdt_iter* it, struct dt_intr_node* node);