2 * Copyright 2009-2011, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
5 #ifndef VM_KERNEL_ADDRESS_SPACE_H
6 #define VM_KERNEL_ADDRESS_SPACE_H
9 #include <vm/VMAddressSpace.h>
11 #include "VMKernelArea.h"
17 struct VMKernelAddressSpace
: VMAddressSpace
{
19 VMKernelAddressSpace(team_id id
, addr_t base
,
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
*
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
*
51 uint32 flags
, uint32 allocationFlags
,
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;
61 typedef VMKernelAddressRange Range
;
62 typedef VMKernelAddressRangeTree RangeTree
;
63 typedef DoublyLinkedList
<Range
,
64 DoublyLinkedListMemberGetLink
<Range
, &Range::listLink
> >
66 typedef DoublyLinkedList
<Range
, VMKernelAddressRangeGetFreeListLink
>
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
*
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;
93 RangeFreeList
* fFreeLists
;
95 ObjectCache
* fAreaObjectCache
;
96 ObjectCache
* fRangesObjectCache
;
100 #endif /* VM_KERNEL_ADDRESS_SPACE_H */