ehci.h
来自「winNT技术操作系统,国外开放的原代码和LIUX一样」· C头文件 代码 · 共 808 行 · 第 1/2 页
H
808 行
ULONG terminal : 1;
ULONG ptr_type : 2;
ULONG reserved : 2;
ULONG next_link : 27;
// DWORD 1;
ULONG dev_addr : 7;
ULONG reserved1 : 1;
ULONG endp_num : 4;
ULONG reserved2 : 4;
ULONG hub_addr : 7;
ULONG reserved3 : 1;
ULONG port_idx : 7;
ULONG io_dir : 1;
// DWORD 2;
ULONG s_mask : 8;
ULONG c_mask : 8;
ULONG reserved4 : 16;
// DWORD 3:
ULONG status : 8;
ULONG c_prog_mask : 8;
ULONG bytes_to_transfer : 10;
ULONG reserved5 : 4;
ULONG page_sel : 1;
ULONG ioc : 1;
// DWORD 4;
ULONG cur_offset : 12;
ULONG page0 : 20;
// DWORD 5;
ULONG trans_count : 3;
ULONG trans_pos : 2;
ULONG reserved6 : 7;
ULONG page1 : 20;
// DWORD 6;
ULONG back_terminal : 1;
ULONG reserved7 : 4;
ULONG back_ptr : 27;
} EHCI_SITD_CONTENT, *PEHCI_SITD_CONTENT;
typedef struct _EHCI_SITD
{
/* first part defined by EHCI spec */
ULONG hw_next;
/* uses bit field macros above - see EHCI 0.95 Table 3-8 */
ULONG hw_fullspeed_ep; /* see EHCI table 3-9 */
ULONG hw_uframe; /* see EHCI table 3-10 */
ULONG hw_tx_results1; /* see EHCI table 3-11 */
ULONG hw_tx_results2; /* see EHCI table 3-12 */
ULONG hw_tx_results3; /* see EHCI table 3-12 */
ULONG hw_backpointer; /* see EHCI table 3-13 */
/* the rest is HCD-private */
PEHCI_ELEM_LINKS elem_head_link;
ULONG phys_addr;
ULONG buf_phys_addr; /* buffer address */
USHORT usecs; /* start bandwidth */
USHORT c_usecs; /* completion bandwidth */
ULONG reserved[ 5 ];
} EHCI_SITD, *PEHCI_SITD; // __attribute__ ((aligned (32)));
/*-------------------------------------------------------------------------*/
/*
* EHCI Specification 0.96 Section 3.7
* Periodic Frame Span Traversal Node (FSTN)
*
* Manages split interrupt transactions (using TT) that span frame boundaries
* into uframes 0/1; see 4.12.2.2. In those uframes, a "save place" FSTN
* makes the HC jump (back) to a QH to scan for fs/ls QH completions until
* it hits a "restore" FSTN; then it returns to finish other uframe 0/1 work.
*/
typedef struct _EHCI_FSTN
{
ULONG hw_next; /* any periodic q entry */
ULONG hw_prev; /* qh or EHCI_LIST_END */
/* the rest is HCD-private */
PEHCI_ELEM_LINKS elem_head_link;
ULONG phys_addr;
ULONG reserved[ 4 ];
} EHCI_FSTN, *PEHCI_FSTN; // __attribute__ ((aligned (32)));
/* NOTE: urb->transfer_flags expected to not use this bit !!! */
#define EHCI_STATE_UNLINK 0x8000 /* urb being unlinked */
/*-------------------------------------------------------------------------*/
/* EHCI register interface, corresponds to EHCI Revision 0.95 specification */
/* Section 2.2 Host Controller Capability Registers */
#define HCS_DEBUG_PORT(p) (((p)>>20)&0xf) /* bits 23:20, debug port? */
#define HCS_INDICATOR(p) ((p)&(1 << 16)) /* true: has port indicators */
#define HCS_N_CC(p) (((p)>>12)&0xf) /* bits 15:12, #companion HCs */
#define HCS_N_PCC(p) (((p)>>8)&0xf) /* bits 11:8, ports per CC */
#define HCS_PORTROUTED(p) ((p)&(1 << 7)) /* true: port routing */
#define HCS_PPC(p) ((p)&(1 << 4)) /* true: port power control */
#define HCS_N_PORTS(p) (((p)>>0)&0xf) /* bits 3:0, ports on HC */
#define HCC_EXT_CAPS(p) (((p)>>8)&0xff) /* for pci extended caps */
#define HCC_ISOC_CACHE(p) ((p)&(1 << 7)) /* true: can cache isoc frame */
#define HCC_ISOC_THRES(p) (((p)>>4)&0x7) /* bits 6:4, uframes cached */
#define HCC_CANPARK(p) ((p)&(1 << 2)) /* true: can park on async qh */
#define HCC_PGM_FRAMELISTLEN(p) ((p)&(1 << 1)) /* true: periodic_size changes*/
#define HCC_64BIT_ADDR(p) ((p)&(1)) /* true: can use 64-bit addr */
/* 23:16 is r/w intr rate, in microframes; default "8" == 1/msec */
#define CMD_PARK (1<<11) /* enable "park" on async qh */
#define CMD_PARK_CNT(c) (((c)>>8)&3) /* how many transfers to park for */
#define CMD_LRESET (1<<7) /* partial reset (no ports, etc) */
#define CMD_IAAD (1<<6) /* "doorbell" interrupt async advance */
#define CMD_ASE (1<<5) /* async schedule enable */
#define CMD_PSE (1<<4) /* periodic schedule enable */
/* 3:2 is periodic frame list size */
#define CMD_RESET (1<<1) /* reset HC not bus */
#define CMD_RUN (1<<0) /* start/stop HC */
/* these STS_* flags are also intr_enable bits (USBINTR) */
#define STS_IAA (1<<5) /* Interrupted on async advance */
#define STS_FATAL (1<<4) /* such as some PCI access errors */
#define STS_FLR (1<<3) /* frame list rolled over */
#define STS_PCD (1<<2) /* port change detect */
#define STS_ERR (1<<1) /* "error" completion (overflow, ...) */
#define STS_INT (1<<0) /* "normal" completion (short, ...) */
#define STS_ASS (1<<15) /* Async Schedule Status */
#define STS_PSS (1<<14) /* Periodic Schedule Status */
#define STS_RECL (1<<13) /* Reclamation */
#define STS_HALT (1<<12) /* Not running (any reason) */
/* 31:23 reserved */
#define PORT_WKOC_E (1<<22) /* wake on overcurrent (enable) */
#define PORT_WKDISC_E (1<<21) /* wake on disconnect (enable) */
#define PORT_WKCONN_E (1<<20) /* wake on connect (enable) */
/* 19:16 for port testing */
/* 15:14 for using port indicator leds (if HCS_INDICATOR allows) */
#define PORT_OWNER (1<<13) /* true: companion hc owns this port */
#define PORT_POWER (1<<12) /* true: has power (see PPC) */
#define PORT_USB11(x) (((x)&(3<<10))==(1<<10)) /* USB 1.1 device */
/* 11:10 for detecting lowspeed devices (reset vs release ownership) */
/* 9 reserved */
#define PORT_PR (1<<8) /* reset port */
#define PORT_SUSP (1<<7) /* suspend port */
#define PORT_RESUME (1<<6) /* resume it */
#define PORT_OCC (1<<5) /* over current change */
#define PORT_OC (1<<4) /* over current active */
#define PORT_PEC (1<<3) /* port enable change */
#define PORT_PE (1<<2) /* port enable */
#define PORT_CSC (1<<1) /* connect status change */
#define PORT_CCS (1<<0) /* device connected */
#define FLAG_CF (1<<0) /* true: we'll support "high speed" */
typedef struct _EHCI_HCS_CONTENT
{
ULONG port_count : 4;
ULONG port_power_control : 1;
ULONG reserved : 2;
ULONG port_rout_rules : 1;
ULONG port_per_chc : 4;
ULONG chc_count : 4;
ULONG port_indicator : 1;
ULONG reserved2 : 3;
ULONG dbg_port_num : 4;
ULONG reserved3 : 8;
} EHCI_HCS_CONTENT, *PEHCI_HCS_CONTENT;
typedef struct _EHCI_HCC_CONTENT
{
ULONG cur_addr_bits : 1; /* 0: 32 bit addressing 1: 64 bit addressing */
ULONG var_frame_list : 1; /* 0: 1024 frames, 1: support other number of frames */
ULONG park_mode : 1;
ULONG reserved : 1;
ULONG iso_sched_threshold : 4;
ULONG eecp_capable : 8;
ULONG reserved2 : 16;
} EHCI_HCC_CONTENT, *PEHCI_HCC_CONTENT;
typedef struct _EHCI_CAPS {
UCHAR length; /* CAPLENGTH - size of this struct */
UCHAR reserved; /* offset 0x1 */
USHORT hci_version; /* HCIVERSION - offset 0x2 */
ULONG hcs_params; /* HCSPARAMS - offset 0x4 */
ULONG hcc_params; /* HCCPARAMS - offset 0x8 */
UCHAR portroute [8]; /* nibbles for routing - offset 0xC */
} EHCI_CAPS, *PEHCI_CAPS;
/* Section 2.3 Host Controller Operational Registers */
#define EHCI_USBCMD 0x00
#define EHCI_USBSTS 0x04
#define EHCI_USBINTR 0x08
#define EHCI_FRINDEX 0x0c
#define EHCI_CTRLDSSEGMENT 0x10
#define EHCI_PERIODICLISTBASE 0x14
#define EHCI_ASYNCLISTBASE 0x18
#define EHCI_CONFIGFLAG 0x40
#define EHCI_PORTSC 0x44
#define EHCI_USBINTR_INTE 0x01
#define EHCI_USBINTR_ERR 0x02
#define EHCI_USBINTR_PC 0x04
#define EHCI_USBINTR_FLROVR 0x08
#define EHCI_USBINTR_HSERR 0x10
#define EHCI_USBINTR_ASYNC 0x20
typedef struct _EHCI_USBCMD_CONTENT
{
ULONG run_stop : 1;
ULONG hcreset : 1;
ULONG frame_list_size : 2;
ULONG periodic_enable : 1;
ULONG async_enable : 1;
ULONG door_bell : 1;
ULONG light_reset : 1;
ULONG async_park_count : 2;
ULONG reserved : 1;
ULONG async_park_enable : 1;
ULONG reserved1 : 4;
ULONG int_threshold : 8;
ULONG reserved2 : 8;
} EHCI_USBCMD_CONTENT, *PEHCI_USBCMD_CONTENT;
typedef struct _EHCI_USBSTS_CONTENT
{
ULONG ioc : 1;
ULONG trasac_error : 1;
ULONG port_change : 1;
ULONG fl_rollover : 1;
ULONG host_system_error : 1;
ULONG async_advance : 1;
ULONG reserved : 6;
ULONG hc_halted : 1;
ULONG reclaimation : 1;
ULONG periodic_status : 1;
ULONG async_status : 1;
ULONG reserved1 : 16;
} EHCI_USBSTS_CONTENT, *PEHCI_USBSTS_CONTENT;
typedef struct _EHCI_RHPORTSC_CONTENT
{
ULONG cur_connect : 1;
ULONG cur_connect_change : 1;
ULONG port_enable : 1;
ULONG port_enable_change : 1;
ULONG over_current : 1;
ULONG over_current_change : 1;
ULONG force_port_resume : 1;
ULONG suspend : 1;
ULONG port_reset : 1;
ULONG reserved : 1;
ULONG line_status : 2;
ULONG port_power : 1;
ULONG port_owner : 1;
ULONG port_indicator : 2;
ULONG port_test : 4;
ULONG we_connect : 1;
ULONG we_disconnect : 1;
ULONG we_over_current : 1;
ULONG reserved1 : 9;
} EHCI_RHPORTSC_CONTENT, *PEHCI_RHPORTSC_CONTENT;
typedef struct _EHCI_REGS {
ULONG command;
ULONG status;
ULONG intr_enable;
ULONG frame_index; /* current microframe number */
ULONG segment; /* address bits 63:32 if needed */
ULONG frame_list; /* points to periodic list */
ULONG async_next; /* address of next async queue head */
ULONG reserved [9];
ULONG configured_flag;
ULONG port_status [0]; /* up to N_PORTS */
} EHCI_REGS, *PEHCI_REGS;
#pragma pack( pop, usb_align )
/* ehci_hcd->lock guards shared data against other CPUs:
* ehci_hcd: async, reclaim, periodic (and shadow), ...
* hcd_dev: ep[]
* ehci_qh: qh_next, qtd_list
* ehci_qtd: qtd_list
*
* Also, hold this lock when talking to HC registers or
* when updating hw_* fields in shared qh/qtd/... structures.
*/
#define EHCI_MAX_ROOT_PORTS 15 /* see HCS_N_PORTS */
#define EHCI_DEVICE_NAME "\\Device\\EHCI"
#define EHCI_DOS_DEVICE_NAME "\\DosDevices\\EHCI"
#define EHCI_ITD_POOL_IDX INIT_LIST_FLAG_ITD
#define EHCI_QH_POOL_IDX INIT_LIST_FLAG_QH
#define EHCI_SITD_POOL_IDX INIT_LIST_FLAG_SITD
#define EHCI_FSTN_POOL_IDX INIT_LIST_FLAG_FSTN
#define EHCI_QTD_POOL_IDX INIT_LIST_FLAG_QTD
#define EHCI_DEFAULT_FRAMES UHCI_MAX_FRAMES
#define EHCI_MAX_SYNC_BUS_TIME 50000 // stands for 100000 ns, only to get wrapped within one word
#define EHCI_SCHED_INT8_INDEX 0
#define EHCI_SCHED_INT4_INDEX 1
#define EHCI_SCHED_INT2_INDEX 2
#define EHCI_SCHED_FSTN_INDEX 3
#define EHCI_SCHED_INT1_INDEX 4
#define qtd_pool ( &ehci->elem_pools[ EHCI_QTD_POOL_IDX ] )
#define qh_pool ( &ehci->elem_pools[ EHCI_QH_POOL_IDX ] )
#define fstn_pool ( &ehci->elem_pools[ EHCI_FSTN_POOL_IDX ] )
#define itd_pool ( &ehci->elem_pools[ EHCI_ITD_POOL_IDX ] )
#define sitd_pool ( &ehci->elem_pools[ EHCI_SITD_POOL_IDX ] )
typedef struct _EHCI_DEV
{
HCD hcd_interf;
EHCI_CAPS ehci_caps;
PHYSICAL_ADDRESS ehci_reg_base; // io space
BOOLEAN port_mapped;
PBYTE port_base; // note: added by ehci_caps.length, operational regs base addr, not the actural base
ULONG frame_count;
PHYSICAL_ADDRESS frame_list_phys_addr;
KSPIN_LOCK frame_list_lock; // run at DIRQL
PULONG frame_list; // periodic schedule
PFRAME_LIST_CPU_ENTRY frame_list_cpu; // periodic schedule shadow
LIST_HEAD urb_list; // active urb-list
LIST_HEAD async_list_cpu;
LIST_HEAD periodic_list_cpu[ 8 ]; // each slot for one periodic
PEHCI_QH skel_async_qh;
//
// pools for device specific data
//
EHCI_ELEM_POOL elem_pools[ 5 ];
//
//for iso and int bandwidth claim, bandwidth schedule
//
KSPIN_LOCK pending_endp_list_lock; //lock to access the following two
LIST_HEAD pending_endp_list;
UHCI_PENDING_ENDP_POOL pending_endp_pool;
PUSHORT frame_bw; //unit uFrame
USHORT min_bw; //the bottle-neck of the bandwidths across frame-list
KTIMER reset_timer; //used to reset the host controller
struct _EHCI_DEVICE_EXTENSION *pdev_ext;
PUSB_DEV root_hub; //root hub
} EHCI_DEV, *PEHCI_DEV;
typedef UHCI_PORT EHCI_MEMORY;
typedef struct _EHCI_DEVICE_EXTENSION
{
//struct _USB_DEV_MANAGER *pdev_mgr;
DEVEXT_HEADER dev_ext_hdr;
PDEVICE_OBJECT pdev_obj;
PDRIVER_OBJECT pdrvr_obj;
PEHCI_DEV ehci;
//device resources
PADAPTER_OBJECT padapter;
ULONG map_regs;
PCM_RESOURCE_LIST res_list;
ULONG pci_addr; // bus number | slot number | funciton number
UHCI_INTERRUPT res_interrupt;
union
{
UHCI_PORT res_port;
EHCI_MEMORY res_memory;
};
PKINTERRUPT ehci_int;
KDPC ehci_dpc;
} EHCI_DEVICE_EXTENSION, *PEHCI_DEVICE_EXTENSION;
/*-------------------------------------------------------------------------*/
#endif /* __EHCI_H__ */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?