There are more ports than meet the eye on the Visor. Connect a ucom
to each of them.
This commit is contained in:
parent
7bb669ca3e
commit
af1fabe1bc
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: uvisor.c,v 1.9 2001/01/23 14:04:14 augustss Exp $ */
|
||||
/* $NetBSD: uvisor.c,v 1.10 2001/01/23 21:19:44 augustss Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
@ -93,12 +93,13 @@ int uvisordebug = 0;
|
||||
/*
|
||||
* UVISOR_GET_CONNECTION_INFORMATION returns data in the following format
|
||||
*/
|
||||
#define UVISOR_MAX_CONN 8
|
||||
struct uvisor_connection_info {
|
||||
uWord num_ports;
|
||||
struct {
|
||||
uByte port_function_id;
|
||||
uByte port;
|
||||
} connections[8];
|
||||
} connections[UVISOR_MAX_CONN];
|
||||
};
|
||||
#define UVISOR_CONNECTION_INFO_SIZE 18
|
||||
|
||||
@ -123,12 +124,14 @@ struct uvisor_softc {
|
||||
usbd_device_handle sc_udev; /* device */
|
||||
usbd_interface_handle sc_iface; /* interface */
|
||||
|
||||
device_ptr_t sc_subdev;
|
||||
device_ptr_t sc_subdevs[UVISOR_MAX_CONN];
|
||||
int sc_numcon;
|
||||
|
||||
u_char sc_dying;
|
||||
};
|
||||
|
||||
Static usbd_status uvisor_init(struct uvisor_softc *);
|
||||
Static usbd_status uvisor_init(struct uvisor_softc *,
|
||||
struct uvisor_connection_info *);
|
||||
|
||||
Static void uvisor_close(void *, int);
|
||||
|
||||
@ -169,10 +172,12 @@ USB_ATTACH(uvisor)
|
||||
usbd_device_handle dev = uaa->device;
|
||||
usbd_interface_handle iface;
|
||||
usb_interface_descriptor_t *id;
|
||||
struct uvisor_connection_info coninfo;
|
||||
usb_endpoint_descriptor_t *ed;
|
||||
char devinfo[1024];
|
||||
char *devname = USBDEVNAME(sc->sc_dev);
|
||||
int i;
|
||||
int i, j, hasin, hasout, port;
|
||||
char *string;
|
||||
usbd_status err;
|
||||
struct ucom_attach_args uca;
|
||||
|
||||
@ -202,41 +207,6 @@ USB_ATTACH(uvisor)
|
||||
sc->sc_udev = dev;
|
||||
sc->sc_iface = iface;
|
||||
|
||||
uca.bulkin = uca.bulkout = -1;
|
||||
for (i = 0; i < id->bNumEndpoints; i++) {
|
||||
int addr, dir, attr;
|
||||
ed = usbd_interface2endpoint_descriptor(iface, i);
|
||||
if (ed == NULL) {
|
||||
printf("%s: could not read endpoint descriptor"
|
||||
": %s\n", devname, usbd_errstr(err));
|
||||
goto bad;
|
||||
}
|
||||
|
||||
addr = ed->bEndpointAddress;
|
||||
dir = UE_GET_DIR(ed->bEndpointAddress);
|
||||
attr = ed->bmAttributes & UE_XFERTYPE;
|
||||
if (dir == UE_DIR_IN && attr == UE_BULK)
|
||||
uca.bulkin = addr;
|
||||
else if (dir == UE_DIR_OUT && attr == UE_BULK)
|
||||
uca.bulkout = addr;
|
||||
else {
|
||||
printf("%s: unexpected endpoint\n", devname);
|
||||
goto bad;
|
||||
}
|
||||
}
|
||||
if (uca.bulkin == -1) {
|
||||
printf("%s: Could not find data bulk in\n",
|
||||
USBDEVNAME(sc->sc_dev));
|
||||
goto bad;
|
||||
}
|
||||
if (uca.bulkout == -1) {
|
||||
printf("%s: Could not find data bulk out\n",
|
||||
USBDEVNAME(sc->sc_dev));
|
||||
goto bad;
|
||||
}
|
||||
|
||||
uca.portno = UCOM_UNK_PORTNO;
|
||||
/* bulkin, bulkout set above */
|
||||
uca.ibufsize = UVISORIBUFSIZE;
|
||||
uca.obufsize = UVISOROBUFSIZE;
|
||||
uca.ibufsizepad = UVISORIBUFSIZE;
|
||||
@ -246,7 +216,7 @@ USB_ATTACH(uvisor)
|
||||
uca.methods = &uvisor_methods;
|
||||
uca.arg = sc;
|
||||
|
||||
err = uvisor_init(sc);
|
||||
err = uvisor_init(sc, &coninfo);
|
||||
if (err) {
|
||||
printf("%s: init failed, %s\n", USBDEVNAME(sc->sc_dev),
|
||||
usbd_errstr(err));
|
||||
@ -256,9 +226,55 @@ USB_ATTACH(uvisor)
|
||||
usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev,
|
||||
USBDEV(sc->sc_dev));
|
||||
|
||||
DPRINTF(("uvisor: in=0x%x out=0x%x\n", uca.bulkin, uca.bulkout));
|
||||
sc->sc_subdev = config_found_sm(self, &uca, ucomprint, ucomsubmatch);
|
||||
|
||||
sc->sc_numcon = UGETW(coninfo.num_ports);
|
||||
/*printf("%s: Number of ports: %d\n", USBDEVNAME(sc->sc_dev), np);*/
|
||||
for (i = 0; i < sc->sc_numcon; ++i) {
|
||||
switch (coninfo.connections[i].port_function_id) {
|
||||
case UVISOR_FUNCTION_GENERIC:
|
||||
string = "Generic";
|
||||
break;
|
||||
case UVISOR_FUNCTION_DEBUGGER:
|
||||
string = "Debugger";
|
||||
break;
|
||||
case UVISOR_FUNCTION_HOTSYNC:
|
||||
string = "HotSync";
|
||||
break;
|
||||
case UVISOR_FUNCTION_REMOTE_FILE_SYS:
|
||||
string = "Remote File System";
|
||||
break;
|
||||
default:
|
||||
string = "unknown";
|
||||
break;
|
||||
}
|
||||
port = coninfo.connections[i].port;
|
||||
printf("%s: portno %d is %s\n", USBDEVNAME(sc->sc_dev), port,
|
||||
string);
|
||||
|
||||
uca.portno = port;
|
||||
uca.bulkin = port | UE_DIR_IN;
|
||||
uca.bulkout = port | UE_DIR_OUT;
|
||||
/* Verify that endpoints exist. */
|
||||
for (hasin = hasout = j = 0; j < id->bNumEndpoints; j++) {
|
||||
ed = usbd_interface2endpoint_descriptor(iface, j);
|
||||
if (ed == NULL)
|
||||
break;
|
||||
if (UE_GET_ADDR(ed->bEndpointAddress) == port &&
|
||||
(ed->bmAttributes & UE_XFERTYPE) == UE_BULK) {
|
||||
if (UE_GET_DIR(ed->bEndpointAddress)
|
||||
== UE_DIR_IN)
|
||||
hasin++;
|
||||
else
|
||||
hasout++;
|
||||
}
|
||||
}
|
||||
if (hasin == 1 && hasout == 1)
|
||||
sc->sc_subdevs[i] = config_found_sm(self, &uca,
|
||||
ucomprint, ucomsubmatch);
|
||||
else
|
||||
printf("%s: no proper endpoints for port %d (%d,%d)\n",
|
||||
USBDEVNAME(sc->sc_dev), port, hasin, hasout);
|
||||
}
|
||||
|
||||
USB_ATTACH_SUCCESS_RETURN;
|
||||
|
||||
bad:
|
||||
@ -272,6 +288,7 @@ uvisor_activate(device_ptr_t self, enum devact act)
|
||||
{
|
||||
struct uvisor_softc *sc = (struct uvisor_softc *)self;
|
||||
int rv = 0;
|
||||
int i;
|
||||
|
||||
switch (act) {
|
||||
case DVACT_ACTIVATE:
|
||||
@ -279,8 +296,9 @@ uvisor_activate(device_ptr_t self, enum devact act)
|
||||
break;
|
||||
|
||||
case DVACT_DEACTIVATE:
|
||||
if (sc->sc_subdev != NULL)
|
||||
rv = config_deactivate(sc->sc_subdev);
|
||||
for (i = 0; i < sc->sc_numcon; i++)
|
||||
if (sc->sc_subdevs[i] != NULL)
|
||||
rv = config_deactivate(sc->sc_subdevs[i]);
|
||||
sc->sc_dying = 1;
|
||||
break;
|
||||
}
|
||||
@ -292,27 +310,29 @@ uvisor_detach(device_ptr_t self, int flags)
|
||||
{
|
||||
struct uvisor_softc *sc = (struct uvisor_softc *)self;
|
||||
int rv = 0;
|
||||
int i;
|
||||
|
||||
DPRINTF(("uvisor_detach: sc=%p flags=%d\n", sc, flags));
|
||||
sc->sc_dying = 1;
|
||||
if (sc->sc_subdev != NULL) {
|
||||
rv = config_detach(sc->sc_subdev, flags);
|
||||
sc->sc_subdev = NULL;
|
||||
for (i = 0; i < sc->sc_numcon; i++) {
|
||||
if (sc->sc_subdevs[i] != NULL) {
|
||||
rv |= config_detach(sc->sc_subdevs[i], flags);
|
||||
sc->sc_subdevs[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
|
||||
USBDEV(sc->sc_dev));
|
||||
|
||||
|
||||
return (0);
|
||||
return (rv);
|
||||
}
|
||||
|
||||
usbd_status
|
||||
uvisor_init(struct uvisor_softc *sc)
|
||||
uvisor_init(struct uvisor_softc *sc, struct uvisor_connection_info *ci)
|
||||
{
|
||||
usbd_status err;
|
||||
usb_device_request_t req;
|
||||
struct uvisor_connection_info coninfo;
|
||||
int actlen;
|
||||
uWord avail;
|
||||
|
||||
@ -322,43 +342,11 @@ uvisor_init(struct uvisor_softc *sc)
|
||||
USETW(req.wValue, 0);
|
||||
USETW(req.wIndex, 0);
|
||||
USETW(req.wLength, UVISOR_CONNECTION_INFO_SIZE);
|
||||
err = usbd_do_request_flags(sc->sc_udev, &req, &coninfo,
|
||||
err = usbd_do_request_flags(sc->sc_udev, &req, ci,
|
||||
USBD_SHORT_XFER_OK, &actlen);
|
||||
if (err)
|
||||
return (err);
|
||||
|
||||
#ifdef UVISOR_DEBUG
|
||||
{
|
||||
int i, np;
|
||||
char *string;
|
||||
|
||||
np = UGETW(coninfo.num_ports);
|
||||
printf("%s: Number of ports: %d\n", USBDEVNAME(sc->sc_dev), np);
|
||||
for (i = 0; i < np; ++i) {
|
||||
switch (coninfo.connections[i].port_function_id) {
|
||||
case UVISOR_FUNCTION_GENERIC:
|
||||
string = "Generic";
|
||||
break;
|
||||
case UVISOR_FUNCTION_DEBUGGER:
|
||||
string = "Debugger";
|
||||
break;
|
||||
case UVISOR_FUNCTION_HOTSYNC:
|
||||
string = "HotSync";
|
||||
break;
|
||||
case UVISOR_FUNCTION_REMOTE_FILE_SYS:
|
||||
string = "Remote File System";
|
||||
break;
|
||||
default:
|
||||
string = "unknown";
|
||||
break;
|
||||
}
|
||||
printf("%s: port %d, is for %s\n",
|
||||
USBDEVNAME(sc->sc_dev), coninfo.connections[i].port,
|
||||
string);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
DPRINTF(("uvisor_init: getting available bytes\n"));
|
||||
req.bmRequestType = UT_READ_VENDOR_ENDPOINT;
|
||||
req.bRequest = UVISOR_REQUEST_BYTES_AVAILABLE;
|
||||
|
Loading…
Reference in New Issue
Block a user