Loading...
Searching...
No Matches
cpu_common.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2020 Koen Zandberg <koen@bergzand.net>
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
17
18#include <stdint.h>
19
20#include "irq_arch.h"
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
31void riscv_init(void);
32
36void riscv_fpu_init(void);
37
41void riscv_irq_init(void);
42
48static inline uintptr_t cpu_get_caller_pc(void)
49{
50 /* This function must exist else RIOT won't compile */
51 return 0;
52}
53
60static inline __attribute__((always_inline))
61void cpu_reg_enable_bits(volatile uint32_t *reg, uint32_t mask)
62{
63 __atomic_fetch_or(reg, mask, __ATOMIC_RELAXED);
64}
65
72static inline __attribute__((always_inline))
73void cpu_reg_disable_bits(volatile uint32_t *reg, uint32_t mask)
74{
75 __atomic_fetch_and(reg, ~mask, __ATOMIC_RELAXED);
76}
77
78#ifdef __cplusplus
79}
80#endif
81
static uintptr_t cpu_get_caller_pc(void)
Gets the last instruction's address.
Definition cpu_common.h:48
static void cpu_reg_enable_bits(volatile uint32_t *reg, uint32_t mask)
Convenience function to set bit flags in a register.
Definition cpu_common.h:61
void riscv_init(void)
Initialize rv32i specific core parts of the CPU.
void riscv_fpu_init(void)
Enable the rv32i FPU when present.
static void cpu_reg_disable_bits(volatile uint32_t *reg, uint32_t mask)
Convenience function to clear bit flags in a register.
Definition cpu_common.h:73
void riscv_irq_init(void)
Initialization of the interrupt controller.
Implementation of the kernels irq interface.