55 TPos headOffset = GetHeadBlockOffset(aPosition); |
52 TPos headOffset = GetHeadBlockOffset(aPosition); |
56 /**** READ10 HEAD ****/ |
53 /**** READ10 HEAD ****/ |
57 if (headOffset) |
54 if (headOffset) |
58 { |
55 { |
59 TPos headpos = aPosition - headOffset; |
56 TPos headpos = aPosition - headOffset; |
60 RBuf8 headbuf; |
57 iHeadbuf->Zero(); |
61 CleanupClosePushL(headbuf); |
|
62 headbuf.Create(iBlockLength); |
|
63 |
|
64 headlen = ((headOffset + aLength - 1) / iBlockLength) == 0 ? aLength : (iBlockLength - headOffset); |
58 headlen = ((headOffset + aLength - 1) / iBlockLength) == 0 ? aLength : (iBlockLength - headOffset); |
65 |
59 |
66 __HOSTPRINT2(_L("\tRead head pos = 0%lx length = 0%lx"), |
60 __HOSTPRINT2(_L("\tRead head pos = 0%lx length = 0%lx"), |
67 headpos, iBlockLength); |
61 headpos, iBlockLength); |
68 aProtocol.BlockReadL(headpos, headbuf, iBlockLength); |
62 aProtocol.BlockReadL(headpos, *iHeadbuf, iBlockLength); |
69 aBuf.Append(headbuf.Ptr() + headOffset, headlen); |
63 aBuf.Append(iHeadbuf->Ptr() + headOffset, headlen); |
70 CleanupStack::PopAndDestroy(&headbuf); |
|
71 } |
64 } |
72 |
65 |
73 /**** READ10 BODY ****/ |
66 /**** READ10 BODY ****/ |
74 TInt blocksInMain = (aLength - headlen)/iBlockLength; |
67 TInt blocksInMain = (aLength - headlen)/iBlockLength; |
75 if (blocksInMain) |
68 if (blocksInMain) |
84 |
77 |
85 /**** READ10 TAIL ****/ |
78 /**** READ10 TAIL ****/ |
86 TInt tailLen = aLength - copylen; |
79 TInt tailLen = aLength - copylen; |
87 if ((tailLen) != 0) |
80 if ((tailLen) != 0) |
88 { |
81 { |
89 RBuf8 tailbuf; |
|
90 CleanupClosePushL(tailbuf); |
|
91 tailbuf.Create(iBlockLength); |
|
92 |
|
93 __HOSTPRINT2(_L("\tRead tail pos = 0%lx length = 0%lx"), |
82 __HOSTPRINT2(_L("\tRead tail pos = 0%lx length = 0%lx"), |
94 aPosition+copylen, iBlockLength); |
83 aPosition+copylen, iBlockLength); |
95 aProtocol.BlockReadL(aPosition+copylen, tailbuf, iBlockLength); |
84 iTailbuf->Zero(); |
96 aBuf.Append(tailbuf.Ptr(), tailLen); |
85 aProtocol.BlockReadL(aPosition+copylen, *iTailbuf, iBlockLength); |
97 |
86 aBuf.Append(iTailbuf->Ptr(), tailLen); |
98 CleanupStack::PopAndDestroy(&tailbuf); |
|
99 } |
87 } |
100 } |
88 } |
101 |
89 |
102 |
90 |
103 /** |
91 /** |
121 /**** WRITE10 HEAD ****/ |
109 /**** WRITE10 HEAD ****/ |
122 if (headOffset) |
110 if (headOffset) |
123 { |
111 { |
124 TPos headpos = aPosition - headOffset; |
112 TPos headpos = aPosition - headOffset; |
125 |
113 |
126 RBuf8 headbuf; |
114 iHeadbuf->Zero(); |
127 CleanupClosePushL(headbuf); |
115 |
128 headbuf.Create(iBlockLength); |
116 RBuf8& buf = *iTailbuf; |
129 |
117 buf.Zero(); |
130 RBuf8 buf; |
|
131 CleanupClosePushL(buf); |
|
132 buf.Create(iBlockLength); |
|
133 |
118 |
134 headlen = ((headOffset + aLength - 1) / iBlockLength) == 0 ? aLength : (iBlockLength - headOffset); |
119 headlen = ((headOffset + aLength - 1) / iBlockLength) == 0 ? aLength : (iBlockLength - headOffset); |
135 |
120 |
136 __HOSTPRINT2(_L("\tWrite-Read head pos = 0%lx length = 0%lx"), |
121 __HOSTPRINT2(_L("\tWrite-Read head pos = 0%lx length = 0%lx"), |
137 headpos, iBlockLength); |
122 headpos, iBlockLength); |
138 |
123 |
139 aProtocol.BlockReadL(headpos, headbuf, iBlockLength); |
124 aProtocol.BlockReadL(headpos, *iHeadbuf, iBlockLength); |
140 /* get head */ |
125 /* get head */ |
141 __HOSTPRINT2(_L("\tcopying read data pos = 0%lx offset = 0%lx"), |
126 __HOSTPRINT2(_L("\tcopying read data pos = 0%lx offset = 0%lx"), |
142 headpos, headOffset); |
127 headpos, headOffset); |
143 buf.Append(headbuf.Ptr(), headOffset); |
128 buf.Append(iHeadbuf->Ptr(), headOffset); |
144 |
129 |
145 /* get body */ |
130 /* get body */ |
146 buf.Append(aBuf.Ptr(), headlen); |
131 buf.Append(aBuf.Ptr(), headlen); |
147 |
132 |
148 /* Is it a short write and tail exist? */ |
133 /* Is it a short write and tail exist? */ |
151 { |
136 { |
152 TInt len = iBlockLength - headEndOffset; |
137 TInt len = iBlockLength - headEndOffset; |
153 |
138 |
154 __HOSTPRINT2(_L("\t(short write) copying read data pos = 0%lx length = %08x"), |
139 __HOSTPRINT2(_L("\t(short write) copying read data pos = 0%lx length = %08x"), |
155 (headpos + headEndOffset), len); |
140 (headpos + headEndOffset), len); |
156 buf.Append(headbuf.Ptr() + headEndOffset, len); |
141 buf.Append(iHeadbuf->Ptr() + headEndOffset, len); |
157 } |
142 } |
158 |
143 |
159 __HOSTPRINT2(_L("\tWrite head pos = 0%lx length = %08x"), |
144 __HOSTPRINT2(_L("\tWrite head pos = 0%lx length = %08x"), |
160 headpos, headlen); |
145 headpos, headlen); |
161 |
146 |
162 aProtocol.BlockWriteL(headpos, (TDes8 &)buf, 0, iBlockLength); |
147 aProtocol.BlockWriteL(headpos, (TDes8 &)buf, 0, iBlockLength); |
163 |
|
164 CleanupStack::PopAndDestroy(&buf); |
|
165 CleanupStack::PopAndDestroy(&headbuf); |
|
166 } |
148 } |
167 |
149 |
168 /**** WRITE10 BODY ****/ |
150 /**** WRITE10 BODY ****/ |
169 TPos blocksInMain = (aLength - headlen)/iBlockLength; |
151 TPos blocksInMain = (aLength - headlen)/iBlockLength; |
170 if (blocksInMain) |
152 if (blocksInMain) |
183 |
165 |
184 /**** WRITE10 TAIL ****/ |
166 /**** WRITE10 TAIL ****/ |
185 TInt tailLen = aLength - copylen;; |
167 TInt tailLen = aLength - copylen;; |
186 if (tailLen != 0) |
168 if (tailLen != 0) |
187 { |
169 { |
188 RBuf8 buf; |
170 RBuf8& buf = *iHeadbuf; |
189 CleanupClosePushL(buf); |
171 buf.Zero(); |
190 buf.Create(iBlockLength); |
172 |
191 |
173 iTailbuf->Zero(); |
192 RBuf8 tailbuf; |
|
193 CleanupClosePushL(tailbuf); |
|
194 tailbuf.Create(iBlockLength); |
|
195 |
174 |
196 const TUint64 pos = aPosition + copylen; |
175 const TUint64 pos = aPosition + copylen; |
197 |
176 |
198 __HOSTPRINT2(_L("\tWrite-Read tail pos = 0%lx length = %08x"), |
177 __HOSTPRINT2(_L("\tWrite-Read tail pos = 0%lx length = %08x"), |
199 pos, iBlockLength); |
178 pos, iBlockLength); |
200 |
179 |
201 aProtocol.BlockReadL(pos, tailbuf, iBlockLength); |
180 aProtocol.BlockReadL(pos, *iTailbuf, iBlockLength); |
202 /* get head */ |
181 /* get head */ |
203 buf.Append(aBuf.Ptr() + copylen, tailLen); |
182 buf.Append(aBuf.Ptr() + copylen, tailLen); |
204 /* get tail */ |
183 /* get tail */ |
205 buf.Append(tailbuf.Ptr() + tailLen, iBlockLength - tailLen); |
184 buf.Append(iTailbuf->Ptr() + tailLen, iBlockLength - tailLen); |
206 |
185 |
207 aProtocol.BlockWriteL(pos, (TDes8 &)buf, 0, iBlockLength); |
186 aProtocol.BlockWriteL(pos, (TDes8 &)buf, 0, iBlockLength); |
208 |
187 } |
209 CleanupStack::PopAndDestroy(&tailbuf); |
188 } |
210 CleanupStack::PopAndDestroy(&buf); |
189 |
211 } |
190 |
212 } |
191 void TBlockTransfer::SetCapacityL(TUint32 aBlockLength, TLba aLastLba) |
213 |
|
214 |
|
215 void TBlockTransfer::SetCapacity(TUint32 aBlockLength, TLba aLastLba) |
|
216 { |
192 { |
217 __MSFNLOG |
193 __MSFNLOG |
218 iBlockLength = static_cast<TInt64>(aBlockLength); |
194 iBlockLength = static_cast<TInt64>(aBlockLength); |
219 iLastLba = aLastLba; |
195 iLastLba = aLastLba; |
|
196 |
|
197 __ASSERT_DEBUG(iHeadbuf, User::Invariant()); |
|
198 __ASSERT_DEBUG(iTailbuf, User::Invariant()); |
|
199 |
|
200 if (iHeadbuf->Length() < iBlockLength) |
|
201 { |
|
202 iHeadbuf->ReAllocL(aBlockLength); |
|
203 iTailbuf->ReAllocL(aBlockLength); |
|
204 } |
220 } |
205 } |
221 |
206 |
222 |
207 |
223 TPos TBlockTransfer::GetHeadBlockOffset(TPos aPos) |
208 TPos TBlockTransfer::GetHeadBlockOffset(TPos aPos) |
224 { |
209 { |