mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
cpu/fe310: migrate to inlined irq API
Co-authored-by: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
This commit is contained in:
parent
8c7b67702b
commit
3d9421571c
@ -39,6 +39,11 @@
|
||||
*/
|
||||
#define HAVE_HEAP_STATS
|
||||
|
||||
/**
|
||||
* @brief This arch uses the inlined irq API.
|
||||
*/
|
||||
#define IRQ_API_INLINED (1)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
99
cpu/fe310/include/irq_arch.h
Normal file
99
cpu/fe310/include/irq_arch.h
Normal file
@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Ken Rabold
|
||||
* 2020 Inria
|
||||
* 2020 Otto-von-Guericke-Universität Magdeburg
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser General
|
||||
* Public License v2.1. See the file LICENSE in the top level directory for more
|
||||
* details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup cpu_fe310
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Implementation of the kernels irq interface
|
||||
*
|
||||
* @author Ken Rabold
|
||||
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
|
||||
* @author Marian Buschsieweke <marian.buschsieweke@ovgu.de>
|
||||
*/
|
||||
|
||||
#ifndef IRQ_ARCH_H
|
||||
#define IRQ_ARCH_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "irq.h"
|
||||
#include "cpu_conf.h"
|
||||
#include "cpu.h"
|
||||
|
||||
#include "vendor/encoding.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern volatile int fe310_in_isr;
|
||||
|
||||
/**
|
||||
* @brief Enable all maskable interrupts
|
||||
*/
|
||||
static inline __attribute__((always_inline)) unsigned int irq_enable(void)
|
||||
{
|
||||
/* Enable all interrupts */
|
||||
unsigned state;
|
||||
__asm__ volatile (
|
||||
"csrrs %[dest], mstatus, %[mask]"
|
||||
: [dest] "=r"(state)
|
||||
: [mask] "i"(MSTATUS_MIE)
|
||||
: "memory"
|
||||
);
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable all maskable interrupts
|
||||
*/
|
||||
static inline __attribute__((always_inline)) unsigned int irq_disable(void)
|
||||
{
|
||||
|
||||
unsigned int state;
|
||||
__asm__ volatile (
|
||||
"csrrc %[dest], mstatus, %[mask]"
|
||||
: [dest] "=r"(state)
|
||||
: [mask] "i"(MSTATUS_MIE)
|
||||
: "memory"
|
||||
);
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Restore the state of the IRQ flags
|
||||
*/
|
||||
static inline __attribute__((always_inline)) void irq_restore(unsigned int state)
|
||||
{
|
||||
/* Restore all interrupts to given state */
|
||||
__asm__ volatile (
|
||||
"csrw mstatus, %[state]"
|
||||
: /* no outputs */
|
||||
: [state] "r"(state)
|
||||
: "memory"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief See if the current context is inside an ISR
|
||||
*/
|
||||
static inline __attribute__((always_inline)) int irq_is_in(void)
|
||||
{
|
||||
return fe310_in_isr;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* IRQ_ARCH_H */
|
||||
/** @} */
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include "cpu.h"
|
||||
#include "irq.h"
|
||||
#include "irq_arch.h"
|
||||
#include "panic.h"
|
||||
#include "sched.h"
|
||||
|
||||
@ -74,45 +75,6 @@ void irq_init(void)
|
||||
set_csr(mstatus, MSTATUS_DEFAULT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable all maskable interrupts
|
||||
*/
|
||||
unsigned int irq_enable(void)
|
||||
{
|
||||
/* Enable all interrupts */
|
||||
set_csr(mstatus, MSTATUS_MIE);
|
||||
return read_csr(mstatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable all maskable interrupts
|
||||
*/
|
||||
unsigned int irq_disable(void)
|
||||
{
|
||||
unsigned int state = read_csr(mstatus);
|
||||
|
||||
/* Disable all interrupts */
|
||||
clear_csr(mstatus, MSTATUS_MIE);
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Restore the state of the IRQ flags
|
||||
*/
|
||||
void irq_restore(unsigned int state)
|
||||
{
|
||||
/* Restore all interrupts to given state */
|
||||
write_csr(mstatus, state);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief See if the current context is inside an ISR
|
||||
*/
|
||||
int irq_is_in(void)
|
||||
{
|
||||
return fe310_in_isr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set External ISR callback
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user