feat: capability list to enable greater flexibility of devices
[lunaix-os.git] / lunaix-os / includes / hal / term.h
index 84da769beb0d4b4c4c9a805d074f08196822adca..0f11e525bac5ce73e15684fd55e9b4e06b609de9 100644 (file)
@@ -31,6 +31,29 @@ struct term_lcntl
     int (*process_and_put)(struct term*, struct linebuffer*, char);
 };
 
+/**
+ * @brief Communication port capability that a device is supported natively, 
+ *          or able to emulate low level serial transmission behaviour specify 
+ *          by POSIX1-2008, section 11.
+ * 
+ */
+#define TERMPORT_CAP 0x4d524554U
+
+/**
+ * @brief A termios capability that a device provide interfaces which is 
+ *          compliant to POSIX1-2008
+ * 
+ */
+#define TERMIOS_CAP 0x534f4954U
+
+struct termport_capability
+{
+    CAPABILITY_META;
+
+    void (*set_speed)(struct device*, speed_t);
+    void (*set_cntrl_mode)(struct device*, tcflag_t);
+};
+
 struct term
 {
     struct device* dev;
@@ -40,19 +63,19 @@ struct term
     struct linebuffer line_in;
     pid_t fggrp;
 
-    struct
-    {
-        int (*set_speed)(struct device*, speed_t);
-    } chdev_ops;
+    struct termport_capability* tp_cap;
 
     /* -- POSIX.1-2008 compliant fields -- */
     tcflag_t iflags;
     tcflag_t oflags;
     tcflag_t lflags;
+    tcflag_t cflags;
     cc_t cc[_NCCS];
     speed_t iospeed;
 };
 
+extern struct device* sysconsole;
+
 struct term*
 term_create(struct device* chardev, char* suffix);