equal
deleted
inserted
replaced
1 // Copyright (c) 1995-2010 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of the License "Eclipse Public License v1.0" |
4 // under the terms of the License "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
471 TInt id = ~m.iValue; |
471 TInt id = ~m.iValue; |
472 TRequestStatus* pS = (TRequestStatus*)m.Ptr0(); |
472 TRequestStatus* pS = (TRequestStatus*)m.Ptr0(); |
473 TInt r = KErrNone; |
473 TInt r = KErrNone; |
474 TTrackingBuffer *trackBuf = NULL; |
474 TTrackingBuffer *trackBuf = NULL; |
475 TUint parms[4]; |
475 TUint parms[4]; |
476 TPowerResourceCb *callBack = NULL; |
476 TPowerResourceCb *callBack; |
477 DPowerResourceNotification *prn; |
477 DPowerResourceNotification *prn; |
478 |
478 |
479 switch(id) |
479 switch(id) |
480 { |
480 { |
481 case RBusDevResManUs::EChangeResourceState: |
481 case RBusDevResManUs::EChangeResourceState: |
482 { |
482 { |
483 __ASSERT_ALWAYS(m.Ptr2() != NULL, RESMANUS_FAULT()); |
483 __ASSERT_ALWAYS(m.Ptr2() != NULL, RESMANUS_FAULT()); |
484 #ifdef _DUMP_TRACKERS |
484 #ifdef _DUMP_TRACKERS |
485 DumpTracker(iSetStateTracker); |
485 if((r=DumpTracker(iSetStateTracker))!=KErrNone) |
|
486 break; |
486 #endif |
487 #endif |
487 r = GetAndInitTrackingBuffer(iSetStateTracker, trackBuf, (TUint)m.Ptr1(), pS); |
488 r = GetAndInitTrackingBuffer(iSetStateTracker, trackBuf, (TUint)m.Ptr1(), pS); |
488 if( r != KErrNone) |
489 if( r != KErrNone) |
489 return r; |
490 return r; |
490 callBack = &(((TTrackSetStateBuf*)trackBuf)->iCtrlBlock); |
491 callBack = &(((TTrackSetStateBuf*)trackBuf)->iCtrlBlock); |
497 case RBusDevResManUs::EGetResourceState: |
498 case RBusDevResManUs::EGetResourceState: |
498 { |
499 { |
499 __ASSERT_ALWAYS(m.Ptr2() != NULL, RESMANUS_FAULT()); |
500 __ASSERT_ALWAYS(m.Ptr2() != NULL, RESMANUS_FAULT()); |
500 umemget32(&(parms[0]), m.Ptr2(), 3*sizeof(TInt)); |
501 umemget32(&(parms[0]), m.Ptr2(), 3*sizeof(TInt)); |
501 #ifdef _DUMP_TRACKERS |
502 #ifdef _DUMP_TRACKERS |
502 DumpTracker(iGetStateTracker); |
503 if((r=DumpTracker(iGetStateTracker))!=KErrNone) |
|
504 break; |
503 #endif |
505 #endif |
504 r = GetStateBuffer(iGetStateTracker, trackBuf, (TUint)m.Ptr1(), (TInt*)parms[1], (TInt*)parms[2], callBack, pS); |
506 r = GetStateBuffer(iGetStateTracker, trackBuf, (TUint)m.Ptr1(), (TInt*)parms[1], (TInt*)parms[2], callBack, pS); |
505 if(r != KErrNone) |
507 if(r != KErrNone) |
506 return r; |
508 return r; |
507 parms[3] = (TUint)callBack; |
509 parms[3] = (TUint)callBack; |
1265 if((r==KErrNone) && (stateRes[1]>0)) |
1267 if((r==KErrNone) && (stateRes[1]>0)) |
1266 r=InitTrackingControl(iSetStateTracker,ESetState,stateRes[1]); |
1268 r=InitTrackingControl(iSetStateTracker,ESetState,stateRes[1]); |
1267 if((r==KErrNone) && (stateRes[2]>0)) |
1269 if((r==KErrNone) && (stateRes[2]>0)) |
1268 r=InitTrackingControl(iListenableTracker,ENotify,stateRes[2]); |
1270 r=InitTrackingControl(iListenableTracker,ENotify,stateRes[2]); |
1269 #ifdef _DUMP_TRACKERS |
1271 #ifdef _DUMP_TRACKERS |
1270 DumpTracker(iGetStateTracker); |
1272 if((r=DumpTracker(iGetStateTracker))!=KErrNone) |
1271 DumpTracker(iSetStateTracker); |
1273 break; |
|
1274 if((r=DumpTracker(iSetStateTracker))!=KErrNone) |
|
1275 break; |
1272 #endif |
1276 #endif |
1273 } |
1277 } |
1274 break; |
1278 break; |
1275 } |
1279 } |
1276 |
1280 |
2008 new (aCb) TPowerResourceCb(&AsyncCallBackFn,(TAny*)aBuffer,iDfcQ,KResManCallBackPriority); |
2012 new (aCb) TPowerResourceCb(&AsyncCallBackFn,(TAny*)aBuffer,iDfcQ,KResManCallBackPriority); |
2009 } |
2013 } |
2010 return r; |
2014 return r; |
2011 } |
2015 } |
2012 |
2016 |
|
2017 |
2013 #ifdef _DUMP_TRACKERS |
2018 #ifdef _DUMP_TRACKERS |
2014 void DChannelResManUs::DumpTracker(TTrackingControl* aTracker) |
2019 TInt DChannelResManUs::DumpTracker(TTrackingControl* aTracker) |
2015 { |
2020 { |
2016 Kern::Printf("\nDChannelResManUs::DumpTracker"); |
2021 Kern::Printf("\nDChannelResManUs::DumpTracker"); |
2017 Kern::Printf("Tracker at 0x%x\n",aTracker); |
2022 Kern::Printf("Tracker at 0x%x\n",aTracker); |
2018 if(!aTracker) |
2023 if(NULL==aTracker) |
2019 { |
2024 return KErrGeneral; |
2020 Kern::Printf("Nothing to dump.."); |
|
2021 return; |
|
2022 } |
|
2023 Kern::Printf("iType=%d",aTracker->iType); |
2025 Kern::Printf("iType=%d",aTracker->iType); |
2024 switch(aTracker->iType) |
2026 switch(aTracker->iType) |
2025 { |
2027 { |
2026 case 0: |
2028 case 0: |
2027 Kern::Printf("= GetState tracker\n"); |
2029 Kern::Printf("= GetState tracker\n"); |
2039 if(aTracker->iFreeQue!=NULL) |
2041 if(aTracker->iFreeQue!=NULL) |
2040 { |
2042 { |
2041 buf=aTracker->iFreeQue->First(); |
2043 buf=aTracker->iFreeQue->First(); |
2042 while(buf!=aTracker->iFreeQue->Last()) |
2044 while(buf!=aTracker->iFreeQue->Last()) |
2043 { |
2045 { |
2044 Kern::Printf("iFreeQue first buffer at 0x%x\n",buf); |
2046 Kern::Printf("iFreeQue buffer at 0x%x\n",buf); |
2045 TAny* intermediatePtr = (TAny*)buf; |
2047 TAny* intermediatePtr = (TAny*)buf; |
2046 if((aTracker->iType == EGetState)||(aTracker->iType == ESetState)) |
2048 if((aTracker->iType == EGetState)||(aTracker->iType == ESetState)) |
2047 { |
2049 { |
2048 TTrackSetStateBuf* tempBuf =(TTrackSetStateBuf*)intermediatePtr; |
2050 TTrackStateBuf* tempBuf =(TTrackStateBuf*)intermediatePtr; |
2049 Kern::Printf("buffer control block at 0x%x\n",(TInt)&tempBuf->iCtrlBlock); |
2051 Kern::Printf("buffer control block at 0x%x\n",tempBuf->iCtrlBlock); |
2050 } |
2052 } |
2051 buf = buf->iNext; |
2053 buf= buf->iNext; |
2052 }; |
2054 }; |
2053 } |
2055 } |
2054 Kern::Printf("iBusyQue at 0x%x\n",aTracker->iBusyQue); |
2056 Kern::Printf("iBusyQue at 0x%x\n",aTracker->iBusyQue); |
2055 if(aTracker->iBusyQue!=NULL) |
2057 if(aTracker->iBusyQue!=NULL) |
2056 { |
2058 { |
2059 { |
2061 { |
2060 Kern::Printf("iBusyQue buffer at 0x%x\n",buf); |
2062 Kern::Printf("iBusyQue buffer at 0x%x\n",buf); |
2061 TAny* intermediatePtr = (TAny*)buf; |
2063 TAny* intermediatePtr = (TAny*)buf; |
2062 if((aTracker->iType == EGetState)||(aTracker->iType == ESetState)) |
2064 if((aTracker->iType == EGetState)||(aTracker->iType == ESetState)) |
2063 { |
2065 { |
2064 TTrackSetStateBuf* tempBuf =(TTrackSetStateBuf*)intermediatePtr; |
2066 TTrackStateBuf* tempBuf =(TTrackStateBuf*)intermediatePtr; |
2065 Kern::Printf("buffer control block at 0x%x\n", (TInt)&tempBuf->iCtrlBlock); |
2067 Kern::Printf("buffer control block at 0x%x\n",tempBuf->iCtrlBlock); |
2066 } |
2068 } |
2067 buf= buf->iNext; |
2069 buf= buf->iNext; |
2068 }; |
2070 }; |
2069 } |
2071 } |
|
2072 |
|
2073 return KErrNone; |
2070 } |
2074 } |
2071 #endif |
2075 #endif |
2072 |
2076 |
2073 TInt DChannelResManUs::InitTrackingControl(TTrackingControl*& aTracker, TUint8 aType, TUint8 aNumBuffers) |
2077 TInt DChannelResManUs::InitTrackingControl(TTrackingControl*& aTracker, TUint8 aType, TUint8 aNumBuffers) |
2074 { |
2078 { |
2159 void DChannelResManUs::RemoveTrackingControl(TTrackingControl*& aTracker) |
2163 void DChannelResManUs::RemoveTrackingControl(TTrackingControl*& aTracker) |
2160 { |
2164 { |
2161 __KTRACE_OPT(KRESMANAGER, Kern::Printf("DChannelResManUs::RemoveTrackingControl()")); |
2165 __KTRACE_OPT(KRESMANAGER, Kern::Printf("DChannelResManUs::RemoveTrackingControl()")); |
2162 |
2166 |
2163 // Free the resource-tracking links and their respective queues |
2167 // Free the resource-tracking links and their respective queues |
|
2168 TAny* buf; |
2164 if(aTracker->iFreeQue!=NULL) |
2169 if(aTracker->iFreeQue!=NULL) |
2165 { |
2170 { |
2166 while(!aTracker->iFreeQue->IsEmpty()) |
2171 while(!aTracker->iFreeQue->IsEmpty()) |
2167 { |
2172 { |
2168 delete aTracker->iFreeQue->GetFirst(); // Dequeues the element; |
2173 buf = (TAny*)(aTracker->iFreeQue->GetFirst()); // Dequeues the element |
|
2174 delete buf; |
2169 } |
2175 } |
2170 delete aTracker->iFreeQue; |
2176 delete aTracker->iFreeQue; |
2171 } |
2177 } |
2172 |
2178 |
2173 if(aTracker->iBusyQue!=NULL) |
2179 if(aTracker->iBusyQue!=NULL) |
2174 { |
2180 { |
2175 while(!aTracker->iBusyQue->IsEmpty()) |
2181 while(!aTracker->iBusyQue->IsEmpty()) |
2176 { |
2182 { |
2177 delete aTracker->iBusyQue->GetFirst(); // Dequeues the element; |
2183 buf = (TAny*)(aTracker->iBusyQue->GetFirst()); // Dequeues the element |
|
2184 delete buf; |
2178 } |
2185 } |
2179 delete aTracker->iBusyQue; |
2186 delete aTracker->iBusyQue; |
2180 } |
2187 } |
2181 delete aTracker; |
2188 delete aTracker; |
2182 } |
2189 } |