/** * @file portmacro.h * @brief RISC-V RV32 specific macros */ #ifndef PORTMACRO_H #define PORTMACRO_H #include /* Data Types */ typedef uint32_t port_stack_type_t; typedef uint32_t port_base_type_t; /* Architecture Constants */ #define PORT_STACK_GROWTH_DIRECTION (-1) #define PORT_BYTE_ALIGNMENT 16 /* Critical Section Macros */ #define portENTER_CRITICAL() __asm volatile("csrci mstatus, 0x8") #define portEXIT_CRITICAL() __asm volatile("csrsi mstatus, 0x8") /* Interrupt Control */ #define portENABLE_INTERRUPTS() __asm volatile("csrsi mstatus, 0x8") #define portDISABLE_INTERRUPTS() __asm volatile("csrci mstatus, 0x8") /* Context Switch */ #define portYIELD() __asm volatile("li t0, 0x8\ncsrs mip, t0") #define portYIELD_FROM_ISR() __asm volatile("li t0, 0x8\ncsrs mip, t0") /* Memory Barriers */ #define portMEMORY_BARRIER() __asm volatile("fence") #define portSYNC_BARRIER() __asm volatile("fence") #define portINSTRUCTION_BARRIER() __asm volatile("fence.i") /* NOP */ #define portNOP() __asm volatile("nop") #endif /* PORTMACRO_H */