btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / system / kernel / vm / VMKernelAddressSpace.h
blobc8eecb76029ad00757b1f30118cb0f161288eb73
1 /*
2 * Copyright 2009-2011, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef VM_KERNEL_ADDRESS_SPACE_H
6 #define VM_KERNEL_ADDRESS_SPACE_H
9 #include <vm/VMAddressSpace.h>
11 #include "VMKernelArea.h"
14 struct ObjectCache;
17 struct VMKernelAddressSpace : VMAddressSpace {
18 public:
19 VMKernelAddressSpace(team_id id, addr_t base,
20 size_t size);
21 virtual ~VMKernelAddressSpace();
23 virtual status_t InitObject();
25 virtual VMArea* FirstArea() const;
26 virtual VMArea* NextArea(VMArea* area) const;
28 virtual VMArea* LookupArea(addr_t address) const;
29 virtual VMArea* CreateArea(const char* name, uint32 wiring,
30 uint32 protection, uint32 allocationFlags);
31 virtual void DeleteArea(VMArea* area,
32 uint32 allocationFlags);
33 virtual status_t InsertArea(VMArea* area, size_t size,
34 const virtual_address_restrictions*
35 addressRestrictions,
36 uint32 allocationFlags, void** _address);
37 virtual void RemoveArea(VMArea* area,
38 uint32 allocationFlags);
40 virtual bool CanResizeArea(VMArea* area, size_t newSize);
41 virtual status_t ResizeArea(VMArea* area, size_t newSize,
42 uint32 allocationFlags);
43 virtual status_t ShrinkAreaHead(VMArea* area, size_t newSize,
44 uint32 allocationFlags);
45 virtual status_t ShrinkAreaTail(VMArea* area, size_t newSize,
46 uint32 allocationFlags);
48 virtual status_t ReserveAddressRange(size_t size,
49 const virtual_address_restrictions*
50 addressRestrictions,
51 uint32 flags, uint32 allocationFlags,
52 void** _address);
53 virtual status_t UnreserveAddressRange(addr_t address,
54 size_t size, uint32 allocationFlags);
55 virtual void UnreserveAllAddressRanges(
56 uint32 allocationFlags);
58 virtual void Dump() const;
60 private:
61 typedef VMKernelAddressRange Range;
62 typedef VMKernelAddressRangeTree RangeTree;
63 typedef DoublyLinkedList<Range,
64 DoublyLinkedListMemberGetLink<Range, &Range::listLink> >
65 RangeList;
66 typedef DoublyLinkedList<Range, VMKernelAddressRangeGetFreeListLink>
67 RangeFreeList;
69 private:
70 inline void _FreeListInsertRange(Range* range, size_t size);
71 inline void _FreeListRemoveRange(Range* range, size_t size);
73 void _InsertRange(Range* range);
74 void _RemoveRange(Range* range);
76 status_t _AllocateRange(
77 const virtual_address_restrictions*
78 addressRestrictions,
79 size_t size, bool allowReservedRange,
80 uint32 allocationFlags, Range*& _range);
81 Range* _FindFreeRange(addr_t start, size_t size,
82 size_t alignment, uint32 addressSpec,
83 bool allowReservedRange,
84 addr_t& _foundAddress);
85 void _FreeRange(Range* range,
86 uint32 allocationFlags);
88 void _CheckStructures() const;
90 private:
91 RangeTree fRangeTree;
92 RangeList fRangeList;
93 RangeFreeList* fFreeLists;
94 int fFreeListCount;
95 ObjectCache* fAreaObjectCache;
96 ObjectCache* fRangesObjectCache;
100 #endif /* VM_KERNEL_ADDRESS_SPACE_H */