aiengine
Xilinx SDK Drivers API Documentation
xaieio.c File Reference

Overview

This file contains the low level layer IO interface.

MODIFICATION HISTORY:
Ver   Who     Date     Changes


1.0 Hyun 07/12/2018 Initial creation 1.1 Hyun 10/11/2018 Initialize the IO device for mem instance 1.2 Nishad 12/05/2018 Renamed ME attributes to AIE

#define SHM_NUM_ULONG   8
 number of ulong for bitmap More...
 
#define SHM_MAX_IDS   (sizeof(unsigned long) * SHM_NUM_ULONG)
 max number of IDs = 64 * 16 = 512 More...
 
void XAieIO_Finish (void)
 This is the memory IO function to free the global IO instance. More...
 
void XAieIO_Init (void)
 This is the memory IO function to initialize the global IO instance. More...
 
void * _XAieIO_GetIO (void)
 This is the memory IO function to get a low level IO instance. More...
 
void XAieIO_IntrUnregisterIsr (int Offset)
 This function unregisters the interrupt handler for given irq offset. More...
 
int XAieIO_IntrRegisterIsr (int Offset, int(*Handler)(void *Data), void *Data)
 This function registers the interrupt handler for given irq offset. More...
 
u32 XAieIO_Read32 (u64 Addr)
 This is the memory IO function to read 32bit data from the specified address. More...
 
void XAieIO_Read128 (u64 Addr, u32 *Data)
 This is the memory IO function to read 128b data from the specified address. More...
 
void XAieIO_Write32 (u64 Addr, u32 Data)
 This is the memory IO function to write 32bit data to the specified address. More...
 
void XAieIO_Write128 (u64 Addr, u32 *Data)
 This is the memory IO function to write 128bit data to the specified address. More...
 
void XAieIO_MemFinish (XAieIO_Mem *IO_MemInstPtr)
 This is the IO memory function to free the memory instance. More...
 
XAieIO_Mem * XAieIO_MemInit (u8 idx)
 This is the IO memory function to initialize the IO memory instance. More...
 
void XAieIO_MemDetach (XAieIO_Mem *IO_MemInstPtr)
 This is the IO memory function to detach the memory from device. More...
 
XAieIO_Mem * XAieIO_MemAttach (uint64_t Vaddr, uint64_t Paddr, uint64_t Size, uint64_t MemHandle)
 This is the IO memory function to attach the external memory to device. More...
 
void XAieIO_MemFree (XAieIO_Mem *IO_MemInstPtr)
 This is the IO memory function to free the memory. More...
 
XAieIO_Mem * XAieIO_MemAllocate (uint64_t Size, u32 Attr)
 This is the IO memory function to allocate a memory. More...
 
u8 XAieIO_MemSyncForCPU (XAieIO_Mem *IO_MemInstPtr)
 This is the IO memory function to sync the memory for CPU. More...
 
u8 XAieIO_MemSyncForDev (XAieIO_Mem *IO_MemInstPtr)
 This is the IO memory function to sync the memory for device. More...
 
uint64_t XAieIO_MemGetSize (XAieIO_Mem *IO_MemInstPtr)
 This is the IO memory function to return the size of the memory instance. More...
 
uint64_t XAieIO_MemGetVaddr (XAieIO_Mem *IO_MemInstPtr)
 This is the IO memory function to return the mapped virtual address of the memory instance. More...
 
uint64_t XAieIO_MemGetPaddr (XAieIO_Mem *IO_MemInstPtr)
 This is the IO memory function to return the physical address of the memory instance. More...
 
void XAieIO_MemWrite32 (XAieIO_Mem *IO_MemInstPtr, uint64_t Addr, u32 Data)
 This is the IO memory function to write to the physical address. More...
 
u32 XAieIO_MemRead32 (XAieIO_Mem *IO_MemInstPtr, uint64_t Addr)
 This is the IO memory function to read from the physical address. More...
 
u32 XAieIO_NPIRead32 (u64 Addr)
 This is the NPI IO function to read 32bit data from the specified address. More...
 
void XAieIO_NPIWrite32 (u64 Addr, u32 Data)
 This is the NPI IO function to write 32bit data to the specified address. More...
 

Macro Definition Documentation

#define SHM_MAX_IDS   (sizeof(unsigned long) * SHM_NUM_ULONG)

max number of IDs = 64 * 16 = 512

Referenced by XAieIO_MemAllocate().

#define SHM_NUM_ULONG   8

number of ulong for bitmap

Function Documentation

void* _XAieIO_GetIO ( void  )

This is the memory IO function to get a low level IO instance.

