LibXenon
Bare-metal Xbox 360 homebrew library
Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
ehci.h File Reference
#include "ehci_types.h"
#include "usb.h"
#include "ehci_defs.h"
Include dependency graph for ehci.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ehci_device
 
struct  ehci_urb
 
struct  ehci_hcd
 
struct  ehci_qtd
 
union  ehci_shadow
 
struct  ehci_qh
 

Macros

#define __hc32   __le32
 
#define __hc16   __le16
 
#define EHCI_MAX_ROOT_PORTS   8 /* see HCS_N_PORTS */
 
#define EHCI_MAX_QTD   8
 
#define ep_bit(ep)   (((ep)&0xf)+(((ep)>>7)?16:0))
 
#define get_toggle(dev, ep)   (((dev)->toggles>>ep_bit(ep))&1)
 
#define set_toggle(dev, ep, v)   (dev)->toggles = ((dev)->toggles &(~(1<<ep_bit(ep)))) | ((v)<<ep_bit(ep))
 
#define DEFAULT_I_TDPS   1024 /* some HCs can do less */
 
#define QTD_NEXT(dma)   cpu_to_hc32( (u32)dma)
 
#define QTD_TOGGLE   (1 << 31) /* data toggle */
 
#define QTD_LENGTH(tok)   (((tok)>>16) & 0x7fff)
 
#define QTD_IOC   (1 << 15) /* interrupt on complete */
 
#define QTD_CERR(tok)   (((tok)>>10) & 0x3)
 
#define QTD_PID(tok)   (((tok)>>8) & 0x3)
 
#define QTD_STS_ACTIVE   (1 << 7) /* HC may execute this */
 
#define QTD_STS_HALT   (1 << 6) /* halted on error */
 
#define QTD_STS_DBE   (1 << 5) /* data buffer error (in HC) */
 
#define QTD_STS_BABBLE   (1 << 4) /* device was babbling (qtd halted) */
 
#define QTD_STS_XACT   (1 << 3) /* device gave illegal response */
 
#define QTD_STS_MMF   (1 << 2) /* incomplete split transaction */
 
#define QTD_STS_STS   (1 << 1) /* split transaction state */
 
#define QTD_STS_PING   (1 << 0) /* issue PING? */
 
#define ACTIVE_BIT(ehci)   cpu_to_hc32( QTD_STS_ACTIVE)
 
#define HALT_BIT(ehci)   cpu_to_hc32( QTD_STS_HALT)
 
#define STATUS_BIT(ehci)   cpu_to_hc32( QTD_STS_STS)
 
#define QTD_MASK(ehci)   cpu_to_hc32 ( ~0x1f)
 
#define IS_SHORT_READ(token)   (QTD_LENGTH (token) != 0 && QTD_PID (token) == 1)
 
#define Q_NEXT_TYPE(dma)   ((dma) & cpu_to_hc32( 3 << 1))
 
#define Q_TYPE_ITD   (0 << 1)
 
#define Q_TYPE_QH   (1 << 1)
 
#define Q_TYPE_SITD   (2 << 1)
 
#define Q_TYPE_FSTN   (3 << 1)
 
#define QH_NEXT(dma)   (cpu_to_hc32( (((u32)dma)&~0x01f)|Q_TYPE_QH))
 
#define EHCI_LIST_END()   cpu_to_hc32( 1) /* "null pointer" to hw */
 
#define QH_HEAD   0x00008000
 
#define QH_SMASK   0x000000ff
 
#define QH_CMASK   0x0000ff00
 
#define QH_HUBADDR   0x007f0000
 
#define QH_HUBPORT   0x3f800000
 
#define QH_MULT   0xc0000000
 
#define NO_FRAME   ((unsigned short)~0) /* pick new start */
 
#define cpu_to_hc32(b)   cpu_to_le32(b)
 
#define hc32_to_cpu(b)   le32_to_cpu(b)
 
#define hc32_to_cpup(b)   le32_to_cpu(*(b))
 
#define STUB_DEBUG_FILES
 

Functions

struct ehci_qtd __attribute__ ((aligned(32)))
 
void * ehci_maligned (int size, int alignement, int crossing)
 
dma_addr_t ehci_virt_to_dma (void *)
 
dma_addr_t ehci_dma_map_to (void *buf, size_t len)
 
dma_addr_t ehci_dma_map_from (void *buf, size_t len)
 
dma_addr_t ehci_dma_map_bidir (void *buf, size_t len)
 
void ehci_dma_unmap_to (dma_addr_t buf, size_t len)
 
void ehci_dma_unmap_from (dma_addr_t buf, size_t len)
 
void ehci_dma_unmap_bidir (dma_addr_t buf, size_t len)
 
void ehci_usleep (int time)
 
void ehci_msleep (int time)
 
