Loading arch/cris/arch-v32/mach-fs/vcs_hook.c +62 −66 Original line number Diff line number Diff line /* * Call simulator hook. This is the part running in the * simulated program. */ // $Id: vcs_hook.c,v 1.2 2003/08/12 12:01:06 starvik Exp $ // // Call simulator hook. This is the part running in the // simulated program. // #include "vcs_hook.h" #include <stdarg.h> Loading @@ -13,14 +14,12 @@ #define HOOK_DATA(offset) ((unsigned*) HOOK_MEM_BASE_ADDR)[offset] #define VHOOK_DATA(offset) ((volatile unsigned*) HOOK_MEM_BASE_ADDR)[offset] #define HOOK_TRIG(funcid) \ do { \ *((unsigned *) HOOK_TRIG_ADDR) = funcid; \ } while (0) #define HOOK_TRIG(funcid) do { *((unsigned *) HOOK_TRIG_ADDR) = funcid; } while(0) #define HOOK_DATA_BYTE(offset) ((unsigned char*) HOOK_MEM_BASE_ADDR)[offset] int hook_call(unsigned id, unsigned pcnt, ...) { // ------------------------------------------------------------------ hook_call int hook_call( unsigned id, unsigned pcnt, ...) { va_list ap; unsigned i; unsigned ret; Loading @@ -28,12 +27,12 @@ int hook_call(unsigned id, unsigned pcnt, ...) PREEMPT_OFF_SAVE(); #endif /* pass parameters */ // pass parameters HOOK_DATA(0) = id; /* Have to make hook_print_str a special case since we call with a * parameter of byte type. Should perhaps be a separate * hook_call. */ parameter of byte type. Should perhaps be a separate hook_call. */ if (id == hook_print_str) { int i; Loading @@ -44,28 +43,27 @@ int hook_call(unsigned id, unsigned pcnt, ...) va_start(ap, pcnt); str = (char*)va_arg(ap,unsigned); for (i = 0; i != pcnt; i++) for (i=0; i!=pcnt; i++) { HOOK_DATA_BYTE(8+i) = str[i]; } HOOK_DATA_BYTE(8+i) = 0; /* null byte */ } else { } else { va_start(ap, pcnt); for (i = 1; i <= pcnt; i++) HOOK_DATA(i) = va_arg(ap, unsigned); for( i = 1; i <= pcnt; i++ ) HOOK_DATA(i) = va_arg(ap,unsigned); va_end(ap); } /* read from mem to make sure data has propagated to memory before * trigging */ ret = *((volatile unsigned *)HOOK_MEM_BASE_ADDR); // read from mem to make sure data has propagated to memory before trigging *((volatile unsigned*) HOOK_MEM_BASE_ADDR); /* trigger hook */ // trigger hook HOOK_TRIG(id); /* wait for call to finish */ while (VHOOK_DATA(0) > 0) ; // wait for call to finish while( VHOOK_DATA(0) > 0 ) {} /* extract return value */ // extract return value ret = VHOOK_DATA(1); Loading @@ -75,26 +73,24 @@ int hook_call(unsigned id, unsigned pcnt, ...) return ret; } unsigned hook_buf(unsigned i) unsigned hook_buf(unsigned i) { return (HOOK_DATA(i)); } void print_str(const char *str) { void print_str( const char *str ) { int i; /* find null at end of string */ for (i = 1; str[i]; i++) ; for (i=1; str[i]; i++); /* find null at end of string */ hook_call(hook_print_str, i, str); } void CPU_KICK_DOG(void) { // --------------------------------------------------------------- CPU_KICK_DOG void CPU_KICK_DOG(void) { (void) hook_call( hook_kick_dog, 0 ); } void CPU_WATCHDOG_TIMEOUT(unsigned t) { // ------------------------------------------------------- CPU_WATCHDOG_TIMEOUT void CPU_WATCHDOG_TIMEOUT( unsigned t ) { (void) hook_call( hook_dog_timeout, 1, t ); } arch/cris/arch-v32/mach-fs/vcs_hook.h +4 −4 Original line number Diff line number Diff line /* * Call simulator hook functions */ // $Id: vcs_hook.h,v 1.1 2003/08/12 12:01:06 starvik Exp $ // // Call simulator hook functions #ifndef HOOK_H #define HOOK_H Loading Loading
arch/cris/arch-v32/mach-fs/vcs_hook.c +62 −66 Original line number Diff line number Diff line /* * Call simulator hook. This is the part running in the * simulated program. */ // $Id: vcs_hook.c,v 1.2 2003/08/12 12:01:06 starvik Exp $ // // Call simulator hook. This is the part running in the // simulated program. // #include "vcs_hook.h" #include <stdarg.h> Loading @@ -13,14 +14,12 @@ #define HOOK_DATA(offset) ((unsigned*) HOOK_MEM_BASE_ADDR)[offset] #define VHOOK_DATA(offset) ((volatile unsigned*) HOOK_MEM_BASE_ADDR)[offset] #define HOOK_TRIG(funcid) \ do { \ *((unsigned *) HOOK_TRIG_ADDR) = funcid; \ } while (0) #define HOOK_TRIG(funcid) do { *((unsigned *) HOOK_TRIG_ADDR) = funcid; } while(0) #define HOOK_DATA_BYTE(offset) ((unsigned char*) HOOK_MEM_BASE_ADDR)[offset] int hook_call(unsigned id, unsigned pcnt, ...) { // ------------------------------------------------------------------ hook_call int hook_call( unsigned id, unsigned pcnt, ...) { va_list ap; unsigned i; unsigned ret; Loading @@ -28,12 +27,12 @@ int hook_call(unsigned id, unsigned pcnt, ...) PREEMPT_OFF_SAVE(); #endif /* pass parameters */ // pass parameters HOOK_DATA(0) = id; /* Have to make hook_print_str a special case since we call with a * parameter of byte type. Should perhaps be a separate * hook_call. */ parameter of byte type. Should perhaps be a separate hook_call. */ if (id == hook_print_str) { int i; Loading @@ -44,28 +43,27 @@ int hook_call(unsigned id, unsigned pcnt, ...) va_start(ap, pcnt); str = (char*)va_arg(ap,unsigned); for (i = 0; i != pcnt; i++) for (i=0; i!=pcnt; i++) { HOOK_DATA_BYTE(8+i) = str[i]; } HOOK_DATA_BYTE(8+i) = 0; /* null byte */ } else { } else { va_start(ap, pcnt); for (i = 1; i <= pcnt; i++) HOOK_DATA(i) = va_arg(ap, unsigned); for( i = 1; i <= pcnt; i++ ) HOOK_DATA(i) = va_arg(ap,unsigned); va_end(ap); } /* read from mem to make sure data has propagated to memory before * trigging */ ret = *((volatile unsigned *)HOOK_MEM_BASE_ADDR); // read from mem to make sure data has propagated to memory before trigging *((volatile unsigned*) HOOK_MEM_BASE_ADDR); /* trigger hook */ // trigger hook HOOK_TRIG(id); /* wait for call to finish */ while (VHOOK_DATA(0) > 0) ; // wait for call to finish while( VHOOK_DATA(0) > 0 ) {} /* extract return value */ // extract return value ret = VHOOK_DATA(1); Loading @@ -75,26 +73,24 @@ int hook_call(unsigned id, unsigned pcnt, ...) return ret; } unsigned hook_buf(unsigned i) unsigned hook_buf(unsigned i) { return (HOOK_DATA(i)); } void print_str(const char *str) { void print_str( const char *str ) { int i; /* find null at end of string */ for (i = 1; str[i]; i++) ; for (i=1; str[i]; i++); /* find null at end of string */ hook_call(hook_print_str, i, str); } void CPU_KICK_DOG(void) { // --------------------------------------------------------------- CPU_KICK_DOG void CPU_KICK_DOG(void) { (void) hook_call( hook_kick_dog, 0 ); } void CPU_WATCHDOG_TIMEOUT(unsigned t) { // ------------------------------------------------------- CPU_WATCHDOG_TIMEOUT void CPU_WATCHDOG_TIMEOUT( unsigned t ) { (void) hook_call( hook_dog_timeout, 1, t ); }
arch/cris/arch-v32/mach-fs/vcs_hook.h +4 −4 Original line number Diff line number Diff line /* * Call simulator hook functions */ // $Id: vcs_hook.h,v 1.1 2003/08/12 12:01:06 starvik Exp $ // // Call simulator hook functions #ifndef HOOK_H #define HOOK_H Loading