本文整理汇总了C++中USB_BUS_LOCK函数的典型用法代码示例。如果您正苦于以下问题:C++ USB_BUS_LOCK函数的具体用法?C++ USB_BUS_LOCK怎么用?C++ USB_BUS_LOCK使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了USB_BUS_LOCK函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: usb_bus_resume
/*------------------------------------------------------------------------*
* usb_bus_resume
*
* This function is used to resume the USB controller.
*------------------------------------------------------------------------*/
static void
usb_bus_resume(struct usb_proc_msg *pm)
{
struct usb_bus *bus;
struct usb_device *udev;
usb_error_t err;
uint8_t do_unlock;
DPRINTF("\n");
bus = ((struct usb_bus_msg *)pm)->bus;
udev = bus->devices[USB_ROOT_HUB_ADDR];
if (udev == NULL || bus->bdev == NULL)
return;
USB_BUS_UNLOCK(bus);
do_unlock = usbd_enum_lock(udev);
#if 0
DEVMETHOD(usb_take_controller, NULL); /* dummy */
#endif
USB_TAKE_CONTROLLER(device_get_parent(bus->bdev));
USB_BUS_LOCK(bus);
bus->hw_power_state =
USB_HW_POWER_CONTROL |
USB_HW_POWER_BULK |
USB_HW_POWER_INTERRUPT |
USB_HW_POWER_ISOC |
USB_HW_POWER_NON_ROOT_HUB;
bus->no_explore = 0;
USB_BUS_UNLOCK(bus);
if (bus->methods->set_hw_power_sleep != NULL)
(bus->methods->set_hw_power_sleep) (bus, USB_HW_POWER_RESUME);
if (bus->methods->set_hw_power != NULL)
(bus->methods->set_hw_power) (bus);
/* restore USB configuration to index 0 */
err = usbd_set_config_index(udev, 0);
if (err)
device_printf(bus->bdev, "Could not configure root HUB\n");
/* probe and attach */
err = usb_probe_and_attach(udev, USB_IFACE_INDEX_ANY);
if (err) {
device_printf(bus->bdev, "Could not probe and "
"attach root HUB\n");
}
if (do_unlock)
usbd_enum_unlock(udev);
USB_BUS_LOCK(bus);
}
示例2: usb_bus_explore
/*------------------------------------------------------------------------*
* usb_bus_explore
*
* This function is used to explore the device tree from the root.
*------------------------------------------------------------------------*/
static void
usb_bus_explore(struct usb_proc_msg *pm)
{
struct usb_bus *bus;
struct usb_device *udev;
bus = ((struct usb_bus_msg *)pm)->bus;
udev = bus->devices[USB_ROOT_HUB_ADDR];
if (bus->no_explore != 0)
return;
if (udev != NULL) {
USB_BUS_UNLOCK(bus);
uhub_explore_handle_re_enumerate(udev);
USB_BUS_LOCK(bus);
}
if (udev != NULL && udev->hub != NULL) {
if (bus->do_probe) {
bus->do_probe = 0;
bus->driver_added_refcount++;
}
if (bus->driver_added_refcount == 0) {
/* avoid zero, hence that is memory default */
bus->driver_added_refcount = 1;
}
#ifdef DDB
/*
* The following three lines of code are only here to
* recover from DDB:
*/
usb_proc_rewakeup(USB_BUS_CONTROL_XFER_PROC(bus));
usb_proc_rewakeup(USB_BUS_GIANT_PROC(bus));
usb_proc_rewakeup(USB_BUS_NON_GIANT_ISOC_PROC(bus));
usb_proc_rewakeup(USB_BUS_NON_GIANT_BULK_PROC(bus));
#endif
USB_BUS_UNLOCK(bus);
#if USB_HAVE_POWERD
/*
* First update the USB power state!
*/
usb_bus_powerd(bus);
#endif
/* Explore the Root USB HUB. */
(udev->hub->explore) (udev);
USB_BUS_LOCK(bus);
}
#if USB_HAVE_ROOT_MOUNT_HOLD
usb_root_mount_rel(bus);
#endif
}
示例3: usb_bus_suspend
/*------------------------------------------------------------------------*
* usb_bus_suspend
*
* This function is used to suspend the USB controller.
*------------------------------------------------------------------------*/
static void
usb_bus_suspend(struct usb_proc_msg *pm)
{
struct usb_bus *bus;
struct usb_device *udev;
usb_error_t err;
uint8_t do_unlock;
DPRINTF("\n");
bus = ((struct usb_bus_msg *)pm)->bus;
udev = bus->devices[USB_ROOT_HUB_ADDR];
if (udev == NULL || bus->bdev == NULL)
return;
USB_BUS_UNLOCK(bus);
/*
* We use the shutdown event here because the suspend and
* resume events are reserved for the USB port suspend and
* resume. The USB system suspend is implemented like full
* shutdown and all connected USB devices will be disconnected
* subsequently. At resume all USB devices will be
* re-connected again.
*/
bus_generic_shutdown(bus->bdev);
do_unlock = usbd_enum_lock(udev);
err = usbd_set_config_index(udev, USB_UNCONFIG_INDEX);
if (err)
device_printf(bus->bdev, "Could not unconfigure root HUB\n");
USB_BUS_LOCK(bus);
bus->hw_power_state = 0;
bus->no_explore = 1;
USB_BUS_UNLOCK(bus);
if (bus->methods->set_hw_power != NULL)
(bus->methods->set_hw_power) (bus);
if (bus->methods->set_hw_power_sleep != NULL)
(bus->methods->set_hw_power_sleep) (bus, USB_HW_POWER_SUSPEND);
if (do_unlock)
usbd_enum_unlock(udev);
USB_BUS_LOCK(bus);
}
示例4: usb_shutdown
/*------------------------------------------------------------------------*
* usb_shutdown
*------------------------------------------------------------------------*/
static int
usb_shutdown(device_t dev)
{
struct usb_bus *bus = device_get_softc(dev);
DPRINTF("\n");
if (bus == NULL) {
/* was never setup properly */
return (0);
}
device_printf(bus->bdev, "Controller shutdown\n");
USB_BUS_LOCK(bus);
usb_proc_msignal(&bus->explore_proc,
&bus->shutdown_msg[0], &bus->shutdown_msg[1]);
if (usb_no_shutdown_wait == 0) {
/* wait for shutdown callback to be executed */
usb_proc_mwait(&bus->explore_proc,
&bus->shutdown_msg[0], &bus->shutdown_msg[1]);
}
USB_BUS_UNLOCK(bus);
device_printf(bus->bdev, "Controller shutdown complete\n");
return (0);
}
示例5: usb_shutdown
/*------------------------------------------------------------------------*
* usb_shutdown
*------------------------------------------------------------------------*/
static int
usb_shutdown(device_t dev)
{
struct usb_bus *bus = device_get_softc(dev);
DPRINTF("\n");
if (bus == NULL) {
/* was never setup properly */
return (0);
}
DPRINTF("%s: Controller shutdown\n", device_get_nameunit(bus->bdev));
USB_BUS_LOCK(bus);
usb_proc_msignal(USB_BUS_EXPLORE_PROC(bus),
&bus->shutdown_msg[0], &bus->shutdown_msg[1]);
if (usb_no_shutdown_wait == 0) {
/* wait for shutdown callback to be executed */
usb_proc_mwait(USB_BUS_EXPLORE_PROC(bus),
&bus->shutdown_msg[0], &bus->shutdown_msg[1]);
}
USB_BUS_UNLOCK(bus);
DPRINTF("%s: Controller shutdown complete\n",
device_get_nameunit(bus->bdev));
return (0);
}
示例6: usb_bus_detach
/*------------------------------------------------------------------------*
* usb_bus_detach
*
* This function is used to detach the device tree from the root.
*------------------------------------------------------------------------*/
void
usb_bus_detach(struct usb_proc_msg *pm)
{
struct usb_bus *bus;
struct usb_device *udev;
device_t dev;
bus = ((struct usb_bus_msg *)pm)->bus;
udev = bus->devices[USB_ROOT_HUB_ADDR];
dev = bus->bdev;
/* clear the softc */
device_set_softc(dev, NULL);
USB_BUS_UNLOCK(bus);
/* detach children first */
mtx_lock(&Giant);
bus_generic_detach(dev);
mtx_unlock(&Giant);
/*
* Free USB device and all subdevices, if any.
*/
usb_free_device(udev, 0);
USB_BUS_LOCK(bus);
/* clear bdev variable last */
bus->bdev = NULL;
}
示例7: usb_power_wdog
static void
usb_power_wdog(void *arg)
{
struct usb_bus *bus = arg;
USB_BUS_LOCK_ASSERT(bus, MA_OWNED);
usb_callout_reset(&bus->power_wdog,
4 * hz, usb_power_wdog, arg);
#ifdef DDB
/*
* The following line of code is only here to recover from
* DDB:
*/
usb_proc_rewakeup(&bus->explore_proc); /* recover from DDB */
#endif
#if USB_HAVE_POWERD
USB_BUS_UNLOCK(bus);
usb_bus_power_update(bus);
USB_BUS_LOCK(bus);
#endif
}
示例8: usb_shutdown
/*------------------------------------------------------------------------*
* usb_shutdown
*------------------------------------------------------------------------*/
static int
usb_shutdown(device_t dev)
{
struct usb_bus *bus = device_get_softc(dev);
DPRINTF("\n");
if (bus == NULL) {
/* was never setup properly */
return (0);
}
DPRINTF("%s: Controller shutdown\n", device_get_nameunit(bus->bdev));
USB_BUS_LOCK(bus);
#ifndef __rtems__
usb_proc_msignal(&bus->explore_proc,
&bus->shutdown_msg[0], &bus->shutdown_msg[1]);
if (usb_no_shutdown_wait == 0) {
/* wait for shutdown callback to be executed */
usb_proc_mwait(&bus->explore_proc,
&bus->shutdown_msg[0], &bus->shutdown_msg[1]);
}
#endif /* __rtems__ */
USB_BUS_UNLOCK(bus);
DPRINTF("%s: Controller shutdown complete\n",
device_get_nameunit(bus->bdev));
return (0);
}
示例9: usb_suspend
/*------------------------------------------------------------------------*
* usb_suspend
*------------------------------------------------------------------------*/
static int
usb_suspend(device_t dev)
{
struct usb_bus *bus = device_get_softc(dev);
DPRINTF("\n");
if (bus == NULL) {
/* was never setup properly */
return (0);
}
USB_BUS_LOCK(bus);
usb_proc_msignal(&bus->explore_proc,
&bus->suspend_msg[0], &bus->suspend_msg[1]);
#ifndef __rtems__
if (usb_no_suspend_wait == 0) {
/* wait for suspend callback to be executed */
usb_proc_mwait(&bus->explore_proc,
&bus->suspend_msg[0], &bus->suspend_msg[1]);
}
#endif /* __rtems__ */
USB_BUS_UNLOCK(bus);
return (0);
}
示例10: at91_udp_detach
static int
at91_udp_detach(device_t dev)
{
struct at91_udp_softc *sc = device_get_softc(dev);
device_t bdev;
int err;
if (sc->sc_dci.sc_bus.bdev) {
bdev = sc->sc_dci.sc_bus.bdev;
device_detach(bdev);
device_delete_child(dev, bdev);
}
/* during module unload there are lots of children leftover */
device_delete_children(dev);
USB_BUS_LOCK(&sc->sc_dci.sc_bus);
callout_stop(&sc->sc_vbus);
USB_BUS_UNLOCK(&sc->sc_dci.sc_bus);
callout_drain(&sc->sc_vbus);
/* disable Transceiver */
AT91_UDP_WRITE_4(&sc->sc_dci, AT91_UDP_TXVC, AT91_UDP_TXVC_DIS);
/* disable and clear all interrupts */
AT91_UDP_WRITE_4(&sc->sc_dci, AT91_UDP_IDR, 0xFFFFFFFF);
AT91_UDP_WRITE_4(&sc->sc_dci, AT91_UDP_ICR, 0xFFFFFFFF);
if (sc->sc_dci.sc_irq_res && sc->sc_dci.sc_intr_hdl) {
/*
* only call at91_udp_uninit() after at91_udp_init()
*/
at91dci_uninit(&sc->sc_dci);
err = bus_teardown_intr(dev, sc->sc_dci.sc_irq_res,
sc->sc_dci.sc_intr_hdl);
sc->sc_dci.sc_intr_hdl = NULL;
}
if (sc->sc_dci.sc_irq_res) {
bus_release_resource(dev, SYS_RES_IRQ, 0,
sc->sc_dci.sc_irq_res);
sc->sc_dci.sc_irq_res = NULL;
}
if (sc->sc_dci.sc_io_res) {
bus_release_resource(dev, SYS_RES_MEMORY, MEM_RID,
sc->sc_dci.sc_io_res);
sc->sc_dci.sc_io_res = NULL;
}
usb_bus_mem_free_all(&sc->sc_dci.sc_bus, NULL);
/* disable clocks */
at91_pmc_clock_disable(sc->sc_iclk);
at91_pmc_clock_disable(sc->sc_fclk);
at91_pmc_clock_disable(sc->sc_mclk);
at91_pmc_clock_deref(sc->sc_fclk);
at91_pmc_clock_deref(sc->sc_iclk);
at91_pmc_clock_deref(sc->sc_mclk);
return (0);
}
示例11: usb_attach_sub
/*------------------------------------------------------------------------*
* usb_attach_sub
*
* This function creates a thread which runs the USB attach code.
*------------------------------------------------------------------------*/
static void
usb_attach_sub(device_t dev, struct usb_bus *bus)
{
const char *pname = device_get_nameunit(dev);
mtx_lock(&Giant);
if (usb_devclass_ptr == NULL)
usb_devclass_ptr = devclass_find("usbus");
mtx_unlock(&Giant);
#if USB_HAVE_PF
usbpf_attach(bus);
#endif
/* Initialise USB process messages */
bus->explore_msg[0].hdr.pm_callback = &usb_bus_explore;
bus->explore_msg[0].bus = bus;
bus->explore_msg[1].hdr.pm_callback = &usb_bus_explore;
bus->explore_msg[1].bus = bus;
bus->detach_msg[0].hdr.pm_callback = &usb_bus_detach;
bus->detach_msg[0].bus = bus;
bus->detach_msg[1].hdr.pm_callback = &usb_bus_detach;
bus->detach_msg[1].bus = bus;
bus->attach_msg[0].hdr.pm_callback = &usb_bus_attach;
bus->attach_msg[0].bus = bus;
bus->attach_msg[1].hdr.pm_callback = &usb_bus_attach;
bus->attach_msg[1].bus = bus;
/* Create USB explore and callback processes */
if (usb_proc_create(&bus->giant_callback_proc,
&bus->bus_mtx, pname, USB_PRI_MED)) {
device_printf(dev, "WARNING: Creation of USB Giant "
"callback process failed.\n");
} else if (usb_proc_create(&bus->non_giant_callback_proc,
&bus->bus_mtx, pname, USB_PRI_HIGH)) {
device_printf(dev, "WARNING: Creation of USB non-Giant "
"callback process failed.\n");
} else if (usb_proc_create(&bus->explore_proc,
&bus->bus_mtx, pname, USB_PRI_MED)) {
device_printf(dev, "WARNING: Creation of USB explore "
"process failed.\n");
} else if (usb_proc_create(&bus->control_xfer_proc,
&bus->bus_mtx, pname, USB_PRI_MED)) {
device_printf(dev, "WARNING: Creation of USB control transfer "
"process failed.\n");
} else {
/* Get final attach going */
USB_BUS_LOCK(bus);
if (usb_proc_msignal(&bus->explore_proc,
&bus->attach_msg[0], &bus->attach_msg[1])) {
/* ignore */
}
USB_BUS_UNLOCK(bus);
/* Do initial explore */
usb_needs_explore(bus, 1);
}
}
示例12: usb_detach
/*------------------------------------------------------------------------*
* usb_detach
*------------------------------------------------------------------------*/
static int
usb_detach(device_t dev)
{
struct usb_bus *bus = device_get_softc(dev);
DPRINTF("\n");
if (bus == NULL) {
/* was never setup properly */
return (0);
}
/* Stop power watchdog */
usb_callout_drain(&bus->power_wdog);
#if USB_HAVE_ROOT_MOUNT_HOLD
/* Let the USB explore process detach all devices. */
usb_root_mount_rel(bus);
#endif
USB_BUS_LOCK(bus);
/* Queue detach job */
usb_proc_msignal(USB_BUS_EXPLORE_PROC(bus),
&bus->detach_msg[0], &bus->detach_msg[1]);
/* Wait for detach to complete */
usb_proc_mwait(USB_BUS_EXPLORE_PROC(bus),
&bus->detach_msg[0], &bus->detach_msg[1]);
#if USB_HAVE_UGEN
/* Wait for cleanup to complete */
usb_proc_mwait(USB_BUS_EXPLORE_PROC(bus),
&bus->cleanup_msg[0], &bus->cleanup_msg[1]);
#endif
USB_BUS_UNLOCK(bus);
#if USB_HAVE_PER_BUS_PROCESS
/* Get rid of USB callback processes */
usb_proc_free(USB_BUS_GIANT_PROC(bus));
usb_proc_free(USB_BUS_NON_GIANT_ISOC_PROC(bus));
usb_proc_free(USB_BUS_NON_GIANT_BULK_PROC(bus));
/* Get rid of USB explore process */
usb_proc_free(USB_BUS_EXPLORE_PROC(bus));
/* Get rid of control transfer process */
usb_proc_free(USB_BUS_CONTROL_XFER_PROC(bus));
#endif
#if USB_HAVE_PF
usbpf_detach(bus);
#endif
return (0);
}
示例13: usb_bus_shutdown
/*------------------------------------------------------------------------*
* usb_bus_shutdown
*
* This function is used to shutdown the USB controller.
*------------------------------------------------------------------------*/
static void
usb_bus_shutdown(struct usb_proc_msg *pm)
{
struct usb_bus *bus;
struct usb_device *udev;
usb_error_t err;
uint8_t do_unlock;
bus = ((struct usb_bus_msg *)pm)->bus;
udev = bus->devices[USB_ROOT_HUB_ADDR];
if (udev == NULL || bus->bdev == NULL)
return;
USB_BUS_UNLOCK(bus);
bus_generic_shutdown(bus->bdev);
do_unlock = usbd_enum_lock(udev);
err = usbd_set_config_index(udev, USB_UNCONFIG_INDEX);
if (err)
device_printf(bus->bdev, "Could not unconfigure root HUB\n");
USB_BUS_LOCK(bus);
bus->hw_power_state = 0;
bus->no_explore = 1;
USB_BUS_UNLOCK(bus);
if (bus->methods->set_hw_power != NULL)
(bus->methods->set_hw_power) (bus);
if (bus->methods->set_hw_power_sleep != NULL)
(bus->methods->set_hw_power_sleep) (bus, USB_HW_POWER_SHUTDOWN);
if (do_unlock)
usbd_enum_unlock(udev);
USB_BUS_LOCK(bus);
}
示例14: usb_detach
/*------------------------------------------------------------------------*
* usb_detach
*------------------------------------------------------------------------*/
static int
usb_detach(device_t dev)
{
struct usb_bus *bus = device_get_softc(dev);
DPRINTF("\n");
if (bus == NULL) {
/* was never setup properly */
return (0);
}
/* Stop power watchdog */
usb_callout_drain(&bus->power_wdog);
/* Let the USB explore process detach all devices. */
usb_root_mount_rel(bus);
USB_BUS_LOCK(bus);
/* Queue detach job */
usb_proc_msignal(&bus->explore_proc,
&bus->detach_msg[0], &bus->detach_msg[1]);
/* Wait for detach to complete */
usb_proc_mwait(&bus->explore_proc,
&bus->detach_msg[0], &bus->detach_msg[1]);
#if USB_HAVE_UGEN
/* Wait for cleanup to complete */
usb_proc_mwait(&bus->explore_proc,
&bus->cleanup_msg[0], &bus->cleanup_msg[1]);
#endif
USB_BUS_UNLOCK(bus);
/* Get rid of USB callback processes */
usb_proc_free(&bus->giant_callback_proc);
usb_proc_free(&bus->non_giant_callback_proc);
/* Get rid of USB explore process */
usb_proc_free(&bus->explore_proc);
/* Get rid of control transfer process */
usb_proc_free(&bus->control_xfer_proc);
#if USB_HAVE_PF
usbpf_detach(bus);
#endif
return (0);
}
示例15: uhci_pci_detach
int
uhci_pci_detach(device_t self)
{
uhci_softc_t *sc = device_get_softc(self);
device_t bdev;
if (sc->sc_bus.bdev) {
bdev = sc->sc_bus.bdev;
device_detach(bdev);
device_delete_child(self, bdev);
}
/* during module unload there are lots of children leftover */
device_delete_children(self);
/*
* disable interrupts that might have been switched on in
* uhci_init.
*/
if (sc->sc_io_res) {
USB_BUS_LOCK(&sc->sc_bus);
/* stop the controller */
uhci_reset(sc);
USB_BUS_UNLOCK(&sc->sc_bus);
}
pci_disable_busmaster(self);
if (sc->sc_irq_res && sc->sc_intr_hdl) {
int err = bus_teardown_intr(self, sc->sc_irq_res, sc->sc_intr_hdl);
if (err) {
/* XXX or should we panic? */
device_printf(self, "Could not tear down irq, %d\n",
err);
}
sc->sc_intr_hdl = NULL;
}
if (sc->sc_irq_res) {
bus_release_resource(self, SYS_RES_IRQ, 0, sc->sc_irq_res);
sc->sc_irq_res = NULL;
}
if (sc->sc_io_res) {
bus_release_resource(self, SYS_RES_IOPORT, PCI_UHCI_BASE_REG,
sc->sc_io_res);
sc->sc_io_res = NULL;
}
usb_bus_mem_free_all(&sc->sc_bus, &uhci_iterate_hw_softc);
return (0);
}