Register eight vHCI buses, and use separate KCOV mailboxes for them.
This commit is contained in:
parent
252a722447
commit
9259199775
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/sh -
|
#!/bin/sh -
|
||||||
# $NetBSD: MAKEDEV.tmpl,v 1.218 2020/04/04 16:04:36 jdolecek Exp $
|
# $NetBSD: MAKEDEV.tmpl,v 1.219 2020/06/05 17:20:56 maxv Exp $
|
||||||
#
|
#
|
||||||
# Copyright (c) 2003,2007,2008 The NetBSD Foundation, Inc.
|
# Copyright (c) 2003,2007,2008 The NetBSD Foundation, Inc.
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
|
@ -1785,8 +1785,9 @@ veriexec)
|
||||||
mkdev veriexec c %veriexec_chr% 0 600
|
mkdev veriexec c %veriexec_chr% 0 600
|
||||||
;;
|
;;
|
||||||
|
|
||||||
vhci)
|
vhci[0-7]*)
|
||||||
mkdev vhci c %vhci_chr% 0
|
unit=${i#vhci}
|
||||||
|
mkdev vhci$unit c %vhci_chr% $unit
|
||||||
;;
|
;;
|
||||||
|
|
||||||
ttyv[0-9]*)
|
ttyv[0-9]*)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: uhub.c,v 1.146 2020/05/31 08:05:30 maxv Exp $ */
|
/* $NetBSD: uhub.c,v 1.147 2020/06/05 17:20:56 maxv Exp $ */
|
||||||
/* $FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $ */
|
/* $FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $ */
|
||||||
/* $OpenBSD: uhub.c,v 1.86 2015/06/29 18:27:40 mpi Exp $ */
|
/* $OpenBSD: uhub.c,v 1.86 2015/06/29 18:27:40 mpi Exp $ */
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.146 2020/05/31 08:05:30 maxv Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.147 2020/06/05 17:20:56 maxv Exp $");
|
||||||
|
|
||||||
#ifdef _KERNEL_OPT
|
#ifdef _KERNEL_OPT
|
||||||
#include "opt_usb.h"
|
#include "opt_usb.h"
|
||||||
|
@ -754,15 +754,19 @@ uhub_explore(struct usbd_device *dev)
|
||||||
port);
|
port);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dev->ud_bus->ub_hctype == USBHCTYPE_VHCI)
|
if (dev->ud_bus->ub_hctype == USBHCTYPE_VHCI) {
|
||||||
kcov_remote_enter(KCOV_REMOTE_VHCI, port);
|
kcov_remote_enter(KCOV_REMOTE_VHCI,
|
||||||
|
KCOV_REMOTE_VHCI_ID(dev->ud_bus->ub_busnum, port));
|
||||||
|
}
|
||||||
|
|
||||||
/* Get device info and set its address. */
|
/* Get device info and set its address. */
|
||||||
err = usbd_new_device(sc->sc_dev, dev->ud_bus,
|
err = usbd_new_device(sc->sc_dev, dev->ud_bus,
|
||||||
dev->ud_depth + 1, speed, port, up);
|
dev->ud_depth + 1, speed, port, up);
|
||||||
|
|
||||||
if (dev->ud_bus->ub_hctype == USBHCTYPE_VHCI)
|
if (dev->ud_bus->ub_hctype == USBHCTYPE_VHCI) {
|
||||||
kcov_remote_leave(KCOV_REMOTE_VHCI, port);
|
kcov_remote_leave(KCOV_REMOTE_VHCI,
|
||||||
|
KCOV_REMOTE_VHCI_ID(dev->ud_bus->ub_busnum, port));
|
||||||
|
}
|
||||||
|
|
||||||
/* XXX retry a few times? */
|
/* XXX retry a few times? */
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: usbdivar.h,v 1.123 2020/05/15 12:34:52 maxv Exp $ */
|
/* $NetBSD: usbdivar.h,v 1.124 2020/06/05 17:20:56 maxv Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1998, 2012 The NetBSD Foundation, Inc.
|
* Copyright (c) 1998, 2012 The NetBSD Foundation, Inc.
|
||||||
|
@ -165,6 +165,7 @@ struct usbd_bus {
|
||||||
#define USBHCTYPE_EHCI 4
|
#define USBHCTYPE_EHCI 4
|
||||||
#define USBHCTYPE_XHCI 5
|
#define USBHCTYPE_XHCI 5
|
||||||
#define USBHCTYPE_VHCI 6
|
#define USBHCTYPE_VHCI 6
|
||||||
|
int ub_busnum;
|
||||||
const struct usbd_bus_methods
|
const struct usbd_bus_methods
|
||||||
*ub_methods;
|
*ub_methods;
|
||||||
uint32_t ub_pipesize; /* size of a pipe struct */
|
uint32_t ub_pipesize; /* size of a pipe struct */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: vhci.c,v 1.19 2020/05/31 07:53:38 maxv Exp $ */
|
/* $NetBSD: vhci.c,v 1.20 2020/06/05 17:20:56 maxv Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019-2020 The NetBSD Foundation, Inc.
|
* Copyright (c) 2019-2020 The NetBSD Foundation, Inc.
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: vhci.c,v 1.19 2020/05/31 07:53:38 maxv Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: vhci.c,v 1.20 2020/06/05 17:20:56 maxv Exp $");
|
||||||
|
|
||||||
#ifdef _KERNEL_OPT
|
#ifdef _KERNEL_OPT
|
||||||
#include "opt_usb.h"
|
#include "opt_usb.h"
|
||||||
|
@ -239,6 +239,7 @@ typedef TAILQ_HEAD(, vhci_xfer) vhci_xfer_list_t;
|
||||||
|
|
||||||
#define VHCI_INDEX2PORT(idx) (idx)
|
#define VHCI_INDEX2PORT(idx) (idx)
|
||||||
#define VHCI_NPORTS 8 /* above 8, update TODO-bitmap */
|
#define VHCI_NPORTS 8 /* above 8, update TODO-bitmap */
|
||||||
|
#define VHCI_NBUSES 8
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
device_t sc_dev;
|
device_t sc_dev;
|
||||||
|
@ -1021,12 +1022,15 @@ const struct fileops vhci_fileops = {
|
||||||
static int
|
static int
|
||||||
vhci_fd_open(dev_t dev, int flags, int type, struct lwp *l)
|
vhci_fd_open(dev_t dev, int flags, int type, struct lwp *l)
|
||||||
{
|
{
|
||||||
|
vhci_softc_t *sc;
|
||||||
vhci_fd_t *vfd;
|
vhci_fd_t *vfd;
|
||||||
struct file *fp;
|
struct file *fp;
|
||||||
int error, fd;
|
int error, fd;
|
||||||
|
|
||||||
if (minor(dev) != 0)
|
sc = device_lookup_private(&vhci_cd, minor(dev));
|
||||||
|
if (sc == NULL)
|
||||||
return EXDEV;
|
return EXDEV;
|
||||||
|
|
||||||
error = fd_allocfile(&fp, &fd);
|
error = fd_allocfile(&fp, &fd);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
@ -1034,7 +1038,7 @@ vhci_fd_open(dev_t dev, int flags, int type, struct lwp *l)
|
||||||
vfd = kmem_alloc(sizeof(*vfd), KM_SLEEP);
|
vfd = kmem_alloc(sizeof(*vfd), KM_SLEEP);
|
||||||
vfd->port = 1;
|
vfd->port = 1;
|
||||||
vfd->addr = 0;
|
vfd->addr = 0;
|
||||||
vfd->softc = device_lookup_private(&vhci_cd, minor(dev));
|
vfd->softc = sc;
|
||||||
|
|
||||||
return fd_clone(fp, fd, flags, &vhci_fileops, vfd);
|
return fd_clone(fp, fd, flags, &vhci_fileops, vfd);
|
||||||
}
|
}
|
||||||
|
@ -1242,13 +1246,9 @@ CFATTACH_DECL_NEW(vhci, sizeof(vhci_softc_t), vhci_match, vhci_attach,
|
||||||
void
|
void
|
||||||
vhciattach(int nunits)
|
vhciattach(int nunits)
|
||||||
{
|
{
|
||||||
static struct cfdata vhci_cfdata = {
|
struct cfdata *cf;
|
||||||
.cf_name = "vhci",
|
|
||||||
.cf_atname = "vhci",
|
|
||||||
.cf_unit = 0,
|
|
||||||
.cf_fstate = FSTATE_STAR,
|
|
||||||
};
|
|
||||||
int error;
|
int error;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
error = config_cfattach_attach(vhci_cd.cd_name, &vhci_ca);
|
error = config_cfattach_attach(vhci_cd.cd_name, &vhci_ca);
|
||||||
if (error) {
|
if (error) {
|
||||||
|
@ -1258,7 +1258,14 @@ vhciattach(int nunits)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
config_attach_pseudo(&vhci_cfdata);
|
for (i = 0; i < VHCI_NBUSES; i++) {
|
||||||
|
cf = kmem_alloc(sizeof(*cf), KM_SLEEP);
|
||||||
|
cf->cf_name = vhci_cd.cd_name;
|
||||||
|
cf->cf_atname = vhci_cd.cd_name;
|
||||||
|
cf->cf_unit = i;
|
||||||
|
cf->cf_fstate = FSTATE_STAR;
|
||||||
|
config_attach_pseudo(cf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -1292,6 +1299,7 @@ vhci_attach(device_t parent, device_t self, void *aux)
|
||||||
sc->sc_dev = self;
|
sc->sc_dev = self;
|
||||||
sc->sc_bus.ub_revision = USBREV_2_0;
|
sc->sc_bus.ub_revision = USBREV_2_0;
|
||||||
sc->sc_bus.ub_hctype = USBHCTYPE_VHCI;
|
sc->sc_bus.ub_hctype = USBHCTYPE_VHCI;
|
||||||
|
sc->sc_bus.ub_busnum = self->dv_unit;
|
||||||
sc->sc_bus.ub_usedma = false;
|
sc->sc_bus.ub_usedma = false;
|
||||||
sc->sc_bus.ub_methods = &vhci_bus_methods;
|
sc->sc_bus.ub_methods = &vhci_bus_methods;
|
||||||
sc->sc_bus.ub_pipesize = sizeof(vhci_pipe_t);
|
sc->sc_bus.ub_pipesize = sizeof(vhci_pipe_t);
|
||||||
|
@ -1307,7 +1315,8 @@ vhci_attach(device_t parent, device_t self, void *aux)
|
||||||
TAILQ_INIT(&port->endpoints[addr].usb_to_host);
|
TAILQ_INIT(&port->endpoints[addr].usb_to_host);
|
||||||
TAILQ_INIT(&port->endpoints[addr].host_to_usb);
|
TAILQ_INIT(&port->endpoints[addr].host_to_usb);
|
||||||
}
|
}
|
||||||
kcov_remote_register(KCOV_REMOTE_VHCI, i);
|
kcov_remote_register(KCOV_REMOTE_VHCI,
|
||||||
|
KCOV_REMOTE_VHCI_ID(sc->sc_bus.ub_busnum, i));
|
||||||
}
|
}
|
||||||
|
|
||||||
sc->sc_child = config_found(self, &sc->sc_bus, usbctlprint);
|
sc->sc_child = config_found(self, &sc->sc_bus, usbctlprint);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: kcov.h,v 1.9 2020/05/15 13:09:02 maxv Exp $ */
|
/* $NetBSD: kcov.h,v 1.10 2020/06/05 17:20:57 maxv Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019-2020 The NetBSD Foundation, Inc.
|
* Copyright (c) 2019-2020 The NetBSD Foundation, Inc.
|
||||||
|
@ -53,6 +53,8 @@ struct kcov_ioc_remote_attach {
|
||||||
};
|
};
|
||||||
|
|
||||||
#define KCOV_REMOTE_VHCI 0
|
#define KCOV_REMOTE_VHCI 0
|
||||||
|
#define KCOV_REMOTE_VHCI_ID(bus, port) \
|
||||||
|
(((uint64_t)bus << 32ULL) | ((uint64_t)port & 0xFFFFFFFFULL))
|
||||||
|
|
||||||
#define KCOV_MODE_NONE 0
|
#define KCOV_MODE_NONE 0
|
||||||
#define KCOV_MODE_TRACE_PC 1
|
#define KCOV_MODE_TRACE_PC 1
|
||||||
|
|
Loading…
Reference in New Issue