2 * Copyright 2009-2011, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the NewOS License.
5 #ifndef VM_KERNEL_AREA_H
6 #define VM_KERNEL_AREA_H
9 #include <util/AVLTree.h>
11 #include <vm/VMArea.h>
15 struct VMKernelAddressSpace
;
19 struct VMKernelAddressRange
: AVLTreeNode
{
29 DoublyLinkedListLink
<VMKernelAddressRange
> listLink
;
38 DoublyLinkedListLink
<VMKernelAddressRange
> freeListLink
;
43 VMKernelAddressRange(addr_t base
, size_t size
, int type
)
51 VMKernelAddressRange(addr_t base
, size_t size
,
52 const VMKernelAddressRange
* other
)
58 if (type
== RANGE_RESERVED
) {
59 reserved
.base
= other
->reserved
.base
;
60 reserved
.flags
= other
->reserved
.flags
;
66 struct VMKernelAddressRangeTreeDefinition
{
68 typedef VMKernelAddressRange Value
;
70 AVLTreeNode
* GetAVLTreeNode(Value
* value
) const
75 Value
* GetValue(AVLTreeNode
* node
) const
77 return static_cast<Value
*>(node
);
80 int Compare(addr_t a
, const Value
* _b
) const
85 return a
< b
? -1 : 1;
88 int Compare(const Value
* a
, const Value
* b
) const
90 return Compare(a
->base
, b
);
94 typedef AVLTree
<VMKernelAddressRangeTreeDefinition
> VMKernelAddressRangeTree
;
97 struct VMKernelAddressRangeGetFreeListLink
{
98 typedef DoublyLinkedListLink
<VMKernelAddressRange
> Link
;
100 inline Link
* operator()(VMKernelAddressRange
* range
) const
102 return &range
->freeListLink
;
105 inline const Link
* operator()(const VMKernelAddressRange
* range
) const
107 return &range
->freeListLink
;
112 struct VMKernelArea
: VMArea
, AVLTreeNode
{
113 VMKernelArea(VMAddressSpace
* addressSpace
,
114 uint32 wiring
, uint32 protection
);
117 static VMKernelArea
* Create(VMAddressSpace
* addressSpace
,
118 const char* name
, uint32 wiring
,
119 uint32 protection
, ObjectCache
* objectCache
,
120 uint32 allocationFlags
);
122 VMKernelAddressRange
* Range() const
124 void SetRange(VMKernelAddressRange
* range
)
128 VMKernelAddressRange
* fRange
;
132 #endif // VM_KERNEL_AREA_H