rem: unsigned int flags;
add: uint32 flags;
context: vm_create_anonymous_region(aspace_id aid, const char *name, void **address, 	int addr_type, addr_t size, int wiring, int lock){	int err;	vm_region *region;	vm_cache *cache;	vm_store *store;	vm_address_space *aspace;	vm_cache_ref *cache_ref;	TRACE(("create_anonymous_region: %s: size 0x%lx\n", name, size));	/* check parameters */	switch (addr_type) {		case B_ANY_ADDRESS:		case B_EXACT_ADDRESS:		case B_BASE_ADDRESS:		case B_ANY_KERNEL_ADDRESS:			break;		default:			return B_BAD_VALUE;	}	switch (wiring) {		case B_NO_LOCK:		case B_FULL_LOCK:		case B_LAZY_LOCK:		case B_CONTIGUOUS:		case B_ALREADY_WIRED:			break;		case B_LOMEM:		//case B_SLOWMEM:			dprintf("B_LOMEM/SLOWMEM is not yet supported!\n");			wiring = B_FULL_LOCK;			break;		default:			return B_BAD_VALUE;	}	aspace = vm_get_aspace_by_id(aid);	if (aspace == NULL)		return ERR_VM_INVALID_ASPACE;	size = PAGE_ALIGN(size);	// create an anonymous store object	store = vm_store_create_anonymous_noswap();	if (store == NULL)		panic("vm_create_anonymous_region: vm_create_store_anonymous_noswap returned NULL");	cache = vm_cache_create(store);	if (cache == NULL)		panic("vm_create_anonymous_region: vm_cache_create returned NULL");	cache_ref = vm_cache_ref_create(cache);	if (cache_ref == NULL)		panic("vm_create_anonymous_region: vm_cache_ref_create returned NULL");	cache->temporary = 1;	switch (wiring) {		case B_LAZY_LOCK:	// for now		case B_FULL_LOCK:		case B_CONTIGUOUS:		case B_ALREADY_WIRED:			cache->scan_skip = 1;			break;		case B_NO_LOCK:		//case B_LAZY_LOCK:			cache->scan_skip = 0;			break;	}//	dprintf("create_anonymous_region: calling map_backing store\n");	vm_cache_acquire_ref(cache_ref, true);	err = map_backing_store(aspace, store, address, 0, size, addr_type, wiring, lock, REGION_NO_PRIVATE_MAP, &region, name);	vm_cache_release_ref(cache_ref);	if (err < 0) {		vm_put_aspace(aspace);		return err;	}//	dprintf("create_anonymous_region: done calling map_backing store\n");	cache_ref = store->cache->ref;	switch (wiring) {		case B_NO_LOCK:		case B_LAZY_LOCK:			break; // do nothing		case B_FULL_LOCK:		{			// pages aren't mapped at this point, but we just simulate a fault on			// every page, which should allocate them			addr_t va;			// XXX remove			for (va = region->base; va < region->base + region->size; va += PAGE_SIZE) {//				dprintf("mapping wired pages: region 0x%x, cache_ref 0x%x 0x%x\n", region, cache_ref, region->cache_ref);				vm_soft_fault(va, false, false);			}			break;		}		case B_ALREADY_WIRED:		{			// the pages should already be mapped. This is only really useful during			// boot time. Find the appropriate vm_page objects and stick them in			// the cache object.			addr_t va;			addr_t pa;			unsigned int flags;			int err;			vm_page *page;			off_t offset = 0;			mutex_lock(&cache_ref->lock);			(*aspace->translation_map.ops->lock)(&aspace->translation_map);			for (va = region->base; va < region->base + region->size; va += PAGE_SIZE, offset += PAGE_SIZE) {				err = (*aspace->translation_map.ops->query)(&aspace->translation_map,					va, &pa, &flags);				if (err < 0) {//					dprintf("vm_create_anonymous_region: error looking up mapping for va 0x%x\n", va);					continue;				}				page = vm_lookup_page(pa / PAGE_SIZE);				if (page == NULL) {//					dprintf("vm_create_anonymous_region: error looking up vm_page structure for pa 0x%x\n", pa);					continue;				}				atomic_add(&page->ref_count, 1);				vm_page_set_state(page, PAGE_STATE_WIRED);				vm_cache_insert_page(cache_ref, page, offset);			}			(*aspace->translation_map.ops->unlock)(&aspace->translation_map);			mutex_unlock(&cache_ref->lock);			break;		}		case B_CONTIGUOUS: {			addr_t va;			addr_t phys_addr;			int err;			vm_page *page;			off_t offset = 0;			page = vm_page_allocate_page_run(PAGE_STATE_CLEAR, ROUNDUP(region->size, PAGE_SIZE) / PAGE_SIZE);			if(page == NULL) {				// XXX back out of this				panic("couldn't allocate page run of size %ld\n", region->size);			}			phys_addr = page->ppn * PAGE_SIZE;			mutex_lock(&cache_ref->lock);			(*aspace->translation_map.ops->lock)(&aspace->translation_map);			for(va = region->base; va < region->base + region->size; va += PAGE_SIZE, offset += PAGE_SIZE, phys_addr += PAGE_SIZE) {				page = vm_lookup_page(phys_addr / PAGE_SIZE);				if(page == NULL) {					panic("couldn't lookup physical page just allocated\n");				}				atomic_add(&page->ref_count, 1);				err = (*aspace->translation_map.ops->map)(&aspace->translation_map, va, phys_addr, lock);				if(err < 0) {					panic("couldn't map physical page in page run\n");				}				vm_page_set_state(page, PAGE_STATE_WIRED);				vm_cache_insert_page(cache_ref, page, offset);			}			(*aspace->translation_map.ops->unlock)(&aspace->translation_map);			mutex_unlock(&cache_ref->lock);			break;		}		default:			;	}	vm_put_aspace(aspace);//	dprintf("create_anonymous_region: done\n");	if(region)		return region->id;	else		return ENOMEM;}