C Microkernel Realtime eXecutive
Realtime Operating System for Cortex-M based microcontrollers
 
Loading...
Searching...
No Matches
corelocal.h
1#pragma once
2
3#include <conf/kernel.h>
4#include <cmrx/arch/riscv/hal.h>
5
6/*
7 * RISC-V corelocal portability layer.
8 *
9 * For single-core builds, these are simple macros.
10 * For SMP builds, actual implementations would be needed.
11 */
12
13typedef void (*callback_t)();
14
15extern void os_core_sleep(void);
16
17#ifndef CMRX_ARCH_SMP_SUPPORTED
18
19# define coreid() 0
20# define OS_NUM_CORES 1
21# define os_smp_lock()
22# define os_smp_unlock()
23
24/*
25 * Core lock/unlock via interrupt disable/enable.
26 * Uses RISC-V HAL primitives.
27 */
28static inline void os_core_lock(void)
29{
30 cmrx_riscv_irq_disable();
31}
32
33static inline void os_core_unlock(void)
34{
35 cmrx_riscv_irq_enable();
36}
37
38#else
39
40/* SMP mode - not implemented yet */
41extern unsigned coreid(void);
42extern void os_core_lock(void);
43extern void os_core_unlock(void);
44extern void os_smp_lock(void);
45extern void os_smp_unlock(void);
46
47#ifndef OS_NUM_CORES
48#error "Macro OS_NUM_CORES is not defined. Use -DOS_NUM_CORES=x to tell the CMRX kernel how many cores it manages!"
49#endif
50
51#endif /* CMRX_ARCH_SMP_SUPPORTED */
52
void os_core_sleep()
Definition cortex.c:276