CRIS v32: Move vcs_hook to machine specific directory.
These files are different for ETRAX FS and ARTPEC-3.
This commit is contained in:
parent
538380da1a
commit
09160d7cc3
2 changed files with 66 additions and 70 deletions
|
@ -1,100 +1,96 @@
|
||||||
/*
|
// $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.
|
// Call simulator hook. This is the part running in the
|
||||||
*/
|
// simulated program.
|
||||||
|
//
|
||||||
|
|
||||||
#include "vcs_hook.h"
|
#include "vcs_hook.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <asm/arch-v32/hwregs/reg_map.h>
|
#include <asm/arch-v32/hwregs/reg_map.h>
|
||||||
#include <asm/arch-v32/hwregs/intr_vect_defs.h>
|
#include <asm/arch-v32/hwregs/intr_vect_defs.h>
|
||||||
|
|
||||||
#define HOOK_TRIG_ADDR 0xb7000000 /* hook cvlog model reg address */
|
#define HOOK_TRIG_ADDR 0xb7000000 /* hook cvlog model reg address */
|
||||||
#define HOOK_MEM_BASE_ADDR 0xa0000000 /* csp4 (shared mem) base addr */
|
#define HOOK_MEM_BASE_ADDR 0xa0000000 /* csp4 (shared mem) base addr */
|
||||||
|
|
||||||
#define HOOK_DATA(offset) ((unsigned *)HOOK_MEM_BASE_ADDR)[offset]
|
#define HOOK_DATA(offset) ((unsigned*) HOOK_MEM_BASE_ADDR)[offset]
|
||||||
#define VHOOK_DATA(offset) ((volatile unsigned *)HOOK_MEM_BASE_ADDR)[offset]
|
#define VHOOK_DATA(offset) ((volatile unsigned*) HOOK_MEM_BASE_ADDR)[offset]
|
||||||
#define HOOK_TRIG(funcid) \
|
#define HOOK_TRIG(funcid) do { *((unsigned *) HOOK_TRIG_ADDR) = funcid; } while(0)
|
||||||
do { \
|
#define HOOK_DATA_BYTE(offset) ((unsigned char*) HOOK_MEM_BASE_ADDR)[offset]
|
||||||
*((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
|
||||||
va_list ap;
|
int hook_call( unsigned id, unsigned pcnt, ...) {
|
||||||
unsigned i;
|
va_list ap;
|
||||||
unsigned ret;
|
unsigned i;
|
||||||
|
unsigned ret;
|
||||||
#ifdef USING_SOS
|
#ifdef USING_SOS
|
||||||
PREEMPT_OFF_SAVE();
|
PREEMPT_OFF_SAVE();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* pass parameters */
|
// pass parameters
|
||||||
HOOK_DATA(0) = id;
|
HOOK_DATA(0) = id;
|
||||||
|
|
||||||
/* Have to make hook_print_str a special case since we call with a
|
/* Have to make hook_print_str a special case since we call with a
|
||||||
* parameter of byte type. Should perhaps be a separate
|
parameter of byte type. Should perhaps be a separate
|
||||||
* hook_call. */
|
hook_call. */
|
||||||
|
|
||||||
if (id == hook_print_str) {
|
if (id == hook_print_str) {
|
||||||
int i;
|
int i;
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
HOOK_DATA(1) = pcnt;
|
HOOK_DATA(1) = pcnt;
|
||||||
|
|
||||||
va_start(ap, pcnt);
|
va_start(ap, pcnt);
|
||||||
str = (char *)va_arg(ap, unsigned);
|
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) = str[i];
|
||||||
|
}
|
||||||
|
HOOK_DATA_BYTE(8+i) = 0; /* null byte */
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
va_start(ap, pcnt);
|
||||||
|
for( i = 1; i <= pcnt; i++ ) HOOK_DATA(i) = va_arg(ap,unsigned);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
HOOK_DATA_BYTE(8 + i) = 0; /* null byte */
|
// read from mem to make sure data has propagated to memory before trigging
|
||||||
} else {
|
*((volatile unsigned*) HOOK_MEM_BASE_ADDR);
|
||||||
va_start(ap, pcnt);
|
|
||||||
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
|
// trigger hook
|
||||||
* trigging */
|
HOOK_TRIG(id);
|
||||||
ret = *((volatile unsigned *)HOOK_MEM_BASE_ADDR);
|
|
||||||
|
|
||||||
/* trigger hook */
|
// wait for call to finish
|
||||||
HOOK_TRIG(id);
|
while( VHOOK_DATA(0) > 0 ) {}
|
||||||
|
|
||||||
/* wait for call to finish */
|
// extract return value
|
||||||
while (VHOOK_DATA(0) > 0) ;
|
|
||||||
|
|
||||||
/* extract return value */
|
ret = VHOOK_DATA(1);
|
||||||
|
|
||||||
ret = VHOOK_DATA(1);
|
|
||||||
|
|
||||||
#ifdef USING_SOS
|
#ifdef USING_SOS
|
||||||
PREEMPT_RESTORE();
|
PREEMPT_RESTORE();
|
||||||
#endif
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned hook_buf(unsigned i)
|
unsigned
|
||||||
|
hook_buf(unsigned i)
|
||||||
{
|
{
|
||||||
return (HOOK_DATA(i));
|
return (HOOK_DATA(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_str(const char *str)
|
void print_str( const char *str ) {
|
||||||
{
|
int i;
|
||||||
int i;
|
for (i=1; str[i]; i++); /* find null at end of string */
|
||||||
/* find null at end of string */
|
hook_call(hook_print_str, i, str);
|
||||||
for (i = 1; str[i]; i++) ;
|
|
||||||
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) 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);
|
(void) hook_call( hook_dog_timeout, 1, t );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*
|
// $Id: vcs_hook.h,v 1.1 2003/08/12 12:01:06 starvik Exp $
|
||||||
* Call simulator hook functions
|
//
|
||||||
*/
|
// Call simulator hook functions
|
||||||
|
|
||||||
#ifndef HOOK_H
|
#ifndef HOOK_H
|
||||||
#define HOOK_H
|
#define HOOK_H
|
||||||
|
|
||||||
int hook_call(unsigned id, unsigned pcnt, ...);
|
int hook_call( unsigned id, unsigned pcnt, ...);
|
||||||
|
|
||||||
enum hook_ids {
|
enum hook_ids {
|
||||||
hook_debug_on = 1,
|
hook_debug_on = 1,
|
||||||
|
|
Loading…
Add table
Reference in a new issue