+
+/* 512 MB hard limit on size of the mbuf pool */
+#define MAX_MBUF_POOL (512 << MBSHIFT)
+#define MAX_NCL (MAX_MBUF_POOL >> MCLSHIFT)
+
+/*
+ * this has been broken out into a separate routine that
+ * can be called from the x86 early vm initialization to
+ * determine how much lo memory to reserve on systems with
+ * DMA hardware that can't fully address all of the physical
+ * memory that is present.
+ */
+int
+bsd_mbuf_cluster_reserve(void)
+{
+ /* If called more than once, return the previously calculated size */
+ if (mbuf_poolsz != 0)
+ goto done;
+
+ PE_parse_boot_argn("ncl", &ncl, sizeof (ncl));
+
+ if (sane_size > (64 * 1024 * 1024) || ncl) {
+ if ((nmbclusters = ncl) == 0) {
+ if ((nmbclusters = ((sane_size / 16)/MCLBYTES)) > 32768)
+ nmbclusters = 32768;
+ }
+ /* Make sure it's not odd in case ncl is manually set */
+ if (nmbclusters & 0x1)
+ --nmbclusters;
+
+ /* And obey the upper limit */
+ if (nmbclusters > MAX_NCL)
+ nmbclusters = MAX_NCL;
+
+ }
+ mbuf_poolsz = nmbclusters << MCLSHIFT;
+done:
+ return (nmbclusters * MCLBYTES);
+}