2002-04-03 08:51:34 +02:00
|
|
|
#include "unwind_i.h"
|
|
|
|
|
|
|
|
/* Apply rotation to a general register. The number REG must be in
|
|
|
|
the range of 0-127. */
|
|
|
|
|
|
|
|
static inline int
|
2002-12-19 08:16:50 +01:00
|
|
|
rotate_gr (struct cursor *c, int reg)
|
2002-04-03 08:51:34 +02:00
|
|
|
{
|
2002-04-25 08:47:29 +02:00
|
|
|
unsigned int rrb_gr, sor, sof;
|
2003-01-23 19:47:51 +01:00
|
|
|
int preg;
|
2002-04-03 08:51:34 +02:00
|
|
|
|
2003-01-23 19:47:51 +01:00
|
|
|
sof = (c->cfm & 0x7f);
|
|
|
|
sor = 8 * ((c->cfm >> 14) & 0xf);
|
|
|
|
rrb_gr = (c->cfm >> 18) & 0x7f;
|
2002-04-03 08:51:34 +02:00
|
|
|
|
2002-04-25 08:47:29 +02:00
|
|
|
if ((unsigned) (reg - 32) > sof)
|
2003-02-08 11:10:59 +01:00
|
|
|
return reg; /* not a valid stacked register: just return original value */
|
2002-04-25 08:47:29 +02:00
|
|
|
else if ((unsigned) (reg - 32) > sor)
|
2003-02-08 11:10:59 +01:00
|
|
|
preg = reg; /* register not part of the rotating partition */
|
2002-04-03 08:51:34 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
preg = reg + rrb_gr; /* apply rotation */
|
2003-02-08 11:10:59 +01:00
|
|
|
if (preg > 32 + (int) sor)
|
2002-04-03 08:51:34 +02:00
|
|
|
preg -= sor; /* wrap around */
|
|
|
|
}
|
2003-02-21 08:36:26 +01:00
|
|
|
if (sor)
|
|
|
|
debug (100, "%s: sor=%u rrb.gr=%u, r%d -> r%d\n",
|
|
|
|
__FUNCTION__, sor, rrb_gr, reg, preg);
|
2002-04-03 08:51:34 +02:00
|
|
|
return preg;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Apply rotation to a floating-point register. The number REG must
|
|
|
|
be in the range of 0-127. */
|
|
|
|
|
|
|
|
static inline int
|
2002-12-19 08:16:50 +01:00
|
|
|
rotate_fr (struct cursor *c, int reg)
|
2002-04-03 08:51:34 +02:00
|
|
|
{
|
|
|
|
unsigned int rrb_fr;
|
2003-01-23 19:47:51 +01:00
|
|
|
int preg;
|
2002-04-03 08:51:34 +02:00
|
|
|
|
2003-01-23 19:47:51 +01:00
|
|
|
rrb_fr = (c->cfm >> 25) & 0x7f;
|
2002-04-03 08:51:34 +02:00
|
|
|
if (reg < 32)
|
|
|
|
preg = reg; /* register not part of the rotating partition */
|
|
|
|
else
|
|
|
|
{
|
|
|
|
preg = reg + rrb_fr; /* apply rotation */
|
|
|
|
if (preg > 127)
|
|
|
|
preg -= 96; /* wrap around */
|
|
|
|
}
|
2003-02-21 08:36:26 +01:00
|
|
|
if (rrb_fr)
|
|
|
|
debug (100, "%s: rrb.fr=%u, f%d -> f%d\n",
|
|
|
|
__FUNCTION__, rrb_fr, reg, preg);
|
2002-04-03 08:51:34 +02:00
|
|
|
return preg;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Apply logical-to-physical rotation. */
|
|
|
|
|
|
|
|
static inline unw_word_t
|
2002-12-19 08:16:50 +01:00
|
|
|
pr_ltop (struct cursor *c, unw_word_t pr)
|
2002-04-03 08:51:34 +02:00
|
|
|
{
|
2003-01-23 19:47:51 +01:00
|
|
|
unw_word_t rrb_pr, mask, rot;
|
2002-04-03 08:51:34 +02:00
|
|
|
|
2003-01-23 19:47:51 +01:00
|
|
|
rrb_pr = (c->cfm >> 32) & 0x3f;
|
2002-04-03 08:51:34 +02:00
|
|
|
rot = pr >> 16;
|
|
|
|
mask = ((unw_word_t) 1 << rrb_pr) - 1;
|
|
|
|
rot = ((pr & mask) << (48 - rrb_pr)) | ((pr >> rrb_pr) & mask);
|
|
|
|
return (pr & 0xffff) | (rot << 16);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Apply physical-to-logical rotation. */
|
|
|
|
|
|
|
|
static inline unw_word_t
|
2002-12-19 08:16:50 +01:00
|
|
|
pr_ptol (struct cursor *c, unw_word_t pr)
|
2002-04-03 08:51:34 +02:00
|
|
|
{
|
2003-01-23 19:47:51 +01:00
|
|
|
unw_word_t rrb_pr, mask, rot;
|
2002-04-03 08:51:34 +02:00
|
|
|
|
2003-01-23 19:47:51 +01:00
|
|
|
rrb_pr = 48 - ((c->cfm >> 32) & 0x3f);
|
2002-04-03 08:51:34 +02:00
|
|
|
rot = pr >> 16;
|
|
|
|
mask = ((unw_word_t) 1 << rrb_pr) - 1;
|
|
|
|
rot = ((pr & mask) << (48 - rrb_pr)) | ((pr >> rrb_pr) & mask);
|
|
|
|
return (pr & 0xffff) | (rot << 16);
|
|
|
|
}
|