summaryrefslogtreecommitdiffstats
path: root/lib/libstand/zalloc_defs.h
diff options
context:
space:
mode:
authorian <ian@FreeBSD.org>2014-02-05 22:53:58 +0000
committerian <ian@FreeBSD.org>2014-02-05 22:53:58 +0000
commit06622912a6d1b3e7836b9bf0bf0127bf814e6c89 (patch)
tree1468352483b9188a31f8a142442ed1984150ea6d /lib/libstand/zalloc_defs.h
parent7de248459b4d943ad4a313358f2051ad69f0d1dc (diff)
downloadFreeBSD-src-06622912a6d1b3e7836b9bf0bf0127bf814e6c89.zip
FreeBSD-src-06622912a6d1b3e7836b9bf0bf0127bf814e6c89.tar.gz
Set the malloc alignment to 64 bytes on platforms that use the U-Boot API
device drivers. Recent versions of u-boot run with the MMU enabled, and require DMA-based I/O to be aligned to cache line boundaries. These changes are based on a patch originally submitted by Juergen Weiss, but I reworked them and thus any problems are purely my fault. Submitted by: "Juergen Weiss" <weiss@uni-mainz.de> Reviewed by: imp, nwhitehorn, jhb
Diffstat (limited to 'lib/libstand/zalloc_defs.h')
-rw-r--r--lib/libstand/zalloc_defs.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/libstand/zalloc_defs.h b/lib/libstand/zalloc_defs.h
index 5331ee0..7f2cc12 100644
--- a/lib/libstand/zalloc_defs.h
+++ b/lib/libstand/zalloc_defs.h
@@ -52,18 +52,26 @@
#define BLKEXTENDMASK (BLKEXTEND - 1)
/*
- * required malloc alignment. Just hardwire to 16.
+ * Required malloc alignment.
*
- * Note: if we implement a more sophisticated realloc, we should ensure that
- * MALLOCALIGN is at least as large as MemNode.
+ * Embedded platforms using the u-boot API drivers require that all I/O buffers
+ * be on a cache line sized boundary. The worst case size for that is 64 bytes.
+ * For other platforms, 16 bytes works fine. The alignment also must be at
+ * least sizeof(struct MemNode); this is asserted in zalloc.c.
*/
+#if defined(__arm__) || defined(__mips__) || defined(__powerpc__)
+#define MALLOCALIGN 64
+#else
+#define MALLOCALIGN 16
+#endif
+#define MALLOCALIGN_MASK (MALLOCALIGN - 1)
+
typedef struct Guard {
size_t ga_Bytes;
size_t ga_Magic; /* must be at least 32 bits */
} Guard;
-#define MALLOCALIGN 16
#define GAMAGIC 0x55FF44FD
#define GAFREE 0x5F54F4DF
OpenPOWER on IntegriCloud