FreeBSD/sys/arm/arm/physmem.c
/*
 * Walk the list of hardware regions, processing it against the list of
 * exclusions that contain the given exflags, and generating an "avail list".
 *
 * Updates the value at *pavail with the sum of all pages in all hw regions.
 *
 * Returns the number of pages of non-excluded memory added to the avail list.
 */
Walk the list of hardware regions, processing it against the list of
exclusions that contain the given exflags, and generating an "avail list".

Updates the value at *pavail with the sum of all pages in all hw regions.

Returns the number of pages of non-excluded memory added to the avail list.
Walk the list of hardware regions processing it against the list of exclusions that contain the given exflags and generating an " avail list " . Updates the value at * pavail with the sum of all pages in all hw regions . Returns the number of pages of non - excluded memory added to the avail list .
static size_t
regions_to_avail(vm_paddr_t *avail, uint32_t exflags, long *pavail)
{
	size_t acnt, exi, hwi;
	uint64_t end, start, xend, xstart;
	long availmem;
	const struct region *exp, *hwp;
	realmem = 0;
	availmem = 0;
	acnt = 0;
	for (hwi = 0, hwp = hwregions; hwi < hwcnt; ++hwi, ++hwp) {
		start = hwp->addr;
		end   = hwp->size + start;
		realmem += arm32_btop((vm_offset_t)(end - start));
		for (exi = 0, exp = exregions; exi < excnt; ++exi, ++exp) {
			if ((exp->flags & exflags) == 0)
				continue;
			xstart = exp->addr;
			xend   = exp->size + xstart;
			if (xend <= start)
				continue;
			if (xstart >= end)
				break;
			if ((start >= xstart) && (end <= xend)) {
				start = xend;
				end = xend;
				break;
			}
			if ((xstart > start) && (xend < end)) {
				avail[acnt++] = (vm_paddr_t)start;
				avail[acnt++] = (vm_paddr_t)xstart;
				availmem += 
				    arm32_btop((vm_offset_t)(xstart - start));
				start = xend;
				continue;
			}
			if (xstart <= start)
				start = xend;
			else
				end = xstart;
		}
		if (end > start) {
			avail[acnt++] = (vm_paddr_t)start;
			avail[acnt++] = (vm_paddr_t)end;
			availmem += arm32_btop((vm_offset_t)(end - start));
		}
		if (acnt >= MAX_AVAIL_ENTRIES)
			panic("Not enough space in the dump/phys_avail arrays");
	}
	if (pavail)
		*pavail = availmem;
	return (acnt);
}
static size_t regions_to_avail ( vm_paddr_t * avail , uint32_t exflags , long * pavail ) { size_t acnt , exi , hwi ; uint64_t end , start , xend , xstart ; long availmem ; const struct region * exp , * hwp ; realmem = 0 ; availmem = 0 ; acnt = 0 ; for ( hwi = 0 , hwp = hwregions ; hwi < hwcnt ; ++ hwi , ++ hwp ) { start = hwp -> addr ; end = hwp -> size + start ; realmem += arm32_btop ( ( vm_offset_t ) ( end - start ) ) ; for ( exi = 0 , exp = exregions ; exi < excnt ; ++ exi , ++ exp ) { if ( ( exp -> flags & exflags ) == 0 ) continue ; xstart = exp -> addr ; xend = exp -> size + xstart ; if ( xend <= start ) continue ; if ( xstart >= end ) break ; if ( ( start >= xstart ) && ( end <= xend ) ) { start = xend ; end = xend ; break ; } if ( ( xstart > start ) && ( xend < end ) ) { avail [ acnt ++ ] = ( vm_paddr_t ) start ; avail [ acnt ++ ] = ( vm_paddr_t ) xstart ; availmem += arm32_btop ( ( vm_offset_t ) ( xstart - start ) ) ; start = xend ; continue ; } if ( xstart <= start ) start = xend ; else end = xstart ; } if ( end > start ) { avail [ acnt ++ ] = ( vm_paddr_t ) start ; avail [ acnt ++ ] = ( vm_paddr_t ) end ; availmem += arm32_btop ( ( vm_offset_t ) ( end - start ) ) ; } if ( acnt >= MAX_AVAIL_ENTRIES ) panic ( " " ) ; } if ( pavail ) * pavail = availmem ; return ( acnt ) ; }
Walk the list of hardware regions, processing it against the list of
 exclusions that contain the given exflags, and generating an "avail list".
Walk the list of hardware regions processing it against the list of exclusions that contain the given exflags and generating an " avail list " .
/*
			 * If the excluded region does not match given flags,
			 * continue checking with the next excluded region.
			 */ /*
			 * If the excluded region ends before this hw region,
			 * continue checking with the next excluded region.
			 */ /*
			 * If the excluded region begins after this hw region
			 * we're done because both lists are sorted.
			 */ /*
			 * If the excluded region completely covers this hw
			 * region, shrink this hw region to zero size.
			 */ /*
			 * If the excluded region falls wholly within this hw
			 * region without abutting or overlapping the beginning
			 * or end, create an available entry from the leading
			 * fragment, then adjust the start of this hw region to
			 * the end of the excluded region, and continue checking
			 * the next excluded region because another exclusion
			 * could affect the remainder of this hw region.
			 */ /*
			 * We know the excluded region overlaps either the start
			 * or end of this hardware region (but not both), trim
			 * the excluded portion off the appropriate end.
			 */ /*
		 * If the trimming actions above left a non-zero size, create an
		 * available entry for it.
		 */