1 #ifndef __LUNAIX_TERM_H
2 #define __LUNAIX_TERM_H
4 #include <lunaix/device.h>
5 #include <lunaix/ds/rbuffer.h>
6 #include <lunaix/ds/waitq.h>
7 #include <lunaix/signal_defs.h>
9 #include <usr/lunaix/term.h>
16 struct rbuffer* current;
21 #define LEVT_EOF (1 << 1)
22 #define LEVT_SIGRAISE (1 << 2)
24 typedef struct rbuffer** lbuf_ref_t;
25 #define ref_current(lbuf) (&(lbuf)->current)
26 #define ref_next(lbuf) (&(lbuf)->next)
27 #define deref(bref) (*(bref))
30 * @brief Communication port capability that a device is supported natively,
31 * or able to emulate low level serial transmission behaviour specify
32 * by POSIX1-2008, section 11.
35 #define TERMPORT_CAP 0x4d524554U
38 * @brief A termios capability that a device provide interfaces which is
39 * compliant to POSIX1-2008
42 #define TERMIOS_CAP 0x534f4954U
46 struct termport_cap_ops
48 void (*set_speed)(struct device*, speed_t);
49 void (*set_clkbase)(struct device*, unsigned int);
50 void (*set_cntrl_mode)(struct device*, tcflag_t);
53 struct termport_capability
56 struct termport_cap_ops* cap_ops;
64 struct linebuffer line_out;
65 struct linebuffer line_in;
69 struct termport_capability* tp_cap;
70 waitq_t line_in_event;
72 /* -- POSIX.1-2008 compliant fields -- */
79 /* -- END POSIX.1-2008 compliant fields -- */
82 tcflag_t tflags; // temp flags
85 extern struct device* sysconsole;
88 term_create(struct device* chardev, char* suffix);
91 term_bind(struct term* tdev, struct device* chdev);
94 line_flip(struct linebuffer* lbf)
96 struct rbuffer* tmp = lbf->current;
97 lbf->current = lbf->next;
102 line_alloc(struct linebuffer* lbf, size_t sz_hlf);
105 line_free(struct linebuffer* lbf, size_t sz_hlf);
108 term_sendsig(struct term* tdev, int signal);
111 term_flush(struct term* tdev);
114 term_read(struct term* tdev);
117 lcntl_transform_inseq(struct term* tdev);
120 lcntl_transform_outseq(struct term* tdev);
123 term_cap_set_operations(struct termport_capability* cap,
124 struct termport_cap_ops* ops)
130 term_notify_data_avaliable(struct termport_capability* cap);
132 #define termport_default_ops \
134 extern struct termport_cap_ops default_termport_cap_ops;\
135 &default_termport_cap_ops; \
138 #endif /* __LUNAIX_TERM_H */