From 55e24e1f24b932592ba3b24c8e97c3410c1a9d8b Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 6 Dec 2016 21:45:20 +0100 Subject: [PATCH] inn was assuming that bitfields were arrays of bytes, when actually they're arrays of words (which makes the LSB move on big-endian systems). --- mach/powerpc/libem/inn.s | 6 +++--- tests/plat/inn_e.e | 27 ++++++++++----------------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/mach/powerpc/libem/inn.s b/mach/powerpc/libem/inn.s index f5ae4c63e..9770ac094 100644 --- a/mach/powerpc/libem/inn.s +++ b/mach/powerpc/libem/inn.s @@ -13,10 +13,10 @@ lwz r4, 4(sp) /* r4 = bit number */ addi r5, sp, 8 /* r5 = base address of bit set */ - srawi r6, r4, 3 /* r6 = byte address into set */ - andi. r7, r4, 7 /* r7 = bit within byte */ + rlwinm r6, r4, 29, 3, 29 /* r6 = byte index of word in set */ + andi. r7, r4, 31 /* r7 = bit within word */ - lbzx r8, r5, r6 /* r8 = individual byte from set */ + lwzx r8, r5, r6 /* r8 = individual byte from set */ sraw r8, r8, r7 rlwinm r8, r8, 0, 31, 31 diff --git a/tests/plat/inn_e.e b/tests/plat/inn_e.e index 7d27abf42..a5aee02f5 100644 --- a/tests/plat/inn_e.e +++ b/tests/plat/inn_e.e @@ -7,10 +7,10 @@ /* Test non-existent bit */ .1 - rom 0I1, 0I1, 0I1, 0I1 + rom 0I4 loe .1 loc 1 /* bit number */ - inn EM_WSIZE + inn 4 zeq *1 loc __LINE__ @@ -21,9 +21,12 @@ /* Test existent bit */ .2 - rom 2I1, 0I1, 0I1, 0I1 + rom 16384 +.21 + rom 14 /* to defeat constant folding */ + loe .2 - loc 1 /* bit number */ + loe .21 /* bit number */ inn EM_WSIZE zne *2 @@ -35,10 +38,9 @@ /* Test non-existent high bit */ .3 - rom 0I1, 0I1, 0I1, 0I1 - rom 0I1, 0I1, 0I1, 0I1 + rom 0, 0 .31 - rom (EM_WSIZE*8)+1 /* to defeat constant folding */ + rom 8 /* to defeat constant folding */ lae .3 loi EM_WSIZE*2 @@ -54,16 +56,7 @@ /* Test existent high bit */ .4 -#if EM_WSIZE == 2 - rom 0I1, 0I1 - rom 2I1, 0I1 -#elif EM_WSIZE == 4 - rom 0I1, 0I1, 0I1, 0I1 - rom 2I1, 0I1, 0I1, 0I1 -#else - #error Unknown word size -#endif - + rom 0, 2 .41 rom (EM_WSIZE*8)+1 /* to defeat constant folding */