dump_avail();
pmap_bootstrap(kernelstart, kernelend)	u_int kernelstart, kernelend;{	struct mem_region *mp, *mp1;	int cnt, i;	u_int s, sz;	/*	 * Get memory.	 */	(fw->mem_regions)(&mem, &avail);	physmem = 0;	for (mp = mem; mp->size; mp++) {		physmem += btoc(mp->size);	}	/*	 * Count the number of available entries.	 */	for (cnt = 0, mp = avail; mp->size; mp++)		cnt++;	/*	 * Page align all regions.	 * Non-page memory isn't very interesting to us.	 * Also, sort the entries for ascending addresses.	 */	kernelstart &= ~PGOFSET;	kernelend = (kernelend + PGOFSET) & ~PGOFSET;	/* make certain that each section is page aligned for base and size */	for (mp = avail; mp->size; mp++) {		u_int32_t end;		s = mp->start - round_page(mp->start);		if (s != 0) {			mp->start = round_page(mp->start);			end = trunc_page(mp->size + mp->start);			mp->size = end - mp->start;		}		mp->size = trunc_page(mp->size);	}	for (mp = avail; mp->size; mp++) {		/*		 * Check whether this region holds all of the kernel.		 */		s = mp->start + mp->size;		if (mp->start < kernelstart && s > kernelend) {			avail[cnt].start = kernelend;			avail[cnt++].size = s - kernelend;			mp->size = kernelstart - mp->start;		}		/*		 * Look whether this regions starts within the kernel.		 */		if (mp->start >= kernelstart && mp->start < kernelend) {			s = kernelend - mp->start;			if (mp->size > s)				mp->size -= s;			else				mp->size = 0;			mp->start = kernelend;		}		/*		 * Now look whether this region ends within the kernel.		 */		s = mp->start + mp->size;		if (s > kernelstart && s < kernelend)			mp->size -= s - kernelstart;		/*		 * Now page align the start of the region.		 */		s = mp->start % NBPG;		if (mp->size >= s) {			mp->size -= s;			mp->start += s;		}		/*		 * And now align the size of the region.		 */		mp->size -= mp->size % NBPG;		/*		 * Check whether some memory is left here.		 */		if (mp->size == 0) {			bcopy(mp + 1, mp,			      (cnt - (mp - avail)) * sizeof *mp);			cnt--;			mp--;			continue;		}		s = mp->start;		sz = mp->size;		npgs += btoc(sz);		for (mp1 = avail; mp1 < mp; mp1++)			if (s < mp1->start)				break;		if (mp1 < mp) {			bcopy(mp1, mp1 + 1, (void *)mp - (void *)mp1);			mp1->start = s;			mp1->size = sz;		}	}#if 0avail_start = 0;avail_end = npgs * NBPG;#endif#ifdef  HTABENTS	ptab_cnt = HTABENTS;#else /* HTABENTS */	ptab_cnt = 1024;	while ((HTABSIZE << 7) < ctob(physmem)) {		ptab_cnt <<= 1;	}#endif /* HTABENTS */	/*	 * Find suitably aligned memory for HTAB.	 */	for (mp = avail; mp->size; mp++) {		if (mp->start % HTABSIZE == 0) {			s = 0;		} else {			s = HTABSIZE - (mp->start % HTABSIZE) ;		}		if (mp->size < s + HTABSIZE)			continue;		ptable = (pte_t *)(mp->start + s);dump_avail();		if (mp->size == s + HTABSIZE) {			if (s)				mp->size = s;			else {				bcopy(mp + 1, mp,				      (cnt - (mp - avail)) * sizeof *mp);				mp = avail;			}			break;		}		if (s != 0) {			bcopy(mp, mp + 1,			      (cnt - (mp - avail)) * sizeof *mp);			mp++->size = s;		}		mp->start += s + HTABSIZE;		mp->size -= s + HTABSIZE;dump_avail();		break;	}	if (!mp->size)		panic("not enough memory?");	bzero((void *)ptable, HTABSIZE);	ptab_mask = ptab_cnt - 1;		/*	 * We cannot do vm_bootstrap_steal_memory here,	 * since we don't run with translation enabled yet.	 */	s = sizeof(struct pte_ovtab) * ptab_cnt;	sz = round_page(s);	for (mp = avail; mp->size; mp++)		if (mp->size >= sz)			break;	if (!mp->size)		panic("not enough memory?");	potable = (struct pte_ovtab *)mp->start;	mp->size -= sz;	mp->start += sz;	if (mp->size == 0)		bcopy(mp + 1, mp, (cnt - (mp - avail)) * sizeof *mp);	for (i = 0; i < ptab_cnt; i++)		LIST_INIT(potable + i);	LIST_INIT(&pv_page_freelist);	/* use only one memory list */	{ 		u_int32_t size;		struct mem_region *curmp;		size = 0;		curmp = NULL;		for (mp = avail; mp->size; mp++) {			if (mp->size > size) {				size = mp->size;				curmp=mp;			}		}		mp = avail;		if (curmp == mp) {			++mp;			mp->size = 0; /* lose the rest of memory */		} else {			*mp = *curmp;			++mp;			mp->size = 0; /* lose the rest of memory */		}	}	#ifdef MACHINE_NEW_NONCONTIG		for (mp = avail; mp->size; mp++) {#ifdef UVM		uvm_page_physload(atop(mp->start), atop(mp->start + mp->size),			atop(mp->start), atop(mp->start + mp->size),			VM_FREELIST_DEFAULT);#else		vm_page_physload(atop(mp->start), atop(mp->start + mp->size),			atop(mp->start), atop(mp->start + mp->size));#endif	}#endif	/*	 * Initialize kernel pmap and hardware.	 */#if NPMAPS >= KERNEL_SEGMENT / 16	usedsr[KERNEL_SEGMENT / 16 / (sizeof usedsr[0] * 8)]		|= 1 << ((KERNEL_SEGMENT / 16) % (sizeof usedsr[0] * 8));#endif	for (i = 0; i < 16; i++) {		pmap_kernel()->pm_sr[i] = EMPTY_SEGMENT;		asm volatile ("mtsrin %0,%1"			      :: "r"(EMPTY_SEGMENT), "r"(i << ADDR_SR_SHFT) );	}	pmap_kernel()->pm_sr[KERNEL_SR] = KERNEL_SEGMENT;	asm volatile ("mtsr %0,%1"		      :: "n"(KERNEL_SR), "r"(KERNEL_SEGMENT));	asm volatile ("sync; mtsdr1 %0; isync"		      :: "r"((u_int)ptable | (ptab_mask >> 10)));	tlbia();	pmap_vp_preinit();	nextavail = avail->start;}