1 /* 2 * Copyright 2009-2010, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the NewOS License. 4 */ 5 #ifndef VM_USER_AREA_H 6 #define VM_USER_AREA_H 7 8 9 #include <util/AVLTree.h> 10 11 #include <vm/VMArea.h> 12 13 14 struct VMUserAddressSpace; 15 16 17 struct VMUserArea : VMArea, AVLTreeNode { 18 VMUserArea(VMAddressSpace* addressSpace, 19 uint32 wiring, uint32 protection); 20 ~VMUserArea(); 21 22 static VMUserArea* Create(VMAddressSpace* addressSpace, 23 const char* name, uint32 wiring, 24 uint32 protection, uint32 allocationFlags); 25 static VMUserArea* CreateReserved(VMAddressSpace* addressSpace, 26 uint32 flags, uint32 allocationFlags); 27 }; 28 29 30 struct VMUserAreaTreeDefinition { 31 typedef addr_t Key; 32 typedef VMUserArea Value; 33 GetAVLTreeNodeVMUserAreaTreeDefinition34 AVLTreeNode* GetAVLTreeNode(Value* value) const 35 { 36 return value; 37 } 38 GetValueVMUserAreaTreeDefinition39 Value* GetValue(AVLTreeNode* node) const 40 { 41 return static_cast<Value*>(node); 42 } 43 CompareVMUserAreaTreeDefinition44 int Compare(addr_t a, const Value* _b) const 45 { 46 addr_t b = _b->Base(); 47 if (a == b) 48 return 0; 49 return a < b ? -1 : 1; 50 } 51 CompareVMUserAreaTreeDefinition52 int Compare(const Value* a, const Value* b) const 53 { 54 return Compare(a->Base(), b); 55 } 56 }; 57 58 typedef AVLTree<VMUserAreaTreeDefinition> VMUserAreaTree; 59 60 61 #endif // VM_USER_AREA_H 62