1 /* 2 * Copyright 2009-2010, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the NewOS License. 4 */ 5 6 7 #include "VMUserArea.h" 8 9 #include <heap.h> 10 #include <vm/vm_priv.h> 11 12 13 VMUserArea::VMUserArea(VMAddressSpace* addressSpace, uint32 wiring, 14 uint32 protection) 15 : 16 VMArea(addressSpace, wiring, protection) 17 { 18 } 19 20 21 VMUserArea::~VMUserArea() 22 { 23 } 24 25 26 /*static*/ VMUserArea* 27 VMUserArea::Create(VMAddressSpace* addressSpace, const char* name, 28 uint32 wiring, uint32 protection, uint32 allocationFlags) 29 { 30 VMUserArea* area = new(malloc_flags(allocationFlags)) VMUserArea( 31 addressSpace, wiring, protection); 32 if (area == NULL) 33 return NULL; 34 35 if (area->Init(name, allocationFlags) != B_OK) { 36 area->~VMUserArea(); 37 free_etc(area, allocationFlags); 38 return NULL; 39 } 40 41 return area; 42 } 43 44 45 /*static*/ VMUserArea* 46 VMUserArea::CreateReserved(VMAddressSpace* addressSpace, uint32 flags, 47 uint32 allocationFlags) 48 { 49 VMUserArea* area = new(malloc_flags(allocationFlags)) VMUserArea( 50 addressSpace, 0, 0); 51 if (area != NULL) { 52 area->id = RESERVED_AREA_ID; 53 area->protection = flags; 54 } 55 return area; 56 } 57