From owner-svn-soc-all@FreeBSD.ORG Sun Jul 21 17:15:15 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id CECC88D2 for ; Sun, 21 Jul 2013 17:15:15 +0000 (UTC) (envelope-from bguan@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id BDE38A54 for ; Sun, 21 Jul 2013 17:15:15 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6LHFFm4054288 for ; Sun, 21 Jul 2013 17:15:15 GMT (envelope-from bguan@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6LHFFMc054286 for svn-soc-all@FreeBSD.org; Sun, 21 Jul 2013 17:15:15 GMT (envelope-from bguan@FreeBSD.org) Date: Sun, 21 Jul 2013 17:15:15 GMT Message-Id: <201307211715.r6LHFFMc054286@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to bguan@FreeBSD.org using -f From: bguan@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255004 - soc2013/bguan/head/sys/dev/xen/usbfront MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Jul 2013 17:15:15 -0000 Author: bguan Date: Sun Jul 21 17:15:15 2013 New Revision: 255004 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255004 Log: move usb_bus_methods to .c file Added: soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c Added: soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c Sun Jul 21 17:15:15 2013 (r255004) @@ -0,0 +1,257 @@ +/* $FreeBSD$ */ +/*- + * Xen Host Controller Interface + * + * Copyright (c) 2013 Bei Guan. 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 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 AUTHOR 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. + */ + +/* + * USB eXtensible Host Controller Interface, a.k.a. USB 3.0 controller. + * + * The XHCI 1.0 spec can be found at + * http://www.intel.com/technology/usb/download/xHCI_Specification_for_USB.pdf + * and the USB 3.0 spec at + * http://www.usb.org/developers/docs/usb_30_spec_060910.zip + */ + +#ifdef USB_GLOBAL_INCLUDE_FILE +#include USB_GLOBAL_INCLUDE_FILE +#else +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#define USB_DEBUG_VAR xhcidebug + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#endif /* USB_GLOBAL_INCLUDE_FILE */ + +#include + +extern struct usb_bus_methods xenhci_bus_methods; + + +static void +xenhci_iterate_hw_softc(struct usb_bus *bus, usb_bus_mem_sub_cb_t *cb) +{ + + printf("[gbtest-xenhci.c]xenhci_iterate_hw_softc()\n"); + //TODO +} + +usb_error_t +xenhci_init(struct xenhci_softc *sc, device_t dev) +{ + /* initialise some bus fields */ + sc->sc_bus.parent = dev; + + /* set up the bus struct */ + sc->sc_bus.methods = &xenhci_bus_methods; + + /* setup devices array */ + sc->sc_bus.devices = sc->sc_devices; + sc->sc_bus.devices_max = XENHCI_MAX_DEVICES; + + return (0); +} + + +static void +xenhci_do_poll(struct usb_bus *bus) +{ + printf("[gbtest-pv]xenhci.c: xenhci_do_poll()\n"); + //TODO +} + +/*------------------------------------------------------------------------* + * xenhci root HUB support + *------------------------------------------------------------------------* + * Simulate a HUB by handling all the necessary requests. + *------------------------------------------------------------------------*/ + +static usb_error_t +xenhci_roothub_exec(struct usb_device *udev, + struct usb_device_request *req, const void **pptr, uint16_t *plength) +{ + printf("[gbtest-pv]xenhci.c: xenhci_roothub_exec()\n"); + //usb_error_t err; + + //return (err); + //TODO + return (0); +} + +static void +xenhci_xfer_setup(struct usb_setup_params *parm) +{ + printf("[gbtest-pv]xenhci.c: ()\n"); + //TODO +} + +static void +xenhci_xfer_unsetup(struct usb_xfer *xfer) +{ + printf("[gbtest-pv]xenhci.c: ()\n"); + return; +} + +static void +xenhci_start_dma_delay(struct usb_xfer *xfer) +{ + printf("[gbtest-pv]xenhci.c: ()\n"); + //TODO +} + +static void +xenhci_ep_init(struct usb_device *udev, struct usb_endpoint_descriptor *edesc, + struct usb_endpoint *ep) +{ + printf("[gbtest-pv]xenhci.c: ()\n"); + //TODO +} + +static void +xenhci_ep_uninit(struct usb_device *udev, struct usb_endpoint *ep) +{ + printf("[gbtest-pv]xenhci.c: ()\n"); +} + +static void +xenhci_ep_clear_stall(struct usb_device *udev, struct usb_endpoint *ep) +{ + printf("[gbtest-pv]xenhci.c: ()\n"); + //TODO +} + +static usb_error_t +xenhci_device_init(struct usb_device *udev) +{ + printf("[gbtest-pv]xenhci.c: xenhci_device_init()\n"); + //usb_error_t err; + //uint8_t temp; + + //return (err); + //TODO + return (0); +} + +static void +xenhci_device_uninit(struct usb_device *udev) +{ + printf("[gbtest-pv]xenhci.c: xenhci_device_uninit()\n"); + //TODO +} + +static void +xenhci_get_dma_delay(struct usb_device *udev, uint32_t *pus) +{ + printf("[gbtest-pv]xenhci.c: xenhci_get_dma_delay()\n"); + //TODO +} + +static void +xenhci_device_resume(struct usb_device *udev) +{ + printf("[gbtest-pv]xenhci.c: xenhci_device_resume()\n"); + //TODO +} + +static void +xenhci_device_suspend(struct usb_device *udev) +{ + printf("[gbtest-pv]xenhci.c: xenhci_device_suspend()\n"); + //TODO +} + +static void +xenhci_set_hw_power(struct usb_bus *bus) +{ + printf("[gbtest-pv]xenhci.c: xenhci_set_hw_power()\n"); + DPRINTF("\n"); +} + +static void +xenhci_device_state_change(struct usb_device *udev) +{ + printf("[gbtest-pv]xenhci.c: xenhci_device_state_change()\n"); + //TODO +} + +static usb_error_t +xenhci_set_endpoint_mode(struct usb_device *udev, struct usb_endpoint *ep, + uint8_t ep_mode) +{ + printf("[gbtest-pv]xenhci.c: xenhci_set_endpoint_mode()\n"); + //TODO + return (0); +} + +struct usb_bus_methods xenhci_bus_methods = { + .endpoint_init = xenhci_ep_init, + .endpoint_uninit = xenhci_ep_uninit, + .xfer_setup = xenhci_xfer_setup, + .xfer_unsetup = xenhci_xfer_unsetup, + .get_dma_delay = xenhci_get_dma_delay, + .device_init = xenhci_device_init, + .device_uninit = xenhci_device_uninit, + .device_resume = xenhci_device_resume, + .device_suspend = xenhci_device_suspend, + .set_hw_power = xenhci_set_hw_power, + .roothub_exec = xenhci_roothub_exec, + .xfer_poll = xenhci_do_poll, + .start_dma_delay = xenhci_start_dma_delay, + .set_address = xenhci_set_address, + .clear_stall = xenhci_ep_clear_stall, + .device_state_change = xenhci_device_state_change, + .set_hw_power_sleep = xenhci_set_hw_power_sleep, + .set_endpoint_mode = xenhci_set_endpoint_mode, +};