diff options
-rw-r--r-- | src/include/usr/hwpf/plat/fapiPlatUtil.H | 2 | ||||
-rw-r--r-- | src/include/util/align.H | 14 | ||||
-rw-r--r-- | src/usr/hwpf/hwp/mvpd_accessors/mvpdRingFuncs.C | 2 | ||||
-rw-r--r-- | src/usr/hwpf/plat/fapiPlatUtil.C | 15 |
4 files changed, 30 insertions, 3 deletions
diff --git a/src/include/usr/hwpf/plat/fapiPlatUtil.H b/src/include/usr/hwpf/plat/fapiPlatUtil.H index ff1464693..2d2d5fbb7 100644 --- a/src/include/usr/hwpf/plat/fapiPlatUtil.H +++ b/src/include/usr/hwpf/plat/fapiPlatUtil.H @@ -72,7 +72,7 @@ template <> inline uint32_t fapiPlatGenHash <fapi::hash::CRC32> #define FAPI_PLAT_HTOBE64(x) htobe64(x) #define FAPI_PLAT_HTOLE64(x) htole64(x) -#define fapiPlatMalloc(s) malloc(s) +void* fapiPlatMalloc(size_t); #define fapiPlatFree(p) free(p) #endif // FAPIPLATUTIL_H_ diff --git a/src/include/util/align.H b/src/include/util/align.H index 0ffec92d1..e0132b2b7 100644 --- a/src/include/util/align.H +++ b/src/include/util/align.H @@ -51,4 +51,18 @@ #define ALIGN_MEGABYTE(u) (ALIGN_X(u,MEGABYTE)) #define ALIGN_MEGABYTE_DOWN(u) (ALIGN_DOWN_X(u,MEGABYTE)) +// Returns a number that is aligned to the next highest power of 2 number of +// pages for the given buffer. +#define ALIGN_TO_NEXT_POWER_OF_TWO_PAGES(b) ({\ + unsigned int v = ALIGN_PAGE(b)/PAGE_SIZE;\ + v--;\ + v |= v >> 1;\ + v |= v >> 2;\ + v |= v >> 4;\ + v |= v >> 8;\ + v |= v >> 16;\ + v++;\ + v * PAGE_SIZE;\ + }) + #endif diff --git a/src/usr/hwpf/hwp/mvpd_accessors/mvpdRingFuncs.C b/src/usr/hwpf/hwp/mvpd_accessors/mvpdRingFuncs.C index e54b0f602..3a532a1dc 100644 --- a/src/usr/hwpf/hwp/mvpd_accessors/mvpdRingFuncs.C +++ b/src/usr/hwpf/hwp/mvpd_accessors/mvpdRingFuncs.C @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2012,2014 */ +/* Contributors Listed Below - COPYRIGHT 2012,2015 */ /* [+] International Business Machines Corp. */ /* */ /* */ diff --git a/src/usr/hwpf/plat/fapiPlatUtil.C b/src/usr/hwpf/plat/fapiPlatUtil.C index 64df4d33a..d03b6705b 100644 --- a/src/usr/hwpf/plat/fapiPlatUtil.C +++ b/src/usr/hwpf/plat/fapiPlatUtil.C @@ -40,7 +40,8 @@ #include <initservice/initsvcbreakpoint.H> #include <errl/errlentry.H> #include <initservice/initserviceif.H> - +#include <util/align.H> +#include <fapiPlatUtil.H> #ifdef __HOSTBOOT_RUNTIME #include <runtime/interface.h> @@ -325,3 +326,15 @@ fapi::ReturnCode fapiSpecialWakeup(const fapi::Target & i_target, } } + +//****************************************************************************** +// fapiPlatMalloc +//****************************************************************************** +void* fapiPlatMalloc(size_t s) +{ + if (s > PAGE_SIZE) + { + s = ALIGN_TO_NEXT_POWER_OF_TWO_PAGES(s); + } + return malloc(s); +} |