From owner-svn-src-all@FreeBSD.ORG Thu Jan 22 17:42:31 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 5FBA9D4D; Thu, 22 Jan 2015 17:42:31 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 335DCA81; Thu, 22 Jan 2015 17:42:31 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t0MHgVQb011519; Thu, 22 Jan 2015 17:42:31 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t0MHgV1t011518; Thu, 22 Jan 2015 17:42:31 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201501221742.t0MHgV1t011518@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Thu, 22 Jan 2015 17:42:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r277532 - head/sys/arm/arm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Jan 2015 17:42:31 -0000 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 #include #include +#include #include /* @@ -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