Date: Sun, 21 Jul 2013 17:15:15 GMT From: bguan@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255004 - soc2013/bguan/head/sys/dev/xen/usbfront Message-ID: <201307211715.r6LHFFMc054286@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 <sys/stdint.h> +#include <sys/stddef.h> +#include <sys/param.h> +#include <sys/queue.h> +#include <sys/types.h> +#include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/bus.h> +#include <sys/module.h> +#include <sys/lock.h> +#include <sys/mutex.h> +#include <sys/condvar.h> +#include <sys/sysctl.h> +#include <sys/sx.h> +#include <sys/unistd.h> +#include <sys/callout.h> +#include <sys/malloc.h> +#include <sys/priv.h> + +#include <dev/usb/usb.h> +#include <dev/usb/usbdi.h> + +#define USB_DEBUG_VAR xhcidebug + +#include <dev/usb/usb_core.h> +#include <dev/usb/usb_debug.h> +#include <dev/usb/usb_busdma.h> +#include <dev/usb/usb_process.h> +#include <dev/usb/usb_transfer.h> +#include <dev/usb/usb_device.h> +#include <dev/usb/usb_hub.h> +#include <dev/usb/usb_util.h> + +#include <dev/usb/usb_controller.h> +#include <dev/usb/usb_bus.h> +#endif /* USB_GLOBAL_INCLUDE_FILE */ + +#include <dev/xen/usbfront/xenhci.h> + +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, +};
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201307211715.r6LHFFMc054286>