Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/virtio/console/virtio_console.c
Show First 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | |||||
#if defined(KDB) | #if defined(KDB) | ||||
int vtcport_alt_break_state; | int vtcport_alt_break_state; | ||||
#endif | #endif | ||||
}; | }; | ||||
#define VTCON_PORT_LOCK(_port) mtx_lock(&(_port)->vtcport_mtx) | #define VTCON_PORT_LOCK(_port) mtx_lock(&(_port)->vtcport_mtx) | ||||
#define VTCON_PORT_UNLOCK(_port) mtx_unlock(&(_port)->vtcport_mtx) | #define VTCON_PORT_UNLOCK(_port) mtx_unlock(&(_port)->vtcport_mtx) | ||||
#define VTCON_PORT_ASSERT(_port, ma) mtx_assert(&(_port)->vtcport_mtx, (ma)) | |||||
struct vtcon_softc_port { | struct vtcon_softc_port { | ||||
struct vtcon_softc *vcsp_sc; | struct vtcon_softc *vcsp_sc; | ||||
struct vtcon_port *vcsp_port; | struct vtcon_port *vcsp_port; | ||||
struct virtqueue *vcsp_invq; | struct virtqueue *vcsp_invq; | ||||
struct virtqueue *vcsp_outvq; | struct virtqueue *vcsp_outvq; | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 1,198 Lines • ▼ Show 20 Lines | |||||
vtcon_port_in(struct vtcon_port *port) | vtcon_port_in(struct vtcon_port *port) | ||||
{ | { | ||||
struct virtqueue *vq; | struct virtqueue *vq; | ||||
struct tty *tp; | struct tty *tp; | ||||
char *buf; | char *buf; | ||||
uint32_t len; | uint32_t len; | ||||
int i, deq; | int i, deq; | ||||
/* Effectively the ttydisc lock. */ | |||||
VTCON_PORT_ASSERT(port, MA_OWNED); | |||||
tp = port->vtcport_tty; | tp = port->vtcport_tty; | ||||
vq = port->vtcport_invq; | vq = port->vtcport_invq; | ||||
again: | again: | ||||
deq = 0; | deq = 0; | ||||
while ((buf = virtqueue_dequeue(vq, &len)) != NULL) { | while ((buf = virtqueue_dequeue(vq, &len)) != NULL) { | ||||
for (i = 0; i < len; i++) { | for (i = 0; i < len; i++) { | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | vtcon_port_submit_event(struct vtcon_port *port, uint16_t event, | ||||
vtcon_ctrl_send_control(sc, port->vtcport_id, event, value); | vtcon_ctrl_send_control(sc, port->vtcport_id, event, value); | ||||
} | } | ||||
static int | static int | ||||
vtcon_tty_open(struct tty *tp) | vtcon_tty_open(struct tty *tp) | ||||
{ | { | ||||
struct vtcon_port *port; | struct vtcon_port *port; | ||||
/* Effectively VTCON_PORT_LOCK. */ | |||||
ttydisc_assert_locked(tp); | |||||
port = tty_softc(tp); | port = tty_softc(tp); | ||||
if (port->vtcport_flags & VTCON_PORT_FLAG_GONE) { | |||||
if (port->vtcport_flags & VTCON_PORT_FLAG_GONE) | |||||
return (ENXIO); | return (ENXIO); | ||||
} | |||||
vtcon_port_submit_event(port, VIRTIO_CONSOLE_PORT_OPEN, 1); | vtcon_port_submit_event(port, VIRTIO_CONSOLE_PORT_OPEN, 1); | ||||
return (0); | return (0); | ||||
} | } | ||||
static void | static void | ||||
vtcon_tty_close(struct tty *tp) | vtcon_tty_close(struct tty *tp) | ||||
{ | { | ||||
struct vtcon_port *port; | struct vtcon_port *port; | ||||
/* Effectively VTCON_PORT_LOCK. */ | |||||
ttydisc_assert_locked(tp); | |||||
port = tty_softc(tp); | port = tty_softc(tp); | ||||
if (port->vtcport_flags & VTCON_PORT_FLAG_GONE) | if (port->vtcport_flags & VTCON_PORT_FLAG_GONE) | ||||
return; | return; | ||||
vtcon_port_submit_event(port, VIRTIO_CONSOLE_PORT_OPEN, 0); | vtcon_port_submit_event(port, VIRTIO_CONSOLE_PORT_OPEN, 0); | ||||
} | } | ||||
static void | static void | ||||
vtcon_tty_outwakeup(struct tty *tp) | vtcon_tty_outwakeup(struct tty *tp) | ||||
{ | { | ||||
struct vtcon_port *port; | struct vtcon_port *port; | ||||
char buf[VTCON_BULK_BUFSZ]; | char buf[VTCON_BULK_BUFSZ]; | ||||
int len; | int len; | ||||
/* Effectively VTCON_PORT_LOCK. */ | |||||
ttydisc_assert_locked(tp); | |||||
port = tty_softc(tp); | port = tty_softc(tp); | ||||
if (port->vtcport_flags & VTCON_PORT_FLAG_GONE) | if (port->vtcport_flags & VTCON_PORT_FLAG_GONE) | ||||
return; | return; | ||||
while ((len = ttydisc_getc(tp, buf, sizeof(buf))) != 0) | while ((len = ttydisc_getc(tp, buf, sizeof(buf))) != 0) | ||||
vtcon_port_out(port, buf, len); | vtcon_port_out(port, buf, len); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 77 Lines • Show Last 20 Lines |