X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/59ecf21e36b2332f6adf2a568ef555283d8c119a..bdc143a7aa3f51a46eceec62b0b364599533fa21:/lunaix-os/includes/hal/term.h diff --git a/lunaix-os/includes/hal/term.h b/lunaix-os/includes/hal/term.h index 00fe32b..407707e 100644 --- a/lunaix-os/includes/hal/term.h +++ b/lunaix-os/includes/hal/term.h @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -11,66 +12,87 @@ struct term; struct linebuffer { - struct rbuffer *next; - struct rbuffer *current; + struct rbuffer* next; + struct rbuffer* current; short sflags; short sz_hlf; }; -#define LSTATE_EOL (1) -#define LSTATE_EOF (1 << 1) -#define LSTATE_SIGRAISE (1 << 2) +#define LEVT_EOL (1) +#define LEVT_EOF (1 << 1) +#define LEVT_SIGRAISE (1 << 2) typedef struct rbuffer** lbuf_ref_t; #define ref_current(lbuf) (&(lbuf)->current) #define ref_next(lbuf) (&(lbuf)->next) #define deref(bref) (*(bref)) -struct term_lcntl +/** + * @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 term; + +struct termport_cap_ops +{ + void (*set_speed)(struct device*, speed_t); + void (*set_clkbase)(struct device*, unsigned int); + void (*set_cntrl_mode)(struct device*, tcflag_t); +}; + +struct termport_capability { - struct llist_header lcntls; + CAPABILITY_META; + struct termport_cap_ops* cap_ops; struct term* term; - size_t (*process_and_put)(struct term*, struct linebuffer*, char); }; struct term { struct device* dev; struct device* chdev; - struct llist_header lcntl_stack; struct linebuffer line_out; struct linebuffer line_in; + char* scratch_pad; pid_t fggrp; - struct - { - int (*set_speed)(struct device*, speed_t); - } chdev_ops; + struct termport_capability* tp_cap; + waitq_t line_in_event; /* -- POSIX.1-2008 compliant fields -- */ tcflag_t iflags; tcflag_t oflags; tcflag_t lflags; + tcflag_t cflags; cc_t cc[_NCCS]; + + /* -- END POSIX.1-2008 compliant fields -- */ speed_t iospeed; + speed_t clkbase; + tcflag_t tflags; // temp flags }; +extern struct device* sysconsole; + struct term* term_create(struct device* chardev, char* suffix); int term_bind(struct term* tdev, struct device* chdev); -int -term_push_lcntl(struct term* tdev, struct term_lcntl* lcntl); - -int -term_pop_lcntl(struct term* tdev); - -struct term_lcntl* -term_get_lcntl(u32_t lcntl_index); - static inline void -line_flip(struct linebuffer* lbf) { +line_flip(struct linebuffer* lbf) +{ struct rbuffer* tmp = lbf->current; lbf->current = lbf->next; lbf->next = tmp; @@ -97,4 +119,20 @@ lcntl_transform_inseq(struct term* tdev); int lcntl_transform_outseq(struct term* tdev); +static inline void +term_cap_set_operations(struct termport_capability* cap, + struct termport_cap_ops* ops) +{ + cap->cap_ops = ops; +} + +void +term_notify_data_avaliable(struct termport_capability* cap); + +#define termport_default_ops \ + ({ \ + extern struct termport_cap_ops default_termport_cap_ops;\ + &default_termport_cap_ops; \ + }) + #endif /* __LUNAIX_TERM_H */