📄 global.c
字号:
#include <stdio.h>
#include "typedef.h"
#include "low.h"
#include "pci.h"
#include "hcd.h"
#include "usb.h"
#include "ehci.h"
#include "ohci.h"
#include "uhci.h"
#include "hub.h"
#include "amecam.h"
/* amecam.c */
struct usb_device_id amecam_id_table [] = {
{/*match_flags;*/USB_DEVICE_ID_MATCH_VENDOR|
USB_DEVICE_ID_MATCH_PRODUCT|
USB_DEVICE_ID_MATCH_INT_CLASS|
USB_DEVICE_ID_MATCH_INT_SUBCLASS|
USB_DEVICE_ID_MATCH_INT_PROTOCOL,
/*idVendor;*/AME_CAM_ID_VENDOR,
/*idProduct;*/AME_CAM_ID_PRODUCT,
/*bcdDevice_lo;*/0,
/*bcdDevice_hi;*/0,
/*bDeviceClass;*/0,
/*bbDeviceSubClass;*/0,
/*bDeviceProtocol;*/0,
/*bInterfaceClass;*/AME_CAM_INTERFACE_CLASS,
/*bInterfaceSubClass;*/AME_CAM_INTERFACE_SUB_CLASS,
/*bInterfaceProtocol;*/AME_CAM_INTERFACE_PROTOCOL,
/*driver_info;*/NULL},
{0,0,0,0,0,0,0,0,0,0,0,NULL} /* Terminating entry */
};
struct usb_driver amecam_driver = {
/*const char far * name;*/"amecam",
/*void far * (*probe)(
struct usb_device far * dev,
unsigned long intf,
const struct usb_device_id far * id);*/
amecam_probe,
/*void (*disconnect)(struct usb_device far *, void far *);*/
amecam_disconnect,
/*long (*ioctl)(struct usb_device far * dev, unsigned short code, void far * buf);*/
NULL,
/*long (* open)(usb_device far * dev);*/NULL,
/*long (* close)(usb_device far * dev);*/NULL,
/*long (* device_ioctl)(usb_device far * dev,unsigned short code,void far * arg);*/
NULL,
/*const struct usb_device_id far * id_table;*/amecam_id_table,
/*unsigned char minor;*/
1,
/*struct list_head driver_list;*/{0,0}
};
/* ehci.c*/
long log2_irq_thresh = 3; // 0 to 6
char ehci_hcd_name [] = "ehci-hcd";
const struct hc_driver ehci_driver = {
/*const char far * description*/ehci_hcd_name,
/*void (*irq) (struct usb_hcd far * hcd)*/
ehci_irq,
/*long flags*/HCD_MEMORY|HCD_USB2,
/*long (*start) (struct usb_hcd far * hcd)*/ehci_start,
#ifdef CONFIG_PM
/*long (*suspend) (struct usb_hcd far * hcd, u32 state)*/ehci_suspend,
/*long (*resume) (struct usb_hcd far * hcd)*/ehci_resume,
#endif
/*void (*stop) (struct usb_hcd far * hcd)*/ehci_stop,
/*long (*get_frame_number) (struct usb_hcd far * hcd)*/NULL,
/*ruct usb_hcd far * (*hcd_alloc) (void)*/ehci_hcd_alloc,
/*void (*hcd_free) (struct usb_hcd far * hcd);*/ehci_hcd_free,
/*long (*urb_enqueue) (struct usb_hcd far * hcd, struct urb far * urb)*/
ehci_urb_enqueue,
/*long (*urb_dequeue) (struct usb_hcd far * hcd, struct urb far * urb)*/
ehci_urb_dequeue,
/*void free_config(struct usb_hcd far * hcd,struct usb_device far * udev,
unsigned char mode)*/ehci_free_config,
/*long (*hub_status_data) (struct usb_hcd far * hcd, char far * buf)*/
ehci_hub_status_data,
/*long (*hub_control) (struct usb_hcd far * hcd,
u16 typeReq, u16 wValue, u16 wIndex,
char far * buf, u16 wLength);*/ehci_hub_control,
/*long (*post_unlink_timeout)(struct usb_hcd far * hcd,
struct usb_device far * dev,atomic_t * p_refcnt);*/ehci_post_unlink_timeout
};
const struct pci_device_id ehci_pci_ids [] =
{
{/*unsigned long vendor*/ PCI_ANY_ID,
/*unsigned long device*/ PCI_ANY_ID,
/*unsigned long subvendor*/ PCI_ANY_ID,
/*unsigned long subdevice*/ PCI_ANY_ID,
/*unsigned long class*/ ((PCI_CLASS_SERIAL_USB << 8) | 0x20),
/*unsigned long class_mask*/ ~0L,
/*unsigned long driver_data*/ (unsigned long) &ehci_driver},
{0,0,0,0,0,0,0}
};
struct pci_driver ehci_pci_driver =
{
/*struct list_head node*/{NULL,NULL},
/*char *name*/ehci_hcd_name,
/*const struct pci_device_id *id_table*/ehci_pci_ids,
/*long (*probe) (struct pci_dev *dev, const struct pci_device_id *id)*/
usb_hcd_pci_probe,
/*void (*remove) (struct pci_dev *dev)*/usb_hcd_pci_remove,
/*long (*save_state) (struct pci_dev *dev, u32 state)*/NULL,
#ifdef CONFIG_PM
/*long (*suspend)(struct pci_dev *dev, u32 state)*/usb_hcd_pci_suspend,
/*long (*resume) (struct pci_dev *dev)*/usb_hcd_pci_resume,
#endif
/*long (*enable_wake) (struct pci_dev *dev, u32 state, long enable)*/NULL
};
/* hcd.c */
LIST_HEAD (hcd_list);
struct usb_operations hcd_operations = {
/*long (*allocate)(struct usb_device far *)*/hcd_alloc_dev,
/*long (*deallocate)(struct usb_device far *,unsigned char mode)*/hcd_free_dev,
/*long (*get_frame_number) (struct usb_device far * usb_dev)*/NULL,
/*long (*submit_urb) (struct urb far * purb)*/hcd_submit_urb,
/*long (*unlink_urb) (struct urb far * purb);*/hcd_unlink_urb
};
const u8 usb2_rh_dev_descriptor [18] =
{
0x12, /* __u8 bLength; */
0x01, /* __u8 bDescriptorType; Device */
0x00, 0x02, /* __u16 bcdUSB; v2.0 */
0x09, /* __u8 bDeviceClass; HUB_CLASSCODE */
0x00, /* __u8 bDeviceSubClass; */
0x01, /* __u8 bDeviceProtocol; [ usb 2.0 single TT ]*/
0x08, /* __u8 bMaxPacketSize0; 8 Bytes */
0x00, 0x00, /* __u16 idVendor; */
0x00, 0x00, /* __u16 idProduct; */
0x40, 0x02, /* __u16 bcdDevice; (v2.4) */
0x03, /* __u8 iManufacturer; */
0x02, /* __u8 iProduct; */
0x01, /* __u8 iSerialNumber; */
0x01 /* __u8 bNumConfigurations; */
};
/* no usb 2.0 root hub "device qualifier" descriptor: one speed only */
/* usb 1.1 root hub device descriptor */
const u8 usb11_rh_dev_descriptor_mem[18] =
{
0x12, /* __u8 bLength; */
0x01, /* __u8 bDescriptorType; Device */
0x10,
0x01, /* __u16 bcdUSB; v1.1 */
0x09, /* __u8 bDeviceClass; HUB_CLASSCODE */
0x00, /* __u8 bDeviceSubClass; */
0x00, /* __u8 bDeviceProtocol; [ low/full speeds only ] */
0x08, /* __u8 bMaxPacketSize0; 8 Bytes */
0x00,
0x00, /* __u16 idVendor; */
0x00,
0x00, /* __u16 idProduct; */
0x40,
0x02, /* __u16 bcdDevice; (v2.4) */
0x03, /* __u8 iManufacturer; */
0x02, /* __u8 iProduct; */
0x01, /* __u8 iSerialNumber; */
0x01 /* __u8 bNumConfigurations; */
};
const u8 usb11_rh_dev_descriptor_io[18] =
{
0x12, /* __u8 bLength; */
0x01, /* __u8 bDescriptorType; Device */
0x00, /* __u16 bcdUSB; v1.0 */
0x01,
0x09, /* __u8 bDeviceClass; HUB_CLASSCODE */
0x00, /* __u8 bDeviceSubClass; */
0x00, /* __u8 bDeviceProtocol; */
0x08, /* __u8 bMaxPacketSize0; 8 Bytes */
0x00, /* __u16 idVendor; */
0x00,
0x00, /* __u16 idProduct; */
0x00,
0x00, /* __u16 bcdDevice; */
0x00,
0x00, /* __u8 iManufacturer; */
0x02, /* __u8 iProduct; */
0x01, /* __u8 iSerialNumber; */
0x01 /* __u8 bNumConfigurations; */
};
/* Configuration descriptor for all our root hubs */
const u8 rh_config_descriptor_mem[] =
{
/* one configuration */
0x09, /* __u8 bLength; */
0x02, /* __u8 bDescriptorType; Configuration */
0x19, 0x00, /* __u16 wTotalLength; */
0x01, /* __u8 bNumInterfaces; (1) */
0x01, /* __u8 bConfigurationValue; */
0x00, /* __u8 iConfiguration; */
0x40, /* __u8 bmAttributes;
Bit 7: Bus-powered,
6: Self-powered,
5 Remote-wakwup,
4..0: resvd */
0x00, /* __u8 MaxPower; */
/* USB 1.1:
* USB 2.0, single TT organization (mandatory):
* one interface, protocol 0
*
* USB 2.0, multiple TT organization (optional):
* two interfaces, protocols 1 (like single TT)
* and 2 (multiple TT mode) ... config is
* sometimes settable
* NOT IMPLEMENTED
*/
/* one interface */
0x09, /* __u8 if_bLength; */
0x04, /* __u8 if_bDescriptorType; Interface */
0x00, /* __u8 if_bInterfaceNumber; */
0x00, /* __u8 if_bAlternateSetting; */
0x01, /* __u8 if_bNumEndpoints; */
0x09, /* __u8 if_bInterfaceClass; HUB_CLASSCODE */
0x00, /* __u8 if_bInterfaceSubClass; */
0x00, /* __u8 if_bInterfaceProtocol; [usb1.1 or single tt] */
0x00, /* __u8 if_iInterface; */
/* one endpoint (status change endpoint) */
0x07, /* __u8 ep_bLength; */
0x05, /* __u8 ep_bDescriptorType; Endpoint */
0x81, /* __u8 ep_bEndpointAddress; IN Endpoint 1 */
0x03, /* __u8 ep_bmAttributes; Interrupt */
0x02, 0x00, /* __u16 ep_wMaxPacketSize; 1 + (MAX_ROOT_PORTS / 8) */
0x0c /* __u8 ep_bInterval; (12ms -- usb 2.0 spec) */
};
const u8 rh_config_descriptor_io[] =
{
0x09, /* __u8 bLength; */
0x02, /* __u8 bDescriptorType; Configuration */
0x19, /* __u16 wTotalLength; */
0x00,
0x01, /* __u8 bNumInterfaces; */
0x01, /* __u8 bConfigurationValue; */
0x00, /* __u8 iConfiguration; */
0x40, /* __u8 bmAttributes;
Bit 7: Bus-powered, 6: Self-powered,
Bit 5 Remote-wakeup, 4..0: resvd */
0x00, /* __u8 MaxPower; */
/* interface */
0x09, /* __u8 if_bLength; */
0x04, /* __u8 if_bDescriptorType; Interface */
0x00, /* __u8 if_bInterfaceNumber; */
0x00, /* __u8 if_bAlternateSetting; */
0x01, /* __u8 if_bNumEndpoints; */
0x09, /* __u8 if_bInterfaceClass; HUB_CLASSCODE */
0x00, /* __u8 if_bInterfaceSubClass; */
0x00, /* __u8 if_bInterfaceProtocol; */
0x00, /* __u8 if_iInterface; */
/* endpoint */
0x07, /* __u8 ep_bLength; */
0x05, /* __u8 ep_bDescriptorType; Endpoint */
0x81, /* __u8 ep_bEndpointAddress; IN Endpoint 1 */
0x03, /* __u8 ep_bmAttributes; Interrupt */
0x08, /* __u16 ep_wMaxPacketSize; 8 Bytes */
0x00,
0xff /* __u8 ep_bInterval; 255 ms */
};
unsigned short sizeof_rh_config_descriptor_mem = sizeof(rh_config_descriptor_mem);
unsigned short sizeof_rh_config_descriptor_io = sizeof(rh_config_descriptor_io);
unsigned long id_died_tasklet;
struct TaskletDef died_tasklet;
struct completion_splice splice;
/* hub.c */
unsigned long id_thread;
struct ThreadDef thread;
LIST_HEAD(hub_event_list); /* List of hubs needing servicing */
LIST_HEAD(hub_list); /* List containing all of the hubs (for cleanup) */
struct usb_device_id hub_id_table [] = {
{/*match_flags;*/USB_DEVICE_ID_MATCH_INT_CLASS,
/*idVendor;*/0,
/*idProduct;*/0,
/*bcdDevice_lo;*/0,
/*bcdDevice_hi;*/0,
/*bDeviceClass;*/0,
/*bbDeviceSubClass;*/0,
/*bDeviceProtocol;*/0,
/*bInterfaceClass;*/USB_CLASS_HUB,
/*bInterfaceSubClass;*/0,
/*bInterfaceProtocol;*/0,
/*driver_info;*/NULL},
{0,0,0,0,0,0,0,0,0,0,0,NULL} /* Terminating entry */
};
struct usb_driver hub_driver = {
/*const char far * name;*/"hub",
/*void far * (*probe)(
struct usb_device far * dev,
unsigned long intf,
const struct usb_device_id far * id);*/
hub_probe,
/*void (*disconnect)(struct usb_device far *, void far *);*/
hub_disconnect,
/*long (*ioctl)(struct usb_device far * dev, unsigned short code, void far * buf);*/
hub_ioctl,
/*long (* open)(usb_device far * dev);*/NULL,
/*long (* close)(usb_device far * dev);*/NULL,
/*long (* device_ioctl)(usb_device far * dev,unsigned short code,void far * arg);*/
NULL,
/*const struct usb_device_id far * id_table;*/hub_id_table,
/*unsigned char minor;*/
0,
/*struct list_head driver_list;*/{0,0}
};
/* ohci.c */
long cc_to_error [16] = {
/* map OHCI status to errno values */
/* No Error */ 0L,
/* CRC Error */ -EILSEQ,
/* Bit Stuff */ -EPROTO,
/* Data Togg */ -EILSEQ,
/* Stall */ -EPIPE,
/* DevNotResp */ -ETIMEDOUT,
/* PIDCheck */ -EPROTO,
/* UnExpPID */ -EPROTO,
/* DataOver */ -EOVERFLOW,
/* DataUnder */ -EREMOTEIO,
/* (for hw) */ -EIO,
/* (for hw) */ -EIO,
/* BufferOver */ -ECOMM,
/* BuffUnder */ -ENOSR,
/* (for HCD) */ -EALREADY,
/* (for HCD) */ -EALREADY
};
char ohci_hcd_name [] = "ohci-hcd";
const struct hc_driver ohci_driver = {
/*const char far * description*/ohci_hcd_name,
/*void (*irq) (struct usb_hcd far * hcd)*/
NULL,
/*long flags*/HCD_MEMORY|HCD_USB11,
/*long (*start) (struct usb_hcd far * hcd)*/NULL,
#ifdef CONFIG_PM
/*long (*suspend) (struct usb_hcd far * hcd, u32 state)*/NULL,
/*long (*resume) (struct usb_hcd far * hcd)*/NULL,
#endif
/*void (*stop) (struct usb_hcd far * hcd)*/NULL,
/*long (*get_frame_number) (struct usb_hcd far * hcd)*/NULL,
/*ruct usb_hcd far * (*hcd_alloc) (void)*/NULL,
/*void (*hcd_free) (struct usb_hcd far * hcd);*/NULL,
/*long (*urb_enqueue) (struct usb_hcd far * hcd, struct urb far * urb)*/
NULL,
/*long (*urb_dequeue) (struct usb_hcd far * hcd, struct urb far * urb)*/
NULL,
/*void free_config(struct usb_hcd far * hcd,struct usb_device far * udev,
unsigned char mode)*/NULL,
/*long (*hub_status_data) (struct usb_hcd far * hcd, char far * buf)*/
NULL,
/*long (*hub_control) (struct usb_hcd far * hcd,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -