diff options
author | William Bryan <wilbryan@us.ibm.com> | 2016-08-24 12:16:26 -0500 |
---|---|---|
committer | William A. Bryan <wilbryan@us.ibm.com> | 2016-08-26 16:45:00 -0400 |
commit | 30ed7685e39b12255247d0c30db8660f4e42eadb (patch) | |
tree | 616b802cbb9ecba0de32ad5044a93b288e3cda25 /src/ppe | |
parent | c184079818cd001b5fd7664ca974ee721c576522 (diff) | |
download | talos-occ-30ed7685e39b12255247d0c30db8660f4e42eadb.tar.gz talos-occ-30ed7685e39b12255247d0c30db8660f4e42eadb.zip |
Update build process for OpenPOWER
Change-Id: I0852869bdc9d527c54112de7223b6e95111c750a
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/28741
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: William A. Bryan <wilbryan@us.ibm.com>
Reviewed-by: Christopher J. Cain <cjcain@us.ibm.com>
Reviewed-by: Wael El-Essawy <welessa@us.ibm.com>
Reviewed-by: Martha Broyles <mbroyles@us.ibm.com>
Diffstat (limited to 'src/ppe')
-rw-r--r-- | src/ppe/pk/ppe42/eabi.c | 47 | ||||
-rw-r--r-- | src/ppe/pk/ppe42/math.c | 207 | ||||
-rw-r--r-- | src/ppe/pk/ppe42/pkppe42files.mk | 9 | ||||
-rw-r--r-- | src/ppe/pk/ppe42/ppe42math.h | 85 | ||||
-rw-r--r-- | src/ppe/tools/ppetracepp/Makefile | 6 |
5 files changed, 347 insertions, 7 deletions
diff --git a/src/ppe/pk/ppe42/eabi.c b/src/ppe/pk/ppe42/eabi.c new file mode 100644 index 0000000..542ff89 --- /dev/null +++ b/src/ppe/pk/ppe42/eabi.c @@ -0,0 +1,47 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/ppe/pk/ppe42/eabi.c $ */ +/* */ +/* OpenPOWER OnChipController 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/src/ppe/pk/ppe42/math.c b/src/ppe/pk/ppe42/math.c new file mode 100644 index 0000000..8d87c8f --- /dev/null +++ b/src/ppe/pk/ppe42/math.c @@ -0,0 +1,207 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/ppe/pk/ppe42/math.c $ */ +/* */ +/* OpenPOWER OnChipController 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/src/ppe/pk/ppe42/pkppe42files.mk b/src/ppe/pk/ppe42/pkppe42files.mk index 8fd241a..1097f0f 100644 --- a/src/ppe/pk/ppe42/pkppe42files.mk +++ b/src/ppe/pk/ppe42/pkppe42files.mk @@ -40,7 +40,9 @@ 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\ @@ -54,7 +56,6 @@ 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/src/ppe/pk/ppe42/ppe42math.h b/src/ppe/pk/ppe42/ppe42math.h new file mode 100644 index 0000000..c63d7e5 --- /dev/null +++ b/src/ppe/pk/ppe42/ppe42math.h @@ -0,0 +1,85 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/ppe/pk/ppe42/ppe42math.h $ */ +/* */ +/* OpenPOWER OnChipController 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 + diff --git a/src/ppe/tools/ppetracepp/Makefile b/src/ppe/tools/ppetracepp/Makefile index 0c52586..e078561 100644 --- a/src/ppe/tools/ppetracepp/Makefile +++ b/src/ppe/tools/ppetracepp/Makefile @@ -5,7 +5,7 @@ # # OpenPOWER OnChipController Project # -# Contributors Listed Below - COPYRIGHT 2015 +# Contributors Listed Below - COPYRIGHT 2015,2016 # [+] International Business Machines Corp. # # @@ -25,11 +25,11 @@ all: ppetracepp ppe2fsp ppetracepp: ppetracepp.C - g++ -m32 -O3 -w -g -I./ ppetracepp.C -o ppetracepp + g++ -O3 -w -g -I./ ppetracepp.C -o ppetracepp # g++ -O3 -w -x c++ -fPIC -g -I./ ppetracepp.C -o ppetracepp ppe2fsp: ppe2fsp.c ppe2fsp_cmd.c - gcc -m32 -w -g -I./ -I../../pk/trace ppe2fsp.c ppe2fsp_cmd.c -o ppe2fsp + gcc -w -g -I./ -I../../pk/trace ppe2fsp.c ppe2fsp_cmd.c -o ppe2fsp clean: rm ppetracepp ppe2fsp |