Parameters
None.
Returns
A void pointer that points to the low level IO instance.
Note
This function is for internal use only, and not meant to be used by applications.
void XAieIO_Finish ( void  )

This is the memory IO function to free the global IO instance.

Parameters
None.
Returns
None.
Note
The global IO instance is a singleton and freed when the reference count reaches a zero.

Referenced by XAieIO_IntrRegisterIsr(), XAieIO_IntrUnregisterIsr(), XAieIO_MemAllocate(), XAieIO_MemAttach(), XAieIO_MemDetach(), XAieIO_MemFinish(), and XAieIO_MemFree().

void XAieIO_Init ( void  )

This is the memory IO function to initialize the global IO instance.

Parameters
None.
Returns
None.
Note
The global IO instance is a singleton and any further attempt to initialize just increments the reference count.

Referenced by XAieIO_IntrRegisterIsr(), XAieIO_MemAllocate(), XAieIO_MemAttach(), XAieIO_MemInit(), and XAieLib_InitDev().

int XAieIO_IntrRegisterIsr ( int  Offset,
int(*)(void *Data)  Handler,
void *  Data 
)

This function registers the interrupt handler for given irq offset.

Parameters
Offset,:The value should one of 1 - 3. Current it's not used.
Handler,:the callback to be called upon interrupt.
Data,:the data to be used with the handler.
Returns
XAIELIB_SUCCESS for success, XAIELIB_FAILURE otherwise.
Note
The driver doesn't support all 4 interrupts yet, so the offset is not used. The handler is registerd as global one, so it isn't allowed to register more than one handlers.

References XAieIO_Finish(), and XAieIO_Init().

Referenced by XAieLib_InterruptRegisterIsr().

void XAieIO_IntrUnregisterIsr ( int  Offset)

This function unregisters the interrupt handler for given irq offset.

Parameters
Offset,:The value should one of 1 - 3. Current it's not used.
Returns
None.
Note
The driver doesn't support all 4 interrupts yet, so the offset is not used.

References XAieIO_Finish().

Referenced by XAieLib_InterruptUnregisterIsr().

XAieIO_Mem* XAieIO_MemAllocate ( uint64_t  Size,
u32  Attr 
)

This is the IO memory function to allocate a memory.

Parameters
Size,:Size of the memory
Attr,:Any of XAIELIB_MEM_ATTR_*
Returns
Pointer to the allocated IO memory instance.
Note
None.

References SHM_MAX_IDS, XAieIO_Finish(), and XAieIO_Init().

Referenced by XAieLib_MemAllocate().

XAieIO_Mem* XAieIO_MemAttach ( uint64_t  Vaddr,
uint64_t  Paddr,
uint64_t  Size,
uint64_t  MemHandle 
)

This is the IO memory function to attach the external memory to device.

Parameters
Vaddr,:Optional. Vaddr of the memory
Paddr,:Optional. Paddr of the memory
Size,:Required. Size of the memory
MemHandle,:Required. Handle of the memory. For linux, dmabuf fd
Returns
Pointer to the attached IO memory instance.
Note
None.

References XAieIO_Finish(), and XAieIO_Init().

Referenced by XAieLib_MemAttach().

void XAieIO_MemDetach ( XAieIO_Mem *  IO_MemInstPtr)

This is the IO memory function to detach the memory from device.

Parameters
IO_MemInstPtr,:IO Memory instance pointer.
Returns
None.
Note
None.

References XAieIO_Finish().

Referenced by XAieLib_MemDetach().

void XAieIO_MemFinish ( XAieIO_Mem *  IO_MemInstPtr)

This is the IO memory function to free the memory instance.

Parameters
IO_MemInstPtr,:IO Memory instance pointer.
Returns
None.
Note
is freed and invalid after this function.

References XAieIO_Finish().

Referenced by XAieLib_MemFinish().

void XAieIO_MemFree ( XAieIO_Mem *  IO_MemInstPtr)

This is the IO memory function to free the memory.

Parameters
IO_MemInstPtr,:IO Memory instance pointer.
Returns
None.
Note
None.

References XAieIO_Finish().

Referenced by XAieLib_MemFree().

uint64_t XAieIO_MemGetPaddr ( XAieIO_Mem *  IO_MemInstPtr)

This is the IO memory function to return the physical address of the memory instance.

Parameters
IO_MemInstPtr,:IO Memory instance pointer.
Returns
Physical address of the memory instance
Note
None.

Referenced by XAieLib_MemGetPaddr().

uint64_t XAieIO_MemGetSize ( XAieIO_Mem *  IO_MemInstPtr)

