FreeBSD/sys/powerpc/aim/mmu_oea.c
/*
 * Allocate a physical page of memory directly from the phys_avail map.
 * Can only be called from moea_bootstrap before avail start and end are
 * calculated.
 */
Allocate a physical page of memory directly from the phys_avail map.
Can only be called from moea_bootstrap before avail start and end are
calculated.
Allocate a physical page of memory directly from the phys_avail map . Can only be called from moea_bootstrap before avail start and end are calculated .
static vm_offset_t
moea_bootstrap_alloc(vm_size_t size, u_int align)
{
	vm_offset_t	s, e;
	int		i, j;
	size = round_page(size);
	for (i = 0; phys_avail[i + 1] != 0; i += 2) {
		if (align != 0)
			s = roundup2(phys_avail[i], align);
		else
			s = phys_avail[i];
		e = s + size;
		if (s < phys_avail[i] || e > phys_avail[i + 1])
			continue;
		if (s == phys_avail[i]) {
			phys_avail[i] += size;
		} else if (e == phys_avail[i + 1]) {
			phys_avail[i + 1] -= size;
		} else {
			for (j = phys_avail_count * 2; j > i; j -= 2) {
				phys_avail[j] = phys_avail[j - 2];
				phys_avail[j + 1] = phys_avail[j - 1];
			}
			phys_avail[i + 3] = phys_avail[i + 1];
			phys_avail[i + 1] = s;
			phys_avail[i + 2] = e;
			phys_avail_count++;
		}
		return (s);
	}
	panic("moea_bootstrap_alloc: could not allocate memory");
}
static vm_offset_t moea_bootstrap_alloc ( vm_size_t size , u_int align ) { vm_offset_t s , e ; int i , j ; size = round_page ( size ) ; for ( i = 0 ; phys_avail [ i + 1 ] != 0 ; i += 2 ) { if ( align != 0 ) s = roundup2 ( phys_avail [ i ] , align ) ; else s = phys_avail [ i ] ; e = s + size ; if ( s < phys_avail [ i ] || e > phys_avail [ i + 1 ] ) continue ; if ( s == phys_avail [ i ] ) { phys_avail [ i ] += size ; } else if ( e == phys_avail [ i + 1 ] ) { phys_avail [ i + 1 ] -= size ; } else { for ( j = phys_avail_count * 2 ; j > i ; j -= 2 ) { phys_avail [ j ] = phys_avail [ j - 2 ] ; phys_avail [ j + 1 ] = phys_avail [ j - 1 ] ; } phys_avail [ i + 3 ] = phys_avail [ i + 1 ] ; phys_avail [ i + 1 ] = s ; phys_avail [ i + 2 ] = e ; phys_avail_count ++ ; } return ( s ) ; } panic ( " " ) ; }
Allocate a physical page of memory directly from the phys_avail map.
Allocate a physical page of memory directly from the phys_avail map .