1 /* 2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef VM_USER_ADDRESS_SPACE_H 6 #define VM_USER_ADDRESS_SPACE_H 7 8 9 #include <vm/VMAddressSpace.h> 10 11 #include "VMUserArea.h" 12 13 14 struct VMUserAddressSpace : VMAddressSpace { 15 public: 16 VMUserAddressSpace(team_id id, addr_t base, 17 size_t size); 18 virtual ~VMUserAddressSpace(); 19 20 virtual VMArea* FirstArea() const; 21 virtual VMArea* NextArea(VMArea* area) const; 22 23 virtual VMArea* LookupArea(addr_t address) const; 24 virtual VMArea* CreateArea(const char* name, uint32 wiring, 25 uint32 protection); 26 virtual void DeleteArea(VMArea* area); 27 virtual status_t InsertArea(void** _address, uint32 addressSpec, 28 size_t size, VMArea* area); 29 virtual void RemoveArea(VMArea* area); 30 31 virtual bool CanResizeArea(VMArea* area, size_t newSize); 32 virtual status_t ResizeArea(VMArea* area, size_t newSize); 33 virtual status_t ShrinkAreaHead(VMArea* area, size_t newSize); 34 virtual status_t ShrinkAreaTail(VMArea* area, size_t newSize); 35 36 virtual status_t ReserveAddressRange(void** _address, 37 uint32 addressSpec, size_t size, 38 uint32 flags); 39 virtual status_t UnreserveAddressRange(addr_t address, 40 size_t size); 41 virtual void UnreserveAllAddressRanges(); 42 43 virtual void Dump() const; 44 45 private: 46 status_t _InsertAreaIntoReservedRegion(addr_t start, 47 size_t size, VMUserArea* area); 48 status_t _InsertAreaSlot(addr_t start, addr_t size, 49 addr_t end, uint32 addressSpec, 50 VMUserArea* area); 51 52 private: 53 VMUserAreaList fAreas; 54 mutable VMArea* fAreaHint; 55 }; 56 57 58 #endif /* VM_USER_ADDRESS_SPACE_H */ 59