Loading...
Searching...
No Matches
cpu_common.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2020, Koen Zandberg <koen@bergzand.net>
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
21#include <stdint.h>
22
23#include "irq_arch.h"
24
25#ifndef CPU_COMMON_H
26#define CPU_COMMON_H
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
37void riscv_init(void);
38
42void riscv_fpu_init(void);
43
47void riscv_irq_init(void);
48
54static inline uintptr_t cpu_get_caller_pc(void)
55{
56 /* This function must exist else RIOT won't compile */
57 return 0;
58}
59
66static inline __attribute__((always_inline))
67void cpu_reg_enable_bits(volatile uint32_t *reg, uint32_t mask)
68{
69 __atomic_fetch_or(reg, mask, __ATOMIC_RELAXED);
70}
71
78static inline __attribute__((always_inline))
79void cpu_reg_disable_bits(volatile uint32_t *reg, uint32_t mask)
80{
81 __atomic_fetch_and(reg, ~mask, __ATOMIC_RELAXED);
82}
83
84#ifdef __cplusplus
85}
86#endif
87
88#endif /* CPU_COMMON_H */
static uintptr_t cpu_get_caller_pc(void)
Gets the last instruction's address.
Definition cpu_common.h:54
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:67
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:79
void riscv_irq_init(void)
Initialization of the interrupt controller.
Implementation of the kernels irq interface.