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