Lines Matching +full:num +full:- +full:cols
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
136 uint16_t cols; member
149 uint16_t cols; member
187 vi_reset_dev(&sc->vsc_vs); in pci_vtcon_reset()
195 sc->vsc_features = negotiated_features; in pci_vtcon_neg_features()
204 ptr = (uint8_t *)sc->vsc_config + offset; in pci_vtcon_cfgread()
219 uint16_t num = vq->vq_num; in pci_vtcon_vq_to_port() local
221 if (num == 0 || num == 1) in pci_vtcon_vq_to_port()
222 return (&sc->vsc_ports[0]); in pci_vtcon_vq_to_port()
224 if (num == 2 || num == 3) in pci_vtcon_vq_to_port()
225 return (&sc->vsc_control_port); in pci_vtcon_vq_to_port()
227 return (&sc->vsc_ports[(num / 2) - 1]); in pci_vtcon_vq_to_port()
235 qnum = tx_queue ? port->vsp_txq : port->vsp_rxq; in pci_vtcon_port_to_vq()
236 return (&port->vsp_sc->vsc_queues[qnum]); in pci_vtcon_port_to_vq()
245 port = &sc->vsc_ports[port_id]; in pci_vtcon_port_add()
246 if (port->vsp_enabled) { in pci_vtcon_port_add()
250 port->vsp_id = port_id; in pci_vtcon_port_add()
251 port->vsp_sc = sc; in pci_vtcon_port_add()
252 port->vsp_name = name; in pci_vtcon_port_add()
253 port->vsp_cb = cb; in pci_vtcon_port_add()
254 port->vsp_arg = arg; in pci_vtcon_port_add()
256 if (port->vsp_id == 0) { in pci_vtcon_port_add()
258 port->vsp_txq = 0; in pci_vtcon_port_add()
259 port->vsp_rxq = 1; in pci_vtcon_port_add()
261 port->vsp_txq = (port_id + 1) * 2; in pci_vtcon_port_add()
262 port->vsp_rxq = port->vsp_txq + 1; in pci_vtcon_port_add()
265 port->vsp_enabled = true; in pci_vtcon_port_add()
278 int s = -1, fd = -1, error = 0; in pci_vtcon_sock_add()
286 error = -1; in pci_vtcon_sock_add()
293 error = -1; in pci_vtcon_sock_add()
299 error = -1; in pci_vtcon_sock_add()
305 error = -1; in pci_vtcon_sock_add()
311 error = -1; in pci_vtcon_sock_add()
318 error = -1; in pci_vtcon_sock_add()
329 error = -1; in pci_vtcon_sock_add()
334 error = -1; in pci_vtcon_sock_add()
339 error = -1; in pci_vtcon_sock_add()
345 if (caph_rights_limit(s, &rights) == -1) in pci_vtcon_sock_add()
352 error = -1; in pci_vtcon_sock_add()
355 sock->vss_port = pci_vtcon_port_add(sc, port, name, pci_vtcon_sock_tx, sock); in pci_vtcon_sock_add()
356 if (sock->vss_port == NULL) { in pci_vtcon_sock_add()
357 error = -1; in pci_vtcon_sock_add()
361 sock->vss_open = false; in pci_vtcon_sock_add()
362 sock->vss_conn_fd = -1; in pci_vtcon_sock_add()
363 sock->vss_server_fd = s; in pci_vtcon_sock_add()
364 sock->vss_server_evp = mevent_add(s, EVF_READ, pci_vtcon_sock_accept, in pci_vtcon_sock_add()
367 if (sock->vss_server_evp == NULL) { in pci_vtcon_sock_add()
368 error = -1; in pci_vtcon_sock_add()
373 if (fd != -1) in pci_vtcon_sock_add()
377 if (s != -1) in pci_vtcon_sock_add()
391 s = accept(sock->vss_server_fd, NULL, NULL); in pci_vtcon_sock_accept()
395 if (sock->vss_open) { in pci_vtcon_sock_accept()
400 sock->vss_open = true; in pci_vtcon_sock_accept()
401 sock->vss_conn_fd = s; in pci_vtcon_sock_accept()
402 sock->vss_conn_evp = mevent_add(s, EVF_READ, pci_vtcon_sock_rx, sock); in pci_vtcon_sock_accept()
404 pci_vtcon_open_port(sock->vss_port, true); in pci_vtcon_sock_accept()
418 port = sock->vss_port; in pci_vtcon_sock_rx()
421 if (!sock->vss_open || !port->vsp_rx_ready) { in pci_vtcon_sock_rx()
422 len = read(sock->vss_conn_fd, dummybuf, sizeof(dummybuf)); in pci_vtcon_sock_rx()
430 len = read(sock->vss_conn_fd, dummybuf, sizeof(dummybuf)); in pci_vtcon_sock_rx()
441 len = readv(sock->vss_conn_fd, &iov, n); in pci_vtcon_sock_rx()
458 mevent_delete_close(sock->vss_conn_evp); in pci_vtcon_sock_rx()
459 sock->vss_conn_fd = -1; in pci_vtcon_sock_rx()
460 sock->vss_open = false; in pci_vtcon_sock_rx()
472 if (sock->vss_conn_fd == -1) in pci_vtcon_sock_tx()
476 ret = stream_write(sock->vss_conn_fd, iov[i].iov_base, in pci_vtcon_sock_tx()
483 mevent_delete_close(sock->vss_conn_evp); in pci_vtcon_sock_tx()
484 sock->vss_conn_fd = -1; in pci_vtcon_sock_tx()
485 sock->vss_open = false; in pci_vtcon_sock_tx()
500 sc = port->vsp_sc; in pci_vtcon_control_tx()
501 ctrl = (struct pci_vtcon_control *)iov->iov_base; in pci_vtcon_control_tx()
503 switch (ctrl->event) { in pci_vtcon_control_tx()
505 sc->vsc_ready = true; in pci_vtcon_control_tx()
508 tmp = &sc->vsc_ports[i]; in pci_vtcon_control_tx()
509 if (tmp->vsp_enabled) in pci_vtcon_control_tx()
512 if (tmp->vsp_open) in pci_vtcon_control_tx()
518 tmp = &sc->vsc_ports[ctrl->id]; in pci_vtcon_control_tx()
519 if (ctrl->id >= VTCON_MAXPORTS || !tmp->vsp_enabled) { in pci_vtcon_control_tx()
521 ctrl->id)); in pci_vtcon_control_tx()
525 if (tmp->vsp_console) { in pci_vtcon_control_tx()
527 resp.id = ctrl->id; in pci_vtcon_control_tx()
540 event.id = port->vsp_id; in pci_vtcon_announce_port()
543 pci_vtcon_control_send(port->vsp_sc, &event, NULL, 0); in pci_vtcon_announce_port()
546 pci_vtcon_control_send(port->vsp_sc, &event, port->vsp_name, in pci_vtcon_announce_port()
547 strlen(port->vsp_name)); in pci_vtcon_announce_port()
555 if (!port->vsp_sc->vsc_ready) { in pci_vtcon_open_port()
556 port->vsp_open = true; in pci_vtcon_open_port()
560 event.id = port->vsp_id; in pci_vtcon_open_port()
563 pci_vtcon_control_send(port->vsp_sc, &event, NULL, 0); in pci_vtcon_open_port()
575 if (len > SIZE_T_MAX - sizeof(struct pci_vtcon_control)) in pci_vtcon_control_send()
578 vq = pci_vtcon_port_to_vq(&sc->vsc_control_port, true); in pci_vtcon_control_send()
616 port->vsp_cb(port, port->vsp_arg, iov, 1); in pci_vtcon_notify_tx()
635 if (!port->vsp_rx_ready) { in pci_vtcon_notify_rx()
636 port->vsp_rx_ready = 1; in pci_vtcon_notify_rx()
656 return (-1); in pci_vtcon_legacy_config_port()
660 return (-1); in pci_vtcon_legacy_config_port()
698 sc->vsc_config = calloc(1, sizeof(struct pci_vtcon_config)); in pci_vtcon_init()
699 sc->vsc_config->max_nr_ports = VTCON_MAXPORTS; in pci_vtcon_init()
700 sc->vsc_config->cols = 80; in pci_vtcon_init()
701 sc->vsc_config->rows = 25; in pci_vtcon_init()
703 pthread_mutex_init(&sc->vsc_mtx, NULL); in pci_vtcon_init()
705 vi_softc_linkup(&sc->vsc_vs, &vtcon_vi_consts, sc, pi, sc->vsc_queues); in pci_vtcon_init()
706 sc->vsc_vs.vs_mtx = &sc->vsc_mtx; in pci_vtcon_init()
709 sc->vsc_queues[i].vq_qsize = VTCON_RINGSZ; in pci_vtcon_init()
710 sc->vsc_queues[i].vq_notify = i % 2 == 0 in pci_vtcon_init()
722 if (vi_intr_init(&sc->vsc_vs, 1, fbsdrun_virtio_msix())) in pci_vtcon_init()
724 vi_set_io_bar(&sc->vsc_vs, 0); in pci_vtcon_init()
727 sc->vsc_control_port.vsp_sc = sc; in pci_vtcon_init()
728 sc->vsc_control_port.vsp_txq = 2; in pci_vtcon_init()
729 sc->vsc_control_port.vsp_rxq = 3; in pci_vtcon_init()
730 sc->vsc_control_port.vsp_cb = pci_vtcon_control_tx; in pci_vtcon_init()
731 sc->vsc_control_port.vsp_enabled = true; in pci_vtcon_init()
758 .pe_emu = "virtio-console",