summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorTomasz Kramkowski <tk@the-tk.com>2017-05-18 19:20:05 +0100
committerTomasz Kramkowski <tk@the-tk.com>2017-05-18 19:26:47 +0100
commit6852efe4a621a52e82ec5371a4b9fc10cc1bea88 (patch)
tree8b9954d397a1ef51ec2375095d6299396c9b37f4 /lib
parentd091b5a0950ea94f66d20eba33e5e96b7b9d5e83 (diff)
downloadfmk-6852efe4a621a52e82ec5371a4b9fc10cc1bea88.tar.gz
fmk-6852efe4a621a52e82ec5371a4b9fc10cc1bea88.tar.xz
fmk-6852efe4a621a52e82ec5371a4b9fc10cc1bea88.zip
asm.h -> lib/asm.h
Diffstat (limited to 'lib')
-rw-r--r--lib/asm.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/asm.h b/lib/asm.h
new file mode 100644
index 0000000..63310b5
--- /dev/null
+++ b/lib/asm.h
@@ -0,0 +1,42 @@
+/*
+ * 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__ volatile ("cpsid i")
+#define STI() __asm__ volatile ("cpsie i")
+#define WFI() __asm__ volatile ("wfi")
+
+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__ volatile ("msr basepri, %0" ::"r"(p));
+}
+
+#endif /* FMK_ASM_H */