summaryrefslogtreecommitdiffstats
path: root/src/include/util
diff options
context:
space:
mode:
authorDan Crowell <dcrowell@us.ibm.com>2015-02-12 15:16:11 -0600
committerA. Patrick Williams III <iawillia@us.ibm.com>2015-02-16 15:30:40 -0600
commit9611008eb6768fc2d23a82560d75f43f101298b6 (patch)
tree9846bb1665f50f783158731cf2335830ceb01b05 /src/include/util
parent0b03c03b42b899fbad17c3aa2f0b0b55c21bd60b (diff)
downloadtalos-hostboot-9611008eb6768fc2d23a82560d75f43f101298b6.tar.gz
talos-hostboot-9611008eb6768fc2d23a82560d75f43f101298b6.zip
Align all HBRT reserved memory to 64K boundary
Change-Id: Ifcc3afa30ed84189cf10c1a8df9a7b4e7d38ffea RTC: 123657 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/15711 Reviewed-by: Andrew J. Geissler <andrewg@us.ibm.com> Tested-by: Jenkins Server Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/include/util')
-rw-r--r--src/include/util/align.H41
1 files changed, 21 insertions, 20 deletions
diff --git a/src/include/util/align.H b/src/include/util/align.H
index 71e1f5e0f..0ffec92d1 100644
--- a/src/include/util/align.H
+++ b/src/include/util/align.H
@@ -5,7 +5,9 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* COPYRIGHT International Business Machines Corp. 2011,2014 */
+/* Contributors Listed Below - COPYRIGHT 2011,2015 */
+/* [+] 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. */
@@ -25,29 +27,28 @@
#include <limits.h>
-// Return a number >= input that is aligned up to the next 4-byte boundary
-#define ALIGN_4(u) (((u) + 0x3ull) & ~0x3ull)
-
-// Return a number <= input that is rounded down to nearest 4-byte boundary
-#define ALIGN_DOWN_4(u) ((u) & ~3ull)
-
-// Return a number >= input that is aligned up to the next 8-byte bounday
-#define ALIGN_8(u) (((u) + 0x7ull) & ~0x7ull)
-
-// Return a number <= input that is rounded down to nearest 8-byte boundary
-#define ALIGN_DOWN_8(u) ((u) & ~7ull)
+// Return a number >= input that is aligned up to the next x boundary,
+// where x is a power of 2.
+#define ALIGN_X(u,x) (((u) + ((x)-1)) & ~((x)-1))
-// Return a number >= input that is aligned up to the next page boundary
-#define ALIGN_PAGE(u) (((u) + (PAGESIZE-1)) & ~(PAGESIZE-1))
+// Return a number <= input that is aligned on a x boundary, where x
+// is a power of 2.
+#define ALIGN_DOWN_X(u,x) ((u) - (u)%(x))
-// Return a number <= input that is aligned on a page boundary
-#define ALIGN_PAGE_DOWN(u) ((u) - (u)%PAGESIZE)
+// Useful shortcut macros for 4.
+#define ALIGN_4(u) (ALIGN_X(u,4))
+#define ALIGN_DOWN_4(u) (ALIGN_DOWN_X(u,4))
-// Return a number >= input that is aligned up to the next MB boundary
-#define ALIGN_MEGABYTE(u) (((u) + (MEGABYTE-1)) & ~(MEGABYTE-1))
+// Useful shortcut macros for 8.
+#define ALIGN_8(u) (ALIGN_X(u,8))
+#define ALIGN_DOWN_8(u) (ALIGN_DOWN_X(u,8))
-// Return a number <= input that is aligned on a MB boundary
-#define ALIGN_MEGABYTE_DOWN(u) ((u) - (u)%MEGABYTE)
+// Useful shortcut macros for a page.
+#define ALIGN_PAGE(u) (ALIGN_X(u,PAGESIZE))
+#define ALIGN_PAGE_DOWN(u) (ALIGN_DOWN_X(u,PAGESIZE))
+// Useful shortcut macros for a MB.
+#define ALIGN_MEGABYTE(u) (ALIGN_X(u,MEGABYTE))
+#define ALIGN_MEGABYTE_DOWN(u) (ALIGN_DOWN_X(u,MEGABYTE))
#endif
OpenPOWER on IntegriCloud