void CTestObjectManager::GetObjectHandlesL( const TMTPObjectMgrQueryParams& aParams, RMTPObjectMgrQueryContext& aContext, RArray<TUint>& aHandles ) const { CleanupClosePushL( aHandles ); PRINTF3( ">CTestObjectManager::GetObjectHandlesL storage = 0x%x parent = 0x%x format = 0x%x", aParams.iStorageId, aParams.iParentHandle, aParams.iFormatCode ); for ( TInt i = 0; i < iMTPObjects.Count(); i++ ) { TUint handle = iMTPObjects[i]->Uint( CMTPObjectMetaData::EHandle ); TUint formatCode = iMTPObjects[i]->Uint( CMTPObjectMetaData::EFormatCode ); TUint storageId = iMTPObjects[i]->Uint( CMTPObjectMetaData::EStorageId ); TInt parentId = iMTPObjects[i]->Int( CMTPObjectMetaData::EParentId ); if ( ( ( aParams.iStorageId == storageId ) || ( aParams.iStorageId == KMTPStorageAll ) ) && ( ( aParams.iFormatCode == formatCode ) || ( aParams.iFormatCode == KMTPFormatsAll ) ) && ( ( aParams.iParentHandle == parentId ) || ( aParams.iParentHandle == KMTPHandleNone ) || ( ( aParams.iParentHandle == KMTPHandleNoParent ) && ( parentId == KErrNotFound ) ) ) ) { PRINTV1( "Appending handle %d", handle ); aHandles.AppendL( handle ); } } aContext.Close(); PRINTF0( "<CTestObjectManager::GetObjectHandlesL" ); CleanupStack::Pop(); }
void CTestObjectManager::ConstructL() { TFileName logFileName; logFileName.Copy( KMtpDataProviderTestModuleLogFile ); iLog = CStifLogger::NewL( KMtpDataProviderTestModuleLogPath, logFileName, CStifLogger::ETxt, TRACE_TARGET, ETrue, ETrue, ETrue, EFalse, ETrue ); PRINTF0( "CTestObjectManager::ConstructL" ); }
void CTestObjectManager::CopyObjectMetadataL( const CMTPObjectMetaData& aSource, CMTPObjectMetaData& aTarget ) const { PRINTF0( ">CTestObjectManager::CopyObjectMetadataL" ); for ( TInt i = CMTPObjectMetaData::EDataProviderId; i <= CMTPObjectMetaData::EStorageVolumeId; i++ ) { aTarget.SetUint( i, aSource.Uint( i ) ); } aTarget.SetDesCL( CMTPObjectMetaData::ESuid, aSource.DesC( CMTPObjectMetaData::ESuid ) ); for ( TInt i = CMTPObjectMetaData::EUserRating; i <= CMTPObjectMetaData::EIdentifier; i++ ) { aTarget.SetUint( i, aSource.Uint( i ) ); } aTarget.SetInt( CMTPObjectMetaData::EParentId, aSource.Int( CMTPObjectMetaData::EParentId ) ); PRINTF0( "<CTestObjectManager::CopyObjectMetadataL" ); }
TBool CTestObjectManager::ObjectL( const TDesC& aSuid, CMTPObjectMetaData& aObject ) const { PRINTF1( ">CTestObjectManager::ObjectL suid = %S", &aSuid ); for ( TInt i = 0; i < iMTPObjects.Count(); i++ ) { if ( ( iMTPObjects[i]->DesC(CMTPObjectMetaData::ESuid ) ).Match( aSuid ) == 0) { PRINTF1( "<CTestObjectManager::ObjectL, index = %d", i ); CopyObjectMetadataL( *( iMTPObjects[i] ), aObject ); return ETrue; } } PRINTF0( "<CTestObjectManager::ObjectL, object not found" ); return EFalse; }
TBool CTestObjectManager::ObjectL( const TMTPTypeUint32& aHandle, CMTPObjectMetaData& aObject ) const { TUint32 handle = aHandle.Value(); PRINTF1( ">CTestObjectManager::ObjectL handle = %d", handle ); for ( TInt i = 0; i < iMTPObjects.Count(); i++ ) { if ( iMTPObjects[i]->Uint( CMTPObjectMetaData::EHandle ) == handle ) { PRINTF1( "<CTestObjectManager::ObjectL, index = %d", i ); CopyObjectMetadataL( *iMTPObjects[i], aObject ); return ETrue; } } PRINTF0( "<CTestObjectManager::ObjectL, object not found" ); return EFalse; }
void CTestObjectManager::ModifyObjectL( const CMTPObjectMetaData& aObject ) { TUint32 handle = aObject.Uint( CMTPObjectMetaData::EHandle ); PRINTF1( ">CTestObjectManager::ModifyObjectL handle = %d", handle ); for ( TInt i = 0; i < iMTPObjects.Count(); i++ ) { if ( iMTPObjects[i]->Uint( CMTPObjectMetaData::EHandle ) == handle ) { PRINTF1( "<CTestObjectManager::ModifyObjectL, index = %d", i ); CopyObjectMetadataL( aObject, *iMTPObjects[i] ); return; } } PRINTF0( "<CTestObjectManager::ModifyObjectL, object not found" ); User::Leave( KErrNotFound ); }
void CTestObjectManager::UnreserveObjectHandleL( const CMTPObjectMetaData& aObject ) { TUint reservedHandle = aObject.Uint( CMTPObjectMetaData::EHandle ); PRINTF1( ">CTestObjectManager::UnreserveObjectHandleL handle = %d", reservedHandle ); for ( TInt i = 0; i < iMTPObjects.Count(); i++) { TUint handle = iMTPObjects[i]->Uint( CMTPObjectMetaData::EHandle ); if ( reservedHandle == handle ) { CMTPObjectMetaData* object = iMTPObjects[i]; iMTPObjects.Remove( i ); delete object; break; } } PRINTF0( "<CTestObjectManager::UnreserveObjectHandleL" ); }
void CTestObjectManager::GetObjectSuidsL( const TMTPObjectMgrQueryParams& aParams, RMTPObjectMgrQueryContext& aContext, CDesCArray& aSuids ) const { PRINTF3( ">CTestObjectManager::GetObjectSuidsL storage = 0x%x parent = 0x%x format = 0x%x", aParams.iStorageId, aParams.iParentHandle, aParams.iFormatCode ); for ( TInt i = 0; i < iMTPObjects.Count(); i++ ) { TPtrC suid = iMTPObjects[i]->DesC( CMTPObjectMetaData::ESuid ); TUint formatCode = iMTPObjects[i]->Uint( CMTPObjectMetaData::EFormatCode ); TUint storageId = iMTPObjects[i]->Uint( CMTPObjectMetaData::EStorageId ); TInt parentId = iMTPObjects[i]->Int( CMTPObjectMetaData::EParentId ); if ( ( ( aParams.iStorageId == storageId ) || ( aParams.iStorageId == KMTPStorageAll ) ) && ( ( aParams.iFormatCode == formatCode ) || ( aParams.iFormatCode == KMTPFormatsAll ) ) && ( ( aParams.iParentHandle == parentId ) || ( aParams.iParentHandle == KMTPHandleNone ) || ( ( aParams.iParentHandle == KMTPHandleNoParent ) && ( parentId == KErrNotFound ) ) ) ) { PRINTV1( "Appending suid %S", &suid ); aSuids.AppendL( suid ); } } aContext.Close(); PRINTF0( "<CTestObjectManager::GetObjectSuidsL" ); }
int main(void) { /* int c = 0;*/ /* int i = 0;*/ /* int data = 0;*/ /* IntVector *vec;*/ /* IntList *lst;*/ /* INTR_DISABLE;*/ init(); /* INTR_ENABLE;*/ puts("Hello, World!\n"); /* printval();*/ /* puts("overwrite variables.\n");*/ /* global_data++;*/ /* global_bss++;*/ /* static_data++;*/ /* static_bss++;*/ /* printval();*/ cmd_map(); #if 0 vec = IntVector_new(); /* lst = IntList_new();*/ while (1) { static char buf[32]; char *p; PRINTF0(">"); gets(buf, sizeof buf); p = strpbrk(buf, "\r\n"); if (p) *p = '\0'; PRINTF1("%s\n", buf); if (sw_is_on(SW1)) { led_on(LED1); i++; if (i > 100) { i = 0; if (IntVector_push_back(vec, data)) { PRINTF1("IntVector_push_back: %d", data); /* putdval(data, 0);*/ data++; PRINTF1(", IntVector_size: %d\n", IntVector_size(vec)); /* putdval(IntVector_size(vec), 0);*/ /* puts("\n");*/ } else { puts("IntVector_push_back: failed\n"); puts("IntVector_capacity: "); putdval(IntVector_capacity(vec), 0); puts(", IntVector_size: "); putdval(IntVector_size(vec), 0); puts("\n"); } } } else { led_off(LED1); } if (sw_is_on(SW2)) { if (!IntVector_empty(vec)) { puts("IntVector_back: "); putdval(*IntVector_back(vec), 0); puts(", IntVector_pop_back"); IntVector_pop_back(vec); puts("\n"); } } if (sw_is_on(SW5_8)) { led_on(LED2); } else { led_off(LED2); } if (sw_is_on(SW3)) { putxval(c++, 0); puts("\n"); } if (sw_is_on(SW4)) { putdval(c++, 0); puts("\n"); } } #endif return 0; }
int main(int argc, char *argv[]) { int ch; extern char *optarg; int i, j, r; thread_t threads[MAX_TPP]; /* init MP */ MP_INIT(argc,argv); MP_PROCS(&size); MP_MYID(&rank); while ((ch = getopt(argc, argv, "t:s:i:d:h")) != -1) { switch(ch) { case 't': /* # of threads */ tpp = atoi(optarg); if (tpp < 1 || tpp > MAX_TPP) { PRINTF0("\"%s\" is improper value for -t, should be a " "number between 1 and %d(MAX_TPP)\n", optarg, MAX_TPP); usage(); } break; case 'i': /* # of iterations */ iters = atoi(optarg); if (iters < 1) { PRINTF0("\"%s\" is improper value for -t, should be a " "number equal or larger than 1\n", optarg); usage(); } break; case 's': /* # of elements in the array */ asize = atoi(optarg); if (iters < 1) { PRINTF0("\"%s\" is improper value for -s, should be a " "number equal or larger than 1\n", optarg); usage(); } break; case 'd': delay = atoi(optarg); break; /* delay before start */ case 'h': usage(); break; /* print usage info */ } } #ifdef NOTHREADS tpp = 1; PRINTF0("Warning: NOTHREADS debug symbol is set -- running w/o threads\n"); #endif th_size = size * tpp; PRINTF0("\nTest of multi-threaded capabilities:\n" "%d threads per process (%d threads total),\n" "%d array elements of size %d,\n" "%d iteration(s)\n\n", tpp, th_size, asize, sizeof(atype_t), iters); if (delay) { printf("%d: %d\n", rank, getpid()); fflush(stdout); sleep(delay); MP_BARRIER(); } TH_INIT(size,tpp); for (i = 0; i < tpp; i++) th_rank[i] = rank * tpp + i; #if defined(DEBUG) && defined(LOG2FILE) for (i = 0; i < tpp; i++) { fname[10] = '0' + th_rank[i] / 100; fname[11] = '0' + th_rank[i] % 100 / 10; fname[12] = '0' + th_rank[i] % 10; dbg[i] = fopen(fname, "w"); } #endif for (i = 0; i < tpp; i++) prndbg(i, "proc %d, thread %d(%d):\n", rank, i, th_rank[i]); /* init ARMCI */ ARMCI_Init(); /* set global seed (to ensure same random sequence across procs) */ time_seed = (unsigned)time(NULL); armci_msg_brdcst(&time_seed, sizeof(time_seed), 0); srand(time_seed); rand(); prndbg(0, "seed = %u\n", time_seed); /* random pairs */ pairs = calloc(th_size, sizeof(int)); for (i = 0; i < th_size; i++) pairs[i] = -1; for (i = 0; i < th_size; i++) { if (pairs[i] != -1) continue; r = RND(0, th_size); while (i == r || pairs[r] != -1 ) r = RND(0, th_size); pairs[i] = r; pairs[r] = i; } for (i = 0, cbufl = 0; i < th_size; i++) cbufl += sprintf(cbuf + cbufl, " %d->%d|%d->%d", i, pairs[i], pairs[i], pairs[pairs[i]]); prndbg(0, "random pairs:%s\n", cbuf); /* random targets */ rnd_tgts = calloc(th_size, sizeof(int)); for (i = 0, cbufl = 0; i < th_size; i++) { rnd_tgts[i] = RND(0, th_size); if (rnd_tgts[i] == i) { i--; continue; } cbufl += sprintf(cbuf + cbufl, " %d", rnd_tgts[i]); } prndbg(0, "random targets:%s\n", cbuf); /* random one */ rnd_one = RND(0, th_size); prndbg(0, "random one = %d\n", rnd_one); assert(ptrs1 = calloc(th_size, sizeof(void *))); assert(ptrs2 = calloc(th_size, sizeof(void *))); #ifdef NOTHREADS thread_main((void *)(long)0); #else for (i = 0; i < tpp; i++) THREAD_CREATE(threads + i, thread_main, (void *)(long)i); for (i = 0; i < tpp; i++) THREAD_JOIN(threads[i], NULL); #endif MP_BARRIER(); PRINTF0("Tests Completed\n"); /* clean up */ #if defined(DEBUG) && defined(LOG2FILE) for (i = 0; i < tpp; i++) fclose(dbg[i]); #endif ARMCI_Finalize(); TH_FINALIZE(); MP_FINALIZE(); return 0; }
CTestObjectManager::~CTestObjectManager() { PRINTF0( "<>CTestObjectManager::~CTestObjectManager()" ); delete iLog; iMTPObjects.ResetAndDestroy(); }
void CTestObjectManager::RemoveObjectsL( const CDesCArray& /*aSuids*/ ) { PRINTF0( "<>CTestObjectManager::RemoveObjectsL suid arr" ); PRINTE0( "NOT IMPLEMENTED" ); }
void CTestObjectManager::InsertObjectsL( RPointerArray<CMTPObjectMetaData>& /*aObjects*/ ) { PRINTF0( "<>CTestObjectManager::InsertObjectsL" ); PRINTE0( "NOT IMPLEMENTED" ); }
tEplKernel PUBLIC AppCbEvent( tEplApiEventType EventType_p, // IN: event type (enum) tEplApiEventArg* pEventArg_p, // IN: event argument (union) void GENERIC* pUserArg_p) { tEplKernel EplRet = kEplSuccessful; // check if NMT_GS_OFF is reached switch (EventType_p) { case kEplApiEventNmtStateChange: { switch (pEventArg_p->m_NmtStateChange.m_NewNmtState) { case kEplNmtGsOff: { // NMT state machine was shut down, // because of critical EPL stack error // -> also shut down EplApiProcess() and main() EplRet = kEplShutdown; fShutdown_l = TRUE; PRINTF2("%s(kEplNmtGsOff) originating event = 0x%X\n", __func__, pEventArg_p->m_NmtStateChange.m_NmtEvent); break; } case kEplNmtGsInitialising: case kEplNmtGsResetApplication: case kEplNmtGsResetConfiguration: case kEplNmtCsPreOperational1: case kEplNmtCsBasicEthernet: case kEplNmtMsBasicEthernet: { PRINTF3("%s(0x%X) originating event = 0x%X\n", __func__, pEventArg_p->m_NmtStateChange.m_NewNmtState, pEventArg_p->m_NmtStateChange.m_NmtEvent); break; } case kEplNmtGsResetCommunication: { BYTE bNodeId = 0xF0; DWORD dwNodeAssignment = EPL_NODEASSIGN_NODE_EXISTS; WORD wPresPayloadLimit = 256; PRINTF3("%s(0x%X) originating event = 0x%X\n", __func__, pEventArg_p->m_NmtStateChange.m_NewNmtState, pEventArg_p->m_NmtStateChange.m_NmtEvent); EplRet = EplApiWriteLocalObject(0x1F81, bNodeId, &dwNodeAssignment, sizeof (dwNodeAssignment)); if (EplRet != kEplSuccessful) { goto Exit; } bNodeId = 0x04; EplRet = EplApiWriteLocalObject(0x1F81, bNodeId, &dwNodeAssignment, sizeof (dwNodeAssignment)); if (EplRet != kEplSuccessful) { goto Exit; } EplRet = EplApiWriteLocalObject(0x1F8D, bNodeId, &wPresPayloadLimit, sizeof (wPresPayloadLimit)); if (EplRet != kEplSuccessful) { goto Exit; } break; } case kEplNmtMsNotActive: break; case kEplNmtCsNotActive: break; break; case kEplNmtCsOperational: break; case kEplNmtMsOperational: break; default: { break; } } break; } case kEplApiEventCriticalError: case kEplApiEventWarning: { // error or warning occurred within the stack or the application // on error the API layer stops the NMT state machine PRINTF3("%s(Err/Warn): Source=%02X EplError=0x%03X", __func__, pEventArg_p->m_InternalError.m_EventSource, pEventArg_p->m_InternalError.m_EplError); // check additional argument switch (pEventArg_p->m_InternalError.m_EventSource) { case kEplEventSourceEventk: case kEplEventSourceEventu: { // error occurred within event processing // either in kernel or in user part PRINTF1(" OrgSource=%02X\n", pEventArg_p->m_InternalError.m_Arg.m_EventSource); break; } case kEplEventSourceDllk: { // error occurred within the data link layer (e.g. interrupt processing) // the DWORD argument contains the DLL state and the NMT event PRINTF1(" val=%lX\n", pEventArg_p->m_InternalError.m_Arg.m_dwArg); break; } default: { PRINTF0("\n"); break; } } break; } case kEplApiEventHistoryEntry: { // new history entry PRINTF("%s(HistoryEntry): Type=0x%04X Code=0x%04X (0x%02X %02X %02X %02X %02X %02X %02X %02X)\n", __func__, pEventArg_p->m_ErrHistoryEntry.m_wEntryType, pEventArg_p->m_ErrHistoryEntry.m_wErrorCode, (WORD) pEventArg_p->m_ErrHistoryEntry.m_abAddInfo[0], (WORD) pEventArg_p->m_ErrHistoryEntry.m_abAddInfo[1], (WORD) pEventArg_p->m_ErrHistoryEntry.m_abAddInfo[2], (WORD) pEventArg_p->m_ErrHistoryEntry.m_abAddInfo[3], (WORD) pEventArg_p->m_ErrHistoryEntry.m_abAddInfo[4], (WORD) pEventArg_p->m_ErrHistoryEntry.m_abAddInfo[5], (WORD) pEventArg_p->m_ErrHistoryEntry.m_abAddInfo[6], (WORD) pEventArg_p->m_ErrHistoryEntry.m_abAddInfo[7]); break; } case kEplApiEventLed: { // status or error LED shall be changed switch (pEventArg_p->m_Led.m_LedType) { #ifdef LED_STATUS_PIO_BASE case kEplLedTypeStatus: { if (pEventArg_p->m_Led.m_fOn != FALSE) { IOWR_ALTERA_AVALON_PIO_DATA(LED_STATUS_PIO_BASE, 1); } else { IOWR_ALTERA_AVALON_PIO_DATA(LED_STATUS_PIO_BASE, 0); } break; } #endif #ifdef LED_ERROR_PIO_BASE case kEplLedTypeError: { if (pEventArg_p->m_Led.m_fOn != FALSE) { IOWR_ALTERA_AVALON_PIO_DATA(LED_ERROR_PIO_BASE, 1); } else { IOWR_ALTERA_AVALON_PIO_DATA(LED_ERROR_PIO_BASE, 0); } break; } #endif default: break; } break; } default: break; } Exit: return EplRet; }