]> bbs.cooldavid.org Git - net-next-2.6.git/blame - arch/cris/arch-v32/mach-fs/vcs_hook.c
[CRIS] Move header files from include to arch/cris/include.
[net-next-2.6.git] / arch / cris / arch-v32 / mach-fs / vcs_hook.c
CommitLineData
a474de0a
JN
1/*
2 * Call simulator hook. This is the part running in the
3 * simulated program.
4 */
035e111f
JN
5
6#include "vcs_hook.h"
7#include <stdarg.h>
556dcee7
JN
8#include <arch-v32/hwregs/reg_map.h>
9#include <arch-v32/hwregs/intr_vect_defs.h>
035e111f 10
a474de0a
JN
11#define HOOK_TRIG_ADDR 0xb7000000 /* hook cvlog model reg address */
12#define HOOK_MEM_BASE_ADDR 0xa0000000 /* csp4 (shared mem) base addr */
035e111f 13
a474de0a
JN
14#define HOOK_DATA(offset) ((unsigned *)HOOK_MEM_BASE_ADDR)[offset]
15#define VHOOK_DATA(offset) ((volatile unsigned *)HOOK_MEM_BASE_ADDR)[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_MEM_BASE_ADDR)[offset]
035e111f 21
a474de0a
JN
22int hook_call(unsigned id, unsigned pcnt, ...)
23{
24 va_list ap;
25 unsigned i;
26 unsigned ret;
035e111f 27#ifdef USING_SOS
a474de0a 28 PREEMPT_OFF_SAVE();
035e111f
JN
29#endif
30
a474de0a
JN
31 /* pass parameters */
32 HOOK_DATA(0) = id;
035e111f 33
a474de0a
JN
34 /* Have to make hook_print_str a special case since we call with a
35 * parameter of byte type. Should perhaps be a separate
36 * hook_call. */
035e111f 37
a474de0a
JN
38 if (id == hook_print_str) {
39 int i;
40 char *str;
035e111f 41
a474de0a 42 HOOK_DATA(1) = pcnt;
035e111f 43
a474de0a
JN
44 va_start(ap, pcnt);
45 str = (char *)va_arg(ap, unsigned);
035e111f 46
a474de0a
JN
47 for (i = 0; i != pcnt; i++)
48 HOOK_DATA_BYTE(8 + i) = str[i];
035e111f 49
a474de0a
JN
50 HOOK_DATA_BYTE(8 + i) = 0; /* null byte */
51 } else {
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 }
035e111f 57
a474de0a
JN
58 /* read from mem to make sure data has propagated to memory before
59 * trigging */
60 ret = *((volatile unsigned *)HOOK_MEM_BASE_ADDR);
035e111f 61
a474de0a
JN
62 /* trigger hook */
63 HOOK_TRIG(id);
035e111f 64
a474de0a
JN
65 /* wait for call to finish */
66 while (VHOOK_DATA(0) > 0) ;
035e111f 67
a474de0a
JN
68 /* extract return value */
69
70 ret = VHOOK_DATA(1);
035e111f
JN
71
72#ifdef USING_SOS
a474de0a 73 PREEMPT_RESTORE();
035e111f 74#endif
a474de0a 75 return ret;
035e111f
JN
76}
77
a474de0a 78unsigned hook_buf(unsigned i)
035e111f 79{
a474de0a 80 return (HOOK_DATA(i));
035e111f
JN
81}
82
a474de0a
JN
83void print_str(const char *str)
84{
85 int i;
86 /* find null at end of string */
87 for (i = 1; str[i]; i++) ;
88 hook_call(hook_print_str, i, str);
035e111f
JN
89}
90
a474de0a
JN
91void CPU_KICK_DOG(void)
92{
93 (void)hook_call(hook_kick_dog, 0);
035e111f
JN
94}
95
a474de0a
JN
96void CPU_WATCHDOG_TIMEOUT(unsigned t)
97{
98 (void)hook_call(hook_dog_timeout, 1, t);
035e111f 99}
a474de0a 100