diff options
| author | Martin Peschke <mpeschke@de.ibm.com> | 2016-05-19 13:09:47 +0200 |
|---|---|---|
| committer | Bill Hoffa <wghoffa@us.ibm.com> | 2016-06-07 16:18:02 -0500 |
| commit | f6e8eea4869b740f680d5d8713504f2942029d16 (patch) | |
| tree | 716225ca1cfc6f1899c0fc560d9897a73004a61d /src | |
| parent | 30a587af28123ad07756f5916002c7a05ae19219 (diff) | |
| download | blackbird-hostboot-f6e8eea4869b740f680d5d8713504f2942029d16.tar.gz blackbird-hostboot-f6e8eea4869b740f680d5d8713504f2942029d16.zip | |
move production code from tools/imageProcs to chips/p9/utils/imageProcs
Change-Id: I5ea81699989be9b72219dd0715a9080f9ee38e87
Original-Change-Id: I516c770ec7fd6d1fb2f8f7933a2579038c13ce6d
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/24786
Tested-by: Jenkins Server
Reviewed-by: Claus M. Olsen <cmolsen@us.ibm.com>
Reviewed-by: Richard J. Knight <rjknight@us.ibm.com>
Reviewed-by: Martin Peschke <mpeschke@de.ibm.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/import/chips/p9/utils/imageProcs/p9_infrastruct_help.H | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/src/import/chips/p9/utils/imageProcs/p9_infrastruct_help.H b/src/import/chips/p9/utils/imageProcs/p9_infrastruct_help.H new file mode 100644 index 000000000..f9b792998 --- /dev/null +++ b/src/import/chips/p9/utils/imageProcs/p9_infrastruct_help.H @@ -0,0 +1,118 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: chips/p9/utils/imageProcs/p9_infrastruct_help.H $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* EKB Project */ +/* */ +/* COPYRIGHT 2016 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* The source code for this program is not published or otherwise */ +/* divested of its trade secrets, irrespective of what has been */ +/* deposited with the U.S. Copyright Office. */ +/* */ +/* IBM_PROLOG_END_TAG */ +#ifndef _P9_INFRASTRUCT_HELP_H_ +#define _P9_INFRASTRUCT_HELP_H_ + +#include <stdint.h> +#include <stdlib.h> +#include <stdio.h> +#include <sys/mman.h> +#include <unistd.h> +#include <fcntl.h> //open() +#include <sys/stat.h> +#include <string.h> //memcpy() +#include <dirent.h> +#include <errno.h> + +// +// Various image/ring buffer sizes. Must be used by all users (VBU, FSP, HB, HBI, Cronus) +// +const uint32_t MAX_REF_IMAGE_SIZE = 1024 * + 1024; // Max reference image size. +const uint32_t FIXED_RING_BUF_SIZE = + 60000; // Fixed ring buf size for _fixed. + +#define CHIPLET_ID_MIN (uint8_t)0x00 +#define CHIPLET_ID_MAX (uint8_t)0x37 + +#define MY_INF(_fmt_, _args_...) printf(_fmt_, ##_args_) +#define MY_ERR(_fmt_, _args_...) printf(_fmt_, ##_args_) +#define MY_DBG(_fmt_, _args_...) printf(_fmt_, ##_args_) + + +// Byte-reverse a 32-bit integer +inline uint32_t myRev32(const uint32_t i_x) +{ + uint32_t rx; + +#ifdef _BIG_ENDIAN + rx = i_x; +#else + uint8_t* pix = (uint8_t*)(&i_x); + uint8_t* prx = (uint8_t*)(&rx); + + prx[0] = pix[3]; + prx[1] = pix[2]; + prx[2] = pix[1]; + prx[3] = pix[0]; +#endif + + return rx; +} + +// Byte-reverse a 64-bit integer +inline uint64_t myRev64(const uint64_t i_x) +{ + uint64_t rx; + +#ifdef _BIG_ENDIAN + rx = i_x; +#else + uint8_t* pix = (uint8_t*)(&i_x); + uint8_t* prx = (uint8_t*)(&rx); + + prx[0] = pix[7]; + prx[1] = pix[6]; + prx[2] = pix[5]; + prx[3] = pix[4]; + prx[4] = pix[3]; + prx[5] = pix[2]; + prx[6] = pix[1]; + prx[7] = pix[0]; +#endif + + return rx; +} + + +// Byte-reverse a 16-bit integer if on an LE machine +inline uint16_t myRev16(const uint16_t i_x) +{ + uint16_t rx; + +#ifdef _BIG_ENDIAN + rx = i_x; +#else + uint8_t* pix = (uint8_t*)(&i_x); + uint8_t* prx = (uint8_t*)(&rx); + + prx[0] = pix[1]; + prx[1] = pix[0]; +#endif + + return rx; +} + +// N-byte align an address, offset or size (aos) +inline uint64_t myByteAlign( const uint8_t nBytes, const uint64_t aos) +{ + return ((aos + nBytes - 1) / nBytes) * nBytes; +} + +#endif //_P9_INFRASTRUCT_HELP_H_ |