This is the IO memory function to return the size of the memory instance.

Parameters
IO_MemInstPtr,:IO Memory instance pointer.
Returns
size of the memory instance
Note
None.

Referenced by XAieLib_MemGetSize().

uint64_t XAieIO_MemGetVaddr ( XAieIO_Mem *  IO_MemInstPtr)

This is the IO memory function to return the mapped virtual address of the memory instance.

Parameters
IO_MemInstPtr,:IO Memory instance pointer.
Returns
Mapped virtual address.
Note
None.

Referenced by XAieLib_MemGetVaddr().

XAieIO_Mem* XAieIO_MemInit ( u8  idx)

This is the IO memory function to initialize the IO memory instance.

Parameters
idx,:Index of the memory to initialize.
Returns
Pointer to the initialized IO memory instance.
Note
None.

References XAieIO_Init().

Referenced by XAieLib_MemInit().

u32 XAieIO_MemRead32 ( XAieIO_Mem *  IO_MemInstPtr,
uint64_t  Addr 
)

This is the IO memory function to read from the physical address.

Parameters
IO_MemInstPtr,:IO Memory instance pointer.
Addr,:Absolute physical address to read from.
Returns
A read 32 bit data.
Note
None.

Referenced by XAieLib_MemRead32().

u8 XAieIO_MemSyncForCPU ( XAieIO_Mem *  IO_MemInstPtr)

This is the IO memory function to sync the memory for CPU.

Parameters
IO_MemInstPtr,:IO Memory instance pointer.
Returns
None.
Note
This only works with imported or allocated memory. This doesn't do anything with memory from the own memory pool, ex XAieIO_MemInit().

Referenced by XAieLib_MemSyncForCPU().

u8 XAieIO_MemSyncForDev ( XAieIO_Mem *  IO_MemInstPtr)

This is the IO memory function to sync the memory for device.

Parameters
IO_MemInstPtr,:IO Memory instance pointer.
Returns
None.
Note
This only works with imported or allocated memory. This doesn't do anything with memory from the own memory pool, ex XAieIO_MemInit().

Referenced by XAieLib_MemSyncForDev().

void XAieIO_MemWrite32 ( XAieIO_Mem *  IO_MemInstPtr,
uint64_t  Addr,
u32  Data 
)

This is the IO memory function to write to the physical address.

Parameters
IO_MemInstPtr,:IO Memory instance pointer.
Addr,:Absolute physical address to write.
Data,:A 32 bit data to write.
Returns
None.
Note
None.

Referenced by XAieLib_MemWrite32().

u32 XAieIO_NPIRead32 ( u64  Addr)

This is the NPI IO function to read 32bit data from the specified address.

Parameters
Addr,:Address to read from.
Returns
32-bit read value.
Note
This only work if NPI is accessble.

Referenced by XAieLib_NPIMaskWrite32(), and XAieLib_NPIRead32().

void XAieIO_NPIWrite32 ( u64  Addr,
u32  Data 
)

This is the NPI IO function to write 32bit data to the specified address.

Parameters
Addr,:Address to write to.
Data,:32-bit data to be written.
Returns
None.
Note
This only work if NPI is accessble.

Referenced by XAieLib_NPIMaskWrite32(), and XAieLib_NPIWrite32().

void XAieIO_Read128 ( u64  Addr,
u32 *  Data 
)

This is the memory IO function to read 128b data from the specified address.

Parameters
Addr,:Address to read from.
Data,:Pointer to the 128-bit buffer to store the read data.
Returns
None.
Note
None.

References XAieIO_Read32().

u32 XAieIO_Read32 ( u64  Addr)

This is the memory IO function to read 32bit data from the specified address.

Parameters
Addr,:Address to read from.
Returns
32-bit read value.
Note
None.

Referenced by XAieIO_Read128(), XAieLib_MaskWrite32(), XAieLib_Read128(), and XAieLib_Read32().

void XAieIO_Write128 ( u64  Addr,
u32 *  Data 
)

This is the memory IO function to write 128bit data to the specified address.

Parameters
Addr,:Address to write to.
Data,:Pointer to the 128-bit data buffer.
Returns
None.
Note
None.

References XAieIO_Write32().

Referenced by XAieLib_Write128().

void XAieIO_Write32 ( u64  Addr,
u32  Data 
)

This is the memory IO function to write 32bit data to the specified address.

Parameters
Addr,:Address to write to.
Data,:32-bit data to be written.
Returns
None.
Note
None.

Referenced by XAieIO_Write128(), XAieLib_MaskWrite32(), and XAieLib_Write32().