summaryrefslogtreecommitdiffstats
path: root/lib/asm.h
blob: ab4acc88867d59d2cc418b1e1d989c2d06727aee (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
/*
 * asm.h -- ARM thumb assembly instructions
 *
 * Copyright (C) 2016-2017 Tomasz Kramkowski <tk@the-tk.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef FMK_ASM_H
#define FMK_ASM_H

#include <stdint.h>

#define CLI() __asm__ ("cpsid i")
#define STI() __asm__ ("cpsie i")
#define WFI() __asm__ ("wfi")
#define DMB() __asm__ ("dmb")

static inline uint32_t get_BASEPRI(void)
{
	uint32_t ret;

	__asm__ volatile ("mrs %0, basepri" :"=r"(ret));

	return ret;
}

static inline void set_BASEPRI(uint32_t p)
{
	__asm__ ("msr basepri, %0" ::"r"(p));
}

#endif /* FMK_ASM_H */