Zephyr API Documentation 4.1.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
main.c File Reference
#include <zephyr/ztest.h>
#include <zephyr/kernel.h>
#include <zephyr/irq_offload.h>

Macros

#define STACK_SIZE   2048
 
#define NO_FPU   NULL
 
#define WITH_FPU   (const void *)1
 
#define TEST_TRAP(insn)
 
#define PRE_INSN   __asm__ volatile (".option push; .option norvc");
 
#define POST_INSN   __asm__ volatile (".option pop");
 
#define PRE_INSN
 
#define POST_INSN
 

Functions

static unsigned long fpu_state (void)
 
static bool fpu_is_off (void)
 
static bool fpu_is_clean (void)
 
static bool fpu_is_dirty (void)
 
void test_basics (void)
 
static void new_thread_check (const char *name)
 
static K_SEM_DEFINE (thread1_sem, 0, 1)
 
static K_SEM_DEFINE (thread2_sem, 0, 1)
 
static K_THREAD_STACK_DEFINE (thread1_stack, 2048)
 
static K_THREAD_STACK_DEFINE (thread2_stack, 2048)
 
static void thread1_entry (void *p1, void *p2, void *p3)
 
static void thread2_entry (void *p1, void *p2, void *p3)
 
void test_multi_thread_interaction (void)
 
static void exception_context (const void *arg)
 
void test_thread_vs_exc_interaction (void)
 
void test_fp_insn_trap (void)
 
 ZTEST_SUITE (riscv_fpu_sharing, NULL, NULL, NULL, NULL, NULL)
 

Variables

static struct k_thread thread1
 
static struct k_thread thread2
 

Macro Definition Documentation

◆ NO_FPU

#define NO_FPU   NULL

◆ POST_INSN [1/2]

#define POST_INSN   __asm__ volatile (".option pop");

◆ POST_INSN [2/2]

#define POST_INSN

◆ PRE_INSN [1/2]

#define PRE_INSN   __asm__ volatile (".option push; .option norvc");

◆ PRE_INSN [2/2]

#define PRE_INSN

◆ STACK_SIZE

#define STACK_SIZE   2048

◆ TEST_TRAP

#define TEST_TRAP ( insn)
Value:
/* disable the FPU access */ \
zassert_true(k_float_disable(k_current_get()) == 0); \
zassert_true(fpu_is_off()); \
/* execute the instruction */ \
{ \
/* use a0 to be universal with all configs */ \
register unsigned long __r __asm__ ("a0") = reg; \
PRE_INSN \
__asm__ volatile (insn : "+r" (__r) : : "fa0", "fa1", "memory"); \
POST_INSN \
reg = __r; \
} \
/* confirm that the FPU state has changed */ \
zassert_true(!fpu_is_off())
static bool fpu_is_off(void)
Definition main.c:19
int k_float_disable(struct k_thread *thread)
Disable preservation of floating point context information.
static __attribute_const__ k_tid_t k_current_get(void)
Get thread ID of the current thread.
Definition kernel.h:676

◆ WITH_FPU

#define WITH_FPU   (const void *)1

Function Documentation

◆ exception_context()

static void exception_context ( const void * arg)
static

◆ fpu_is_clean()

static bool fpu_is_clean ( void )
inlinestatic

◆ fpu_is_dirty()

static bool fpu_is_dirty ( void )
inlinestatic

◆ fpu_is_off()

static bool fpu_is_off ( void )
inlinestatic

◆ fpu_state()

static unsigned long fpu_state ( void )
inlinestatic

◆ K_SEM_DEFINE() [1/2]

static K_SEM_DEFINE ( thread1_sem ,
0 ,
1  )
static

◆ K_SEM_DEFINE() [2/2]

static K_SEM_DEFINE ( thread2_sem ,
0 ,
1  )
static

◆ K_THREAD_STACK_DEFINE() [1/2]

static K_THREAD_STACK_DEFINE ( thread1_stack ,
2048  )
static

◆ K_THREAD_STACK_DEFINE() [2/2]

static K_THREAD_STACK_DEFINE ( thread2_stack ,
2048  )
static

◆ new_thread_check()

static void new_thread_check ( const char * name)
static

◆ test_basics()

void test_basics ( void )

◆ test_fp_insn_trap()

void test_fp_insn_trap ( void )

◆ test_multi_thread_interaction()

void test_multi_thread_interaction ( void )

◆ test_thread_vs_exc_interaction()

void test_thread_vs_exc_interaction ( void )

◆ thread1_entry()

static void thread1_entry ( void * p1,
void * p2,
void * p3 )
static

◆ thread2_entry()

static void thread2_entry ( void * p1,
void * p2,
void * p3 )
static

◆ ZTEST_SUITE()

ZTEST_SUITE ( riscv_fpu_sharing ,
NULL ,
NULL ,
NULL ,
NULL ,
NULL  )

Variable Documentation

◆ thread1

struct k_thread thread1
static

◆ thread2

struct k_thread thread2
static