s32 ehci_control_message (struct ehci_hcd *ehci, struct ehci_device *dev, u8 bmRequestType, u8 bmRequest, u16 wValue, u16 wIndex, u16 wLength, void *buf)
 
s32 ehci_bulk_message (struct ehci_hcd *ehci, struct ehci_device *dev, u8 bEndpoint, u16 wLength, void *rpData)
 
int ehci_discover (struct ehci_hcd *ehci)
 
int ehci_get_device_list (struct ehci_hcd *ehci, u8 maxdev, u8 b0, u8 *num, u16 *buf)
 
int ehci_reset_port2 (struct ehci_hcd *ehci, int port)
 
int ehci_open_device (struct ehci_hcd *ehci, int vid, int pid, int fd)
 
int ehci_close_device (struct ehci_device *dev)
 
void * ehci_fd_to_dev (struct ehci_hcd *ehci, int fd)
 
int ehci_release_ports (struct ehci_hcd *ehci)
 
s32 USBStorage_Init (void)
 
s32 USBStorage_Read_Sectors (int device, u32 sector, u32 numSectors, void *buffer)
 
s32 USBStorage_Read_Stress (u32 sector, u32 numSectors, void *buffer)
 
s32 USBStorage_Write_Sectors (int device, u32 sector, u32 numSectors, const void *buffer)
 

Variables

__hc32 hw_next
 
__hc32 hw_alt_next
 
__hc32 hw_token
 
__hc32 hw_buf [5]
 
__hc32 hw_buf_hi [5]
 
dma_addr_t qtd_dma
 
struct ehci_qtdnext
 
struct ehci_urburb
 
size_t length
 
union ehci_shadow __attribute__
 
__hc32 hw_info1
 
__hc32 hw_info2
 
__hc32 hw_current
 
__hc32 hw_qtd_next
 
dma_addr_t qh_dma
 
struct ehci_qtdqtd_head
 
struct ehci_hcdehci
 

Macro Definition Documentation

◆ __hc16

#define __hc16   __le16

Definition at line 40 of file ehci.h.

◆ __hc32

#define __hc32   __le32

Definition at line 39 of file ehci.h.

◆ ACTIVE_BIT

#define ACTIVE_BIT (   ehci)    cpu_to_hc32( QTD_STS_ACTIVE)

Definition at line 18 of file ehci.h.

◆ cpu_to_hc32

#define cpu_to_hc32 (   b)    cpu_to_le32(b)

Definition at line 244 of file ehci.h.

◆ DEFAULT_I_TDPS

#define DEFAULT_I_TDPS   1024 /* some HCs can do less */

Definition at line 94 of file ehci.h.

◆ EHCI_LIST_END

#define EHCI_LIST_END ( )    cpu_to_hc32( 1) /* "null pointer" to hw */

Definition at line 179 of file ehci.h.

◆ EHCI_MAX_QTD

#define EHCI_MAX_QTD   8

Definition at line 46 of file ehci.h.

◆ EHCI_MAX_ROOT_PORTS

#define EHCI_MAX_ROOT_PORTS   8 /* see HCS_N_PORTS */

Definition at line 45 of file ehci.h.

◆ ep_bit

#define ep_bit (   ep)    (((ep)&0xf)+(((ep)>>7)?16:0))

Definition at line 57 of file ehci.h.

◆ get_toggle

#define get_toggle (   dev,
  ep 
)    (((dev)->toggles>>ep_bit(ep))&1)

Definition at line 58 of file ehci.h.

◆ HALT_BIT

#define HALT_BIT (   ehci)    cpu_to_hc32( QTD_STS_HALT)

Definition at line 19 of file ehci.h.

◆ hc32_to_cpu

#define hc32_to_cpu (   b)    le32_to_cpu(b)

Definition at line 245 of file ehci.h.

◆ hc32_to_cpup

#define hc32_to_cpup (   b)    le32_to_cpu(*(b))

Definition at line 246 of file ehci.h.

◆ IS_SHORT_READ

#define IS_SHORT_READ (   token)    (QTD_LENGTH (token) != 0 && QTD_PID (token) == 1)

Definition at line 155 of file ehci.h.

◆ NO_FRAME

#define NO_FRAME   ((unsigned short)~0) /* pick new start */

Definition at line 25 of file ehci.h.

◆ Q_NEXT_TYPE

#define Q_NEXT_TYPE (   dma)    ((dma) & cpu_to_hc32( 3 << 1))

Definition at line 160 of file ehci.h.

◆ Q_TYPE_FSTN

#define Q_TYPE_FSTN   (3 << 1)

Definition at line 173 of file ehci.h.

◆ Q_TYPE_ITD

#define Q_TYPE_ITD   (0 << 1)

Definition at line 170 of file ehci.h.

◆ Q_TYPE_QH

#define Q_TYPE_QH   (1 << 1)

