libparanut
A Hardware Abstraction Layer for ParaNut Architectures.
|
API of the libparanut. More...
#include <stdint.h>
#include <stdlib.h>
#include "pn_config.h"
Go to the source code of this file.
Classes | |
struct | __pn_spinlock |
A synchronization primitive. Use _pn_spinlock instead of this. More... | |
Macros | |
#define | PN_SUCCESS 0 |
Successful execution. More... | |
#define | PN_ERR_PARAM (-1) |
Parameter error. More... | |
#define | PN_ERR_NOIMP (-2) |
Function not implemented. More... | |
#define | PN_ERR_COPU (-3) |
CoPU error. More... | |
#define | PN_ERR_MATCH (-4) |
Mode begin and end matching error. More... | |
#define | PN_ERR_LOCKOCC (-5) |
Lock occupied error. More... | |
#define | PN_ERR_CACHE_LINESIZE (-6) |
Weird cache line size error. More... | |
#define | PN_ERR_EXC (-8) |
Exception code not implemented error. More... | |
#define | PN_M0 0x0U |
Mode 0 (halted Mode). | |
#define | PN_M1 0x1U |
Mode 1 (linked Mode). | |
#define | PN_M2 0x2U |
Mode 2 (unlinked or threaded Mode). | |
#define | PN_M3 0x3U |
Mode 3 (autonomous Mode). | |
#define | PN_BEGIN_LINKED(NUMCORES) |
Call pn_begin_linked with the __buitlin_frame_address(0). More... | |
#define | PN_BEGIN_LINKED_M(COREMASK) |
Call pn_begin_linked_m with the __buitlin_frame_address(0). More... | |
#define | PN_END_LINKED() pn_end_linked() |
Call pn_end_linked. More... | |
Functions | |
PN_NUMC | pn_numcores (void) |
Get the number of cores in your system. More... | |
PN_CMSK | pn_m2cap (void) |
Check which cores are capable of Mode 2 operation. More... | |
PN_CMSK | pn_m2cap_g (PN_NUMG groupnum) |
Check which cores are capable of Mode 2 operation. More... | |
PN_CMSK | pn_m3cap (void) |
Check which cores are capable of Mode 3 operation. More... | |
PN_CMSK | pn_m3cap_g (PN_NUMG groupnum) |
Check which cores are capable of Mode 3 operation. More... | |
PN_CID | pn_coreid (void) |
Get the ID of the core that this function is executed on. More... | |
PN_CID | pn_coreid_g (PN_NUMG *groupnum) |
Get the ID and group number of the core that this code is running on. More... | |
void | pn_halt (void) |
Halt whatever core the function is executed on. More... | |
int | pn_halt_CoPU (PN_CID coreid) |
Halts a CoPU. More... | |
int | pn_halt_CoPU_m (PN_CMSK coremask) |
Halts one or more CoPUs. More... | |
int | pn_halt_CoPU_gm (PN_CMSK *coremask_array, PN_NUMG array_size) |
Halts the CoPUs specified in the coremask_array. More... | |
unsigned int | pn_clock_freq (void) |
Returns system clock frequency in Hz. More... | |
unsigned int | pn_timebase_us (void) |
Returns machine timer timebase in us. More... | |
long long int | pn_time_ns (void) |
Returns system time in ns. Does not care for overflow. More... | |
int | pn_simulation (void) |
Checks if we run in simulation instead of real hardware. More... | |
PN_CID | pn_begin_linked_gm (PN_CMSK *coremask_array, PN_NUMG array_size, char flags) |
int | pn_end_linked (void) |
Ends linked execution. More... | |
PN_CID | pn_run_linked_gm (PN_CMSK *coremask_array, PN_NUMG array_size, void *function, void *args) |
NOT IMPLEMENTED YET, run a function in linked mode using group mask. More... | |
void | pn_thread_entry (void) |
Function that has to be called for CoPUs at the end of the startup code. More... | |
PN_CID | pn_begin_threaded (PN_NUMC numcores) |
Puts numcores CPUs in threaded mode. More... | |
PN_CID | pn_begin_threaded_m (PN_CMSK coremask) |
Puts the CPUs specified in the coremask in threaded mode. More... | |
PN_CID | pn_begin_threaded_gm (PN_CMSK *coremask_array, PN_NUMG array_size) |
Puts the CPUs specified in the coremask_array in threaded mode. More... | |
int | pn_end_threaded (void) |
Ends threaded execution. More... | |
PN_CMSK | pn_run_threaded (PN_NUMC numcores, void(*function)(void *args, PN_CID cid), void *args) |
Excutes a given function on the CoPUs specified in numcores. More... | |
PN_CMSK | pn_join_thread_m (PN_CMSK coremask, uint32_t timeout) |
Waits until a specified set of CePUs is stopped. More... | |
int | pn_cache_init (void) |
Function that has to be called in the main function before any of the functions in the Cache Module can be called. Initializes some internal data and enables the cache. More... | |
int | pn_cache_enable (void) |
Enables instruction and data cache. When changing this, make sure that the pn_cache_init() function is still correct! More... | |
int | pn_cache_disable (void) |
Disables instruction and data cache. More... | |
unsigned long | pn_cache_linesize (void) |
Returns the cache line size in bit. More... | |
unsigned long | pn_cache_size (void) |
Returns the cache size in Byte. More... | |
int | pn_cache_invalidate (void *addr, unsigned long size) |
Invalidates the cache entries containing the given address range. More... | |
int | pn_cache_invalidate_all (void) |
Invalidates the whole cache. When changing this, make sure that the pn_cache_init() function is still correct! More... | |
int | pn_cache_writeback (void *addr, unsigned long size) |
Writes back the cache lines that cached the given address range. More... | |
int | pn_cache_writeback_all (void) |
Writes whole cache back. More... | |
int | pn_cache_flush (void *addr, unsigned long size) |
Combination of pn_cache_invalidate() and pn_cache_writeback(). More... | |
int | pn_cache_flush_all (void) |
Flushes the whole cache. More... | |
void | pn_exception_init (void) |
Initializes libparanut internal exception handling. Interrupts (not exceptions in general!) are disabled after. Should be called before using pn_exception_set_handler(). | |
int | pn_exception_set_handler (void(*handler)(unsigned int cause, unsigned int program_counter, unsigned int mtval), unsigned int exception_code) |
Set your own exception handler. More... | |
void | pn_ecall (void) |
Raises an environment call exception. More... | |
void | pn_interrupt_enable (void) |
Enables interrupts only. More... | |
void | pn_interrupt_disable (void) |
Disables interrupts only. More... | |
void | pn_progress_mepc (void) |
Sets program counter of the register which keeps the exception return adress to next instruction. More... | |
int | pn_spinlock_init (_pn_spinlock *spinlock) |
Creates a lock. More... | |
int | pn_spinlock_lock (_pn_spinlock *spinlock) |
Waits for a lock. Forever, if it must. Use with caution. More... | |
int | pn_spinlock_trylock (_pn_spinlock *spinlock) |
Tries to acquire a lock. Nonblocking. More... | |
int | pn_spinlock_unlock (_pn_spinlock *spinlock) |
Unlocks a lock. More... | |
int | pn_spinlock_destroy (_pn_spinlock *spinlock) |
Destroys a lock. More... | |
API of the libparanut.