📄 usbpcistub.c
字号:
*
* Inputs a byte from a PCI I/O address <address>.
*
* RETURNS: byte input from i/o address
*/
UINT8 usbPciByteIn
(
UINT32 address /* PCI I/O address */
)
{
return USB_PCI_IN_BYTE (address);
}
/***************************************************************************
*
* usbPciWordIn - input a word from PCI I/O space
*
* Inputs a word from a PCI I/O address <address>.
*
* NOTE: This function adjusts for big vs. little endian environments.
*
* RETURNS: word input from i/o address
*/
UINT16 usbPciWordIn
(
UINT32 address /* PCI I/O address */
)
{
UINT16 w = USB_PCI_IN_WORD (address);
return FROM_LITTLEW (w);
}
/***************************************************************************
*
* usbPciDwordIn - input a dword from PCI I/O space
*
* Inputs a dword from a PCI I/O address <address>.
*
* NOTE: This function adjusts for big vs. little endian environments.
*
* RETURNS: dword input from i/o address
*/
UINT32 usbPciDwordIn
(
UINT32 address /* PCI I/O address */
)
{
UINT32 l = USB_PCI_IN_DWORD (address);
return FROM_LITTLEL (l);
}
/***************************************************************************
*
* usbPciByteOut - output a byte to PCI I/O space
*
* Outputs <value> to the PCI I/O address <address>.
*
* RETURNS: N/A
*/
VOID usbPciByteOut
(
UINT32 address, /* PCI I/O address */
UINT8 value /* value */
)
{
USB_PCI_OUT_BYTE (address, value);
CACHE_PIPE_FLUSH ();
}
/***************************************************************************
*
* usbPciWordOut - outputs a word to PCI I/O space
*
* Outputs <value> to the PCI I/O address <address>.
*
* NOTE: This function adjusts for big vs. little endian environments.
*
* RETURNS: N/A
*/
VOID usbPciWordOut
(
UINT32 address, /* PCI I/O address */
UINT16 value /* value */
)
{
UINT16 w = TO_LITTLEW (value);
USB_PCI_OUT_WORD (address, w);
CACHE_PIPE_FLUSH ();
}
/***************************************************************************
*
* usbPciDwordOut - outputs a dword to PCI I/O space
*
* Outputs <value> to the PCI I/O address <address>.
*
* NOTE: This function adjusts for big vs. little endian environments.
*
* RETURNS: N/A
*/
VOID usbPciDwordOut
(
UINT32 address, /* PCI I/O address */
UINT32 value /* value */
)
{
UINT32 l = TO_LITTLEL (value);
USB_PCI_OUT_DWORD (address, l);
CACHE_PIPE_FLUSH ();
}
#endif
/***************************************************************************
*
* usbPciMemioOffset - Return PCI MEMIO to CPU MEMIO offset
*
* For memory-mapped I/O, the CPU's view of a memory address may not be the
* same as that programmed into the base address register of a PCI adapter.
* The CPU should add the value returned by this function to the BAR in order
* to produce the correct CPU-visible memory address.
*
* RETURNS: PCI_MEMIO_OFFSET
*/
UINT32 usbPciMemioOffset (void)
{
#ifdef INCLUDE_USB_PCI
return PCI_MEMIO_OFFSET;
#else
return 0;
#endif
}
/***************************************************************************
*
* usbMemToPci - Convert a memory address to a PCI-reachable memory address
*
* Converts <pMem> to an equivalent 32-bit memory address visible from the
* PCI bus. This conversion is necessary to allow PCI bus masters to address
* the same memory viewed by the processor.
*
* RETURNS: converted memory address
*/
UINT32 usbMemToPci
(
pVOID pMem /* memory address to convert */
)
{
#ifdef INCLUDE_USB_PCI
pVOID pPhys;
/* The conversion is a two-step process. First, we need to convert the
* logical processor address (virtual) to a physical address. Then, we
* convert the physical address to one which can be seen from the PCI
* bus.
*/
pPhys = CACHE_DRV_VIRT_TO_PHYS (&cacheUserFuncs, pMem);
return ((UINT32) pPhys) + PCI_MEM_OFFSET;
#else
return(UINT32)pMem ;
#endif
}
/***************************************************************************
*
* usbPciToMem - Convert a PCI-reachable address to a CPU-reachable pointer
*
* Converts <pciAdrs> to an equivalent CPU memory address.
*
* RETURNS: pointer to PCI memory
*/
pVOID usbPciToMem
(
UINT32 pciAdrs /* 32-bit PCI address to be converted */
)
{
#ifdef INCLUDE_USB_PCI
return CACHE_DRV_PHYS_TO_VIRT (&cacheUserFuncs,
(void *) (pciAdrs - PCI_MEM_OFFSET));
#else
return (pVOID)pciAdrs ;
#endif
}
#ifdef INCLUDE_USB_PCI
/***************************************************************************
*
* usbPciMemInvalidate - Invalidate cache for a region of memory
*
* When another bus master, such as a PCI bus master, writes to memory, the
* cache may need to be invalidated for that region of memory.
*
* NOTE: Returns immediately if size == 0.
*
* RETURNS: N/A
*/
VOID usbPciMemInvalidate
(
pVOID pMem, /* base of memory region to invalidate */
UINT32 size /* size of region to invalidate */
)
{
if (size != 0)
CACHE_USER_INVALIDATE (pMem, size);
}
/***************************************************************************
*
* usbPciMemFlush - Flush a region of memory through the cache
*
* In systems which implement a non-write-thru cache, the processor may have
* written data to memory which has not yet been flushed to the actual system
* memory. Before other bus masters may interrogate this memory, it may be
* necessary to flush the cache.
*
* NOTE: Returns immediately if size == 0.
*
* RETURNS: N/A
*/
VOID usbPciMemFlush
(
pVOID pMem, /* base of memory region to invalidate */
UINT32 size /* size of region to invalidate */
)
{
if (size != 0)
CACHE_USER_FLUSH (pMem, size);
}
#endif
/***************************************************************************
*
* usbPciIntConnect - Connect to a interrupt vector
*
* Connects the <func> to the interrupt number <intNo>. <param> is an
* application-specific value which will be passed to <func> each time
* the interrupt handler is invoked.
*
* RETURNS: OK, or ERROR if unable to connect/enable interrupt
*/
STATUS usbPciIntConnect
(
INT_HANDLER_PROTOTYPE func, /* new interrupt handler */
pVOID param, /* parameter for int handler */
UINT16 intNo /* interrupt vector number */
)
{
#ifdef INCLUDE_USB_PCI
if (USB_INT_CONNECT (intNo, func, param) != OK)
return ERROR;
if (USB_INT_ENABLE (intNo) != OK)
{
USB_INT_DISCONNECT (intNo, func, param);
return ERROR;
}
if (intNo < USB_MAX_INT_NO)
intUsage [intNo]++;
#endif
return OK;
}
/***************************************************************************
*
* usbPciIntDisconnect - Removes an interrupt handler
*
* Removes an interrupt handler installed by usbPciIntConnect(). <func>,
* <param>, and <intNo> must match the corresponding parameters from an earlier
* call to usbPciIntConnect().
*
* RETURNS: N/A
*/
VOID usbPciIntRestore
(
INT_HANDLER_PROTOTYPE func, /* int handler to be removed */
pVOID param, /* parameter for int handler */
UINT16 intNo /* interrupt vector number */
)
{
#ifdef INCLUDE_USB_PCI
if (intNo >= USB_MAX_INT_NO ||
(intUsage [intNo] != 0 && --intUsage [intNo] == 0))
{
USB_INT_DISABLE (intNo);
}
USB_INT_DISCONNECT (intNo, func, param);
#endif
}
/* End of file. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -