First public contribution.
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32\debug\crashMonitor\src\scmromdata.cpp
15 // Core dump server - ROM Data for System Crash
24 #include <scmdatatypes.h>
29 * TRomHeaderData implementation
30 * @internal technology
34 * TRomHeaderData constructor
36 TRomHeaderData::TRomHeaderData():
38 iVersion(ERomHeaderDataVersion1),
47 * Writes this classes data to the specified byte stream
48 * @param aWriter byte stream to use
51 TInt TRomHeaderData::Serialize(TByteStreamWriter& aWriter)
53 TInt startPos = aWriter.CurrentPosition();
55 if(iId != ESCMRomHeader)
57 CLTRACE("TRomHeaderData::Serialize Corrupt ID");
62 aWriter.WriteInt(iId); // 4
64 aWriter.WriteShort((TUint16) iVersion); // 2
66 if(iVersion == ERomHeaderDataVersion1)
69 aWriter.WriteInt64(iTime); // 8
72 aWriter.WriteByte(iMajorVersion); // 1
73 aWriter.WriteByte(iMinorVersion); // 1
74 aWriter.WriteShort(iBuildNumber); // 2
78 CLTRACE("TRomHeaderData::Serialize Unsupported version");
82 TInt pos1 = aWriter.CurrentPosition();
83 if( pos1 - startPos != GetSize())
85 // error between actual size & real size in data
86 CLTRACE("TRomHeaderData::Serialize serialization size error");
94 * Reads the classes data from the specified byte stream
95 * @param aReader Byte stream to use
98 TInt TRomHeaderData::Deserialize(TByteStreamReader& aReader)
100 TInt startPos = aReader.CurrentPosition();
102 iId = (SCMStructId)aReader.ReadInt(); // 4
103 if(iId != ESCMRomHeader)
105 CLTRACE("TRomHeaderData::Deserialize Corrupt ID read");
109 iVersion = (TRomHeaderDataVersion)aReader.ReadShort(); // 2
111 if(iVersion == ERomHeaderDataVersion1)
114 iTime = aReader.ReadInt64(); // 8
116 //Now the ROM version
117 iMajorVersion = aReader.ReadByte(); // 1
118 iMinorVersion = aReader.ReadByte(); // 1
119 iBuildNumber = aReader.ReadShort(); // 2
123 iId = ESCMLast; //unrecognised header
124 CLTRACE("TRomHeaderData::Deserialize Unsupported version");
128 TInt pos1 = aReader.CurrentPosition();
129 if( pos1 - startPos != GetSize())
131 iId = ESCMLast; //unrecognised header
133 // error between actual size & real size in data
134 CLTRACE("TRomHeaderData::Deserialize serialization size error");
141 * Returns the externalised size of this class
144 TInt TRomHeaderData::GetSize() const
146 if(iVersion == ERomHeaderDataVersion1)
152 CLTRACE("ERomHeaderDataVersion1::GetSize Unsupported version");
153 return KErrNotSupported;