Skip to content

Commit

Permalink
DERP/DORP Implementation for pgpe dd2
Browse files Browse the repository at this point in the history
Change-Id: Iccfab131b8704666b2a45c20d6326f2007acced9
RTC:173229
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/41634
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: PPE CI <ppe-ci+hostboot@us.ibm.com>
Reviewed-by: Michael S. Floyd <mfloyd@us.ibm.com>
Reviewed-by: Brian T. Vanderpool <vanderp@us.ibm.com>
Reviewed-by: Gregory S. Still <stillgs@us.ibm.com>
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/41636
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Sachin Gupta <sgupta2m@in.ibm.com>
  • Loading branch information
dgilbert999 authored and sgupta2m committed Jun 22, 2017
1 parent 0a96b93 commit f2de0d3
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/import/chips/p9/procedures/ppe/pk/ppe42/div32.S
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
# OpenPOWER sbe Project
#
# Contributors Listed Below - COPYRIGHT 2016
# Contributors Listed Below - COPYRIGHT 2016,2017
# [+] International Business Machines Corp.
#
#
Expand All @@ -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
Expand Down Expand Up @@ -78,5 +79,5 @@ __umodsi3:
mtctr %r10
li %r9,1
b udivmodsi4_loop

#endif

75 changes: 73 additions & 2 deletions src/import/chips/p9/procedures/ppe/pk/ppe42/math.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER sbe Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2016 */
/* Contributors Listed Below - COPYRIGHT 2016,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f2de0d3

Please sign in to comment.