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
9#pragma once
10
22
23#include <stdint.h>
24
25#include "irq_arch.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
36void riscv_init(void);
37
41void riscv_fpu_init(void);
42
46void riscv_irq_init(void);
47
53static inline uintptr_t cpu_get_caller_pc(void)
54{
55 /* This function must exist else RIOT won't compile */
56 return 0;
57}
58
65static inline __attribute__((always_inline))
66void cpu_reg_enable_bits(volatile uint32_t *reg, uint32_t mask)
67{
68 __atomic_fetch_or(reg, mask, __ATOMIC_RELAXED);
69}
70
77static inline __attribute__((always_inline))
78void cpu_reg_disable_bits(volatile uint32_t *reg, uint32_t mask)
79{
80 __atomic_fetch_and(reg, ~mask, __ATOMIC_RELAXED);
81}
82
83#ifdef __cplusplus
84}
85#endif
86
static uintptr_t cpu_get_caller_pc(void)
Gets the last instruction's address.
Definition cpu_common.h:53
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:66
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:78
void riscv_irq_init(void)
Initialization of the interrupt controller.
Implementation of the kernels irq interface.