Line 15... |
Line 15... |
|
|
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|
|
#include "spr_defs.h"
|
|
|
|
typedef unsigned long sprword;
|
|
|
|
/* Prototypes */
|
/* Prototypes */
|
inline void mtspr(uint16_t regno, const sprword value);
|
void mtspr(uint16_t regno, const uorreg_t value);
|
static inline sprword mfspr_(const uint16_t regno);
|
uorreg_t mfspr(const uint16_t regno);
|
extern sprword sprs[MAX_SPRS];
|
void sprs_status(void);
|
#define mfspr(regno) mfspr_(regno)
|
|
|
/* Set specific SPR bit(s) identified by mask. */
|
static inline void setsprbit(const int regno, const int bitnum, const unsigned long bitvalue);
|
static inline void
|
static inline int getsprbit(const int regno, const int bitnum);
|
setsprbits(const int regno, const unsigned long mask, const unsigned long value)
|
void sprs_status();
|
|
|
|
#include "sim-config.h"
|
|
#include "tick.h"
|
|
|
|
/* Ugly, but fast */
|
|
/* Get a specific SPR. */
|
|
static inline sprword
|
|
mfspr_(const uint16_t regno)
|
|
{
|
{
|
extern oraddr_t pcprev;
|
uorreg_t regvalue = cpu_state.sprs[regno];
|
|
uorreg_t shifted = 0x0;
|
|
int m, v = 0;
|
|
|
switch (regno) {
|
/* m counts bits in valuemask */
|
case SPR_NPC:
|
/* v counts bits in value */
|
return cpu_state.pc;
|
for (m = 0; m < 32; m++)
|
case SPR_PPC:
|
if ((mask >> m) & 0x1) {
|
return pcprev;
|
shifted |= ((value >> v) & 0x1) << m;
|
case SPR_TTCR:
|
v++;
|
return spr_read_ttcr();
|
|
default:
|
|
/* Links to GPRS */
|
|
if(regno >= 0x0400 && regno < 0x0420)
|
|
return cpu_state.reg[regno - 0x0400];
|
|
else if (regno < MAX_SPRS)
|
|
return cpu_state.sprs[regno];
|
|
}
|
}
|
if (config.sim.verbose)
|
|
PRINTF ("WARNING: read out of SPR range %08X\n", regno);
|
/* PRINTF("oldvalue %x setsprbits(%x, %x, %x) shifted %x", regvalue, regno, mask, value, shifted); */
|
return 0;
|
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 = cpu_state.sprs[regno];
|
uorreg_t regvalue = cpu_state.sprs[regno];
|
sprword shifted = 0x0;
|
uorreg_t 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 */
|
for (m = 0; m < 32; m++)
|
for (m = 0; m < 32; m++)
|