summaryrefslogtreecommitdiff
path: root/libcpu/arm/cortex-m85/cpuport.h
blob: 9bf02e57af0cc65a9c39a5379e1e6d5ffe050c26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
 * Copyright (c) 2006-2020, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 */

#ifndef  CPUPORT_H__
#define  CPUPORT_H__

#include <rtdef.h>

#ifdef rt_hw_isb
#undef rt_hw_isb
#endif
#ifdef rt_hw_dsb
#undef rt_hw_dsb
#endif

rt_inline void rt_hw_isb(void)
{
#if defined(__CC_ARM)
    __asm
    {
        ISB
    }
#elif defined(__clang__) || defined(__CLANG_ARM) || defined(__GNUC__)
    __asm volatile("isb 0xf" ::: "memory");
#elif defined(__IAR_SYSTEMS_ICC__)
    __asm("ISB");
#endif
}

rt_inline void rt_hw_dsb(void)
{
#if defined(__CC_ARM)
    __asm
    {
        DSB
    }
#elif defined(__clang__) || defined(__CLANG_ARM) || defined(__GNUC__)
    __asm volatile("dsb 0xf" ::: "memory");
#elif defined(__IAR_SYSTEMS_ICC__)
    __asm("DSB");
#endif
}

#ifdef RT_USING_SMP
typedef union {
    unsigned long slock;
    struct __arch_tickets {
        unsigned short owner;
        unsigned short next;
    } tickets;
} rt_hw_spinlock_t;
#endif

#endif  /*CPUPORT_H__*/