|
1 /* |
|
2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: WlanChunk declaration |
|
15 * |
|
16 */ |
|
17 |
|
18 /* |
|
19 * %version: 6 % |
|
20 */ |
|
21 |
|
22 #ifndef WLANCHUNK_H |
|
23 #define WLANCHUNK_H |
|
24 |
|
25 #include "wlanobject.h" |
|
26 |
|
27 #include "osalist.h" |
|
28 #include "osachunkbase.h" |
|
29 |
|
30 class RWlanHeap; |
|
31 |
|
32 /** |
|
33 * Memory chunk allocation management object. |
|
34 * |
|
35 * Management of memory is based on buddy system, where righ hand side (rhs) |
|
36 * and left hand side (lhs) memory links are coalesced (if they are free) to |
|
37 * the current link to be freed. Allocation size is always alinged to |
|
38 * allocation unit, which equals to the size of cache line. The pointer |
|
39 * returned to the caller is also aligned to the allocation unit. |
|
40 * |
|
41 */ |
|
42 class WlanChunk : |
|
43 public DBase, public WlanObject, public MWlanOsaChunkBase |
|
44 { |
|
45 public: |
|
46 |
|
47 /** |
|
48 * ctor |
|
49 * NOTE: call IsValid() member from super class |
|
50 * to validate object after ctor |
|
51 * |
|
52 * @since S60 v3.2 |
|
53 * @param aStartOfBuf start of buffer |
|
54 * @param aEndOfBuf 1 past end of buffer |
|
55 * @param aAllocationUnit allocation unit size in bytes |
|
56 */ |
|
57 WlanChunk( TUint8* aStartOfBuf, TUint8* aEndOfBuf, TInt aAllocationUnit ); |
|
58 |
|
59 /** |
|
60 * Destructor. |
|
61 * |
|
62 * @since S60 v3.2 |
|
63 */ |
|
64 virtual ~WlanChunk(); |
|
65 |
|
66 // from base class MWlanOsaChunkBase |
|
67 |
|
68 /** |
|
69 * From MWlanOsaChunkBase. |
|
70 * Memory allocation. Correct alignment guaranteed |
|
71 * |
|
72 * @since S60 v3.2 |
|
73 * @param aSize size of the buffer to be allocated in bytes. |
|
74 * Must be positive otherwise the allocation fails |
|
75 * @param aZeroStamp zero stamp memory or not |
|
76 * @return begin of the allocated memory, NULL upon failure |
|
77 */ |
|
78 virtual void* Alloc( TInt aSize, TBool aZeroStamp ); |
|
79 |
|
80 /** |
|
81 * From MWlanOsaChunkBase. |
|
82 * Releases memory allocated by the Alloc method |
|
83 * |
|
84 * @since S60 v3.2 |
|
85 * @param aPtr begin of the buffer to be freed |
|
86 */ |
|
87 virtual void Free( void* aPtr ); |
|
88 |
|
89 /** |
|
90 * From MWlanOsaChunkBase. |
|
91 * Returns the maximum free link size |
|
92 * |
|
93 * @since S60 v3.2 |
|
94 * @return maximum free link size |
|
95 */ |
|
96 virtual TInt MaxFreeLinkSize() const; |
|
97 |
|
98 /** |
|
99 * From MWlanOsaChunkBase. |
|
100 * Evaluates is chunk in use or not, |
|
101 * meaning is memory allocated from there or not |
|
102 * |
|
103 * @since S60 v3.2 |
|
104 * @return ETrue for unused chunk any other for used chunk |
|
105 */ |
|
106 virtual TBool IsInUse() const; |
|
107 |
|
108 /** |
|
109 * From MWlanOsaChunkBase. |
|
110 * Returns the size of the memory chunk meta header in bytes |
|
111 * |
|
112 * @since S60 v3.2 |
|
113 * @return size of the memory chunk meta header |
|
114 */ |
|
115 virtual TInt HeaderSize() const; |
|
116 |
|
117 |
|
118 // Prohibit copy constructor. |
|
119 WlanChunk( const WlanChunk& ); |
|
120 // Prohibit assigment operator. |
|
121 WlanChunk& operator= ( const WlanChunk& ); |
|
122 |
|
123 private: // data |
|
124 |
|
125 RWlanHeap* iHeap; |
|
126 |
|
127 }; |
|
128 |
|
129 #endif // WLANCHUNK_H |