Lines Matching refs:port

112 	 * indexed by the port ID.
134 ("%s: port ID %d out of range", __func__, _id))
327 device_printf(dev, "cannot allocate softc port structures\n");
504 /* The control virtqueues are after the first port. */
517 scport, &scport->vcsp_invq, "%s-port%d in",
520 NULL, &scport->vcsp_outvq, "%s-port%d out",
550 struct vtcon_port *port;
561 port = scport->vcsp_port;
562 if (port != NULL) {
564 VTCON_PORT_LOCK(port);
566 vtcon_port_teardown(port);
708 device_printf(dev, "%s: adding port %d, but already exists\n",
715 device_printf(dev, "%s: cannot create port %d: %d\n",
727 struct vtcon_port *port;
733 port = scport->vcsp_port;
734 if (port == NULL) {
736 device_printf(dev, "%s: remove port %d, but does not exist\n",
742 VTCON_PORT_LOCK(port);
744 vtcon_port_teardown(port);
752 struct vtcon_port *port;
758 port = scport->vcsp_port;
759 if (port == NULL) {
761 device_printf(dev, "%s: console port %d, but does not exist\n",
766 VTCON_PORT_LOCK(port);
768 port->vtcport_flags |= VTCON_PORT_FLAG_CONSOLE;
769 vtcon_port_submit_event(port, VIRTIO_CONSOLE_PORT_OPEN, 1);
770 VTCON_PORT_UNLOCK(port);
778 struct vtcon_port *port;
784 port = scport->vcsp_port;
785 if (port == NULL) {
787 device_printf(dev, "%s: open port %d, but does not exist\n",
792 VTCON_PORT_LOCK(port);
794 vtcon_port_enable_intr(port);
795 VTCON_PORT_UNLOCK(port);
809 device_printf(dev, "%s: invalid port ID %d\n", __func__, id);
906 * port lock held. Acquiring the softc would violate our lock
937 vtcon_port_enqueue_buf(struct vtcon_port *port, void *buf, size_t len)
944 vq = port->vtcport_invq;
957 vtcon_port_create_buf(struct vtcon_port *port)
966 error = vtcon_port_enqueue_buf(port, buf, VTCON_BULK_BUFSZ);
974 vtcon_port_requeue_buf(struct vtcon_port *port, void *buf)
978 error = vtcon_port_enqueue_buf(port, buf, VTCON_BULK_BUFSZ);
984 vtcon_port_populate(struct vtcon_port *port)
989 vq = port->vtcport_invq;
993 error = vtcon_port_create_buf(port);
1007 vtcon_port_destroy(struct vtcon_port *port)
1010 port->vtcport_sc = NULL;
1011 port->vtcport_scport = NULL;
1012 port->vtcport_invq = NULL;
1013 port->vtcport_outvq = NULL;
1014 port->vtcport_id = -1;
1015 mtx_destroy(&port->vtcport_mtx);
1016 free(port, M_DEVBUF);
1020 vtcon_port_init_vqs(struct vtcon_port *port)
1025 scport = port->vtcport_scport;
1027 port->vtcport_invq = scport->vcsp_invq;
1028 port->vtcport_outvq = scport->vcsp_outvq;
1032 * prior port. We have not yet notified the host that the port is
1035 vtcon_port_drain(port);
1037 KASSERT(virtqueue_empty(port->vtcport_invq),
1039 KASSERT(virtqueue_empty(port->vtcport_outvq),
1042 error = vtcon_port_populate(port);
1054 struct vtcon_port *port;
1063 port = malloc(sizeof(struct vtcon_port), M_DEVBUF, M_NOWAIT | M_ZERO);
1064 if (port == NULL)
1067 port->vtcport_sc = sc;
1068 port->vtcport_scport = scport;
1069 port->vtcport_id = id;
1070 mtx_init(&port->vtcport_mtx, "vtcpmtx", NULL, MTX_DEF);
1071 port->vtcport_tty = tty_alloc_mutex(&vtcon_tty_class, port,
1072 &port->vtcport_mtx);
1074 error = vtcon_port_init_vqs(port);
1076 VTCON_PORT_LOCK(port);
1077 vtcon_port_teardown(port);
1082 VTCON_PORT_LOCK(port);
1083 scport->vcsp_port = port;
1084 vtcon_port_enable_intr(port);
1085 vtcon_port_submit_event(port, VIRTIO_CONSOLE_PORT_READY, 1);
1086 VTCON_PORT_UNLOCK(port);
1089 tty_makedev(port->vtcport_tty, NULL, "%s%r.%r", VTCON_TTY_PREFIX,
1108 vtcon_port_drain(struct vtcon_port *port)
1111 vtcon_port_drain_bufs(port->vtcport_invq);
1115 vtcon_port_teardown(struct vtcon_port *port)
1119 tp = port->vtcport_tty;
1121 port->vtcport_flags |= VTCON_PORT_FLAG_GONE;
1127 vtcon_port_destroy(port);
1131 vtcon_port_change_size(struct vtcon_port *port, uint16_t cols, uint16_t rows)
1136 tp = port->vtcport_tty;
1151 struct vtcon_port *port;
1158 * For now, assume the first (only) port is the console. Note
1164 port = scport->vcsp_port;
1166 if (port != NULL) {
1167 VTCON_PORT_LOCK(port);
1169 vtcon_port_change_size(port, cols, rows);
1170 VTCON_PORT_UNLOCK(port);
1176 vtcon_port_enable_intr(struct vtcon_port *port)
1183 virtqueue_enable_intr(port->vtcport_invq);
1187 vtcon_port_disable_intr(struct vtcon_port *port)
1190 if (port->vtcport_invq != NULL)
1191 virtqueue_disable_intr(port->vtcport_invq);
1192 if (port->vtcport_outvq != NULL)
1193 virtqueue_disable_intr(port->vtcport_outvq);
1197 vtcon_port_in(struct vtcon_port *port)
1205 tp = port->vtcport_tty;
1206 vq = port->vtcport_invq;
1214 if (port->vtcport_flags & VTCON_PORT_FLAG_CONSOLE)
1216 &port->vtcport_alt_break_state);
1220 vtcon_port_requeue_buf(port, buf);
1237 struct vtcon_port *port;
1243 port = scport->vcsp_port;
1244 if (port == NULL) {
1248 VTCON_PORT_LOCK(port);
1250 if ((port->vtcport_flags & VTCON_PORT_FLAG_GONE) == 0)
1251 vtcon_port_in(port);
1252 VTCON_PORT_UNLOCK(port);
1256 vtcon_port_out(struct vtcon_port *port, void *buf, int bufsize)
1263 vq = port->vtcport_outvq;
1265 ("%s: port %p out virtqueue not emtpy", __func__, port));
1280 vtcon_port_submit_event(struct vtcon_port *port, uint16_t event,
1285 sc = port->vtcport_sc;
1287 vtcon_ctrl_send_control(sc, port->vtcport_id, event, value);
1293 struct vtcon_port *port;
1295 port = tty_softc(tp);
1297 if (port->vtcport_flags & VTCON_PORT_FLAG_GONE)
1300 vtcon_port_submit_event(port, VIRTIO_CONSOLE_PORT_OPEN, 1);
1308 struct vtcon_port *port;
1310 port = tty_softc(tp);
1312 if (port->vtcport_flags & VTCON_PORT_FLAG_GONE)
1315 vtcon_port_submit_event(port, VIRTIO_CONSOLE_PORT_OPEN, 0);
1321 struct vtcon_port *port;
1325 port = tty_softc(tp);
1327 if (port->vtcport_flags & VTCON_PORT_FLAG_GONE)
1331 vtcon_port_out(port, buf, len);
1337 struct vtcon_port *port;
1339 port = xport;
1341 vtcon_port_destroy(port);
1363 struct vtcon_port *port;
1374 port = scport->vcsp_port;
1375 if (port == NULL)
1378 VTCON_PORT_LOCK(port);
1379 vtcon_port_enable_intr(port);
1380 VTCON_PORT_UNLOCK(port);
1390 struct vtcon_port *port;
1401 port = scport->vcsp_port;
1402 if (port == NULL)
1405 VTCON_PORT_LOCK(port);
1406 vtcon_port_disable_intr(port);
1407 VTCON_PORT_UNLOCK(port);