From f2de0d3c03281e942b1d9d5f0874f5558d20c9ac Mon Sep 17 00:00:00 2001 From: Doug Gilbert Date: Fri, 9 Jun 2017 15:51:51 -0500 Subject: DERP/DORP Implementation for pgpe dd2 Change-Id: Iccfab131b8704666b2a45c20d6326f2007acced9 RTC:173229 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/41634 Tested-by: Jenkins Server Tested-by: PPE CI Reviewed-by: Michael S. Floyd Reviewed-by: Brian T. Vanderpool Reviewed-by: Gregory S. Still Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/41636 Tested-by: FSP CI Jenkins Reviewed-by: Sachin Gupta --- .../chips/p9/procedures/ppe/pk/ppe42/div32.S | 5 +- src/import/chips/p9/procedures/ppe/pk/ppe42/math.c | 75 +++++++++++++++++++++- 2 files changed, 76 insertions(+), 4 deletions(-) (limited to 'src/import/chips/p9/procedures/ppe') diff --git a/src/import/chips/p9/procedures/ppe/pk/ppe42/div32.S b/src/import/chips/p9/procedures/ppe/pk/ppe42/div32.S index d9e7aa0c..aeeadf86 100644 --- a/src/import/chips/p9/procedures/ppe/pk/ppe42/div32.S +++ b/src/import/chips/p9/procedures/ppe/pk/ppe42/div32.S @@ -5,7 +5,7 @@ # # OpenPOWER sbe Project # -# Contributors Listed Below - COPYRIGHT 2016 +# Contributors Listed Below - COPYRIGHT 2016,2017 # [+] International Business Machines Corp. # # @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +#if (!defined(PSTATE_GPE) || NIMBUS_DD_LEVEL==1) .nolist #include "ppe42_asm.h" .list @@ -78,5 +79,5 @@ __umodsi3: mtctr %r10 li %r9,1 b udivmodsi4_loop - +#endif diff --git a/src/import/chips/p9/procedures/ppe/pk/ppe42/math.c b/src/import/chips/p9/procedures/ppe/pk/ppe42/math.c index 10943ce8..4deeb8b2 100644 --- a/src/import/chips/p9/procedures/ppe/pk/ppe42/math.c +++ b/src/import/chips/p9/procedures/ppe/pk/ppe42/math.c @@ -5,7 +5,7 @@ /* */ /* OpenPOWER sbe Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2016 */ +/* Contributors Listed Below - COPYRIGHT 2016,2017 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -37,6 +37,75 @@ extern "C" //} +#ifdef PSTATE_GPE +#if (NIMBUS_DD_LEVEL != 1) + +#include "ocb_register_addresses.h" +#define out64(addr, data) \ + {\ + unsigned long long __d = (data); \ + unsigned long* __a = (unsigned long*)(addr); \ + asm volatile \ + (\ + "stvd %1, %0 \n" \ + : "=o"(*__a) \ + : "r"(__d) \ + ); \ + } + +#define in64(addr) \ + ({\ + unsigned long long __d; \ + unsigned long* __a = (unsigned long*)(addr); \ + asm volatile \ + (\ + "lvd %0, %1 \n" \ + :"=r"(__d) \ + :"o"(*__a) \ + ); \ + __d; \ + }) + + +unsigned long udivmodsi4(unsigned long long _a, + unsigned long _mod) +{ + + out64(OCB_DERP, _a); + + do + { + _a = in64(OCB_DORP); + } + while((~_a) == 0); + + if(_mod) + { + return (unsigned long)_a; + } + + return (unsigned long)(_a >> 32); +} + +unsigned long __udivsi3(unsigned long _a, unsigned long _b) +{ + unsigned long long v = + ((unsigned long long)_a) << 32 | + ((unsigned long long)_b); + + return udivmodsi4(v, 0); +} + +unsigned long __umodsi3(unsigned long _a, unsigned long _b) +{ + unsigned long long v = + ((unsigned long long)_a) << 32 | + ((unsigned long long)_b); + return udivmodsi4(v, 1); +} +#endif +#endif + // 32 bit signed divide int __divsi3(int _a, int _b) { @@ -54,7 +123,7 @@ int __divsi3(int _a, int _b) neg = !neg; } - int c = __udivsi3((unsigned long)_a, (unsigned long)_b); + int c = (int)__udivsi3((unsigned long)_a, (unsigned long)_b); if(neg) { @@ -64,6 +133,7 @@ int __divsi3(int _a, int _b) return c; } + // 32 bit unsigned mutiply unsigned long __umulsi3(unsigned long _a, unsigned long _b) { @@ -139,6 +209,7 @@ unsigned long long __muldi3(unsigned long long _a, unsigned long long _b) return sum; } + //float __mulsf3(float _a , float _b) //{ // // floating point math -- cgit v1.2.1