btrfs: [] on the end of a struct field is a variable length array.
[haiku.git] / headers / private / graphics / intel_extreme / AreaKeeper.h
blob83861397f2a0dd0f285fb475ec96d884840a5550
1 /*
2 * Copyright 2006-2008, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Axel Dörfler, axeld@pinc-software.de
7 */
8 #ifndef AREA_KEEPER_H
9 #define AREA_KEEPER_H
12 #include <KernelExport.h>
13 #include <OS.h>
15 #include <util/kernel_cpp.h>
18 class AreaKeeper {
19 public:
20 AreaKeeper();
21 ~AreaKeeper();
23 area_id Create(const char *name, void **_virtualAddress, uint32 spec,
24 size_t size, uint32 lock, uint32 protection);
25 area_id Map(const char *name, phys_addr_t physicalAddress,
26 size_t numBytes, uint32 spec, uint32 protection,
27 void **_virtualAddress);
29 status_t InitCheck() { return fArea < B_OK ? (status_t)fArea : B_OK; }
30 void Detach();
32 private:
33 area_id fArea;
37 AreaKeeper::AreaKeeper()
39 fArea(-1)
44 AreaKeeper::~AreaKeeper()
46 if (fArea >= B_OK)
47 delete_area(fArea);
51 area_id
52 AreaKeeper::Create(const char *name, void **_virtualAddress, uint32 spec,
53 size_t size, uint32 lock, uint32 protection)
55 fArea = create_area(name, _virtualAddress, spec, size, lock, protection);
56 return fArea;
60 area_id
61 AreaKeeper::Map(const char *name, phys_addr_t physicalAddress, size_t numBytes,
62 uint32 spec, uint32 protection, void **_virtualAddress)
64 fArea = map_physical_memory(name, physicalAddress, numBytes, spec,
65 protection, _virtualAddress);
66 return fArea;
70 void
71 AreaKeeper::Detach()
73 fArea = -1;
76 #endif // AREA_KEEPER_H