249 #include "pn_config.h"
347 #elif PN_RWIDTH == 16
354 #elif PN_RWIDTH == 32
361 #elif PN_RWIDTH == 64
368 #elif PN_RWIDTH == 128
377 #error Your ParaNut has a very exotic register width that was not considered\
378 when libparanut was written. Check paranut.h, section Typedefs, and add \
379 your funky register width there.
421 #define PN_ERR_PARAM (-1)
429 #define PN_ERR_NOIMP (-2)
437 #define PN_ERR_COPU (-3)
446 #define PN_ERR_MATCH (-4)
455 #define PN_ERR_LOCKOCC (-5)
495 #define PN_ERR_CACHE_LINESIZE (-6)
504 #define PN_ERR_EXC (-8)
981 PN_CID pn_begin_linked(
PN_NUMC numcores,
void *frame_adr,
char flags);
990 #define PN_BEGIN_LINKED(NUMCORES) ({ \
992 void *frame_addr = __builtin_frame_address(0); \
994 asm volatile("mv %0, s0" : "=r" (fp)); \
995 if(fp == frame_addr){ \
998 pn_begin_linked(NUMCORES, __builtin_frame_address(0), flags);})
1052 PN_CID pn_begin_linked_m(
PN_CMSK coremask,
void *frame_adr,
char flags);
1061 #define PN_BEGIN_LINKED_M(COREMASK) \
1063 void *frame_addr = __builtin_frame_address(0); \
1065 asm volatile("mv %0, s0" : "=r" (fp)); \
1066 if(fp == frame_addr){ \
1069 pn_begin_linked_m(COREMASK, __builtin_frame_address(0), flags)
1135 #define PN_END_LINKED() pn_end_linked()
1225 PN_CID pn_run_linked_m(
PN_CMSK coremask,
void (*func)(),
void *args);
1501 PN_CMSK pn_run_threaded_m(
PN_CMSK coremask,
void (*
function)(
void *args,
PN_CID cid),
void *args);
1785 unsigned int program_counter,
1786 unsigned int mtval),
1787 unsigned int exception_code
int pn_halt_CoPU_gm(PN_CMSK *coremask_array, PN_NUMG array_size)
Halts the CoPUs specified in the coremask_array.
Definition: pn_base.c:221
void pn_halt(void)
Halt whatever core the function is executed on.
Definition: pn_base.c:134
unsigned int pn_clock_freq(void)
Returns system clock frequency in Hz.
Definition: pn_base.c:235
PN_CMSK pn_m3cap_g(PN_NUMG groupnum)
Check which cores are capable of Mode 3 operation.
Definition: pn_base.c:107
int pn_halt_CoPU_m(PN_CMSK coremask)
Halts one or more CoPUs.
Definition: pn_base.c:187
int pn_halt_CoPU(PN_CID coreid)
Halts a CoPU.
Definition: pn_base.c:140
PN_CID pn_coreid(void)
Get the ID of the core that this function is executed on.
Definition: pn_base.c:120
unsigned int pn_timebase_us(void)
Returns machine timer timebase in us.
Definition: pn_base.c:240
PN_NUMC pn_numcores(void)
Get the number of cores in your system.
Definition: pn_base.c:62
PN_CMSK pn_m2cap(void)
Check which cores are capable of Mode 2 operation.
Definition: pn_base.c:71
PN_CMSK pn_m3cap(void)
Check which cores are capable of Mode 3 operation.
Definition: pn_base.c:93
long long int pn_time_ns(void)
Returns system time in ns. Does not care for overflow.
Definition: pn_base.c:245
PN_CID pn_coreid_g(PN_NUMG *groupnum)
Get the ID and group number of the core that this code is running on.
Definition: pn_base.c:125
PN_CMSK pn_m2cap_g(PN_NUMG groupnum)
Check which cores are capable of Mode 2 operation.
Definition: pn_base.c:80
int pn_simulation(void)
Checks if we run in simulation instead of real hardware.
Definition: pn_base.c:291
int pn_cache_disable(void)
Disables instruction and data cache.
Definition: pn_cache.c:351
unsigned long pn_cache_linesize(void)
Returns the cache line size in bit.
Definition: pn_cache.c:368
unsigned long pn_cache_size(void)
Returns the cache size in Byte.
Definition: pn_cache.c:373
int pn_cache_flush(void *addr, unsigned long size)
Combination of pn_cache_invalidate() and pn_cache_writeback().
Definition: pn_cache.c:403
int pn_cache_invalidate(void *addr, unsigned long size)
Invalidates the cache entries containing the given address range.
Definition: pn_cache.c:378
int pn_cache_flush_all(void)
Flushes the whole cache.
Definition: pn_cache.c:408
int pn_cache_init(void)
Function that has to be called in the main function before any of the functions in the Cache Module c...
Definition: pn_cache.c:211
int pn_cache_enable(void)
Enables instruction and data cache. When changing this, make sure that the pn_cache_init() function i...
Definition: pn_cache.c:333
int pn_cache_invalidate_all(void)
Invalidates the whole cache. When changing this, make sure that the pn_cache_init() function is still...
Definition: pn_cache.c:383
int pn_cache_writeback(void *addr, unsigned long size)
Writes back the cache lines that cached the given address range.
Definition: pn_cache.c:393
int pn_cache_writeback_all(void)
Writes whole cache back.
Definition: pn_cache.c:398
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.
Definition: pn_exception.c:370
void pn_interrupt_disable(void)
Disables interrupts only.
Definition: pn_exception.c:546
void pn_interrupt_enable(void)
Enables interrupts only.
Definition: pn_exception.c:537
void pn_progress_mepc(void)
Sets program counter of the register which keeps the exception return adress to next instruction.
Definition: pn_exception.c:555
void pn_exception_init(void)
Initializes libparanut internal exception handling. Interrupts (not exceptions in general!...
Definition: pn_exception.c:362
void pn_ecall(void)
Raises an environment call exception.
Definition: pn_exception.c:529
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.
Definition: pn_link.c:186
PN_CID pn_begin_linked_gm(PN_CMSK *coremask_array, PN_NUMG array_size, char flags)
Definition: pn_link.c:102
PN_CID pn_run_linked(PN_NUMC numcores, void(*func)(), void *args)
Starts a given function in linked mode.
Definition: pn_link.c:139
int pn_end_linked(void)
Ends linked execution.
Definition: pn_link.c:112
int pn_spinlock_lock(_pn_spinlock *spinlock)
Waits for a lock. Forever, if it must. Use with caution.
Definition: pn_spinlock.c:79
int pn_spinlock_destroy(_pn_spinlock *spinlock)
Destroys a lock.
Definition: pn_spinlock.c:139
int pn_spinlock_init(_pn_spinlock *spinlock)
Creates a lock.
Definition: pn_spinlock.c:64
int pn_spinlock_trylock(_pn_spinlock *spinlock)
Tries to acquire a lock. Nonblocking.
Definition: pn_spinlock.c:98
int pn_spinlock_unlock(_pn_spinlock *spinlock)
Unlocks a lock.
Definition: pn_spinlock.c:114
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.
Definition: pn_thread.c:166
PN_CMSK pn_join_thread_m(PN_CMSK coremask, uint32_t timeout)
Waits until a specified set of CePUs is stopped.
Definition: pn_thread.c:259
void pn_thread_entry(void)
Function that has to be called for CoPUs at the end of the startup code.
Definition: pn_thread.c:79
PN_CID pn_begin_threaded(PN_NUMC numcores)
Puts numcores CPUs in threaded mode.
Definition: pn_thread.c:116
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.
Definition: pn_thread.c:209
int pn_end_threaded(void)
Ends threaded execution.
Definition: pn_thread.c:176
PN_CID pn_begin_threaded_m(PN_CMSK coremask)
Puts the CPUs specified in the coremask in threaded mode.
Definition: pn_thread.c:145
int32_t PN_CID
Signed type that can be used to address any core in this architecture.
Definition: paranut.h:356
int32_t PN_NUMG
Signed type that can be used to address any group in this architecture.
Definition: paranut.h:359
struct __pn_spinlock _pn_spinlock
Renaming of struct __pn_spinlock for your convenience.
int32_t PN_NUMC
Signed type that can hold the maximum number of cores in this architecture.
Definition: paranut.h:357
uint32_t PN_CMSK
Unsigned type that can act as a core mask.
Definition: paranut.h:358
A synchronization primitive. Use _pn_spinlock instead of this.
Definition: paranut.h:1897