Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 22 Jan 2015 17:42:31 +0000 (UTC)
From:      Ian Lepore <ian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r277532 - head/sys/arm/arm
Message-ID:  <201501221742.t0MHgV1t011518@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ian
Date: Thu Jan 22 17:42:30 2015
New Revision: 277532
URL: https://svnweb.freebsd.org/changeset/base/277532

Log:
  Add the Maxmem global and set it to the highest physical page number plus 1.

Modified:
  head/sys/arm/arm/physmem.c

Modified: head/sys/arm/arm/physmem.c
==============================================================================
--- head/sys/arm/arm/physmem.c	Thu Jan 22 17:13:43 2015	(r277531)
+++ head/sys/arm/arm/physmem.c	Thu Jan 22 17:42:30 2015	(r277532)
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <vm/vm.h>
+#include <machine/md_var.h>
 #include <machine/physmem.h>
 
 /*
@@ -86,8 +87,12 @@ static size_t excnt;
 vm_paddr_t phys_avail[MAX_AVAIL_ENTRIES + 2]; /* +2 to allow for a pair  */
 vm_paddr_t dump_avail[MAX_AVAIL_ENTRIES + 2]; /* of zeroes to terminate. */
 
-/* This is the total number of hardware pages, excluded or not. */
+/*
+ * realmem is the total number of hardware pages, excluded or not.
+ * Maxmem is one greater than the last physical page number.
+ */
 long realmem;
+long Maxmem;
 
 /* The address at which the kernel was loaded.  Set early in initarm(). */
 vm_paddr_t arm_physmem_kernaddr;
@@ -152,8 +157,8 @@ arm_physmem_print_tables()
  *
  * Returns the number of pages of non-excluded memory added to the avail list.
  */
-static long
-regions_to_avail(vm_paddr_t *avail, uint32_t exflags)
+static size_t
+regions_to_avail(vm_paddr_t *avail, uint32_t exflags, long *pavail)
 {
 	size_t acnt, exi, hwi;
 	vm_paddr_t end, start, xend, xstart;
@@ -236,7 +241,9 @@ regions_to_avail(vm_paddr_t *avail, uint
 			panic("Not enough space in the dump/phys_avail arrays");
 	}
 
-	return (availmem);
+	if (pavail)
+		*pavail = availmem;
+	return (acnt);
 }
 
 /*
@@ -311,13 +318,23 @@ void arm_physmem_exclude_region(vm_paddr
 
 /*
  * Process all the regions added earlier into the global avail lists.
+ *
+ * Updates the kernel global 'physmem' with the number of physical pages
+ * available for use (all pages not in any exclusion region).
+ *
+ * Updates the kernel global 'Maxmem' with the page number one greater then the
+ * last page of physical memory in the system.
  */
 void
 arm_physmem_init_kernel_globals(void)
 {
+	size_t nextidx;
 
-	regions_to_avail(dump_avail, EXFLAG_NODUMP);
-	physmem = regions_to_avail(phys_avail, EXFLAG_NOALLOC);
+	regions_to_avail(dump_avail, EXFLAG_NODUMP, NULL);
+	nextidx = regions_to_avail(phys_avail, EXFLAG_NOALLOC, &physmem);
+	if (nextidx == 0)
+		panic("No memory entries in phys_avail");
+	Maxmem = atop(phys_avail[nextidx - 1]);
 }
 
 #ifdef DDB



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201501221742.t0MHgV1t011518>