diff options
author | Doug Gilbert <dgilbert@us.ibm.com> | 2016-07-29 14:34:32 -0500 |
---|---|---|
committer | Sachin Gupta <sgupta2m@in.ibm.com> | 2016-08-16 11:58:14 -0400 |
commit | 67672ae5b7cdc76dfb32495c44e1c477a199b1b2 (patch) | |
tree | de15b6659913d40ade7d8ec40abaf41091fe0e9b /import | |
parent | e2e36e35d07154797c06783cec84db69a3192725 (diff) | |
download | talos-sbe-67672ae5b7cdc76dfb32495c44e1c477a199b1b2.tar.gz talos-sbe-67672ae5b7cdc76dfb32495c44e1c477a199b1b2.zip |
PPE42 PK lib locaton changes
Change-Id: I292a3e823073233eafb95f549cd4ccb1e7c9294a
RTC: 157965
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/27653
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Reviewed-by: YUE DU <daviddu@us.ibm.com>
Reviewed-by: Gregory S. Still <stillgs@us.ibm.com>
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/28292
Reviewed-by: Sachin Gupta <sgupta2m@in.ibm.com>
Diffstat (limited to 'import')
-rw-r--r-- | import/chips/p9/procedures/ppe/pk/ppe42/eabi.c | 46 | ||||
-rw-r--r-- | import/chips/p9/procedures/ppe/pk/ppe42/math.c | 206 | ||||
-rw-r--r-- | import/chips/p9/procedures/ppe/pk/ppe42/pkppe42files.mk | 15 | ||||
-rw-r--r-- | import/chips/p9/procedures/ppe/pk/ppe42/ppe42math.h | 84 |
4 files changed, 344 insertions, 7 deletions
diff --git a/import/chips/p9/procedures/ppe/pk/ppe42/eabi.c b/import/chips/p9/procedures/ppe/pk/ppe42/eabi.c new file mode 100644 index 00000000..140cc2be --- /dev/null +++ b/import/chips/p9/procedures/ppe/pk/ppe42/eabi.c @@ -0,0 +1,46 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: import/chips/p9/procedures/ppe/pk/ppe42/eabi.c $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2016 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ +// assuming link script instructs the c++ compiler to put +// ctor_start_address and ctor_end_address in .rodata + +//extern void (*ctor_start_address)() __attribute__ ((section (".rodata"))); +//extern void (*ctor_end_address)() __attribute__((section(".rodata"))); +#ifdef __cplusplus + extern "C" +#endif +__attribute__((weak)) void __eabi() +{ + // This is the default eabi and can be overridden. + // eabi environment is already set up by the PK kernel + // Call static C++ constructors if you use C++ global/static objects + + //void(**ctors)() = &ctor_start_address; + //while(ctors != &ctor_end_address) + //{ + // (*ctors)(); + // ctors++; + //} +} + diff --git a/import/chips/p9/procedures/ppe/pk/ppe42/math.c b/import/chips/p9/procedures/ppe/pk/ppe42/math.c new file mode 100644 index 00000000..1cddc624 --- /dev/null +++ b/import/chips/p9/procedures/ppe/pk/ppe42/math.c @@ -0,0 +1,206 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: import/chips/p9/procedures/ppe/pk/ppe42/math.c $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2016 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ +#include "ppe42math.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +unsigned long +udivmodsi4(unsigned long num, unsigned long den, int modwanted) +{ + unsigned long bit = 1; + unsigned long res = 0; + + while (den < num && bit && !(den & (1L << 31))) + { + den <<= 1; + bit <<= 1; + } + + while (bit) + { + if (num >= den) + { + num -= den; + res |= bit; + } + + bit >>= 1; + den >>= 1; + } + + if (modwanted) + { + return num; + } + + return res; +} + +// 64 bit divide. Note: TBD add when needed +//unsigned long long __udivdi3(unsigned long long a, unsigned long long b) +//{ +// unsigned long long c = 0; +// return c; +//} + +// 32 bit unsigned integer divide +unsigned long __udivsi3(unsigned long a, unsigned long b) +{ + return udivmodsi4(a, b, 0); +} + +// 32 bit modulus +unsigned long __umodsi3(unsigned long a, unsigned long b) +{ + return udivmodsi4(a, b, 1); +} + +// 32 bit signed divide +int __divsi3(int _a, int _b) +{ + register unsigned long neg = 0; + + if(_a & 0x80000000) + { + neg = !neg; + _a = (~_a) + 1; + } + + if(_b & 0x80000000) + { + _b = (~_b) + 1; + neg = !neg; + } + + int c = __udivsi3((unsigned long)_a, (unsigned long)_b); + + if(neg) + { + c = (~c) + 1; + } + + return c; +} + +// 32 bit unsigned mutiply +unsigned long __umulsi3(unsigned long _a, unsigned long _b) +{ + register unsigned long a = _a; + register unsigned long b = _b; + register unsigned long c; + register unsigned long d; + asm volatile("mullhwu %0, %1, %2" : "=r"(c) : "r"(a), "r"(b)); + d = c; + c = a >> 16; + asm volatile("mullhwu %0, %1, %2" : "=r"(c) : "r"(c), "r"(b)); + d += (c << 16); + c = b >> 16; + asm volatile("mullhwu %0, %1, %2" : "=r"(c) : "r"(c), "r"(a)); + d += (c << 16); + return d; +} + +// 32 bit signed multiply +unsigned int __mulsi3(unsigned int _a, unsigned int _b) +{ + register unsigned long neg = 0; + register unsigned long a = _a; + register unsigned long b = _b; + register unsigned long c; + register unsigned long d; + + if(a & 0x80000000) + { + a = (~a) + 1; + neg = !neg; + } + + if(b & 0x80000000) + { + b = (~b) + 1; + neg = !neg; + } + + asm volatile("mullhwu %0, %1, %2" : "=r"(c) : "r"(a), "r"(b)); + d = c; + c = a >> 16; + asm volatile("mullhwu %0, %1, %2" : "=r"(c) : "r"(c), "r"(b)); + d += (c << 16); + c = b >> 16; + asm volatile("mullhwu %0, %1, %2" : "=r"(c) : "r"(c), "r"(a)); + d += (c << 16); + + if(neg) + { + d = (~d) + 1; + } + + return d; +} + +// 64 bit signed multiply +unsigned long long __muldi3(unsigned long long _a, unsigned long long _b) +{ + unsigned long long sum = 0; + + while(_a) + { + if(_a & 1) + { + sum += _b; + } + + _a >>= 1; + _b <<= 1; + } + + return sum; +} + +//float __mulsf3(float _a , float _b) +//{ +// // floating point math +// return 0.0; +//} + +//float __subsf3(float _a, float _b) +//{ +// // floating point sub +// return 0.0; +//} + +//unsigned long __fixsfsi (float _a) +//{ +// // float to int +// return 0; +//} + +#ifdef __cplusplus +}; +#endif + diff --git a/import/chips/p9/procedures/ppe/pk/ppe42/pkppe42files.mk b/import/chips/p9/procedures/ppe/pk/ppe42/pkppe42files.mk index a489d7fd..4df5178d 100644 --- a/import/chips/p9/procedures/ppe/pk/ppe42/pkppe42files.mk +++ b/import/chips/p9/procedures/ppe/pk/ppe42/pkppe42files.mk @@ -50,21 +50,22 @@ PPE42-C-SOURCES = ppe42_core.c \ ppe42_init.c \ ppe42_irq_core.c\ ppe42_gcc.c\ - ppe42_scom.c - + ppe42_scom.c\ + eabi.c\ + math.c + PPE42-S-SOURCES = ppe42_boot.S \ ppe42_exceptions.S\ div64.S\ ppe42_timebase.S -PPE42-TIMER-C-SOURCES = -PPE42-TIMER-S-SOURCES = +PPE42-TIMER-C-SOURCES = +PPE42-TIMER-S-SOURCES = PPE42-THREAD-C-SOURCES = PPE42-THREAD-S-SOURCES = ppe42_thread_init.S PPE42_THREAD_OBJECTS= $(PPE42-THREAD-S-SOURCES:.S=.o) -PPE42_OBJECTS = $(PPE42-C-SOURCES:.c=.o) $(PPE42-S-SOURCES:.S=.o) - - +PPE42_OBJECTS = $(PPE42-C-SOURCES:.c=.o) +PPE42_OBJECTS += $(PPE42-S-SOURCES:.S=.o) diff --git a/import/chips/p9/procedures/ppe/pk/ppe42/ppe42math.h b/import/chips/p9/procedures/ppe/pk/ppe42/ppe42math.h new file mode 100644 index 00000000..e4f98cdd --- /dev/null +++ b/import/chips/p9/procedures/ppe/pk/ppe42/ppe42math.h @@ -0,0 +1,84 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: import/chips/p9/procedures/ppe/pk/ppe42/ppe42math.h $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2016 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ +#ifndef _MATH_H +#define _MATH_H + +#ifdef __cplusplus +extern "C" +{ +#endif +// These names are emitted by the ppe42 compiler. +// Implement the ones that will be used. + +// 64 bit unsigned divide. Implement if needed +// unsigned long long __udivdi3(unsigned long long a, unsigned long long b); + +/** 32 bit unsigned divide + * @param[in] Dividend + * @param[in] Divisor + * @return quotient + */ +unsigned long __udivsi3(unsigned long a, unsigned long b); + +/** 32 bit signed divide + * @param[in] Dividend + * @param[in] Divisor + * @return quotient + */ +int __divsi3(int _a, int _b); + +/** 32 bit unsigned modulus + * @param[in] Dividend + * @param[in] Divisor + * @return modulus + */ +unsigned long __umodsi3(unsigned long a, unsigned long b); + +/** 32 bit unsigned multiply + * @param[in] multiplier + * @param[in] multiplier + * @return product + */ +unsigned long __umulsi3(unsigned long _a, unsigned long _b); + +/** 32 bit signed multiply + * @param[in] multiplier + * @param[in] multiplier + * @return product + */ +unsigned int __mulsi3(unsigned int _a, unsigned int _b); + +/** 64 bit signed multiply + * @param[in] multiplier + * @param[in] multiplier + * @return product + */ +unsigned long long __muldi3(unsigned long long _a, unsigned long long _b); + +#ifdef __cplusplus +}; +#endif + +#endif |