feat: IO polling for file descriptor
[lunaix-os.git] / lunaix-os / includes / lunaix / device.h
index f65082126313c81202e0b587d7ae869849c73d01..affdb10200a91f23b690ddb20fdc2d6f13f0569d 100644 (file)
@@ -9,6 +9,7 @@
 #include <lunaix/ds/ldga.h>
 #include <lunaix/ds/llist.h>
 #include <lunaix/ds/mutex.h>
 #include <lunaix/ds/ldga.h>
 #include <lunaix/ds/llist.h>
 #include <lunaix/ds/mutex.h>
+#include <lunaix/iopoll.h>
 #include <lunaix/types.h>
 
 #include <usr/lunaix/device.h>
 #include <lunaix/types.h>
 
 #include <usr/lunaix/device.h>
 
 struct device
 {
 
 struct device
 {
+    /* -- device structing -- */
+
     u32_t magic;
     struct llist_header siblings;
     struct llist_header children;
     struct device* parent;
     u32_t magic;
     struct llist_header siblings;
     struct llist_header children;
     struct device* parent;
-    mutex_t lock;
 
 
-    // TODO investigate event polling
+    /* -- device state -- */
+
+    mutex_t lock;
 
     struct hstr name;
     struct devident ident;
 
     struct hstr name;
     struct devident ident;
@@ -111,6 +115,10 @@ struct device
     char name_val[DEVICE_NAME_SIZE];
     void* underlay;
 
     char name_val[DEVICE_NAME_SIZE];
     void* underlay;
 
+    /* -- polling -- */
+    int poll_evflags;
+    poll_evt_q pollers;
+
     struct
     {
         // TODO Think about where will they fit.
     struct
     {
         // TODO Think about where will they fit.
@@ -122,6 +130,7 @@ struct device
         int (*read_page)(struct device* dev, void* buf, size_t offset);
         int (*write_page)(struct device* dev, void* buf, size_t offset);
         int (*exec_cmd)(struct device* dev, u32_t req, va_list args);
         int (*read_page)(struct device* dev, void* buf, size_t offset);
         int (*write_page)(struct device* dev, void* buf, size_t offset);
         int (*exec_cmd)(struct device* dev, u32_t req, va_list args);
+        int (*poll)(struct device* dev);
     } ops;
 };
 
     } ops;
 };