Line 21... |
Line 21... |
|
|
typedef unsigned long sprword;
|
typedef unsigned long sprword;
|
|
|
/* Prototypes */
|
/* Prototypes */
|
inline void mtspr(const int regno, const sprword value);
|
inline void mtspr(const int regno, const sprword value);
|
inline sprword mfspr_(const int regno);
|
static inline sprword mfspr_(const int regno);
|
#ifdef DEBUGMOD_OFF
|
#ifdef DEBUGMOD_OFF
|
extern sprword sprs[MAX_SPRS];
|
extern sprword sprs[MAX_SPRS];
|
extern int cont_run; /* defined in toplevel.c */
|
extern int cont_run; /* defined in toplevel.c */
|
#define mfspr(regno)\
|
#define mfspr(regno)\
|
((regno == SPR_SR && temp_disable_except > 0)?(sprs[regno] & ~SPR_SR_EXR)\
|
((regno == SPR_SR && temp_disable_except > 0)?(sprs[regno] & ~SPR_SR_EXR)\
|
Line 34... |
Line 34... |
cont_run = 0))))
|
cont_run = 0))))
|
#else /* DEBUGMOD_OFF */
|
#else /* DEBUGMOD_OFF */
|
#define mfspr(regno) mfspr_(regno)
|
#define mfspr(regno) mfspr_(regno)
|
#endif /* DEBUGMOD_OFF */
|
#endif /* DEBUGMOD_OFF */
|
|
|
inline void setsprbit(const int regno, const int bitnum, const unsigned long bitvalue);
|
static inline void setsprbit(const int regno, const int bitnum, const unsigned long bitvalue);
|
inline int getsprbit(const int regno, const int bitnum);
|
static inline int getsprbit(const int regno, const int bitnum);
|
void sprs_status();
|
void sprs_status();
|
|
|
#include "sim-config.h"
|
#include "sim-config.h"
|
|
|
/* Ugly, but fast */
|
/* Ugly, but fast */
|
Line 70... |
Line 70... |
if (config.sim.verbose)
|
if (config.sim.verbose)
|
printf ("WARNING: read out of SPR range %08X\n", regno);
|
printf ("WARNING: read out of SPR range %08X\n", regno);
|
return 0;
|
return 0;
|
}
|
}
|
|
|
No newline at end of file
|
No newline at end of file
|
|
/* Set specific SPR bit(s) identified by mask. */
|
|
static inline void
|
|
setsprbits(const int regno, const unsigned long mask, const unsigned long value)
|
|
{
|
|
sprword regvalue = mfspr(regno);
|
|
sprword shifted = 0x0;
|
|
int m, v = 0;
|
|
|
|
/* m counts bits in valuemask */
|
|
/* v counts bits in value */
|
|
for (m = 0; m < 32; m++)
|
|
if ((mask >> m) & 0x1) {
|
|
shifted |= ((value >> v) & 0x1) << m;
|
|
v++;
|
|
}
|
|
|
|
/* printf("oldvalue %x setsprbits(%x, %x, %x) shifted %x", regvalue, regno, mask, value, shifted); */
|
|
mtspr(regno, (regvalue & ~mask) | shifted);
|
|
|
|
return;
|
|
}
|
|
|
|
/* Get specific SPR bit(s) identified by mask. */
|
|
static inline unsigned long
|
|
getsprbits(const int regno, const unsigned long mask)
|
|
{
|
|
sprword regvalue = mfspr(regno);
|
|
sprword shifted = 0x0;
|
|
int m, v = 0;
|
|
|
|
/* m counts bits in valuemask */
|
|
/* v counts bits in regvalue */
|
|
for (m = 0; m < 32; m++)
|
|
if ((mask >> m) & 0x1) {
|
|
shifted |= ((regvalue >> m) & 0x1) << v;
|
|
v++;
|
|
}
|
|
|
|
return shifted;
|
|
}
|
|
|
|
/* Set a specific bit from SPR. LSB in a word is numbered zero. */
|
|
static inline void
|
|
setsprbit(const int regno, const int bitnum, const unsigned long bitvalue)
|
|
{
|
|
sprword mask;
|
|
sprword regvalue = mfspr(regno);
|
|
|
|
mask = ~(1 << bitnum);
|
|
|
|
mtspr(regno, (regvalue & mask) | ((bitvalue & 0x1) << bitnum));
|
|
|
|
return;
|
|
}
|
|
|
|
/* Get a specific bit from SPR. */
|
|
static inline int
|
|
getsprbit(const int regno, const int bitnum)
|
|
{
|
|
sprword regvalue = mfspr(regno);
|
|
|
|
return (regvalue >> bitnum) & 0x1;
|
|
}
|
|
|
|
/* Get specific SPR bit(s) identified by mask. */
|
|
static inline unsigned long
|
|
testsprbits(const int regno, const unsigned long mask)
|
|
{
|
|
sprword regvalue = mfspr(regno);
|
|
return regvalue & mask;
|
|
}
|
|
|
|
|
No newline at end of file
|
No newline at end of file
|