|
1 // Copyright (c) 2007-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 the License "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 // Description: |
|
12 // |
|
13 |
|
14 /** |
|
15 @file |
|
16 @internalComponent |
|
17 */ |
|
18 |
|
19 #ifndef ZEROCOPYMETADATA_H |
|
20 #define ZEROCOPYMETADATA_H |
|
21 |
|
22 #include <e32def.h> |
|
23 |
|
24 // The type used to represent an address various betwen user and kernel |
|
25 // mode. To aid us we use a macro to produce only one definition. |
|
26 #ifndef __KERNEL_MODE__ |
|
27 #define TAddrType TUint8* |
|
28 #else // __KERNEL_MODE__ |
|
29 #define TAddrType TLinAddr |
|
30 #endif // __KERNEL_MODE__ |
|
31 |
|
32 |
|
33 NONSHARABLE_CLASS(UsbZeroCopyChunkHeaderBase) |
|
34 { |
|
35 public: |
|
36 static inline RUsbTransferDescriptor::TTransferType& TransferType(TAddrType aBase, TInt aHeaderOffset); |
|
37 protected: |
|
38 enum THeaderBaseSizes |
|
39 { |
|
40 ETransferTypeSize = sizeof(RUsbTransferDescriptor::TTransferType) |
|
41 }; |
|
42 enum THeaderBaseLayout |
|
43 { |
|
44 ETransferType = 0, |
|
45 // End of fields |
|
46 EHeaderBaseSize = ETransferType + ETransferTypeSize |
|
47 }; |
|
48 }; |
|
49 |
|
50 |
|
51 NONSHARABLE_CLASS(UsbZeroCopyBulkIntrChunkHeader) : public UsbZeroCopyChunkHeaderBase |
|
52 { |
|
53 public: |
|
54 static inline TInt HeaderSize(); |
|
55 |
|
56 static inline TInt& DataOffset(TAddrType aBase, TInt aHeaderOffset); |
|
57 static inline TInt& DataLength(TAddrType aBase, TInt aHeaderOffset); |
|
58 static inline TInt& DataMaxLength(TAddrType aBase, TInt aHeaderOffset); |
|
59 static inline RUsbTransferDescriptor::TZlpStatus& ZlpStatus(TAddrType aBase, TInt aHeaderOffset); |
|
60 private: |
|
61 enum THeaderSizes |
|
62 { |
|
63 EDataOffsetSize = sizeof(TInt), |
|
64 EDataLengthSize = sizeof(TInt), |
|
65 EDataMaxLengthSize = sizeof(TInt), |
|
66 EZlpStatusSize = sizeof(RUsbTransferDescriptor::TZlpStatus) |
|
67 }; |
|
68 enum THeaderLayout |
|
69 { |
|
70 EDataOffset = EHeaderBaseSize, |
|
71 EDataLength = EDataOffset + EDataOffsetSize, |
|
72 EDataMaxLength = EDataLength + EDataLengthSize, |
|
73 EZlpStatus = EDataMaxLength + EDataMaxLengthSize, |
|
74 // End of fields |
|
75 EHeaderSize = EZlpStatus + EZlpStatusSize |
|
76 }; |
|
77 }; |
|
78 |
|
79 |
|
80 NONSHARABLE_CLASS(UsbZeroCopyIsocChunkHeader) : public UsbZeroCopyChunkHeaderBase |
|
81 { |
|
82 public: // Lengths Array constants |
|
83 static const TInt KLengthsElementSize = sizeof(TUint16); |
|
84 static const TInt KResultsElementSize = sizeof(TInt); |
|
85 public: |
|
86 static inline TInt HeaderSize(); |
|
87 |
|
88 static inline TInt& FirstElementOffset(TAddrType aBase, TInt aHeaderOffset); |
|
89 static inline TInt& MaxNumPackets(TAddrType aBase, TInt aHeaderOffset); |
|
90 static inline TInt& MaxPacketSize(TAddrType aBase, TInt aHeaderOffset); |
|
91 static inline TInt& LengthsOffset(TAddrType aBase, TInt aHeaderOffset); |
|
92 static inline TInt& ReqLenOffset(TAddrType aBase, TInt aHeaderOffset); |
|
93 static inline TInt& ResultsOffset(TAddrType aBase, TInt aHeaderOffset); |
|
94 private: |
|
95 enum THeaderSizes |
|
96 { |
|
97 EFirstElementOffsetSize = sizeof(TInt), |
|
98 EMaxNumPacketsSize = sizeof(TInt), |
|
99 EMaxPacketSizeSize = sizeof(TInt), |
|
100 ELengthsOffsetSize = sizeof(TInt), |
|
101 EReqLenOffsetSize = sizeof(TInt), |
|
102 EResultsOffsetSize = sizeof(TInt) |
|
103 }; |
|
104 enum THeaderLayout |
|
105 { |
|
106 EFirstElementOffset = EHeaderBaseSize, |
|
107 EMaxNumPackets = EFirstElementOffset + EFirstElementOffsetSize, |
|
108 EMaxPacketSize = EMaxNumPackets + EMaxNumPacketsSize, |
|
109 ELengthsOffset = EMaxPacketSize + EMaxPacketSizeSize, |
|
110 EReqLenOffset = ELengthsOffset + ELengthsOffsetSize, |
|
111 EResultsOffset = EReqLenOffset + EReqLenOffsetSize, |
|
112 // End of fields |
|
113 EHeaderSize = EResultsOffset + EResultsOffsetSize |
|
114 }; |
|
115 }; |
|
116 |
|
117 |
|
118 NONSHARABLE_CLASS(UsbZeroCopyIsocChunkElement) |
|
119 { |
|
120 public: |
|
121 // NumOfPackets constants |
|
122 static const TInt KInvalidElement = -1; |
|
123 // NextElementOffset constants |
|
124 static const TInt KEndOfList = -1; |
|
125 public: |
|
126 static inline TInt ElementSize(); |
|
127 |
|
128 static inline TInt& DataOffset(TAddrType aBase, TInt aHeaderOffset); |
|
129 static inline TInt& NumPackets(TAddrType aBase, TInt aHeaderOffset); |
|
130 static inline TInt& NextElementOffset(TAddrType aBase, TInt aHeaderOffset); |
|
131 private: |
|
132 enum THeaderSizes |
|
133 { |
|
134 EDataOffsetSize = sizeof(TInt), |
|
135 ENumPacketsSize = sizeof(TInt), |
|
136 ENextElementOffsetSize = sizeof(TInt), |
|
137 }; |
|
138 enum THeaderLayout |
|
139 { |
|
140 EDataOffset = 0, |
|
141 ENumPackets = EDataOffset + EDataOffsetSize, |
|
142 ENextElementOffset = ENumPackets + ENumPacketsSize, |
|
143 // End of fields |
|
144 EElementSize = ENextElementOffset + ENextElementOffsetSize |
|
145 }; |
|
146 }; |
|
147 |
|
148 #include "zerocopymetadata.inl" |
|
149 |
|
150 #undef TAddrType // Prevent the macro from leaking outside this header |
|
151 |
|
152 #endif // ZEROCOPYMETADATA_H |