diff options
author | Jesper Nilsson <jesper.nilsson@axis.com> | 2008-01-25 10:43:53 -0500 |
---|---|---|
committer | Jesper Nilsson <jesper.nilsson@axis.com> | 2008-02-08 05:06:35 -0500 |
commit | 09160d7cc39ab1015d23428f3995cd49eacfaebf (patch) | |
tree | 0ccd5233b09297b03a3070e82397de551451be28 | |
parent | 538380da1a41c981c640bd22a091fdfc32d1e81e (diff) |
CRIS v32: Move vcs_hook to machine specific directory.
These files are different for ETRAX FS and ARTPEC-3.
-rw-r--r-- | arch/cris/arch-v32/mach-fs/vcs_hook.c | 128 | ||||
-rw-r--r-- | arch/cris/arch-v32/mach-fs/vcs_hook.h | 8 |
2 files changed, 66 insertions, 70 deletions
diff --git a/arch/cris/arch-v32/mach-fs/vcs_hook.c b/arch/cris/arch-v32/mach-fs/vcs_hook.c index 593b10f07ef1..64d71c54c22c 100644 --- a/arch/cris/arch-v32/mach-fs/vcs_hook.c +++ b/arch/cris/arch-v32/mach-fs/vcs_hook.c | |||
@@ -1,100 +1,96 @@ | |||
1 | /* | 1 | // $Id: vcs_hook.c,v 1.2 2003/08/12 12:01:06 starvik Exp $ |
2 | * Call simulator hook. This is the part running in the | 2 | // |
3 | * simulated program. | 3 | // Call simulator hook. This is the part running in the |
4 | */ | 4 | // simulated program. |
5 | // | ||
5 | 6 | ||
6 | #include "vcs_hook.h" | 7 | #include "vcs_hook.h" |
7 | #include <stdarg.h> | 8 | #include <stdarg.h> |
8 | #include <asm/arch-v32/hwregs/reg_map.h> | 9 | #include <asm/arch-v32/hwregs/reg_map.h> |
9 | #include <asm/arch-v32/hwregs/intr_vect_defs.h> | 10 | #include <asm/arch-v32/hwregs/intr_vect_defs.h> |
10 | 11 | ||
11 | #define HOOK_TRIG_ADDR 0xb7000000 /* hook cvlog model reg address */ | 12 | #define HOOK_TRIG_ADDR 0xb7000000 /* hook cvlog model reg address */ |
12 | #define HOOK_MEM_BASE_ADDR 0xa0000000 /* csp4 (shared mem) base addr */ | 13 | #define HOOK_MEM_BASE_ADDR 0xa0000000 /* csp4 (shared mem) base addr */ |
13 | 14 | ||
14 | #define HOOK_DATA(offset) ((unsigned *)HOOK_MEM_BASE_ADDR)[offset] | 15 | #define HOOK_DATA(offset) ((unsigned*) HOOK_MEM_BASE_ADDR)[offset] |
15 | #define VHOOK_DATA(offset) ((volatile unsigned *)HOOK_MEM_BASE_ADDR)[offset] | 16 | #define VHOOK_DATA(offset) ((volatile unsigned*) HOOK_MEM_BASE_ADDR)[offset] |
16 | #define HOOK_TRIG(funcid) \ | 17 | #define HOOK_TRIG(funcid) do { *((unsigned *) HOOK_TRIG_ADDR) = funcid; } while(0) |
17 | do { \ | 18 | #define HOOK_DATA_BYTE(offset) ((unsigned char*) HOOK_MEM_BASE_ADDR)[offset] |
18 | *((unsigned *) HOOK_TRIG_ADDR) = funcid; \ | ||
19 | } while (0) | ||
20 | #define HOOK_DATA_BYTE(offset) ((unsigned char *)HOOK_MEM_BASE_ADDR)[offset] | ||
21 | 19 | ||
22 | int hook_call(unsigned id, unsigned pcnt, ...) | 20 | |
23 | { | 21 | // ------------------------------------------------------------------ hook_call |
24 | va_list ap; | 22 | int hook_call( unsigned id, unsigned pcnt, ...) { |
25 | unsigned i; | 23 | va_list ap; |
26 | unsigned ret; | 24 | unsigned i; |
25 | unsigned ret; | ||
27 | #ifdef USING_SOS | 26 | #ifdef USING_SOS |
28 | PREEMPT_OFF_SAVE(); | 27 | PREEMPT_OFF_SAVE(); |
29 | #endif | 28 | #endif |
30 | 29 | ||
31 | /* pass parameters */ | 30 | // pass parameters |
32 | HOOK_DATA(0) = id; | 31 | HOOK_DATA(0) = id; |
33 | 32 | ||
34 | /* Have to make hook_print_str a special case since we call with a | 33 | /* Have to make hook_print_str a special case since we call with a |
35 | * parameter of byte type. Should perhaps be a separate | 34 | parameter of byte type. Should perhaps be a separate |
36 | * hook_call. */ | 35 | hook_call. */ |
37 | 36 | ||
38 | if (id == hook_print_str) { | 37 | if (id == hook_print_str) { |
39 | int i; | 38 | int i; |
40 | char *str; | 39 | char *str; |
41 | 40 | ||
42 | HOOK_DATA(1) = pcnt; | 41 | HOOK_DATA(1) = pcnt; |
43 | 42 | ||
44 | va_start(ap, pcnt); | 43 | va_start(ap, pcnt); |
45 | str = (char *)va_arg(ap, unsigned); | 44 | str = (char*)va_arg(ap,unsigned); |
46 | 45 | ||
47 | for (i = 0; i != pcnt; i++) | 46 | for (i=0; i!=pcnt; i++) { |
48 | HOOK_DATA_BYTE(8 + i) = str[i]; | 47 | HOOK_DATA_BYTE(8+i) = str[i]; |
48 | } | ||
49 | HOOK_DATA_BYTE(8+i) = 0; /* null byte */ | ||
50 | } | ||
51 | else { | ||
52 | va_start(ap, pcnt); | ||
53 | for( i = 1; i <= pcnt; i++ ) HOOK_DATA(i) = va_arg(ap,unsigned); | ||
54 | va_end(ap); | ||
55 | } | ||
49 | 56 | ||
50 | HOOK_DATA_BYTE(8 + i) = 0; /* null byte */ | 57 | // read from mem to make sure data has propagated to memory before trigging |
51 | } else { | 58 | *((volatile unsigned*) HOOK_MEM_BASE_ADDR); |
52 | va_start(ap, pcnt); | ||
53 | for (i = 1; i <= pcnt; i++) | ||
54 | HOOK_DATA(i) = va_arg(ap, unsigned); | ||
55 | va_end(ap); | ||
56 | } | ||
57 | 59 | ||
58 | /* read from mem to make sure data has propagated to memory before | 60 | // trigger hook |
59 | * trigging */ | 61 | HOOK_TRIG(id); |
60 | ret = *((volatile unsigned *)HOOK_MEM_BASE_ADDR); | ||
61 | 62 | ||
62 | /* trigger hook */ | 63 | // wait for call to finish |
63 | HOOK_TRIG(id); | 64 | while( VHOOK_DATA(0) > 0 ) {} |
64 | 65 | ||
65 | /* wait for call to finish */ | 66 | // extract return value |
66 | while (VHOOK_DATA(0) > 0) ; | ||
67 | 67 | ||
68 | /* extract return value */ | 68 | ret = VHOOK_DATA(1); |
69 | |||
70 | ret = VHOOK_DATA(1); | ||
71 | 69 | ||
72 | #ifdef USING_SOS | 70 | #ifdef USING_SOS |
73 | PREEMPT_RESTORE(); | 71 | PREEMPT_RESTORE(); |
74 | #endif | 72 | #endif |
75 | return ret; | 73 | return ret; |
76 | } | 74 | } |
77 | 75 | ||
78 | unsigned hook_buf(unsigned i) | 76 | unsigned |
77 | hook_buf(unsigned i) | ||
79 | { | 78 | { |
80 | return (HOOK_DATA(i)); | 79 | return (HOOK_DATA(i)); |
81 | } | 80 | } |
82 | 81 | ||
83 | void print_str(const char *str) | 82 | void print_str( const char *str ) { |
84 | { | 83 | int i; |
85 | int i; | 84 | for (i=1; str[i]; i++); /* find null at end of string */ |
86 | /* find null at end of string */ | 85 | hook_call(hook_print_str, i, str); |
87 | for (i = 1; str[i]; i++) ; | ||
88 | hook_call(hook_print_str, i, str); | ||
89 | } | 86 | } |
90 | 87 | ||
91 | void CPU_KICK_DOG(void) | 88 | // --------------------------------------------------------------- CPU_KICK_DOG |
92 | { | 89 | void CPU_KICK_DOG(void) { |
93 | (void)hook_call(hook_kick_dog, 0); | 90 | (void) hook_call( hook_kick_dog, 0 ); |
94 | } | 91 | } |
95 | 92 | ||
96 | void CPU_WATCHDOG_TIMEOUT(unsigned t) | 93 | // ------------------------------------------------------- CPU_WATCHDOG_TIMEOUT |
97 | { | 94 | void CPU_WATCHDOG_TIMEOUT( unsigned t ) { |
98 | (void)hook_call(hook_dog_timeout, 1, t); | 95 | (void) hook_call( hook_dog_timeout, 1, t ); |
99 | } | 96 | } |
100 | |||
diff --git a/arch/cris/arch-v32/mach-fs/vcs_hook.h b/arch/cris/arch-v32/mach-fs/vcs_hook.h index c000b9fece41..7d73709e3cc6 100644 --- a/arch/cris/arch-v32/mach-fs/vcs_hook.h +++ b/arch/cris/arch-v32/mach-fs/vcs_hook.h | |||
@@ -1,11 +1,11 @@ | |||
1 | /* | 1 | // $Id: vcs_hook.h,v 1.1 2003/08/12 12:01:06 starvik Exp $ |
2 | * Call simulator hook functions | 2 | // |
3 | */ | 3 | // Call simulator hook functions |
4 | 4 | ||
5 | #ifndef HOOK_H | 5 | #ifndef HOOK_H |
6 | #define HOOK_H | 6 | #define HOOK_H |
7 | 7 | ||
8 | int hook_call(unsigned id, unsigned pcnt, ...); | 8 | int hook_call( unsigned id, unsigned pcnt, ...); |
9 | 9 | ||
10 | enum hook_ids { | 10 | enum hook_ids { |
11 | hook_debug_on = 1, | 11 | hook_debug_on = 1, |