0
|
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".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// e32\debug\crashMonitor\src\scmromdata.cpp
|
|
15 |
// Core dump server - ROM Data for System Crash
|
|
16 |
//
|
|
17 |
//
|
|
18 |
|
|
19 |
/**
|
|
20 |
@file
|
|
21 |
@internalTechnology
|
|
22 |
*/
|
|
23 |
|
|
24 |
#include <scmdatatypes.h>
|
|
25 |
|
|
26 |
namespace Debug
|
|
27 |
{
|
|
28 |
/**
|
|
29 |
* TRomHeaderData implementation
|
|
30 |
* @internal technology
|
|
31 |
*/
|
|
32 |
|
|
33 |
/**
|
|
34 |
* TRomHeaderData constructor
|
|
35 |
*/
|
|
36 |
TRomHeaderData::TRomHeaderData():
|
|
37 |
iId(ESCMRomHeader),
|
|
38 |
iVersion(ERomHeaderDataVersion1),
|
|
39 |
iMajorVersion(0),
|
|
40 |
iMinorVersion(0),
|
|
41 |
iBuildNumber(0),
|
|
42 |
iTime(0)
|
|
43 |
{
|
|
44 |
}
|
|
45 |
|
|
46 |
/**
|
|
47 |
* Writes this classes data to the specified byte stream
|
|
48 |
* @param aWriter byte stream to use
|
|
49 |
* @return void
|
|
50 |
*/
|
|
51 |
TInt TRomHeaderData::Serialize(TByteStreamWriter& aWriter)
|
|
52 |
{
|
|
53 |
TInt startPos = aWriter.CurrentPosition();
|
|
54 |
|
|
55 |
if(iId != ESCMRomHeader)
|
|
56 |
{
|
|
57 |
CLTRACE("TRomHeaderData::Serialize Corrupt ID");
|
|
58 |
return KErrCorrupt;
|
|
59 |
}
|
|
60 |
|
|
61 |
// ID saved first
|
|
62 |
aWriter.WriteInt(iId); // 4
|
|
63 |
|
|
64 |
aWriter.WriteShort((TUint16) iVersion); // 2
|
|
65 |
|
|
66 |
if(iVersion == ERomHeaderDataVersion1)
|
|
67 |
{
|
|
68 |
//ROM time
|
|
69 |
aWriter.WriteInt64(iTime); // 8
|
|
70 |
|
|
71 |
//Now the ROM version
|
|
72 |
aWriter.WriteByte(iMajorVersion); // 1
|
|
73 |
aWriter.WriteByte(iMinorVersion); // 1
|
|
74 |
aWriter.WriteShort(iBuildNumber); // 2
|
|
75 |
}
|
|
76 |
else
|
|
77 |
{
|
|
78 |
CLTRACE("TRomHeaderData::Serialize Unsupported version");
|
|
79 |
return KErrCorrupt;
|
|
80 |
}
|
|
81 |
|
|
82 |
TInt pos1 = aWriter.CurrentPosition();
|
|
83 |
if( pos1 - startPos != GetSize())
|
|
84 |
{
|
|
85 |
// error between actual size & real size in data
|
|
86 |
CLTRACE("TRomHeaderData::Serialize serialization size error");
|
|
87 |
return KErrCorrupt;
|
|
88 |
}
|
|
89 |
|
|
90 |
return KErrNone;
|
|
91 |
}
|
|
92 |
|
|
93 |
/**
|
|
94 |
* Reads the classes data from the specified byte stream
|
|
95 |
* @param aReader Byte stream to use
|
|
96 |
* @return void
|
|
97 |
*/
|
|
98 |
TInt TRomHeaderData::Deserialize(TByteStreamReader& aReader)
|
|
99 |
{
|
|
100 |
TInt startPos = aReader.CurrentPosition();
|
|
101 |
|
|
102 |
iId = (SCMStructId)aReader.ReadInt(); // 4
|
|
103 |
if(iId != ESCMRomHeader)
|
|
104 |
{
|
|
105 |
CLTRACE("TRomHeaderData::Deserialize Corrupt ID read");
|
|
106 |
return KErrCorrupt;
|
|
107 |
}
|
|
108 |
|
|
109 |
iVersion = (TRomHeaderDataVersion)aReader.ReadShort(); // 2
|
|
110 |
|
|
111 |
if(iVersion == ERomHeaderDataVersion1)
|
|
112 |
{
|
|
113 |
//ROM time
|
|
114 |
iTime = aReader.ReadInt64(); // 8
|
|
115 |
|
|
116 |
//Now the ROM version
|
|
117 |
iMajorVersion = aReader.ReadByte(); // 1
|
|
118 |
iMinorVersion = aReader.ReadByte(); // 1
|
|
119 |
iBuildNumber = aReader.ReadShort(); // 2
|
|
120 |
}
|
|
121 |
else
|
|
122 |
{
|
|
123 |
iId = ESCMLast; //unrecognised header
|
|
124 |
CLTRACE("TRomHeaderData::Deserialize Unsupported version");
|
|
125 |
return KErrCorrupt;
|
|
126 |
}
|
|
127 |
|
|
128 |
TInt pos1 = aReader.CurrentPosition();
|
|
129 |
if( pos1 - startPos != GetSize())
|
|
130 |
{
|
|
131 |
iId = ESCMLast; //unrecognised header
|
|
132 |
|
|
133 |
// error between actual size & real size in data
|
|
134 |
CLTRACE("TRomHeaderData::Deserialize serialization size error");
|
|
135 |
return KErrCorrupt;
|
|
136 |
}
|
|
137 |
return KErrNone;
|
|
138 |
}
|
|
139 |
|
|
140 |
/**
|
|
141 |
* Returns the externalised size of this class
|
|
142 |
* @return TInt size
|
|
143 |
*/
|
|
144 |
TInt TRomHeaderData::GetSize() const
|
|
145 |
{
|
|
146 |
if(iVersion == ERomHeaderDataVersion1)
|
|
147 |
{
|
|
148 |
return 18;
|
|
149 |
}
|
|
150 |
else
|
|
151 |
{
|
|
152 |
CLTRACE("ERomHeaderDataVersion1::GetSize Unsupported version");
|
|
153 |
return KErrNotSupported;
|
|
154 |
}
|
|
155 |
}
|
|
156 |
|
|
157 |
}
|