[arch] factor out the debug_cycle_count to arch specific code
Conflicts: arch/arm/ops.S Change-Id: Id0d9baa3e669cc59822819c797ce913dba1606d6
This commit is contained in:
1 parent
2ce7b9713b
commit
ca0b6a2d2f
12 files changed
+40
-32
No files matched your search
+2
-2
@@ -29,8 +29,8 @@
|
||||
#include <lib/console.h>
|
||||
|
||||
STATIC_COMMAND_START
|
||||
{ "printf_tests", NULL, (console_cmd)&printf_tests },
|
||||
{ "thread_tests", NULL, (console_cmd)&thread_tests },
|
||||
STATIC_COMMAND("printf_tests", NULL, (console_cmd)&printf_tests)
|
||||
STATIC_COMMAND("thread_tests", NULL, (console_cmd)&thread_tests)
|
||||
STATIC_COMMAND_END(tests);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -221,11 +221,11 @@ static int context_switch_tester(void *arg)
|
||||
|
||||
event_wait(&context_switch_event);
|
||||
|
||||
uint count = debug_cycle_count();
|
||||
uint count = arch_cycle_count();
|
||||
for (i = 0; i < iter; i++) {
|
||||
thread_yield();
|
||||
}
|
||||
total_count += debug_cycle_count() - count;
|
||||
total_count += arch_cycle_count() - count;
|
||||
thread_sleep(1000);
|
||||
printf("took %u cycles to yield %d times, %u per yield, %u per yield per thread\n",
|
||||
total_count, iter, total_count / iter, total_count / iter / thread_count);
|
||||
|
||||
@@ -64,6 +64,19 @@ void arch_early_init(void)
|
||||
val = (1<<30);
|
||||
__asm__ volatile("mcr p10, 7, %0, c8, c0, 0" :: "r" (val));
|
||||
#endif
|
||||
|
||||
#if ARM_CPU_CORTEX_A8
|
||||
/* enable the cycle count register */
|
||||
uint32_t en;
|
||||
__asm__ volatile("mrc p15, 0, %0, c9, c12, 0" : "=r" (en));
|
||||
en &= ~(1<<3); /* cycle count every cycle */
|
||||
en |= 1; /* enable all performance counters */
|
||||
__asm__ volatile("mcr p15, 0, %0, c9, c12, 0" :: "r" (en));
|
||||
|
||||
/* enable cycle counter */
|
||||
en = (1<<31);
|
||||
__asm__ volatile("mcr p15, 0, %0, c9, c12, 1" :: "r" (en));
|
||||
#endif
|
||||
}
|
||||
|
||||
void arch_init(void)
|
||||
|
||||
@@ -221,3 +221,15 @@ FUNCTION(dsb)
|
||||
mcr p15, 0, r0, c7, c10, 4
|
||||
#endif
|
||||
bx lr
|
||||
|
||||
/* uint32_t arm_read_cycle_count(void); */
|
||||
FUNCTION(arm_read_cycle_count)
|
||||
|
||||
/* uint32_t arch_cycle_count(void); */
|
||||
FUNCTION(arch_cycle_count)
|
||||
#if ARM_CPU_CORTEX_A8
|
||||
mrc p15, 0, r0, c9, c13, 0
|
||||
#else
|
||||
mov r0, #0
|
||||
#endif
|
||||
bx lr
|
||||
@@ -60,3 +60,11 @@ void arch_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
uint32_t arch_cycle_count(void)
|
||||
{
|
||||
uint32_t timestamp;
|
||||
rdtscl(timestamp);
|
||||
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
@@ -58,6 +58,8 @@ void arch_disable_mmu(void);
|
||||
|
||||
void arch_switch_stacks_and_call(addr_t call, addr_t stack) __NO_RETURN;
|
||||
|
||||
uint32_t arch_cycle_count(void);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -32,7 +32,6 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
void debug_dump_regs(void);
|
||||
uint32_t debug_cycle_count(void);
|
||||
|
||||
void debug_dump_memory_bytes(void *mem, int len);
|
||||
void debug_dump_memory_halfwords(void *mem, int len);
|
||||
|
||||
@@ -75,7 +75,3 @@ void platform_halt()
|
||||
for(;;);
|
||||
}
|
||||
|
||||
uint32_t debug_cycle_count()
|
||||
{
|
||||
PANIC_UNIMPLEMENTED;
|
||||
}
|
||||
@@ -140,7 +140,3 @@ void debug_set_trace_level(int trace_type, int level)
|
||||
PANIC_UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
uint32_t debug_cycle_count()
|
||||
{
|
||||
PANIC_UNIMPLEMENTED;
|
||||
}
|
||||
@@ -79,8 +79,3 @@ void debug_set_trace_level(int trace_type, int level)
|
||||
PANIC_UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
uint32_t debug_cycle_count(void)
|
||||
{
|
||||
// PANIC_UNIMPLEMENTED;
|
||||
return 0;
|
||||
}
|
||||
@@ -150,12 +150,6 @@ void debug_set_trace_level(int trace_type, int level)
|
||||
PANIC_UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
uint32_t debug_cycle_count(void)
|
||||
{
|
||||
// PANIC_UNIMPLEMENTED;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void platform_init_debug(void)
|
||||
{
|
||||
cbuf_initialize(&debug_buf, 512);
|
||||
|
||||
+1
-8
@@ -35,7 +35,7 @@ void _dputc(char c)
|
||||
cputc(c);
|
||||
}
|
||||
|
||||
int dgetc(char *c)
|
||||
int dgetc(char *c, bool wait)
|
||||
{
|
||||
int ret = platform_read_key(c);
|
||||
if (ret < 0)
|
||||
@@ -72,10 +72,3 @@ void debug_set_trace_level(int trace_type, int level)
|
||||
{
|
||||
}
|
||||
|
||||
uint32_t debug_cycle_count()
|
||||
{
|
||||
uint32_t timestamp;
|
||||
rdtscl(timestamp);
|
||||
|
||||
return timestamp;
|
||||
}
|
||||
Reference in new issue
Block a user