|
1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __COMMSBUFS_KERNEL_LIBRARY_H__ |
|
17 #define __COMMSBUFS_KERNEL_LIBRARY_H__ |
|
18 |
|
19 |
|
20 #include <e32cmn.h> |
|
21 |
|
22 #include <comms-infras/commsbuf.h> |
|
23 #include <comms-infras/commsbufpond.h> |
|
24 |
|
25 class TShBuf; |
|
26 |
|
27 /** |
|
28 Kernel side representation of commsbuf metadata. Maps on top of fields that user side and kernel side share an interest in. |
|
29 @publishedPartner |
|
30 */ |
|
31 class DCommsBuf : public TCommsBuf |
|
32 { |
|
33 friend class DCommsPond; |
|
34 |
|
35 public: |
|
36 DCommsBuf() |
|
37 {}; |
|
38 |
|
39 IMPORT_C static TInt AcceptFromClient(DThread* aClient, TInt aHandle, DCommsBuf* aSanitised); |
|
40 IMPORT_C TInt TransferToClient(DThread* aClient); |
|
41 IMPORT_C void Free(); |
|
42 |
|
43 inline TInt Length() const; |
|
44 inline void SetLength(TInt aLength); |
|
45 |
|
46 inline TInt Offset() const; |
|
47 inline void SetOffset(TInt aOffset); |
|
48 |
|
49 inline TUint8* Ptr() const; |
|
50 |
|
51 private: |
|
52 DCommsBuf(TShBuf* aShBuf, TInt aCommsPoolHandle, TInt aBufSize); |
|
53 DCommsBuf(TShBuf* aShBuf, TInt aCommsPoolHandle, TInt aBufSize, TInt aLength); |
|
54 |
|
55 inline TAny* operator new(TUint aSize, const TUint8* aPtr); |
|
56 inline void operator delete(TAny* aPtr, const TUint8*); |
|
57 }; |
|
58 |
|
59 |
|
60 class TCommsPond; |
|
61 class TPoolRecord; |
|
62 |
|
63 /** |
|
64 Kernel side representation of an RCommsPond. A collection of shared buffer pools. |
|
65 @publishedPartner |
|
66 */ |
|
67 class DCommsPond |
|
68 { |
|
69 public: |
|
70 IMPORT_C static DCommsPond* New(); |
|
71 ~DCommsPond(); |
|
72 |
|
73 IMPORT_C TInt Load(TPondTransferBuf& aPondStore, DThread* aClient); |
|
74 IMPORT_C void Unload(); |
|
75 |
|
76 IMPORT_C TInt SetDefaultAllocPool(TInt aRequiredBufferSize); |
|
77 |
|
78 IMPORT_C TInt Alloc(DCommsBuf& aBuf); |
|
79 IMPORT_C void Free(DCommsBuf& aBuf); |
|
80 |
|
81 private: |
|
82 DCommsPond() : iInitialised(EFalse), iDefaultAllocPool(NULL) {} |
|
83 |
|
84 TBool iInitialised; |
|
85 TCommsPond* iPond; |
|
86 TPoolRecord* iDefaultAllocPool; |
|
87 }; |
|
88 |
|
89 |
|
90 /** |
|
91 Panic codes associated with kernel side commsbufs operations |
|
92 @publishedPartner |
|
93 */ |
|
94 enum TKernCommsBufsPanicCodes |
|
95 { |
|
96 EPondNotReady = 0, |
|
97 EPondAlreadyLoaded = 1, |
|
98 EPondCorrupt = 2, |
|
99 ECommsBufDimensionsOutOfBounds = 3, |
|
100 ECommsBufMetadataCorrupt = 4 |
|
101 }; |
|
102 |
|
103 /** |
|
104 Standard panic operations. Encapsulates panic catgory. |
|
105 @publishedPartner |
|
106 */ |
|
107 class KernCommsBuf |
|
108 { |
|
109 public: |
|
110 IMPORT_C static void PanicClient(DThread* aClient, TInt aReason); |
|
111 IMPORT_C static void Fault(TInt aReason); |
|
112 }; |
|
113 |
|
114 |
|
115 #include <comms-infras/commsbufskern.inl> |
|
116 |
|
117 #endif // __COMMSBUFS_KERNEL_LIBRARY_H__ |
|
118 |