xref: /haiku/src/system/kernel/vm/VMUserAddressSpace.h (revision 7749d0bb0c358a3279b1b9cc76d8376e900130a5)
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, uint32 allocationFlags);
26 	virtual	void				DeleteArea(VMArea* area,
27 									uint32 allocationFlags);
28 	virtual	status_t			InsertArea(VMArea* area, size_t size,
29 									const virtual_address_restrictions*
30 										addressRestrictions,
31 									uint32 allocationFlags, void** _address);
32 	virtual	void				RemoveArea(VMArea* area,
33 									uint32 allocationFlags);
34 
35 	virtual	bool				CanResizeArea(VMArea* area, size_t newSize);
36 	virtual	status_t			ResizeArea(VMArea* area, size_t newSize,
37 									uint32 allocationFlags);
38 	virtual	status_t			ShrinkAreaHead(VMArea* area, size_t newSize,
39 									uint32 allocationFlags);
40 	virtual	status_t			ShrinkAreaTail(VMArea* area, size_t newSize,
41 									uint32 allocationFlags);
42 
43 	virtual	status_t			ReserveAddressRange(size_t size,
44 									const virtual_address_restrictions*
45 										addressRestrictions,
46 									uint32 flags, uint32 allocationFlags,
47 									void** _address);
48 	virtual	status_t			UnreserveAddressRange(addr_t address,
49 									size_t size, uint32 allocationFlags);
50 	virtual	void				UnreserveAllAddressRanges(
51 									uint32 allocationFlags);
52 
53 	virtual	void				Dump() const;
54 
55 private:
56 			status_t			_InsertAreaIntoReservedRegion(addr_t start,
57 									size_t size, VMUserArea* area,
58 									uint32 allocationFlags);
59 			status_t			_InsertAreaSlot(addr_t start, addr_t size,
60 									addr_t end, uint32 addressSpec,
61 									size_t alignment, VMUserArea* area,
62 									uint32 allocationFlags);
63 
64 private:
65 			VMUserAreaList		fAreas;
66 	mutable	VMUserArea*			fAreaHint;
67 };
68 
69 
70 #endif	/* VM_USER_ADDRESS_SPACE_H */
71