[arch] factor out the debug_cycle_count to arch specific code

This commit is contained in:
Travis Geiselbrecht
2009-06-28 12:48:18 -07:00
parent f5afcca893
commit 2d23d7f9e3
12 changed files with 21 additions and 35 deletions

View File

@@ -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

View File

@@ -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);

View File

@@ -76,7 +76,6 @@ void arch_early_init(void)
/* enable cycle counter */
en = (1<<31);
__asm__ volatile("mcr p15, 0, %0, c9, c12, 1" :: "r" (en));
#endif
}

View File

@@ -203,8 +203,12 @@ FUNCTION(arch_switch_stacks_and_call)
mov sp, r1
bx r0
/* 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

View File

@@ -60,3 +60,11 @@ void arch_init(void)
{
}
uint32_t arch_cycle_count(void)
{
uint32_t timestamp;
rdtscl(timestamp);
return timestamp;
}

View File

@@ -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

View File

@@ -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);

View File

@@ -75,7 +75,3 @@ void platform_halt()
for(;;);
}
uint32_t debug_cycle_count()
{
PANIC_UNIMPLEMENTED;
}

View File

@@ -140,7 +140,3 @@ void debug_set_trace_level(int trace_type, int level)
PANIC_UNIMPLEMENTED;
}
uint32_t debug_cycle_count()
{
PANIC_UNIMPLEMENTED;
}

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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;
}