CDSP L2 cache locking manager
CDSP L2 Cache locking manager API
sysmon_cachelock.h File Reference

CDSP L2 cache locking manager API. More...

Go to the source code of this file.

Functions

void * HAP_cache_lock (unsigned int size, unsigned long long *paddr_ptr)
 
int HAP_cache_unlock (void *vaddr_ptr)
 
int HAP_cache_lock_addr (void *vaddr_ptr, unsigned int size)
 
int HAP_cache_unlock_addr (void *vaddr_ptr)
 
int HAP_query_avail_cachelock (void)
 
int HAP_query_total_cachelock (void)
 

Detailed Description

CDSP L2 cache locking manager API.

Function Documentation

◆ HAP_cache_lock()

void* HAP_cache_lock ( unsigned int  size,
unsigned long long *  paddr_ptr 
)

Allocates a memory buffer, locks it in L2 cache, and returns the locked virtual address.

Parameters
[in]sizeMemory size (in bytes) to lock.
[out]paddr_ptrPointer to unsigned long long variable to get the locked 64-bit physical address upon success. NULL if the allocation and cache lock failed.
Returns
void* Virtual address of the locked memory region.
0 if the requested buffer size could not be allocated and locked in the L2 cache.

◆ HAP_cache_lock_addr()

int HAP_cache_lock_addr ( void *  vaddr_ptr,
unsigned int  size 
)

Locks the cache for a given virtual address and memory size (in bytes).

Align the address and size to 32 bytes. The size should not be more than 64 KB, and at any point of time, only one such request is honored (this restriction has been removed from SM8250 onwards).

Use this function to lock an existing memory block, for example, to lock a code segment or data buffer. Note that whenever possible, it is preferable to let the driver allocate the memory to be locked in L2 via the HAP_cache_lock API, as it can often avoid the fragmentation likely to occur when the user provides the memory ranges to be locked.

Parameters
[in]vaddr_ptrVirtual address of the memory block to lock; should be 32-byte aligned.
[in]sizeMemory size (in bytes) to lock; should be 32-byte aligned. The maximum size limit is 64 KB. From SM8250, this size limit is the same as HAP_cache_lock().
Returns
0 upon success.
Others values upon failure.

◆ HAP_cache_unlock()

int HAP_cache_unlock ( void *  vaddr_ptr)

Unlocks cache and deallocates memory for a virtual address returned by the corresponding HAP_cache_lock() call.

Parameters
[in]vaddr_ptrVirtual address of the memory block to unlock.
Returns
0 upon success.
Other values upon failure.

◆ HAP_cache_unlock_addr()

int HAP_cache_unlock_addr ( void *  vaddr_ptr)

Unlocks the cache for a given virtual address.

Use this function together with HAP_cache_lock_addr().

Parameters
[in]vaddr_ptrVirtual address of the memory block to unlock.
Returns
0 upon success.
Other values upon failure.

◆ HAP_query_avail_cachelock()

int HAP_query_avail_cachelock ( void  )

Queries the API to get the size of largest contiguous memory block available for cache locking.

Returns
Available size in bytes upon success.
-1 upon failure.

◆ HAP_query_total_cachelock()

int HAP_query_total_cachelock ( void  )

Queries the API to get the total locked cache size.

Returns
Total locked cache size in bytes upon success.
-1 upon failure.