Change of vterm handling logic on backend chardev input event (#40)
[lunaix-os.git] / lunaix-os / includes / hal / serial.h
index 1211ed04cb0793018d6f5a8799b48d637f1e5789..af345dad6d50ffa358d0449d696db48e91afdaed 100644 (file)
@@ -2,10 +2,12 @@
 #define __LUNAIX_SERIAL_H
 
 #include <lunaix/device.h>
-#include <lunaix/ds/fifo.h>
 #include <lunaix/ds/llist.h>
 #include <lunaix/ds/mutex.h>
 #include <lunaix/ds/waitq.h>
+#include <lunaix/ds/rbuffer.h>
+
+#include <usr/lunaix/serial.h>
 
 #define SERIAL_RW_RX 0x0
 #define SERIAL_RW_TX 0x1
@@ -28,9 +30,11 @@ struct serial_dev
     struct waitq wq_txdone;
     void* backend;
 
-    struct fifo_buf rxbuf;
+    struct rbuffer rxbuf;
     int wr_len;
 
+    struct capability_meta* tp_cap;
+
     /**
      * @brief Write buffer to TX. The return code indicate
      * the transaction is either done in synced mode (TX_DONE) or will be
@@ -41,8 +45,18 @@ struct serial_dev
     int (*exec_cmd)(struct serial_dev* sdev, u32_t, va_list);
 };
 
+/**
+ * @brief Create a serial device.
+ *
+ *
+ * @param if_ident a string that differentiate the underlying interface of
+ * serial ports
+ * @param with_tty whether a `/dev/tty*` will be automatically created and
+ * attach to it.
+ * @return struct serial_dev*
+ */
 struct serial_dev*
-serial_create(struct devclass* class);
+serial_create(struct devclass* class, char* if_ident);
 
 void
 serial_readone(struct serial_dev* sdev, u8_t* val);