📄 hcd.h
字号:
#endif /* CONFIG_PCI *//* pci-ish (pdev null is ok) buffer alloc/mapping support */int hcd_buffer_create (struct usb_hcd *hcd);void hcd_buffer_destroy (struct usb_hcd *hcd);///void *hcd_buffer_alloc (struct usb_bus *bus, size_t size,/// unsigned mem_flags, dma_addr_t *dma);///void hcd_buffer_free (struct usb_bus *bus, size_t size,/// void *addr, dma_addr_t dma);/* generic bus glue, needed for host controllers that don't use PCI *////extern irqreturn_t usb_hcd_irq (int irq, void *__hcd, struct pt_regs *r);extern void usb_hc_died (struct usb_hcd *hcd);extern void usb_hcd_poll_rh_status(struct usb_hcd *hcd);/* -------------------------------------------------------------------------- *//* Enumeration is only for the hub driver, or HCD virtual root hubs */extern struct usb_device *usb_alloc_dev(struct usb_device *parent, struct usb_bus *, unsigned port);extern int usb_new_device(struct usb_device *dev);extern void usb_disconnect(struct usb_device **);extern int usb_get_configuration(struct usb_device *dev);extern void usb_destroy_configuration(struct usb_device *dev);/*-------------------------------------------------------------------------*//* * HCD Root Hub support *////#include "hub.h"/* (shifted) direction/type/recipient from the USB 2.0 spec, table 9.2 */#define DeviceRequest \ ((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_DEVICE)<<8)#define DeviceOutRequest \ ((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_DEVICE)<<8)#define InterfaceRequest \ ((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8)#define EndpointRequest \ ((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8)#define EndpointOutRequest \ ((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8)/* class requests from the USB 2.0 hub spec, table 11-15 *//* GetBusState and SetHubDescriptor are optional, omitted */#define ClearHubFeature (0x2000 | USB_REQ_CLEAR_FEATURE)#define ClearPortFeature (0x2300 | USB_REQ_CLEAR_FEATURE)#define GetHubDescriptor (0xa000 | USB_REQ_GET_DESCRIPTOR)#define GetHubStatus (0xa000 | USB_REQ_GET_STATUS)#define GetPortStatus (0xa300 | USB_REQ_GET_STATUS)#define SetHubFeature (0x2000 | USB_REQ_SET_FEATURE)#define SetPortFeature (0x2300 | USB_REQ_SET_FEATURE)/*-------------------------------------------------------------------------*//* * Generic bandwidth allocation constants/support */#define FRAME_TIME_USECS 1000L#define BitTime(bytecount) (7 * 8 * bytecount / 6) /* with integer truncation */ /* Trying not to use worst-case bit-stuffing of (7/6 * 8 * bytecount) = 9.33 * bytecount */ /* bytecount = data payload byte count */#define NS_TO_US(ns) ((ns + 500L) / 1000L) /* convert & round nanoseconds to microseconds */extern void usb_claim_bandwidth (struct usb_device *dev, struct urb *urb, int bustime, int isoc);extern void usb_release_bandwidth (struct usb_device *dev, struct urb *urb, int isoc);/* * Full/low speed bandwidth allocation constants/support. */#define BW_HOST_DELAY 1000L /* nanoseconds */#define BW_HUB_LS_SETUP 333L /* nanoseconds */ /* 4 full-speed bit times (est.) */#define FRAME_TIME_BITS 12000L /* frame = 1 millisecond */#define FRAME_TIME_MAX_BITS_ALLOC (90L * FRAME_TIME_BITS / 100L)#define FRAME_TIME_MAX_USECS_ALLOC (90L * FRAME_TIME_USECS / 100L)extern int usb_check_bandwidth (struct usb_device *dev, struct urb *urb);/* * Ceiling [nano/micro]seconds (typical) for that many bytes at high speed * ISO is a bit less, no ACK ... from USB 2.0 spec, 5.11.3 (and needed * to preallocate bandwidth) */#define USB2_HOST_DELAY 5 /* nsec, guess */#define HS_NSECS(bytes) ( ((55 * 8 * 2083) \ + (2083UL * (3 + BitTime(bytes))))/1000 \ + USB2_HOST_DELAY)#define HS_NSECS_ISO(bytes) ( ((38 * 8 * 2083) \ + (2083UL * (3 + BitTime(bytes))))/1000 \ + USB2_HOST_DELAY)#define HS_USECS(bytes) NS_TO_US (HS_NSECS(bytes))#define HS_USECS_ISO(bytes) NS_TO_US (HS_NSECS_ISO(bytes))extern long usb_calc_bus_time (int speed, int is_input, int isoc, int bytecount);/*-------------------------------------------------------------------------*/extern struct usb_bus *usb_alloc_bus (struct usb_operations *);extern void usb_hcd_resume_root_hub (struct usb_hcd *hcd);extern void usb_set_device_state(struct usb_device *udev, enum usb_device_state new_state);/*-------------------------------------------------------------------------*//* exported only within usbcore */extern struct list_head usb_bus_list;extern struct semaphore usb_bus_list_lock;///extern wait_queue_head_t usb_kill_urb_queue;extern struct usb_bus *usb_bus_get (struct usb_bus *bus);extern void usb_bus_put (struct usb_bus *bus);extern void usb_enable_root_hub_irq (struct usb_bus *bus);extern int usb_find_interface_driver (struct usb_device *dev, struct usb_interface *interface);#define usb_endpoint_out(ep_dir) (!((ep_dir) & USB_DIR_IN))/* * USB device fs stuff */#ifdef CONFIG_USB_DEVICEFS/* * these are expected to be called from the USB core/hub thread * with the kernel lock held */extern void usbfs_add_bus(struct usb_bus *bus);extern void usbfs_remove_bus(struct usb_bus *bus);extern void usbfs_add_device(struct usb_device *dev);extern void usbfs_remove_device(struct usb_device *dev);extern void usbfs_update_special (void);extern int usbfs_init(void);extern void usbfs_cleanup(void);#else /* CONFIG_USB_DEVICEFS */static inline void usbfs_add_bus(struct usb_bus *bus) {}static inline void usbfs_remove_bus(struct usb_bus *bus) {}static inline void usbfs_add_device(struct usb_device *dev) {}static inline void usbfs_remove_device(struct usb_device *dev) {}static inline void usbfs_update_special (void) {}static inline int usbfs_init(void) { return 0; }static inline void usbfs_cleanup(void) { }#endif /* CONFIG_USB_DEVICEFS *//*-------------------------------------------------------------------------*/#if defined(CONFIG_USB_MON)struct usb_mon_operations { void (*urb_submit)(struct usb_bus *bus, struct urb *urb); void (*urb_submit_error)(struct usb_bus *bus, struct urb *urb, int err); void (*urb_complete)(struct usb_bus *bus, struct urb *urb); /* void (*urb_unlink)(struct usb_bus *bus, struct urb *urb); */ void (*bus_add)(struct usb_bus *bus); void (*bus_remove)(struct usb_bus *bus);};extern struct usb_mon_operations *mon_ops;static inline void usbmon_urb_submit(struct usb_bus *bus, struct urb *urb){ if (bus->monitored) (*mon_ops->urb_submit)(bus, urb);}static inline void usbmon_urb_submit_error(struct usb_bus *bus, struct urb *urb, int error){ if (bus->monitored) (*mon_ops->urb_submit_error)(bus, urb, error);}static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb){ if (bus->monitored) (*mon_ops->urb_complete)(bus, urb);} static inline void usbmon_notify_bus_add(struct usb_bus *bus){ if (mon_ops) (*mon_ops->bus_add)(bus);}static inline void usbmon_notify_bus_remove(struct usb_bus *bus){ if (mon_ops) (*mon_ops->bus_remove)(bus);}int usb_mon_register(struct usb_mon_operations *ops);void usb_mon_deregister(void);#elsestatic inline void usbmon_urb_submit(struct usb_bus *bus, struct urb *urb) {}static inline void usbmon_urb_submit_error(struct usb_bus *bus, struct urb *urb, int error) {}static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb) {}static inline void usbmon_notify_bus_add(struct usb_bus *bus) {}static inline void usbmon_notify_bus_remove(struct usb_bus *bus) {}#endif /* CONFIG_USB_MON *//*-------------------------------------------------------------------------*//* hub.h ... DeviceRemovable in 2.4.2-ac11, gone in 2.4.10 */// bleech -- resurfaced in 2.4.11 or 2.4.12#define bitmap DeviceRemovable/*-------------------------------------------------------------------------*//* random stuff */#define RUN_CONTEXT (in_irq () ? "in_irq" \ : (in_interrupt () ? "in_interrupt" : "can sleep"))#endif /* __KERNEL__ */#endif//__HCD_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -