TAny* CMemSpyEngineHelperActiveObject::ReadActiveObjectDataL( TAny* aCellAddress, CMemSpyEngineActiveObjectArray& aArray ) { //RDebug::Printf("CMemSpyEngineHelperActiveObject::ReadActiveObjectDataL() - START"); //RDebug::Printf("CMemSpyEngineHelperActiveObject::ReadActiveObjectDataL() - AO.cellAddress: 0x%08x", aCellAddress); TAny* nextCellAddress = NULL; TMemSpyDriverCellType cellType; TInt cellLength; TInt cellNestingLevel; TInt cellAllocationNumber; TInt cellHeaderSize; TAny* cellPayloadAddress; // Make a separate copy of the cell address - calling GetCellInfo may well result in the address being // changed in order to match the real starting address of a *heap cell*. TAny* requestedCellAddress = aCellAddress; TInt err = iEngine.Driver().WalkHeapGetCellInfo( requestedCellAddress, cellType, cellLength, cellNestingLevel, cellAllocationNumber, cellHeaderSize, cellPayloadAddress ); //RDebug::Printf("CMemSpyEngineHelperActiveObject::ReadActiveObjectDataL() - err: %d, cellLength: %d, cellAllocationNumber: %d, cellType: %d", err, cellLength, cellAllocationNumber, cellType); User::LeaveIfError( err ); if (cellType & EMemSpyDriverAllocatedCellMask) { const TInt payloadLength = cellLength; //RDebug::Printf("CMemSpyEngineHelperActiveObject::ReadActiveObjectDataL() - payloadLength: %d", payloadLength); // const TInt payloadLength = Max( 512, cellLength - iHeapInfo.iHeapCellHeaderLengthAllocated ); // Prevent negative payload lengths? CBufFlat* data = CBufFlat::NewL( payloadLength ); CleanupStack::PushL( data ); data->ResizeL( payloadLength ); TPtr8 pData( data->Ptr( 0 ) ); // err = iEngine.Driver().WalkHeapReadCellData( requestedCellAddress, pData, payloadLength ); //RDebug::Printf("CMemSpyEngineHelperActiveObject::ReadActiveObjectDataL() - AO.heapCellAddress: 0x%08x (err: %d)", requestedCellAddress, err); User::LeaveIfError( err ); // If an object is embedded directly within a class, for example // // class CSomething : public CBase // { // CIdle iEmbeddedIdler; // } // // then aCellAddress actually points to somewhere *within* a heap cell, not to the actual starting address of // the heap cell itself. We must take this into account when parsing the heap cell data (i.e. the bit of the cell we // are interested in starts part way through the cell data). TInt cellOffset = TUint32( aCellAddress ) - TUint32( requestedCellAddress ); //RDebug::Printf("CMemSpyEngineHelperActiveObject::ReadActiveObjectDataL() - AO.cellOffset: %d (ignoring cell header)", cellOffset); cellOffset -= cellHeaderSize; //RDebug::Printf("CMemSpyEngineHelperActiveObject::ReadActiveObjectDataL() - AO.cellOffset: %d (adjusted for cell header)", cellOffset); // Got the cell data for the active object. Let's parse it. RBufReadStream stream( *data, cellOffset ); CleanupClosePushL( stream ); // First item should be vTable TAny* vTable = (TAny*) stream.ReadUint32L(); //RDebug::Printf("CMemSpyEngineHelperActiveObject::ReadActiveObjectDataL() - AO.vTable: 0x%08x", vTable ); // Next item should be the request status. First the iStatus, then the iFlags const TInt requestStatusValue = stream.ReadInt32L(); //RDebug::Printf("CMemSpyEngineHelperActiveObject::ReadActiveObjectDataL() - AO.rsVal: %10d", requestStatusValue ); const TUint requestStatusFlags = stream.ReadUint32L(); //RDebug::Printf("CMemSpyEngineHelperActiveObject::ReadActiveObjectDataL() - AO.rsFlags: 0x%02x", requestStatusFlags ); // Next comes the baseclass for the link - TDblQueLinkBase TAny* nextEntryAddress = (TAny*) stream.ReadUint32L(); //RDebug::Printf("CMemSpyEngineHelperActiveObject::ReadActiveObjectDataL() - AO.iLink.Next: 0x%08x", nextEntryAddress ); TAny* prevEntryAddress = (TAny*) stream.ReadUint32L(); //RDebug::Printf("CMemSpyEngineHelperActiveObject::ReadActiveObjectDataL() - AO.iLink.Prev: 0x%08x", prevEntryAddress ); // Next comes the TPriQueueLink itself const TInt priority = stream.ReadInt32L(); //RDebug::Printf("CMemSpyEngineHelperActiveObject::ReadActiveObjectDataL() - AO.iLink.Pri: %d", priority ); // Done - save object & tidy up CMemSpyEngineActiveObject* object = CMemSpyEngineActiveObject::NewLC( aCellAddress, vTable, priority, requestStatusValue, requestStatusFlags, nextEntryAddress, prevEntryAddress, iEngine ); aArray.AddItemL( object ); CleanupStack::Pop( object ); CleanupStack::PopAndDestroy( 2, data ); // stream & data nextCellAddress = (TAny*) nextEntryAddress; //RDebug::Printf(" "); } return nextCellAddress; }
bool CCpu::SingleStep() { ServiceInterruptRequest(); //Save incoming PC to compare with the outgoing one. If they are identical //this indicates a "halt" instruction. TUint16 incommingPc = iRegMap.iPC; //Read the instruction, and decode the op code. TUint16 inst = iMemMap[iRegMap.iPC++]; TUint op = Decode::BasicOpCode(inst); //All opcodes need to read and/or write operand A. TUint16& a = Decode::OperandA(iRegMap, iMemMap, Decode::A(inst)); if(op != Decode::EOpCodeSPECIAL) { //All basic instructions need to read A and read and/or write B. TUint16& b = Decode::OperandB(iRegMap, iMemMap, Decode::B(inst)); switch(op) { case Decode::EOpCodeSET: { b = a; AddCycles(1); break; } case Decode::EOpCodeADD: { TUint32 u32 = TUint32(b) + TUint32(a); b = TUint16(u32 & 0xffff); iRegMap.iEX = TUint16(u32 >> 16); AddCycles(2); break; } case Decode::EOpCodeSUB: { TUint32 u32 = TUint32(b) - TUint32(a); b = TUint16(u32 & 0xffff); iRegMap.iEX = TUint16(u32 >> 16); AddCycles(2); break; } case Decode::EOpCodeMUL: { TUint32 u32 = TUint32(b) * TUint32(a); b = TUint16(u32 & 0xffff); iRegMap.iEX = TUint16(u32 >> 16); AddCycles(2); break; } case Decode::EOpCodeMLI: { TInt32 i32 = TInt32(b) * TInt32(a); b = TUint16(i32 & 0x7fff); iRegMap.iEX = TUint16(i32 >> 16); AddCycles(2); break; } case Decode::EOpCodeDIV: { if(a == 0) { b = 0; iRegMap.iEX = 0; } else { b /= a; iRegMap.iEX = TUint16(((TUint32(b) << 16) / TUint32(a))); } AddCycles(3); break; } case Decode::EOpCodeDVI: { if(a == 0) { b = 0; iRegMap.iEX = 0; } else { TInt32 sa = TInt32(a); TInt32 sb = TInt32(b); b = TUint16(sb / sa); iRegMap.iEX = TUint16((sb << 16) / sa); } AddCycles(3); break; } case Decode::EOpCodeMOD: { if(a == 0) { b = 0; } else { b = TUint16(TInt32(b) % TInt32(a)); } AddCycles(3); break; } case Decode::EOpCodeMDI: { if(a == 0) { b = 0; } else { b = TUint16(TInt32(b) % TInt32(a)); } AddCycles(3); break; } case Decode::EOpCodeAND: { b &= a; AddCycles(1); break; } case Decode::EOpCodeBOR: { b |= a; AddCycles(1); break; } case Decode::EOpCodeXOR: { b ^= a; AddCycles(1); break; } case Decode::EOpCodeSHR: { b >>= a; iRegMap.iEX = TUint16(((TUint32(b) << 16) >> TUint32(a))); AddCycles(1); break; } case Decode::EOpCodeASR: { TInt32 sb = TInt32(b); b = TUint16(sb >> a); iRegMap.iEX = TUint16((TInt32(sb) << 16) >> TUint32(a)); AddCycles(1); break; } case Decode::EOpCodeSHL: { TUint32 u32 = TUint32(b) << TUint32(a); b = TUint16(u32 & 0xffff); iRegMap.iEX = TUint16(u32 >> 16); AddCycles(1); break; } case Decode::EOpCodeIFB: { if((b & a) == 0) { SkipInstructions(); } AddCycles(2); break; } case Decode::EOpCodeIFC: { if((b & a) != 0) { SkipInstructions(); } AddCycles(2); break; } case Decode::EOpCodeIFE: { if(b != a) { SkipInstructions(); } AddCycles(2); break; } case Decode::EOpCodeIFN: { if(b == a) { SkipInstructions(); } AddCycles(2); break; } case Decode::EOpCodeIFG: { if(b <= a) { SkipInstructions(); } AddCycles(2); break; } case Decode::EOpCodeIFA: { if(TInt32(b) <= TInt32(a)) { SkipInstructions(); } AddCycles(2); break; } case Decode::EOpCodeIFL: { if(b >= a) { SkipInstructions(); } AddCycles(2); break; } case Decode::EOpCodeIFU: { if(TInt32(b) >= TInt32(a)) { SkipInstructions(); } AddCycles(2); break; } case Decode::EOpCodeADX: { TUint32 u32 = TUint32(b) + TUint32(a) + TUint32(iRegMap.iEX); b = TUint16(u32 & 0xffff); iRegMap.iEX = TUint16(u32 >> 16); AddCycles(3); break; } case Decode::EOpCodeSBX: { TUint32 u32 = TUint32(b) - TUint32(a) + TUint32(iRegMap.iEX); b = TUint16(u32 & 0xffff); iRegMap.iEX = TUint16(u32 >> 16); AddCycles(3); break; } case Decode::EOpCodeSTI: { b = a; iRegMap.iI++; iRegMap.iJ++; AddCycles(2); break; } case Decode::EOpCodeSTD: { b = a; iRegMap.iI--; iRegMap.iJ--; AddCycles(2); break; } default: assert("Unknown basic op code" && false); } }
void BuildRecordZeroL(CSdpDatabase* aDb) /** Record 0 should be used when a server instance is created. note that attributes 2, 5 and 0x201 should be updated. also note only English, pas de Francais, keine Deutsch, non Espanol **/ { TBuf8<2> attrId; TBuf8<4> val; CSdpServRecord* theRec = CSdpServRecord::NewL(); CleanupStack::PushL(theRec); // Set Attr 0 (Record handle) to 0 attrId.FillZ(2); val.FillZ(4); theRec->BuildUintL(attrId)->BuildUintL(val); // Set Attr 1 (service class list) to list with UUID = 0x1000 attrId[0] = 0x00; attrId[1] = 0x01; theRec->BuildUintL(attrId)->BuildDESL() ->StartListL() ->BuildUUIDL(TUUID(TUint16(0x1000))) ->EndListL(); // Set Attr 2 (service record state) to 0 attrId[0] = 0x00; attrId[1] = 0x02; val.FillZ(4); theRec->BuildUintL(attrId)->BuildUintL(val); // Set attr 4 (protocol list) to L2CAP, no RFCOMM, no OBEX attrId[0] = 0x00; attrId[1] = 0x04; val.FillZ(4); val[3] = 1; theRec->BuildUintL(attrId)->BuildDESL() ->StartListL() ->BuildDESL() ->StartListL() ->BuildUUIDL(TUUID(TUint16(0x0100))) // L2CAP ->EndListL() ->EndListL(); // Set Attr 5 (browse group list) to list with one UUID // 0x1000 (SDP server class) // this should be updated with other service classes when other services are added. attrId[0] = 0x00; attrId[1] = 5; theRec->BuildUintL(attrId)->BuildDESL() ->StartListL() ->BuildUUIDL(TUUID(TUint32(0x1002))) ->EndListL(); // Set Attr 0x006 (language base) attrId[0] = 0x00; attrId[1] = 0x06; TUint16 lang = 0x656e; TUint16 coding = 0x006a; TUint16 base = 0x0100; theRec->BuildUintL(attrId)->BuildDESL() ->StartListL() ->BuildUintL(TSdpIntBuf<TUint16>(lang)) // english ->BuildUintL(TSdpIntBuf<TUint16>(coding)) // UTF-8 ->BuildUintL(TSdpIntBuf<TUint16>(base)) // language base ->EndListL(); // Set Attr 0x007 (time to live) to 1200 (0x4B0) seconds (20 minutes) attrId[0] = 0x00; attrId[1] = 0x07; val.FillZ(4); val[2]=4; val[3]=0xb0; theRec->BuildUintL(attrId)->BuildUintL(val); // Set Attr 0x008 (availability) to 0xff - fully available - not in use attrId[0] = 0x00; attrId[1] = 0x08; TBuf8<1> val4; val4.FillZ(1); val4[0]=0xff; theRec->BuildUintL(attrId)->BuildUintL(val4); // Set Attr 0x100 (default Name) to string attrId[0] = 0x01; attrId[1] = 0; theRec->BuildUintL(attrId)->BuildStringL(_L8("SDP Server")); // Set Attr 0x101 (def. description) to string attrId[0] = 0x01; attrId[1] = 1; theRec->BuildUintL(attrId)->BuildStringL(_L8("EPOC SDP server UPF-4")); // Set Attr 0x102 (def. provider) to Symbian attrId[0] = 0x01; attrId[1] = 2; theRec->BuildUintL(attrId)->BuildStringL(_L8("Symbian Ltd.")); // Set Attr 0x201 (service database state) to 0 attrId[0] = 0x02; attrId[1] = 0x01; val.FillZ(4); theRec->BuildUintL(attrId)->BuildUintL(val); CleanupStack::Pop(); // Add the record into the database aDb->AddRecord(theRec); }
// this is a real dummy database which doesn't conform to the service class attribute numbering CSdpDatabase *BuildDbL() { CSdpDatabase *theDb = CSdpDatabase::NewL(); // First Record CSdpServRecord *theRec = CSdpServRecord::NewL(); // Set Attr 0 (Record handle) to 0 theRec->BuildUintL(TSdpIntBuf<TUint16>(0))->BuildUintL(TSdpIntBuf<TUint32>(0)); // Set Attr 0x100 (default Name) to string theRec->BuildUintL(TSdpIntBuf<TUint16>(0x100))->BuildStringL(_L8("SDP Server")); // Set Attr 0x102 (def. provider) to Symbian theRec->BuildUintL(TSdpIntBuf<TUint16>(0x102))->BuildStringL(_L8("Symbian Ltd.")); // Set Attr 0x101 (def. description) to string theRec->BuildUintL(TSdpIntBuf<TUint16>(0x101))->BuildStringL(_L8("EPOC SDP server test suite")); // Set Attr 1 (service class list) to list with one UUID = 0x1000 (SDP server service) theRec->BuildUintL(TSdpIntBuf<TUint16>(1))->BuildDESL() ->StartListL() ->BuildUUIDL(TUUID(TUint32(0x1000))) ->EndListL(); // Add the record into the database theDb->AddRecord(theRec); // Second Record theRec = CSdpServRecord::NewL(); // Set Attr 0 (Record handle) to 0x11223344 theRec->BuildUintL(TSdpIntBuf<TUint16>(0))->BuildUintL(TSdpIntBuf<TUint32>(0x11223344)); // Set Attr 0x100 (default Name) to string theRec->BuildUintL(TSdpIntBuf<TUint16>(0x100))->BuildStringL(_L8("Dummy Service")); // Set Attr 0x101 (def. description) to string theRec->BuildUintL(TSdpIntBuf<TUint16>(0x101))->BuildStringL(_L8("A Test SDP record")); // Set Attr 1 (service class list) to list with Two UUID = 0x1000, 0x55667788 theRec->BuildUintL(TSdpIntBuf<TUint16>(1))->BuildDESL() ->StartListL() ->BuildUUIDL(TUUID(TUint32(0x1000))) ->BuildUUIDL(TUUID(TUint32(0x55667788))) ->EndListL(); // Set Attr 3 (service ID) to a bogoid 0x9999 theRec->BuildUintL(TSdpIntBuf<TUint16>(3))->BuildUUIDL(TUUID(TUint16(0x9999))); // Add the record into the database theDb->AddRecord(theRec); // Third Record theRec = CSdpServRecord::NewL(); // Set Attr 0 (Record handle) to 0x9899 theRec->BuildUintL(TSdpIntBuf<TUint16>(0))->BuildUintL(TSdpIntBuf<TUint32>(0x9899)); // Set Attr 0x100 (default Name) to string theRec->BuildUintL(TSdpIntBuf<TUint16>(0x100))->BuildStringL(_L8("Another dummy service")); // Set Attr 0x101 (def. description) to string theRec->BuildUintL(TSdpIntBuf<TUint16>(0x101))->BuildStringL(_L8("This is the second service on SDP")); // Set Attr 1 (service class list) to list with one UUID = 0x1105 (OBEX Push) theRec->BuildUintL(TSdpIntBuf<TUint16>(1))->BuildDESL() ->StartListL() ->BuildUUIDL(TUUID(TUint32(0x1105))) ->EndListL(); // Set attr 4 (protocol list) to L2CAP, RFCOMM (DLCI=5) theRec->BuildUintL(TSdpIntBuf<TUint16>(4))->BuildDESL() ->StartListL() ->BuildDESL() ->StartListL() ->BuildUUIDL(TUUID(TUint16(0x0100))) // L2CAP ->EndListL() ->BuildDESL() ->StartListL() ->BuildUUIDL(TUUID(TUint16(0x0003))) // RFCOMM ->BuildUintL(TSdpIntBuf<TUint32>(5)) // DLCI = 5 ->EndListL() ->BuildDESL() ->StartListL() ->BuildUUIDL(TUUID(TUint16(0x0008))) // OBEX ->EndListL() ->EndListL(); // Add the record into the database theDb->AddRecord(theRec); return theDb; }
/** Apply the references to the specified object @return EFalse */ TBool CMTPSetObjectPropValue::DoHandleResponsePhaseL() { TMTPResponseCode responseCode = EMTPRespCodeInvalidObjectPropFormat; TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter2); switch(propCode) { case EMTPObjectPropCodeDateModified: { TTime modifiedTime; if( iDpSingletons.MTPUtility().MTPTimeStr2TTime(iMTPTypeString->StringChars(), modifiedTime) ) { iRfs.SetModified( iObjMeta->DesC(CMTPObjectMetaData::ESuid), modifiedTime ); responseCode = EMTPRespCodeOK; } else { responseCode = EMTPRespCodeInvalidObjectPropValue; } } break; case EMTPObjectPropCodeHidden: { if ( EMTPHidden == iMTPTypeUint16.Value()) { TEntry entry; User::LeaveIfError(iFramework.Fs().Entry(iObjMeta->DesC(CMTPObjectMetaData::ESuid), entry)); if ( !entry.IsHidden()) { entry.iAtt &= ~KEntryAttHidden; entry.iAtt |= KEntryAttHidden; User::LeaveIfError(iFramework.Fs().SetAtt(iObjMeta->DesC(CMTPObjectMetaData::ESuid), entry.iAtt, ~entry.iAtt)); } responseCode = EMTPRespCodeOK; } else if ( EMTPVisible == iMTPTypeUint16.Value()) { TEntry entry; User::LeaveIfError(iFramework.Fs().Entry(iObjMeta->DesC(CMTPObjectMetaData::ESuid), entry)); if ( entry.IsHidden()) { entry.iAtt &= ~KEntryAttHidden; User::LeaveIfError(iFramework.Fs().SetAtt(iObjMeta->DesC(CMTPObjectMetaData::ESuid), entry.iAtt, ~entry.iAtt)); } responseCode = EMTPRespCodeOK; } else { responseCode = EMTPRespCodeInvalidObjectPropValue; } } break; case EMTPObjectPropCodeObjectFileName: { TRAPD(err, iDpSingletons.MTPUtility().RenameObjectL(iObjMeta->Uint(CMTPObjectMetaData::EHandle),iMTPTypeString->StringChars())) ; if( KErrNone == err ) { responseCode = EMTPRespCodeOK; } else if(KErrNotFound == err) { responseCode = EMTPRespCodeInvalidObjectHandle; } else if( KErrAlreadyExists == err) { responseCode = EMTPRespCodeInvalidObjectPropValue; } else { responseCode = EMTPRespCodeAccessDenied; } } break; case EMTPObjectPropCodeName: { //Might need to consider to save this name into meta-data base. //Notify all the Data Providers if the Owner of the object is DeviceDP const TDesC& name = iMTPTypeString->StringChars(); if(name != iFileEntry.iName) { iObjMeta->SetDesCL( CMTPObjectMetaData::EName, name); iFramework.ObjectMgr().ModifyObjectL(*iObjMeta); } responseCode = EMTPRespCodeOK; } break; case EMTPObjectPropCodeNonConsumable: { iObjMeta->SetUint( CMTPObjectMetaData::ENonConsumable, iMTPTypeUint8.Value()); iFramework.ObjectMgr().ModifyObjectL(*iObjMeta); responseCode = EMTPRespCodeOK; } break; case EMTPObjectPropCodeAssociationType: { if (EModeMTP != iFramework.Mode()) { responseCode = EMTPRespCodeOK; } else if( iMTPTypeUint16.Value() != EMTPAssociationTypeGenericFolder ) { responseCode = EMTPRespCodeInvalidObjectPropValue; } else { responseCode = EMTPRespCodeOK; } } break; case EMTPObjectPropCodeAssociationDesc: { if(TUint32(iMTPTypeUint32.Value()) == 0 ) { responseCode = EMTPRespCodeOK; } else responseCode = EMTPRespCodeInvalidObjectPropValue; } break; default: OstTrace1( TRACE_ERROR, CMTPSETOBJECTPROPVALUE_DOHANDLERESPONSEPHASEL, "Invalid property code %d", propCode); User::Leave( KErrNotSupported ); break; } SendResponseL(responseCode); return EFalse; }
/** Converts a time interval in microseconds to thread timeslice ticks @param aMicroseconds time interval in microseconds. @return Number of thread timeslice ticks. Non-integral results are rounded up. @pre aMicroseconds should be nonnegative @pre any context */ EXPORT_C TInt NKern::TimesliceTicks(TUint32 aMicroseconds) { TUint32 msp = TheTimerQ.iTickPeriod; TUint32 ticks = (TUint32(aMicroseconds) + msp - 1) / msp; return ticks; }