rewrite the gic implementation, some other fix ups
[lunaix-os.git] / lunaix-os / includes / hal / devtree.h
index e7e0cf37ce0a32c36ece6877426e7db109ec8ab2..f95abf2faff7362248c8deb34cdf3220e3aa84fe 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef __LUNAIX_DEVTREE_H
 #define __LUNAIX_DEVTREE_H
 
 #ifndef __LUNAIX_DEVTREE_H
 #define __LUNAIX_DEVTREE_H
 
+#ifdef CONFIG_USE_DEVICETREE
 #include <lunaix/types.h>
 #include <lunaix/ds/llist.h>
 #include <lunaix/ds/hstr.h>
 #include <lunaix/types.h>
 #include <lunaix/ds/llist.h>
 #include <lunaix/ds/hstr.h>
@@ -46,14 +47,14 @@ struct dtp_val
 {
     union
     {
 {
     union
     {
-        union {
-            const char*  str_val;
-            const char*  str_lst;
-        };
         ptr_t        ptr_val;
         dt_enc_t     encoded;
         
         union dtp_baseval* ref;
         ptr_t        ptr_val;
         dt_enc_t     encoded;
         
         union dtp_baseval* ref;
+        union {
+            const char*  str_val;
+            const char*  str_lst;
+        };
     };
     unsigned int size;
 };
     };
     unsigned int size;
 };
@@ -259,7 +260,7 @@ struct dtn_base
 
     struct dtp_table        *props;
 
 
     struct dtp_table        *props;
 
-    morph_t                 *binded_dev;
+    morph_t                 *binded_obj;
 };
 
 struct dtspec_key
 };
 
 struct dtspec_key
@@ -442,6 +443,12 @@ dtp_val_set(struct dtp_val* val, dt_enc_t raw, unsigned cells)
     val->size = cells * sizeof(u32_t);
 }
 
     val->size = cells * sizeof(u32_t);
 }
 
+static inline void
+dtn_bind_object(struct dtn* node, morph_t* mobj)
+{
+    node->base.binded_obj = changeling_ref(mobj);
+}
+
 
 //////////////////////////////////////
 ///     DT Methods: Specifier Map
 
 //////////////////////////////////////
 ///     DT Methods: Specifier Map
@@ -589,11 +596,11 @@ struct dtpropx
 #define dtprop_reglike(base)                    \
     ({                                          \
         dt_proplet p = {                        \
 #define dtprop_reglike(base)                    \
     ({                                          \
         dt_proplet p = {                        \
-            dtprop_compx(base->addr_c),         \
-            dtprop_compx(base->sz_c),           \
+            dtprop_compx((base)->addr_c),       \
+            dtprop_compx((base)->sz_c),         \
             dtprop_end                          \
         };                                      \
             dtprop_end                          \
         };                                      \
-        dt_proplet;                             \
+        p;                             \
     })
 
 #define dtprop_rangelike(node)                  \
     })
 
 #define dtprop_rangelike(node)                  \
@@ -604,7 +611,7 @@ struct dtpropx
             dtprop_compx(base->sz_c),           \
             dtprop_end                          \
         };                                      \
             dtprop_compx(base->sz_c),           \
             dtprop_end                          \
         };                                      \
-        dt_proplet;                             \
+        p;                             \
     })
 
 #define dtprop_strlst_foreach(pos, prop)    \
     })
 
 #define dtprop_strlst_foreach(pos, prop)    \
@@ -669,7 +676,7 @@ static inline void
 dtpi_init_empty(struct dtpropi* dtpi)
 {
     *dtpi = (struct dtpropi) {
 dtpi_init_empty(struct dtpropi* dtpi)
 {
     *dtpi = (struct dtpropi) {
-        .prop = { 0, 0 },
+        .prop = { {0}, 0 },
         .loc = 0
     };
 }
         .loc = 0
     };
 }
@@ -686,23 +693,27 @@ dtpi_has_next(struct dtpropi* dtpi)
     return dtpi->loc < dtpi->prop.size / sizeof(u32_t);
 }
 
     return dtpi->loc < dtpi->prop.size / sizeof(u32_t);
 }
 
-static inline u32_t
-dtpi_next_u32(struct dtpropi* dtpi
+static inline u64_t
+dtpi_next_integer(struct dtpropi* dtpi, int int_cells
 {
     union dtp_baseval* val;
 {
     union dtp_baseval* val;
-    val = (union dtp_baseval*)&dtpi->prop.encoded[dtpi->loc++];
-    return val->u32_val;
+    off_t loc = dtpi->loc;
+    dtpi->loc += int_cells;
+    val = (union dtp_baseval*)&dtpi->prop.encoded[loc];
+    
+    return int_cells == 1 ? val->u32_val : val->u64_val;
 }
 
 static inline u64_t
 dtpi_next_u64(struct dtpropi* dtpi) 
 {
 }
 
 static inline u64_t
 dtpi_next_u64(struct dtpropi* dtpi) 
 {
-    union dtp_baseval* val;
-    off_t loc = dtpi->loc;
-    dtpi->loc += 2;
-    val = (union dtp_baseval*)&dtpi->prop.encoded[loc];
-    
-    return val->u64_val;
+    return dtpi_next_integer(dtpi, 2);
+}
+
+static inline u32_t
+dtpi_next_u32(struct dtpropi* dtpi) 
+{
+    return (u32_t)dtpi_next_integer(dtpi, 1);
 }
 
 static inline struct dtn*
 }
 
 static inline struct dtn*
@@ -727,4 +738,5 @@ dtpi_next_val(struct dtpropi* dtpi, struct dtp_val* val, int cells)
     return true;
 }
 
     return true;
 }
 
+#endif
 #endif /* __LUNAIX_DEVTREE_H */
 #endif /* __LUNAIX_DEVTREE_H */