Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 34093
b: refs/heads/master
c: c3412dc
h: refs/heads/master
i:
  34091: c767193
v: v3
  • Loading branch information
Will Schmidt authored and Paul Mackerras committed Sep 13, 2006
1 parent 2f168ed commit eae4a14
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f50d4cfc98d70f919afb2924b1b53c36b2f4e62f
refs/heads/master: c3412dcb75ff4d64b44bedc72761d5707d19edf7
25 changes: 25 additions & 0 deletions trunk/arch/powerpc/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,9 @@ static void parse_fpe(struct pt_regs *regs)
#define INST_STSWI 0x7c0005aa
#define INST_STSWX 0x7c00052a

#define INST_POPCNTB 0x7c0000f4
#define INST_POPCNTB_MASK 0xfc0007fe

static int emulate_string_inst(struct pt_regs *regs, u32 instword)
{
u8 rT = (instword >> 21) & 0x1f;
Expand Down Expand Up @@ -666,6 +669,23 @@ static int emulate_string_inst(struct pt_regs *regs, u32 instword)
return 0;
}

static int emulate_popcntb_inst(struct pt_regs *regs, u32 instword)
{
u32 ra,rs;
unsigned long tmp;

ra = (instword >> 16) & 0x1f;
rs = (instword >> 21) & 0x1f;

tmp = regs->gpr[rs];
tmp = tmp - ((tmp >> 1) & 0x5555555555555555ULL);
tmp = (tmp & 0x3333333333333333ULL) + ((tmp >> 2) & 0x3333333333333333ULL);
tmp = (tmp + (tmp >> 4)) & 0x0f0f0f0f0f0f0f0fULL;
regs->gpr[ra] = tmp;

return 0;
}

static int emulate_instruction(struct pt_regs *regs)
{
u32 instword;
Expand Down Expand Up @@ -703,6 +723,11 @@ static int emulate_instruction(struct pt_regs *regs)
if ((instword & INST_STRING_GEN_MASK) == INST_STRING)
return emulate_string_inst(regs, instword);

/* Emulate the popcntb (Population Count Bytes) instruction. */
if ((instword & INST_POPCNTB_MASK) == INST_POPCNTB) {
return emulate_popcntb_inst(regs, instword);
}

return -EINVAL;
}

Expand Down

0 comments on commit eae4a14

Please sign in to comment.