Definition at line 171 of file ehci.h.

◆ Q_TYPE_SITD

#define Q_TYPE_SITD   (2 << 1)

Definition at line 172 of file ehci.h.

◆ QH_CMASK

#define QH_CMASK   0x0000ff00

Definition at line 6 of file ehci.h.

◆ QH_HEAD

#define QH_HEAD   0x00008000

Definition at line 3 of file ehci.h.

◆ QH_HUBADDR

#define QH_HUBADDR   0x007f0000

Definition at line 7 of file ehci.h.

◆ QH_HUBPORT

#define QH_HUBPORT   0x3f800000

Definition at line 8 of file ehci.h.

◆ QH_MULT

#define QH_MULT   0xc0000000

Definition at line 9 of file ehci.h.

◆ QH_NEXT

#define QH_NEXT (   dma)    (cpu_to_hc32( (((u32)dma)&~0x01f)|Q_TYPE_QH))

Definition at line 176 of file ehci.h.

◆ QH_SMASK

#define QH_SMASK   0x000000ff

Definition at line 5 of file ehci.h.

◆ QTD_CERR

#define QTD_CERR (   tok)    (((tok)>>10) & 0x3)

Definition at line 7 of file ehci.h.

◆ QTD_IOC

#define QTD_IOC   (1 << 15) /* interrupt on complete */

Definition at line 6 of file ehci.h.

◆ QTD_LENGTH

#define QTD_LENGTH (   tok)    (((tok)>>16) & 0x7fff)

Definition at line 5 of file ehci.h.

◆ QTD_MASK

#define QTD_MASK (   ehci)    cpu_to_hc32 ( ~0x1f)

Definition at line 153 of file ehci.h.

◆ QTD_NEXT

#define QTD_NEXT (   dma)    cpu_to_hc32( (u32)dma)

Definition at line 109 of file ehci.h.

◆ QTD_PID

#define QTD_PID (   tok)    (((tok)>>8) & 0x3)

Definition at line 8 of file ehci.h.

◆ QTD_STS_ACTIVE

#define QTD_STS_ACTIVE   (1 << 7) /* HC may execute this */

Definition at line 9 of file ehci.h.

◆ QTD_STS_BABBLE

#define QTD_STS_BABBLE   (1 << 4) /* device was babbling (qtd halted) */

Definition at line 12 of file ehci.h.

◆ QTD_STS_DBE

#define QTD_STS_DBE   (1 << 5) /* data buffer error (in HC) */

Definition at line 11 of file ehci.h.

◆ QTD_STS_HALT

#define QTD_STS_HALT   (1 << 6) /* halted on error */

Definition at line 10 of file ehci.h.

◆ QTD_STS_MMF

#define QTD_STS_MMF   (1 << 2) /* incomplete split transaction */

Definition at line 14 of file ehci.h.

◆ QTD_STS_PING

#define QTD_STS_PING   (1 << 0) /* issue PING? */

Definition at line 16 of file ehci.h.

◆ QTD_STS_STS

#define QTD_STS_STS   (1 << 1) /* split transaction state */

Definition at line 15 of file ehci.h.

◆ QTD_STS_XACT

#define QTD_STS_XACT   (1 << 3) /* device gave illegal response */

Definition at line 13 of file ehci.h.

◆ QTD_TOGGLE

#define QTD_TOGGLE   (1 << 31) /* data toggle */

Definition at line 4 of file ehci.h.

◆ set_toggle

#define set_toggle (   dev,
  ep,
 
)    (dev)->toggles = ((dev)->toggles &(~(1<<ep_bit(ep)))) | ((v)<<ep_bit(ep))

Definition at line 59 of file ehci.h.

◆ STATUS_BIT

#define STATUS_BIT (   ehci)    cpu_to_hc32( QTD_STS_STS)

Definition at line 20 of file ehci.h.

◆ STUB_DEBUG_FILES

#define STUB_DEBUG_FILES

Definition at line 286 of file ehci.h.

Function Documentation

◆ __attribute__()

struct ehci_qtd __attribute__ ( (aligned(32))  )

◆ ehci_bulk_message()

s32 ehci_bulk_message ( struct ehci_hcd ehci,
struct ehci_device dev,
u8  bEndpoint,
u16  wLength,
void *  rpData 
)

Definition at line 682 of file ehci.c.

◆ ehci_close_device()

int ehci_close_device ( struct ehci_device dev)

Definition at line 1028 of file ehci.c.

◆ ehci_control_message()

s32 ehci_control_message ( struct ehci_hcd ehci,
struct ehci_device dev,
u8  bmRequestType,
u8  bmRequest,
u16  wValue,
u16  wIndex,
u16  wLength,
void *  buf 
)

Definition at line 651 of file ehci.c.

◆ ehci_discover()

int ehci_discover ( struct ehci_hcd ehci)

