git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
rewrite the device subsystem interfaces (#48)
[lunaix-os.git]
/
lunaix-os
/
hal
/
char
/
serial.c
diff --git
a/lunaix-os/hal/char/serial.c
b/lunaix-os/hal/char/serial.c
index d3d14c70eb66dbe13b1e0136aed677a0f4c0537d..7943bb3c36ab732ac897e0ad4fc6f0476afc72ab 100644
(file)
--- a/
lunaix-os/hal/char/serial.c
+++ b/
lunaix-os/hal/char/serial.c
@@
-8,7
+8,6
@@
#include <asm/pagetable.h>
#include <hal/serial.h>
#include <asm/pagetable.h>
#include <hal/serial.h>
-#include <hal/term.h>
LOG_MODULE("serial")
LOG_MODULE("serial")
@@
-47,9
+46,7
@@
serial_end_recv(struct serial_dev* sdev)
pwake_one(&sdev->wq_rxdone);
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
}
void
@@
-256,7
+253,7
@@
__serial_set_cntrl_mode(struct device* dev, tcflag_t cflag)
#define RXBUF_SIZE 512
#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
.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*
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;
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;
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);
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);
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;
}
return sdev;
}