mirror of
https://github.com/Rockbox/rockbox.git
synced 2026-10-10 08:03:04 -04:00
A host can replace an unfinished control transfer with a new SETUP. ARC and DesignWare flush EP0 without reporting completion callbacks, leaving the core waiting for a data/status packet that will never arrive. Explicitly notify the core after both directions and stale completion bits have been cancelled. Return an abandoned data/status stage to READY. If a queued or running handler still owns the request and data buffer, keep that ownership and suppress its response; dispatch only the latest replacement when it returns. A driver-owned SET_ADDRESS can also cancel a deferred request without passing its SETUP to the core. Do not overwrite an arbitrary busy state in usb_core_setup_received(). ARC cancellation is a prerequisite in the preceding patch; DesignWare cancels both EP0 directions before notifying and rearming reception. Change-Id: Ia8e0a68fe47ccab952168da24a2f76e311ca2b15
81 lines
2.7 KiB
C
81 lines
2.7 KiB
C
/***************************************************************************
|
|
* __________ __ ___.
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
* \/ \/ \/ \/ \/
|
|
*
|
|
* Copyright (C) 2007 by Björn Stenberg
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version 2
|
|
* of the License, or (at your option) any later version.
|
|
*
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
* KIND, either express or implied.
|
|
*
|
|
****************************************************************************/
|
|
#ifndef USB_CORE_H
|
|
#define USB_CORE_H
|
|
|
|
#include "usb_ch9.h"
|
|
#include "usb.h"
|
|
|
|
/* endpoints */
|
|
#define EP_CONTROL 0
|
|
|
|
#define DIR_OUT 0
|
|
#define DIR_IN 1
|
|
|
|
/* The USB core is a device, and OUT is RX from that P.O.V */
|
|
#define DIR_RX DIR_OUT
|
|
#define DIR_TX DIR_IN
|
|
|
|
#define EP_DIR(ep) (((ep) & USB_ENDPOINT_DIR_MASK) ? DIR_IN : DIR_OUT)
|
|
#define EP_NUM(ep) ((ep) & USB_ENDPOINT_NUMBER_MASK)
|
|
|
|
extern int usb_max_pkt_size;
|
|
|
|
enum usb_control_response {
|
|
USB_CONTROL_ACK,
|
|
USB_CONTROL_STALL,
|
|
};
|
|
|
|
enum {
|
|
USB_STRING_INDEX_LANGUAGE,
|
|
USB_STRING_INDEX_MANUFACTURER,
|
|
USB_STRING_INDEX_PRODUCT,
|
|
USB_STRING_INDEX_SERIAL,
|
|
USB_STRING_INDEX_MAX,
|
|
};
|
|
|
|
struct usb_class_driver;
|
|
|
|
void usb_core_init(void);
|
|
void usb_core_exit(void);
|
|
/* IRQ context, after both EP0 directions and their stale completions have
|
|
* been cancelled. Does not release a request buffer still owned by a handler. */
|
|
void usb_core_control_cancelled(void);
|
|
void usb_core_setup_received(struct usb_ctrlrequest* req);
|
|
void usb_core_control_response(enum usb_control_response response, const void* data, size_t size);
|
|
void usb_core_transfer_complete(int endpoint,int dir,int status,int length);
|
|
void usb_core_bus_reset(void);
|
|
void usb_core_enable_driver(int driver,bool enabled);
|
|
bool usb_core_driver_enabled(int driver);
|
|
#ifdef HAVE_USBSTACK
|
|
void usb_core_handle_transfer_completion(
|
|
struct usb_transfer_completion_event_data* event);
|
|
#endif
|
|
void usb_core_handle_notify(long id, intptr_t data);
|
|
/* For controllers which handle SET ADDR and/or SET CONFIG in hardware */
|
|
/* Address state only; hardware programming and status timing belong to drivers. */
|
|
void usb_core_notify_set_address(uint8_t addr); /* IRQ-safe notification */
|
|
void usb_core_notify_set_config(uint8_t config);
|
|
|
|
#ifdef HAVE_HOTSWAP
|
|
void usb_core_hotswap_event(int volume,bool inserted);
|
|
#endif
|
|
|
|
#endif
|