Definition at line 984 of file ehci.c.

◆ ehci_dma_map_bidir()

dma_addr_t ehci_dma_map_bidir ( void *  buf,
size_t  len 
)

Definition at line 84 of file usb_os.c.

◆ ehci_dma_map_from()

dma_addr_t ehci_dma_map_from ( void *  buf,
size_t  len 
)

Definition at line 78 of file usb_os.c.

◆ ehci_dma_map_to()

dma_addr_t ehci_dma_map_to ( void *  buf,
size_t  len 
)

Definition at line 72 of file usb_os.c.

◆ ehci_dma_unmap_bidir()

void ehci_dma_unmap_bidir ( dma_addr_t  buf,
size_t  len 
)

Definition at line 100 of file usb_os.c.

◆ ehci_dma_unmap_from()

void ehci_dma_unmap_from ( dma_addr_t  buf,
size_t  len 
)

Definition at line 95 of file usb_os.c.

◆ ehci_dma_unmap_to()

void ehci_dma_unmap_to ( dma_addr_t  buf,
size_t  len 
)

Definition at line 90 of file usb_os.c.

◆ ehci_fd_to_dev()

void * ehci_fd_to_dev ( struct ehci_hcd ehci,
int  fd 
)

Definition at line 1034 of file ehci.c.

◆ ehci_get_device_list()

int ehci_get_device_list ( struct ehci_hcd ehci,
u8  maxdev,
u8  b0,
u8 num,
u16 buf 
)

Definition at line 1048 of file ehci.c.

◆ ehci_maligned()

void * ehci_maligned ( int  size,
int  alignement,
int  crossing 
)

Definition at line 41 of file usb_os.c.

◆ ehci_msleep()

void ehci_msleep ( int  time)

Definition at line 110 of file usb_os.c.

◆ ehci_open_device()

int ehci_open_device ( struct ehci_hcd ehci,
int  vid,
int  pid,
int  fd 
)

Definition at line 1013 of file ehci.c.

◆ ehci_release_ports()

int ehci_release_ports ( struct ehci_hcd ehci)

Definition at line 998 of file ehci.c.

◆ ehci_reset_port2()

int ehci_reset_port2 ( struct ehci_hcd ehci,
int  port 
)

Definition at line 966 of file ehci.c.

◆ ehci_usleep()

void ehci_usleep ( int  time)

Definition at line 105 of file usb_os.c.

◆ ehci_virt_to_dma()

dma_addr_t ehci_virt_to_dma ( void *  a)

Definition at line 67 of file usb_os.c.

◆ USBStorage_Init()

s32 USBStorage_Init ( void  )

Definition at line 1215 of file usbstorage.c.

◆ USBStorage_Read_Sectors()

s32 USBStorage_Read_Sectors ( int  device,
u32  sector,
u32  numSectors,
void *  buffer 
)

Definition at line 1342 of file usbstorage.c.

◆ USBStorage_Read_Stress()

s32 USBStorage_Read_Stress ( u32  sector,
u32  numSectors,
void *  buffer 
)

◆ USBStorage_Write_Sectors()

s32 USBStorage_Write_Sectors ( int  device,
u32  sector,
u32  numSectors,
const void *  buffer 
)

Definition at line 1378 of file usbstorage.c.

Variable Documentation

◆ __attribute__

union ehci_shadow __attribute__

◆ ehci

struct ehci_hcd* ehci

Definition at line 23 of file ehci.h.

◆ hw_alt_next

__hc32 hw_alt_next

Definition at line 2 of file ehci.h.

◆ hw_buf

__hc32 hw_buf

Definition at line 22 of file ehci.h.

◆ hw_buf_hi

__hc32 hw_buf_hi

Definition at line 23 of file ehci.h.

◆ hw_current

__hc32 hw_current

Definition at line 10 of file ehci.h.

◆ hw_info1

__hc32 hw_info1

Definition at line 2 of file ehci.h.

◆ hw_info2

__hc32 hw_info2

Definition at line 4 of file ehci.h.

◆ hw_next

__hc32 hw_next

Definition at line 1 of file ehci.h.

◆ hw_qtd_next

__hc32 hw_qtd_next

Definition at line 13 of file ehci.h.

◆ hw_token

__hc32 hw_token

Definition at line 3 of file ehci.h.

◆ length

size_t length

Definition at line 29 of file ehci.h.

◆ next

struct ehci_qtd* next

Definition at line 27 of file ehci.h.

◆ qh_dma

dma_addr_t qh_dma

Definition at line 20 of file ehci.h.

◆ qtd_dma

dma_addr_t qtd_dma

Definition at line 26 of file ehci.h.

◆ qtd_head

struct ehci_qtd* qtd_head

Definition at line 21 of file ehci.h.

◆ urb

struct ehci_urb* urb

Definition at line 28 of file ehci.h.