📄 hcd.h
字号:
/****************************************************************
* MT View Silicon Tech. Inc.
*
* Copyright 2007, MT View Silicon Tech. Inc., ShangHai, China
* All rights reserved.
*
*
* Filename: hcd.h
*
* Programmer: Grey
*
* Created: 12/xx/2007
*
* Description: host controller driver head file
*
*
*****************************************************************/
#ifndef __HCD_H__
#define __HCD_H__
#include "hc_otg.h"
/* HCD logic source config */
#define MAX_HCI_NUM 1 /* host controller interface number 1 */
#define MAX_HCI_ED_NUM 16 /* host controller interface endpoint descriptor number 5 */
/*
* Host controller interface
*/
typedef struct _HCI
{
BYTE UsbStatus; /* USB status: suspend, normal, reset */
HC *Hc; /* host controller control structure */
HC_ED Ed[MAX_HCI_ED_NUM]; /* host endpoint descriptor source array */
WORD EdMap; /* host endpoint descriptor allocate map */
BYTE Set;
}HCI;
/* define USB status */
#define USB_STATUS_RESET 0
#define USB_STATUS_NORMAL 1
#define USB_STATUS_RESUME 2
#define USB_STATUS_SUSPEND 3
/* -------------------------------------------------------------------------- */
/*
* For various legacy reasons, Linux has a small cookie that's paired with
* a struct usb_device to identify an endpoint queue. Queue characteristics
* are defined by the endpoint's descriptor. This cookie is called a "pipe",
* an unsigned int encoded as:
*
* - direction: bit 7 (0 = Host-to-Device [Out],
* 1 = Device-to-Host [In] ...
* like endpoint bEndpointAddress)
* - device address: bits 8-14 ... bit positions known to uhci-hcd
* - endpoint: bits 15-18 ... bit positions known to uhci-hcd
* - pipe type: bits 30-31 (00 = isochronous, 01 = interrupt,
* 10 = control, 11 = bulk)
*
* Given the device address and endpoint descriptor, pipes are redundant.
*/
/* NOTE: these are not the standard USB_ENDPOINT_XFER_* values!! */
/* (yet ... they're the values used by usbfs) */
#define PIPE_ISOCHRONOUS 0
#define PIPE_INTERRUPT 1
#define PIPE_CONTROL 2
#define PIPE_BULK 3
#define PipeIn(pipe) ((pipe) & USB_DIR_IN)
#define PipeOut(pipe) (!usb_pipein(pipe))
#define PipeDevice(pipe) (((pipe) >> 8) & 0x7F)
#define PipeEndpoint(pipe) (((pipe) >> 15) & 0xF)
#define PipeType(pipe) (((pipe) >> 30) & 3)
#define PipeIsoc(pipe) (PipeType((pipe)) == PIPE_ISOCHRONOUS)
#define PipeInt(pipe) (PipeType((pipe)) == PIPE_INTERRUPT)
#define PipeControl(pipe) (PipeType((pipe)) == PIPE_CONTROL)
#define PipeBulk(pipe) (PipeType((pipe)) == PIPE_BULK)
#define PipeMaxPacketSize(pipe) (0x0001 << ((pipe & 0x7) + 3))
/*-------------------------------------------------------------------------*/
/*
* USB Request Block
* it is the bridge of HCD and USBD. USBD config and send it to HCD,
* HCD process the transfer through the endpoint which USBD configurated.
*/
typedef struct _URB
{
// BYTE FuncAddr; /* function address */
// BYTE EndPointNum; /* endpoint number */
// BYTE TransferType; /* endpoint type: ctrl, bulk, interrupt, isochronous */
// BYTE Direction; /* endpoint transfer direction: in, out */
DWORD Pipe;
WORD MaxPacketSize; /* max packet size */
BYTE Interval; /* for interrupt and isochronous endpoint, control and bulk set 0 */
BYTE *SetupPacket; /* setup packet */
BYTE *DataBuffer; /* received and send data buffer, USBD config the buffer address */
WORD DataLength; /* received and send data length, USBD set the length */
BOOL IsUseDMA; /* use DMA option, bulk/iso valid */
BYTE Err; /* current URB response status */
VOID *HcPriv; /* host controller driver control interface */
}URB;
/*
* process URB from USBD
* it is the transfer control interface of HCD
*/
extern BYTE
HciSendUrb(
URB *urb
);
/*
* host reset USB
*/
extern VOID
HciResetUsb(
VOID *hcpriv
);
/*
* host suspend USB
*/
extern VOID
HciSuspendUsb(
VOID *hcpriv
);
/*
* host resume USB from suspend
*/
extern VOID
HciResumeUsb(
VOID *hcpriv
);
/*
* get current frame number
*/
extern DWORD
HciGetFrameNum(
VOID *hcpriv
);
/*
* allocate one hci control structure
*/
extern VOID*
AllocHci(VOID);
/*
* free one hci control structure
*/
extern VOID
FreeHci(
VOID *hcpriv
);
/*
* allocate one hci endpoint descriptor
*/
extern HC_ED*
HciAllocED(
HCI *hci
);
/*
* free one hci endpoint descriptor
*/
extern VOID
HciFreeED(
HCI *hci,
HC_ED *ed
);
/*
* open host controller, init HCI and HC
*/
extern VOID
OpenHci(
VOID *hcpriv
);
/*
* polling root hub port
* update port connection status
*/
extern VOID
HciPollRootHub(
VOID *hcpriv
);
/*
* HCI get root hub port status.
* Return port status and port change. port status field is the low word of return value,
* port change field is the high word of return value.
* The port status and port change is defined in USB2.0 spec table-11.21 and table-11.22
*/
extern DWORD
HciGetRootHubPortStatus(
VOID *hcpriv,
BYTE portNum
);
/*
* HCI enable root hub port.
*/
extern BOOL
HciEnableRootHubPort(
VOID *hcpriv,
BYTE portNum
);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -