Line 62... |
Line 62... |
|
|
/* Set specific SPR bit(s) identified by mask. */
|
/* Set specific SPR bit(s) identified by mask. */
|
static inline void
|
static inline void
|
setsprbits(const int regno, const unsigned long mask, const unsigned long value)
|
setsprbits(const int regno, const unsigned long mask, const unsigned long value)
|
{
|
{
|
sprword regvalue = mfspr(regno);
|
sprword regvalue = cpu_state.sprs[regno];
|
sprword shifted = 0x0;
|
sprword shifted = 0x0;
|
int m, v = 0;
|
int m, v = 0;
|
|
|
/* m counts bits in valuemask */
|
/* m counts bits in valuemask */
|
/* v counts bits in value */
|
/* v counts bits in value */
|
Line 75... |
Line 75... |
shifted |= ((value >> v) & 0x1) << m;
|
shifted |= ((value >> v) & 0x1) << m;
|
v++;
|
v++;
|
}
|
}
|
|
|
/* PRINTF("oldvalue %x setsprbits(%x, %x, %x) shifted %x", regvalue, regno, mask, value, shifted); */
|
/* PRINTF("oldvalue %x setsprbits(%x, %x, %x) shifted %x", regvalue, regno, mask, value, shifted); */
|
mtspr(regno, (regvalue & ~mask) | shifted);
|
cpu_state.sprs[regno] = (regvalue & ~mask) | shifted;
|
}
|
}
|
|
|
/* Get specific SPR bit(s) identified by mask. */
|
/* Get specific SPR bit(s) identified by mask. */
|
static inline unsigned long
|
static inline unsigned long
|
getsprbits(const int regno, const unsigned long mask)
|
getsprbits(const int regno, const unsigned long mask)
|
{
|
{
|
sprword regvalue = mfspr(regno);
|
sprword regvalue = cpu_state.sprs[regno];
|
sprword shifted = 0x0;
|
sprword shifted = 0x0;
|
int m, v = 0;
|
int m, v = 0;
|
|
|
/* m counts bits in valuemask */
|
/* m counts bits in valuemask */
|
/* v counts bits in regvalue */
|
/* v counts bits in regvalue */
|
Line 102... |
Line 102... |
/* Set a specific bit from SPR. LSB in a word is numbered zero. */
|
/* Set a specific bit from SPR. LSB in a word is numbered zero. */
|
static inline void
|
static inline void
|
setsprbit(const int regno, const int bitnum, const unsigned long bitvalue)
|
setsprbit(const int regno, const int bitnum, const unsigned long bitvalue)
|
{
|
{
|
sprword mask;
|
sprword mask;
|
sprword regvalue = mfspr(regno);
|
sprword regvalue = cpu_state.sprs[regno];
|
|
|
mask = ~(1 << bitnum);
|
mask = ~(1 << bitnum);
|
|
|
mtspr(regno, (regvalue & mask) | ((bitvalue & 0x1) << bitnum));
|
cpu_state.sprs[regno] = (regvalue & mask) | ((bitvalue & 0x1) << bitnum);
|
|
|
return;
|
return;
|
}
|
}
|
|
|
/* Get a specific bit from SPR. */
|
/* Get a specific bit from SPR. */
|
static inline int
|
static inline int
|
getsprbit(const int regno, const int bitnum)
|
getsprbit(const int regno, const int bitnum)
|
{
|
{
|
sprword regvalue = mfspr(regno);
|
sprword regvalue = cpu_state.sprs[regno];
|
|
|
return (regvalue >> bitnum) & 0x1;
|
return (regvalue >> bitnum) & 0x1;
|
}
|
}
|
|
|
/* Get specific SPR bit(s) identified by mask. */
|
/* Get specific SPR bit(s) identified by mask. */
|
static inline unsigned long
|
static inline unsigned long
|
testsprbits(const int regno, const unsigned long mask)
|
testsprbits(const int regno, const unsigned long mask)
|
{
|
{
|
sprword regvalue = mfspr(regno);
|
sprword regvalue = cpu_state.sprs[regno];
|
return regvalue & mask;
|
return regvalue & mask;
|
}
|
}
|
|
|
|
|
No newline at end of file
|
No newline at end of file
|