summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/export/system.h4
-rw-r--r--firmware/target/sh/system-sh.c11
-rw-r--r--firmware/target/sh/system-target.h7
3 files changed, 22 insertions, 0 deletions
diff --git a/firmware/export/system.h b/firmware/export/system.h
index b44600d2c2..489ed8dc12 100644
--- a/firmware/export/system.h
+++ b/firmware/export/system.h
@@ -266,6 +266,10 @@ static inline uint32_t swap_odd_even32(uint32_t value)
#endif /* !SIMULATOR */
+#ifndef TEST_BIT_N
+#define TEST_BIT_N(n, mask) ((1UL << (n)) & (mask))
+#endif
+
/* Declare this as HIGHEST_IRQ_LEVEL if they don't differ */
#ifndef DISABLE_INTERRUPTS
#define DISABLE_INTERRUPTS HIGHEST_IRQ_LEVEL
diff --git a/firmware/target/sh/system-sh.c b/firmware/target/sh/system-sh.c
index 02af40282f..7779c975a7 100644
--- a/firmware/target/sh/system-sh.c
+++ b/firmware/target/sh/system-sh.c
@@ -27,6 +27,17 @@
#include "font.h"
#include "led.h"
+const unsigned bit_n_table[32] = {
+ 1LU<< 0, 1LU<< 1, 1LU<< 2, 1LU<< 3,
+ 1LU<< 4, 1LU<< 5, 1LU<< 6, 1LU<< 7,
+ 1LU<< 8, 1LU<< 9, 1LU<<10, 1LU<<11,
+ 1LU<<12, 1LU<<13, 1LU<<14, 1LU<<15,
+ 1LU<<16, 1LU<<17, 1LU<<18, 1LU<<19,
+ 1LU<<20, 1LU<<21, 1LU<<22, 1LU<<23,
+ 1LU<<24, 1LU<<25, 1LU<<26, 1LU<<27,
+ 1LU<<28, 1LU<<29, 1LU<<30, 1LU<<31
+};
+
static const char* const irqname[] = {
"", "", "", "", "IllInstr", "", "IllSltIn","","",
"CPUAdrEr", "DMAAdrEr", "NMI", "UserBrk",
diff --git a/firmware/target/sh/system-target.h b/firmware/target/sh/system-target.h
index 3c225fbb69..2568911a1e 100644
--- a/firmware/target/sh/system-target.h
+++ b/firmware/target/sh/system-target.h
@@ -126,4 +126,11 @@ static inline uint32_t swap_odd_even32(uint32_t value)
return value;
}
+extern const unsigned bit_n_table[32];
+#define BIT_N(n) ( \
+ __builtin_constant_p(n) \
+ ? (1LU << (n)) \
+ : bit_n_table[n] \
+)
+
#endif /* SYSTEM_TARGET_H */