Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-7-nhusb]: src/sys/dev/usb Add missing files (to the right branch ...
details: https://anonhg.NetBSD.org/src/rev/eba0219b3e72
branches: netbsd-7-nhusb
changeset: 801027:eba0219b3e72
user: skrll <skrll%NetBSD.org@localhost>
date: Wed Sep 07 09:03:33 2016 +0000
description:
Add missing files (to the right branch this time)
diffstat:
sys/dev/usb/usbhist.h | 91 ++++++++
sys/dev/usb/usbroothub.c | 491 +++++++++++++++++++++++++++++++++++++++++++++++
sys/dev/usb/usbroothub.h | 43 ++++
3 files changed, 625 insertions(+), 0 deletions(-)
diffs (truncated from 637 to 300 lines):
diff -r 57812971cd7c -r eba0219b3e72 sys/dev/usb/usbhist.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/usb/usbhist.h Wed Sep 07 09:03:33 2016 +0000
@@ -0,0 +1,91 @@
+/* $NetBSD: usbhist.h,v 1.4.4.2 2016/09/07 09:03:33 skrll Exp $ */
+
+/*
+ * Copyright (c) 2012 Matthew R. Green
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _DEV_USB_USBHIST_H_
+#define _DEV_USB_USBHIST_H_
+
+#if defined(_KERNEL_OPT)
+#include "opt_usb.h"
+#endif
+
+/*
+ * Make USBHIST_PRINT force on KERNHIST_PRINT for at least USBHIST_* usage.
+ */
+#if defined(USBHIST_PRINT) && !defined(KERNHIST_PRINT)
+#define KERNHIST_PRINT 1
+#endif
+
+#include <sys/kernhist.h>
+
+#ifdef USB_DEBUG
+
+extern int usbdebug;
+
+#define USBHIST_DECL(NAME) KERNHIST_DECL(NAME)
+#define USBHIST_DEFINE(NAME) KERNHIST_DEFINE(NAME)
+#define USBHIST_INIT(NAME,N) KERNHIST_INIT(NAME,N)
+#define USBHIST_INIT_STATIC(NAME,BUF) KERNHIST_INIT_STATIC(NAME,BUF)
+#define USBHIST_LINK_STATIC(NAME) KERNHIST_LINK_STATIC(NAME)
+#define USBHIST_LOGN(NAME,N,FMT,A,B,C,D) do { \
+ if ((NAME) >= (N)) { \
+ KERNHIST_LOG(usbhist,FMT,A,B,C,D); \
+ } \
+} while (0)
+#define USBHIST_LOGM(NAME,N,FMT,A,B,C,D) do { \
+ if ((NAME) & (N)) { \
+ KERNHIST_LOG(usbhist,FMT,A,B,C,D); \
+ } \
+} while (0)
+#define USBHIST_LOG(NAME,FMT,A,B,C,D) USBHIST_LOGN(NAME,1,FMT,A,B,C,D)
+#define USBHIST_CALLED(NAME) do { \
+ if ((NAME) != 0) { \
+ KERNHIST_CALLED(usbhist); \
+ } \
+} while (0)
+#define USBHIST_FUNC() KERNHIST_FUNC(__func__)
+
+USBHIST_DECL(usbhist);
+
+#else
+
+#define USBHIST_DECL(NAME)
+#define USBHIST_DEFINE(NAME)
+#define USBHIST_INIT(NAME,N)
+#define USBHIST_INIT_STATIC(NAME,BUF)
+#define USBHIST_LINK_STATIC(NAME)
+#define USBHIST_LOGN(N,NAME,FMT,A,B,C,D) do { } while(0)
+#define USBHIST_LOGM(N,NAME,FMT,A,B,C,D) do { } while(0)
+#define USBHIST_LOG(NAME,FMT,A,B,C,D) do { } while(0)
+#define USBHIST_CALLED(NAME)
+#define USBHIST_FUNC()
+
+#endif
+
+#endif /* _DEV_USBUSB_HIST_H_ */
diff -r 57812971cd7c -r eba0219b3e72 sys/dev/usb/usbroothub.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/usb/usbroothub.c Wed Sep 07 09:03:33 2016 +0000
@@ -0,0 +1,491 @@
+/* $NetBSD: usbroothub.c,v 1.2.6.2 2016/09/07 09:03:33 skrll Exp $ */
+
+/*-
+ * Copyright (c) 1998, 2004, 2011, 2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Lennart Augustsson (lennart%augustsson.net@localhost) at
+ * Carlstedt Research & Technology, Jared D. McNeill (jmcneill%invisible.ca@localhost),
+ * Matthew R. Green (mrg%eterna.com.au@localhost) and Nick Hudson.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 2008
+ * Matthias Drochner. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdivar.h>
+#include <dev/usb/usbroothub.h>
+#include <dev/usb/usbhist.h>
+
+extern int usbdebug;
+
+/* helper functions for USB root hub emulation */
+
+static usbd_status roothub_ctrl_transfer(struct usbd_xfer *);
+static usbd_status roothub_ctrl_start(struct usbd_xfer *);
+static void roothub_ctrl_abort(struct usbd_xfer *);
+static void roothub_ctrl_close(struct usbd_pipe *);
+static void roothub_ctrl_done(struct usbd_xfer *);
+static void roothub_noop(struct usbd_pipe *pipe);
+
+const struct usbd_pipe_methods roothub_ctrl_methods = {
+ .upm_transfer = roothub_ctrl_transfer,
+ .upm_start = roothub_ctrl_start,
+ .upm_abort = roothub_ctrl_abort,
+ .upm_close = roothub_ctrl_close,
+ .upm_cleartoggle = roothub_noop,
+ .upm_done = roothub_ctrl_done,
+};
+
+int
+usb_makestrdesc(usb_string_descriptor_t *p, int l, const char *s)
+{
+ int i;
+
+ if (l == 0)
+ return 0;
+ p->bLength = 2 * strlen(s) + 2;
+ if (l == 1)
+ return 1;
+ p->bDescriptorType = UDESC_STRING;
+ l -= 2;
+ /* poor man's utf-16le conversion */
+ for (i = 0; s[i] && l > 1; i++, l -= 2)
+ USETW2(p->bString[i], 0, s[i]);
+ return 2 * i + 2;
+}
+
+int
+usb_makelangtbl(usb_string_descriptor_t *p, int l)
+{
+
+ if (l == 0)
+ return 0;
+ p->bLength = 4;
+ if (l == 1)
+ return 1;
+ p->bDescriptorType = UDESC_STRING;
+ if (l < 4)
+ return 2;
+ USETW(p->bString[0], 0x0409); /* english/US */
+ return 4;
+}
+
+/*
+ * Data structures and routines to emulate the root hub.
+ */
+static const usb_device_descriptor_t usbroothub_devd1 = {
+ .bLength = sizeof(usb_device_descriptor_t),
+ .bDescriptorType = UDESC_DEVICE,
+ .bcdUSB = {0x00, 0x01},
+ .bDeviceClass = UDCLASS_HUB,
+ .bDeviceSubClass = UDSUBCLASS_HUB,
+ .bDeviceProtocol = UDPROTO_FSHUB,
+ .bMaxPacketSize = 64,
+ .idVendor = {0},
+ .idProduct = {0},
+ .bcdDevice = {0x00, 0x01},
+ .iManufacturer = 1,
+ .iProduct = 2,
+ .iSerialNumber = 0,
+ .bNumConfigurations = 1
+};
+
+static const struct usb_roothub_descriptors usbroothub_confd1 = {
+ .urh_confd = {
+ .bLength = USB_CONFIG_DESCRIPTOR_SIZE,
+ .bDescriptorType = UDESC_CONFIG,
+ .wTotalLength = USETWD(sizeof(usbroothub_confd1)),
+ .bNumInterface = 1,
+ .bConfigurationValue = 1,
+ .iConfiguration = 0,
+ .bmAttributes = UC_ATTR_MBO | UC_SELF_POWERED,
+ .bMaxPower = 0,
+ },
+ .urh_ifcd = {
+ .bLength = USB_INTERFACE_DESCRIPTOR_SIZE,
+ .bDescriptorType = UDESC_INTERFACE,
+ .bInterfaceNumber = 0,
+ .bAlternateSetting = 0,
+ .bNumEndpoints = 1,
+ .bInterfaceClass = UICLASS_HUB,
+ .bInterfaceSubClass = UISUBCLASS_HUB,
+ .bInterfaceProtocol = UIPROTO_FSHUB,
+ .iInterface = 0
+ },
+ .urh_endpd = {
+ .bLength = USB_ENDPOINT_DESCRIPTOR_SIZE,
+ .bDescriptorType = UDESC_ENDPOINT,
+ .bEndpointAddress = UE_DIR_IN | USBROOTHUB_INTR_ENDPT,
+ .bmAttributes = UE_INTERRUPT,
+ .wMaxPacketSize = USETWD(8), /* max packet */
+ .bInterval = 255,
+ },
+};
+
+static const usb_device_descriptor_t usbroothub_devd2 = {
+ .bLength = sizeof(usb_device_descriptor_t),
+ .bDescriptorType = UDESC_DEVICE,
+ .bcdUSB = {0x00, 0x02},
+ .bDeviceClass = UDCLASS_HUB,
+ .bDeviceSubClass = UDSUBCLASS_HUB,
+ .bDeviceProtocol = UDPROTO_HSHUBSTT,
+ .bMaxPacketSize = 64,
+ .idVendor = {0},
+ .idProduct = {0},
+ .bcdDevice = {0x00, 0x01},
+ .iManufacturer = 1,
+ .iProduct = 2,
+ .iSerialNumber = 0,
+ .bNumConfigurations = 1
+};
+
+static const usb_device_qualifier_t usbroothub_odevd2 = {
+ .bLength = USB_DEVICE_QUALIFIER_SIZE,
+ .bDescriptorType = UDESC_DEVICE_QUALIFIER,
+ .bcdUSB = {0x00, 0x02},
+ .bDeviceClass = UDCLASS_HUB,
+ .bDeviceSubClass = UDSUBCLASS_HUB,
+ .bDeviceProtocol = UDPROTO_FSHUB,
+ .bMaxPacketSize0 = 64,
+ .bNumConfigurations = 1,
+};
+
+static const struct usb_roothub_descriptors usbroothub_confd2 = {
+ .urh_confd = {
Home |
Main Index |
Thread Index |
Old Index