Developer World
Spresense SDK Library v3.3.0-375c679
Collaboration diagram for Functions:

Macros

#define mpshm_unmap(shm)   mpshm_detach(shm);
 

Functions

int mpshm_init (mpshm_t *shm, key_t key, size_t size)
 
int mpshm_destroy (mpshm_t *shm)
 
void * mpshm_attach (mpshm_t *shm, int shmflg)
 
int mpshm_detach (mpshm_t *shm)
 
int mpshm_control (mpshm_t *shm, int cmd, void *buf)
 
uintptr_t mpshm_virt2phys (mpshm_t *shm, void *vaddr)
 
void * mpshm_phys2virt (mpshm_t *shm, uintptr_t paddr)
 
int mpshm_remap (mpshm_t *shm, void *vaddr)
 

Detailed Description

Macro Definition Documentation

◆ mpshm_unmap

#define mpshm_unmap (   shm)    mpshm_detach(shm);

Unmap mapped memory

It's just an alias of mpshm_detach().

Function Documentation

◆ mpshm_init()

int mpshm_init ( mpshm_t shm,
key_t  key,
size_t  size 
)

Initialize MP shared memory

mpshm_init() initialize MP shared memory object and allocate actual shared memory area.

Parameters
[in,out]shmMP shared memory object
[in]keyUnique object ID
[in]sizeSize of shared memory
Returns
On success, mpshm_init() returns 0. On error, it returns an error number.
Return values
-EINVALInvalid argument
-ENOMEMNo memory space left
Note
MP shared memory area is always allocated in meaningful size for platform. On CXD5602, its size is 128KB.

◆ mpshm_destroy()

int mpshm_destroy ( mpshm_t shm)

Destroy MP shared memory

Parameters
[in,out]shmMP shared memory object
Returns
On success, mpshm_destroy() returns 0. On error, it returns an error number.
Return values
-EINVALInvalid argument

◆ mpshm_attach()

void * mpshm_attach ( mpshm_t shm,
int  shmflg 
)

Attach MP shared memory

mpshm_attach() is map shared memory to virtual address. User must be call this function to use allocated shared memory.

Parameters
[in,out]shmMP shared memory object
[in]shmflgFlags
Returns
On success, mpshm_attach() returns virtual address. On error, it returns NULL.
Note
shmflg is reserved for future extention. Not affected now.

◆ mpshm_detach()

int mpshm_detach ( mpshm_t shm)

Detach MP shared memory

Parameters
[in,out]shmMP shared memory object
Returns
On success, mpshm_detach() returns 0. On error, it returns an error number.
Return values
-EINVALInvalid argument

◆ mpshm_control()

int mpshm_control ( mpshm_t shm,
int  cmd,
void *  buf 
)

MP shared memory control

mpshm_control() now provides RAM power control for managed memory area. User can be control power mode to on, off and retention. ASMP framework performs power control automatically, so typically user unnecessary to power control manually.

Parameters
[in,out]shmMP shared memory object
[in]cmdCommand
[in,out]bufArguments for cmd
Returns
On success, mpshm_control() returns 0. On error it returns an error number.
Return values
-ENOTTYUnknown command
Attention
If set MPC_RETENTION or MPC_POWEROFF, then can't access to any management area.

◆ mpshm_virt2phys()

uintptr_t mpshm_virt2phys ( mpshm_t shm,
void *  vaddr 
)

Convert virtual address to physical address

Parameters
[in,out]shmMP shared memory object
[in]vaddrVirtual address
Returns
On success, mpshm_virt2phys() returns physical address. On error, it returns 0.
Note
This function affects only mapped virtual addresses.

◆ mpshm_phys2virt()

void * mpshm_phys2virt ( mpshm_t shm,
uintptr_t  paddr 
)

Convert physical address to virtial address

Parameters
[in,out]shmMP shared memory object
[in]paddrPhysical address
Returns
On success, mpshm_phys2virt() returns virtual address. On error, it returns NULL.

◆ mpshm_remap()

int mpshm_remap ( mpshm_t shm,
void *  vaddr 
)

Map allocated memory into specified virtual address

Parameters
[in,out]shmMP shared memory object
[in]vaddrVirtual address
Returns
On success, mpshm_remap() returns 0. On error, it returns on error number.
Return values
-EINVALInvalid argument
-ENOENTVirtual space is in use