Table Of Contents

Previous topic

C Task API: System Resource Layer

Next topic

The Log API

This Page

The resources access API

The whole resource access API is defined in srl.h. Task code should include it:

#include <srl.h>

Retrieving resources associated to ports

Todo

GET_ARG

MWMR channels

srl_mwmr_t

Abstract type for a MWMR channel

void srl_mwmr_read(srl_mwmr_t channel, void *buffer, size_t size)

Reads from an MWMR channel to the given buffer. Block the task until the whole transfer is completed.

Parameters:
  • channel – the MWMR channel where to make transfer
  • buffer – Buffer’s base address to copy data into
  • size – Size of transfer in bytes. This must be a multiple of the channel’s width.
void srl_mwmr_write(srl_mwmr_t channel, const void *buffer, size_t size)

Writes to an MWMR channel to the given buffer. Block the task until the whole transfer is completed.

Parameters:
  • channel – the MWMR channel where to make transfer
  • buffer – Buffer’s base address to copy data from
  • size – Size of transfer in bytes. This must be a multiple of the channel’s width.
size_t srl_mwmr_try_read(srl_mwmr_t channel, void *buffer, size_t size)

Reads from an MWMR channel to the given buffer. Returns as soon as a blocking could occur.

Parameters:
  • channel – the MWMR channel where to make transfer
  • buffer – Buffer’s base address to copy data into
  • size – Size of transfer in bytes. This must be a multiple of the channel’s width.
Returns:

The actual size transfered, in bytes.

size_t srl_mwmr_try_write(srl_mwmr_t channel, const void *buffer, size_t size)

Writes to an MWMR channel to the given buffer. Returns as soon as a blocking could occur.

Parameters:
  • channel – the MWMR channel where to make transfer
  • buffer – Buffer’s base address to copy data from
  • size – Size of transfer in bytes. This must be a multiple of the channel’s width.
Returns:

The actual size transfered, in bytes.

void srl_mwmr_config(void *coproc, size_t no, uint32_t value)

Writes a config register of an MWMR controller.

Parameters:
  • coproc – Controller base address
  • no – Configuration register number
  • value – Value to put in configuration register
uint32_t srl_mwmr_status(void *coproc, size_t no)

Reads a status register of an MWMR controller.

Parameters:
  • coproc – Controller base address
  • no – Configuration register number
Returns:

the value present is status register

Barriers

srl_barrier_t

Abstract type for a Synchronization barrier

void srl_barrier_wait(srl_barrier_t barrier)

Waits until all tasks registered on the barrier have called this function.

Parameters:
  • barrier – barrier to wait on
void srl_barrier_reset(srl_barrier_t barrier)

Resets the internal state of the barrier. If tasks are waiting on the same barrier at time of call, application behavior is undefined.

Parameters:
  • barrier – barrier to reset

Memspaces

srl_memspace_t

Abstract type for a Shared-memory buffer

void *SRL_MEMSPACE_ADDR(srl_memspace_t memspace)

Retrieves the base address of a memspace

Parameters:
  • memspace – a memspace
Returns:

The memspace base address

size_t SRL_MEMSPACE_SIZE(srl_memspace_t memspace)

Retrieves the size of a memspace

Parameters:
  • memspace – a memspace
Returns:

The memspace size, in bytes

Locks

srl_lock_t

Abstract type for a Lock

void srl_lock_lock(srl_lock_t lock)

Waits until the lock is taken exclusively.

Parameters:
  • lock – lock to wait on
void srl_lock_unlock(srl_lock_t lock)

Releases the taken lock. If a task releases a lock it does not own, application behavior is undefined.

Parameters:
  • lock – lock to release
void srl_lock_try_lock(srl_lock_t lock)

Try to take a lock, if it would block, don’t take it and return immediately.

Parameters:
  • lock – lock to take
Returns:

0 if taken successfully, non-0 otherwise