Path: blob/master/arch/cris/arch-v32/mach-a3/vcs_hook.c
15125 views
/*1* Simulator hook mechanism2*/34#include "vcs_hook.h"5#include <asm/io.h>6#include <stdarg.h>78#define HOOK_TRIG_ADDR 0xb70000009#define HOOK_MEM_BASE_ADDR 0xce0000001011static volatile unsigned *hook_base;1213#define HOOK_DATA(offset) hook_base[offset]14#define VHOOK_DATA(offset) hook_base[offset]15#define HOOK_TRIG(funcid) \16do { \17*((unsigned *) HOOK_TRIG_ADDR) = funcid; \18} while (0)19#define HOOK_DATA_BYTE(offset) ((unsigned char *)hook_base)[offset]2021static void hook_init(void)22{23static int first = 1;24if (first) {25first = 0;26hook_base = ioremap(HOOK_MEM_BASE_ADDR, 8192);27}28}2930static unsigned hook_trig(unsigned id)31{32unsigned ret;3334/* preempt_disable(); */3536/* Dummy read from mem to make sure data has propagated to memory37* before trigging */38ret = *hook_base;3940/* trigger hook */41HOOK_TRIG(id);4243/* wait for call to finish */44while (VHOOK_DATA(0) > 0) ;4546/* extract return value */4748ret = VHOOK_DATA(1);4950return ret;51}5253int hook_call(unsigned id, unsigned pcnt, ...)54{55va_list ap;56int i;57unsigned ret;5859hook_init();6061HOOK_DATA(0) = id;6263va_start(ap, pcnt);64for (i = 1; i <= pcnt; i++)65HOOK_DATA(i) = va_arg(ap, unsigned);66va_end(ap);6768ret = hook_trig(id);6970return ret;71}7273int hook_call_str(unsigned id, unsigned size, const char *str)74{75int i;76unsigned ret;7778hook_init();7980HOOK_DATA(0) = id;81HOOK_DATA(1) = size;8283for (i = 0; i < size; i++)84HOOK_DATA_BYTE(8 + i) = str[i];85HOOK_DATA_BYTE(8 + i) = 0;8687ret = hook_trig(id);8889return ret;90}9192void print_str(const char *str)93{94int i;95/* find null at end of string */96for (i = 1; str[i]; i++) ;97hook_call(hook_print_str, i, str);98}99100void CPU_WATCHDOG_TIMEOUT(unsigned t)101{102}103104105