1 #ifndef __LUNAIX_TERM_H
2 #define __LUNAIX_TERM_H
4 #include <lunaix/device.h>
5 #include <lunaix/ds/rbuffer.h>
6 #include <lunaix/signal_defs.h>
8 #include <usr/lunaix/term.h>
15 struct rbuffer* current;
19 #define LSTATE_EOL (1)
20 #define LSTATE_EOF (1 << 1)
21 #define LSTATE_SIGRAISE (1 << 2)
23 typedef struct rbuffer** lbuf_ref_t;
24 #define ref_current(lbuf) (&(lbuf)->current)
25 #define ref_next(lbuf) (&(lbuf)->next)
26 #define deref(bref) (*(bref))
31 int (*process_and_put)(struct term*, struct linebuffer*, char);
35 * @brief Communication port capability that a device is supported natively,
36 * or able to emulate low level serial transmission behaviour specify
37 * by POSIX1-2008, section 11.
40 #define TERMPORT_CAP 0x4d524554U
43 * @brief A termios capability that a device provide interfaces which is
44 * compliant to POSIX1-2008
47 #define TERMIOS_CAP 0x534f4954U
49 struct termport_capability
53 void (*set_speed)(struct device*, speed_t);
54 void (*set_cntrl_mode)(struct device*, tcflag_t);
61 struct term_lcntl* lcntl;
62 struct linebuffer line_out;
63 struct linebuffer line_in;
67 struct termport_capability* tp_cap;
69 /* -- POSIX.1-2008 compliant fields -- */
78 extern struct device* sysconsole;
81 term_create(struct device* chardev, char* suffix);
84 term_bind(struct term* tdev, struct device* chdev);
87 term_push_lcntl(struct term* tdev, struct term_lcntl* lcntl);
90 term_pop_lcntl(struct term* tdev);
93 term_get_lcntl(u32_t lcntl_index);
96 line_flip(struct linebuffer* lbf)
98 struct rbuffer* tmp = lbf->current;
99 lbf->current = lbf->next;
104 line_alloc(struct linebuffer* lbf, size_t sz_hlf);
107 line_free(struct linebuffer* lbf, size_t sz_hlf);
110 term_sendsig(struct term* tdev, int signal);
113 term_flush(struct term* tdev);
116 term_read(struct term* tdev);
119 lcntl_transform_inseq(struct term* tdev);
122 lcntl_transform_outseq(struct term* tdev);
124 #endif /* __LUNAIX_TERM_H */