X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/99f2ed669601a61f4f0210e0b481ff877cd9bea7..35a7d633d3f16c1e0539af6ca5d8e7482926cd93:/lunaix-os/hal/char/serial.c?ds=sidebyside diff --git a/lunaix-os/hal/char/serial.c b/lunaix-os/hal/char/serial.c index d3d14c7..7943bb3 100644 --- a/lunaix-os/hal/char/serial.c +++ b/lunaix-os/hal/char/serial.c @@ -8,7 +8,6 @@ #include #include -#include LOG_MODULE("serial") @@ -47,9 +46,7 @@ serial_end_recv(struct serial_dev* sdev) pwake_one(&sdev->wq_rxdone); - struct termport_capability* tpcap; - tpcap = get_capability(sdev->tp_cap, typeof(*tpcap)); - term_notify_data_avaliable(tpcap); + term_notify_data_avaliable(sdev->tp_cap); } void @@ -256,7 +253,7 @@ __serial_set_cntrl_mode(struct device* dev, tcflag_t cflag) #define RXBUF_SIZE 512 -static struct termport_cap_ops tpcap_ops = { +static struct termport_pot_ops tppot_ops = { .set_cntrl_mode = __serial_set_cntrl_mode, .set_clkbase = __serial_set_baseclk, .set_speed = __serial_set_speed @@ -265,8 +262,12 @@ static struct termport_cap_ops tpcap_ops = { struct serial_dev* serial_create(struct devclass* class, char* if_ident) { - struct serial_dev* sdev = vzalloc(sizeof(struct serial_dev)); - struct device* dev = device_allocseq(dev_meta(serial_cat), sdev); + struct serial_dev* sdev; + struct device* dev; + + sdev = vzalloc(sizeof(struct serial_dev)); + dev = device_allocseq(dev_meta(serial_cat), sdev); + dev->ops.read = __serial_read; dev->ops.read_page = __serial_read_page; dev->ops.read_async = __serial_read_async; @@ -279,27 +280,18 @@ serial_create(struct devclass* class, char* if_ident) sdev->dev = dev; dev->underlay = sdev; - struct termport_capability* tp_cap = - new_capability(TERMPORT_CAP, struct termport_capability); - - term_cap_set_operations(tp_cap, &tpcap_ops); - sdev->tp_cap = cap_meta(tp_cap); - waitq_init(&sdev->wq_rxdone); waitq_init(&sdev->wq_txdone); rbuffer_init(&sdev->rxbuf, valloc(RXBUF_SIZE), RXBUF_SIZE); llist_append(&serial_devs, &sdev->sdev_list); - device_grant_capability(dev, cap_meta(tp_cap)); - - register_device(dev, class, "%s%d", if_ident, class->variant); - - term_create(dev, if_ident); + register_device_var(dev, class, "%s", if_ident); INFO("interface: %s, %xh:%xh.%d", dev->name_val, class->fn_grp, class->device, class->variant); - class->variant++; + sdev->tp_cap = term_attach_potens(dev, &tppot_ops, if_ident); + return sdev; }