diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
commit | fcc9d2e5a6c89d22b8b773a64fb4ad21ac318446 (patch) | |
tree | a57612d1888735a2ec7972891b68c1ac5ec8faea /arch/cris/arch-v32/mach-a3 | |
parent | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (diff) |
Diffstat (limited to 'arch/cris/arch-v32/mach-a3')
-rw-r--r-- | arch/cris/arch-v32/mach-a3/vcs_hook.c | 103 | ||||
-rw-r--r-- | arch/cris/arch-v32/mach-a3/vcs_hook.h | 58 |
2 files changed, 161 insertions, 0 deletions
diff --git a/arch/cris/arch-v32/mach-a3/vcs_hook.c b/arch/cris/arch-v32/mach-a3/vcs_hook.c new file mode 100644 index 00000000000..58b1a5469fd --- /dev/null +++ b/arch/cris/arch-v32/mach-a3/vcs_hook.c | |||
@@ -0,0 +1,103 @@ | |||
1 | /* | ||
2 | * Simulator hook mechanism | ||
3 | */ | ||
4 | |||
5 | #include "vcs_hook.h" | ||
6 | #include <asm/io.h> | ||
7 | #include <stdarg.h> | ||
8 | |||
9 | #define HOOK_TRIG_ADDR 0xb7000000 | ||
10 | #define HOOK_MEM_BASE_ADDR 0xce000000 | ||
11 | |||
12 | static volatile unsigned *hook_base; | ||
13 | |||
14 | #define HOOK_DATA(offset) hook_base[offset] | ||
15 | #define VHOOK_DATA(offset) hook_base[offset] | ||
16 | #define HOOK_TRIG(funcid) \ | ||
17 | do { \ | ||
18 | *((unsigned *) HOOK_TRIG_ADDR) = funcid; \ | ||
19 | } while (0) | ||
20 | #define HOOK_DATA_BYTE(offset) ((unsigned char *)hook_base)[offset] | ||
21 | |||
22 | static void hook_init(void) | ||
23 | { | ||
24 | static int first = 1; | ||
25 | if (first) { | ||
26 | first = 0; | ||
27 | hook_base = ioremap(HOOK_MEM_BASE_ADDR, 8192); | ||
28 | } | ||
29 | } | ||
30 | |||
31 | static unsigned hook_trig(unsigned id) | ||
32 | { | ||
33 | unsigned ret; | ||
34 | |||
35 | /* preempt_disable(); */ | ||
36 | |||
37 | /* Dummy read from mem to make sure data has propagated to memory | ||
38 | * before trigging */ | ||
39 | ret = *hook_base; | ||
40 | |||
41 | /* trigger hook */ | ||
42 | HOOK_TRIG(id); | ||
43 | |||
44 | /* wait for call to finish */ | ||
45 | while (VHOOK_DATA(0) > 0) ; | ||
46 | |||
47 | /* extract return value */ | ||
48 | |||
49 | ret = VHOOK_DATA(1); | ||
50 | |||
51 | return ret; | ||
52 | } | ||
53 | |||
54 | int hook_call(unsigned id, unsigned pcnt, ...) | ||
55 | { | ||
56 | va_list ap; | ||
57 | int i; | ||
58 | unsigned ret; | ||
59 | |||
60 | hook_init(); | ||
61 | |||
62 | HOOK_DATA(0) = id; | ||
63 | |||
64 | va_start(ap, pcnt); | ||
65 | for (i = 1; i <= pcnt; i++) | ||
66 | HOOK_DATA(i) = va_arg(ap, unsigned); | ||
67 | va_end(ap); | ||
68 | |||
69 | ret = hook_trig(id); | ||
70 | |||
71 | return ret; | ||
72 | } | ||
73 | |||
74 | int hook_call_str(unsigned id, unsigned size, const char *str) | ||
75 | { | ||
76 | int i; | ||
77 | unsigned ret; | ||
78 | |||
79 | hook_init(); | ||
80 | |||
81 | HOOK_DATA(0) = id; | ||
82 | HOOK_DATA(1) = size; | ||
83 | |||
84 | for (i = 0; i < size; i++) | ||
85 | HOOK_DATA_BYTE(8 + i) = str[i]; | ||
86 | HOOK_DATA_BYTE(8 + i) = 0; | ||
87 | |||
88 | ret = hook_trig(id); | ||
89 | |||
90 | return ret; | ||
91 | } | ||
92 | |||
93 | void print_str(const char *str) | ||
94 | { | ||
95 | int i; | ||
96 | /* find null at end of string */ | ||
97 | for (i = 1; str[i]; i++) ; | ||
98 | hook_call(hook_print_str, i, str); | ||
99 | } | ||
100 | |||
101 | void CPU_WATCHDOG_TIMEOUT(unsigned t) | ||
102 | { | ||
103 | } | ||
diff --git a/arch/cris/arch-v32/mach-a3/vcs_hook.h b/arch/cris/arch-v32/mach-a3/vcs_hook.h new file mode 100644 index 00000000000..8b73d0e8392 --- /dev/null +++ b/arch/cris/arch-v32/mach-a3/vcs_hook.h | |||
@@ -0,0 +1,58 @@ | |||
1 | /* | ||
2 | * Simulator hook call mechanism | ||
3 | */ | ||
4 | |||
5 | #ifndef __hook_h__ | ||
6 | #define __hook_h__ | ||
7 | |||
8 | int hook_call(unsigned id, unsigned pcnt, ...); | ||
9 | int hook_call_str(unsigned id, unsigned size, const char *str); | ||
10 | |||
11 | enum hook_ids { | ||
12 | hook_debug_on = 1, | ||
13 | hook_debug_off, | ||
14 | hook_stop_sim_ok, | ||
15 | hook_stop_sim_fail, | ||
16 | hook_alloc_shared, | ||
17 | hook_ptr_shared, | ||
18 | hook_free_shared, | ||
19 | hook_file2shared, | ||
20 | hook_cmp_shared, | ||
21 | hook_print_params, | ||
22 | hook_sim_time, | ||
23 | hook_stop_sim, | ||
24 | hook_kick_dog, | ||
25 | hook_dog_timeout, | ||
26 | hook_rand, | ||
27 | hook_srand, | ||
28 | hook_rand_range, | ||
29 | hook_print_str, | ||
30 | hook_print_hex, | ||
31 | hook_cmp_offset_shared, | ||
32 | hook_fill_random_shared, | ||
33 | hook_alloc_random_data, | ||
34 | hook_calloc_random_data, | ||
35 | hook_print_int, | ||
36 | hook_print_uint, | ||
37 | hook_fputc, | ||
38 | hook_init_fd, | ||
39 | hook_sbrk, | ||
40 | hook_print_context_descr, | ||
41 | hook_print_data_descr, | ||
42 | hook_print_group_descr, | ||
43 | hook_fill_shared, | ||
44 | hook_sl_srand, | ||
45 | hook_sl_rand_irange, | ||
46 | hook_sl_rand_urange, | ||
47 | hook_sl_sh_malloc_aligned, | ||
48 | hook_sl_sh_calloc_aligned, | ||
49 | hook_sl_sh_alloc_random_data, | ||
50 | hook_sl_sh_file2mem, | ||
51 | hook_sl_vera_mbox_handle, | ||
52 | hook_sl_vera_mbox_put, | ||
53 | hook_sl_vera_mbox_get, | ||
54 | hook_sl_system, | ||
55 | hook_sl_sh_hexdump | ||
56 | }; | ||
57 | |||
58 | #endif | ||