X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/6f6da1abb22dff69dbb710bd2fd9d95f083f2b43..35a7d633d3f16c1e0539af6ca5d8e7482926cd93:/lunaix-os/includes/hal/serial.h diff --git a/lunaix-os/includes/hal/serial.h b/lunaix-os/includes/hal/serial.h index 8346fd0..ba2185c 100644 --- a/lunaix-os/includes/hal/serial.h +++ b/lunaix-os/includes/hal/serial.h @@ -2,10 +2,13 @@ #define __LUNAIX_SERIAL_H #include -#include #include #include #include +#include +#include + +#include #define SERIAL_RW_RX 0x0 #define SERIAL_RW_TX 0x1 @@ -24,14 +27,15 @@ struct serial_dev { struct llist_header sdev_list; struct device* dev; - mutex_t lock; struct waitq wq_rxdone; struct waitq wq_txdone; void* backend; - struct fifo_buf rxbuf; + struct rbuffer rxbuf; int wr_len; + struct termport_potens* tp_cap; + /** * @brief Write buffer to TX. The return code indicate * the transaction is either done in synced mode (TX_DONE) or will be @@ -42,8 +46,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);