302 { |
302 { |
303 Kern::Printf("Memory not allocated"); |
303 Kern::Printf("Memory not allocated"); |
304 p->AsyncDelete(); |
304 p->AsyncDelete(); |
305 return NULL; |
305 return NULL; |
306 } |
306 } |
|
307 |
|
308 #ifdef CPU_AFFINITY_ANY |
|
309 NKern::ThreadSetCpuAffinity((NThread*)(p->iDfcQ->iThread), KCpuAffinityAny); |
|
310 #endif |
|
311 |
307 //Register client with Resource Controller |
312 //Register client with Resource Controller |
308 TBuf8<32> ClientName(_L8("Client")); |
313 TBuf8<32> ClientName(_L8("Client")); |
309 p->iClient.pName = HBuf::New((const TDesC&)ClientName); |
314 p->iClient.pName = HBuf::New((const TDesC&)ClientName); |
310 if(!p->iClient.pName) |
315 if(!p->iClient.pName) |
311 { |
316 { |
516 TInt DTestResManLdd::DoControl(TInt aFunction, TAny* a1, TAny* a2) |
521 TInt DTestResManLdd::DoControl(TInt aFunction, TAny* a1, TAny* a2) |
517 { |
522 { |
518 TInt r = KErrNone; |
523 TInt r = KErrNone; |
519 TParameterListInfo ptr = {0, 0, 0, 0, 0}; |
524 TParameterListInfo ptr = {0, 0, 0, 0, 0}; |
520 //Copy parameter structure from user space. |
525 //Copy parameter structure from user space. |
521 if((aFunction != RTestResMan::EDeRegisterClient) && (aFunction != RTestResMan::ERequestNotificationUncond) && |
526 if((aFunction != RTestResMan::EDeRegisterClient) |
522 (aFunction != RTestResMan::ERegisterForIdleResourcesInfo) && (aFunction != RTestResMan::EGetIdleResourcesInfo) |
527 && (aFunction != RTestResMan::ERequestNotificationUncond) |
523 && (aFunction != RTestResMan::EDeRegisterClientLevelFromResource) && (aFunction != RTestResMan::ECheckPostBootLevelNotifications) |
528 && (aFunction != RTestResMan::EGetIdleResourcesInfo) |
524 && (aFunction != RTestResMan::EGetControllerVersion) |
529 && (aFunction != RTestResMan::EDeRegisterClientLevelFromResource) |
|
530 && (aFunction != RTestResMan::ECheckPostBootLevelNotifications) |
|
531 && (aFunction != RTestResMan::EGetControllerVersion) |
525 #ifdef PRM_ENABLE_EXTENDED_VERSION |
532 #ifdef PRM_ENABLE_EXTENDED_VERSION |
526 && (aFunction != RTestResMan::ERegisterDynamicResource)) |
533 && (aFunction != RTestResMan::ERegisterDynamicResource)) |
527 #else |
534 #else |
528 ) |
535 ) |
529 #endif |
536 #endif |
949 { |
956 { |
950 r = KErrAlreadyExists; |
957 r = KErrAlreadyExists; |
951 break; |
958 break; |
952 } |
959 } |
953 NKern::ThreadEnterCS(); |
960 NKern::ThreadEnterCS(); |
954 pBuf = HBuf::New((TUint)a2 * sizeof(SIdleResourceInfo)); //Allocate buffer for requested resources |
961 pBuf = HBuf::New((TUint)ptr.iPtr1 * sizeof(SIdleResourceInfo)); //Allocate buffer for requested resources |
955 NKern::ThreadLeaveCS(); |
962 NKern::ThreadLeaveCS(); |
956 if(!pBuf) |
963 if(!pBuf) |
957 return KErrNoMemory; |
964 return KErrNoMemory; |
958 SIdleResourceInfo* pI = (SIdleResourceInfo*)pBuf->Ptr(); |
965 r = Kern::ThreadRawRead(iClientThreadPtr, ptr.iPtr2, (TAny*)pBuf->Ptr(), (TUint)ptr.iPtr1 * sizeof(SIdleResourceInfo)); |
959 for(TUint c = 0; c < (TUint)a2; c++) |
966 if(r != KErrNone) |
960 pI[c].iResourceId = c+1; //Update resource id |
967 { |
|
968 Kern::Printf("RTestResMan::ERegisterForIdleResourceInfo threadRawRead failed with %d\n", r); |
|
969 break; |
|
970 } |
961 //Below function calls RegisterForResourceIdle resource controller virtual function, |
971 //Below function calls RegisterForResourceIdle resource controller virtual function, |
962 //This is for testing purposes only. |
972 //This is for testing purposes only. |
963 |
973 |
964 r =DSimulatedPowerResourceController::CaptureIdleResourcesInfo((TUint)a1, (TUint)a2, (TPtr*)pI); |
974 r =DSimulatedPowerResourceController::CaptureIdleResourcesInfo((TUint)ptr.iClientId, (TUint)ptr.iPtr1, (TPtr*)pBuf); |
965 if( r == KErrInUse) |
975 if( r == KErrInUse) |
966 delete pBuf; |
976 delete pBuf; |
967 break; |
977 break; |
968 } |
978 } |
969 case RTestResMan::EGetIdleResourcesInfo: |
979 case RTestResMan::EGetIdleResourcesInfo: |