summaryrefslogtreecommitdiff
path: root/firmware/target/mips/ingenic_x1000/system-target.h
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/mips/ingenic_x1000/system-target.h')
-rw-r--r--firmware/target/mips/ingenic_x1000/system-target.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/firmware/target/mips/ingenic_x1000/system-target.h b/firmware/target/mips/ingenic_x1000/system-target.h
index 050afcca9e..45a1eab1ff 100644
--- a/firmware/target/mips/ingenic_x1000/system-target.h
+++ b/firmware/target/mips/ingenic_x1000/system-target.h
@@ -37,6 +37,11 @@
37# define MIPS_CACHEFUNC_ATTR 37# define MIPS_CACHEFUNC_ATTR
38#endif 38#endif
39 39
40#ifdef DEBUG
41/* Define this to get CPU idle stats, visible in the debug menu. */
42# define X1000_CPUIDLE_STATS
43#endif
44
40#include "mmu-mips.h" 45#include "mmu-mips.h"
41#include "mipsregs.h" 46#include "mipsregs.h"
42#include "mipsr2-endian.h" 47#include "mipsr2-endian.h"
@@ -66,16 +71,20 @@ static inline int set_irq_level(int lev)
66 return oldreg; 71 return oldreg;
67} 72}
68 73
74#ifdef X1000_CPUIDLE_STATS
69/* CPU idle stats, updated each kernel tick in kernel-x1000.c */ 75/* CPU idle stats, updated each kernel tick in kernel-x1000.c */
70extern int __cpu_idle_avg; 76extern int __cpu_idle_avg;
71extern int __cpu_idle_cur; 77extern int __cpu_idle_cur;
72extern uint32_t __cpu_idle_ticks; 78extern uint32_t __cpu_idle_ticks;
73extern uint32_t __cpu_idle_reftick; 79extern uint32_t __cpu_idle_reftick;
80#endif
74 81
75static inline uint32_t __ost_read32(void); 82static inline uint32_t __ost_read32(void);
76static inline void core_sleep(void) 83static inline void core_sleep(void)
77{ 84{
85#ifdef X1000_CPUIDLE_STATS
78 uint32_t t1 = __ost_read32(); 86 uint32_t t1 = __ost_read32();
87#endif
79 88
80 __asm__ __volatile__( 89 __asm__ __volatile__(
81 ".set push\n\t" 90 ".set push\n\t"
@@ -90,8 +99,10 @@ static inline void core_sleep(void)
90 ".set pop\n\t" 99 ".set pop\n\t"
91 ::: "t0", "t1", "t2"); 100 ::: "t0", "t1", "t2");
92 101
102#ifdef X1000_CPUIDLE_STATS
93 uint32_t t2 = __ost_read32(); 103 uint32_t t2 = __ost_read32();
94 __cpu_idle_ticks += t2 - t1; 104 __cpu_idle_ticks += t2 - t1;
105#endif
95 106
96 enable_irq(); 107 enable_irq();
97} 108}