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\include\kernel\scmdatasave.h |
|
15 // Kernel System crash data save header file |
|
16 // |
|
17 // WARNING: This file contains some APIs which are internal and are subject |
|
18 // to change without notice. Such APIs should therefore not be used |
|
19 // outside the Kernel and Hardware Services package. |
|
20 // |
|
21 |
|
22 #ifndef SCMDATASAVE_H |
|
23 #define SCMDATASAVE_H |
|
24 |
|
25 /** |
|
26 @file |
|
27 @internalComponent |
|
28 */ |
|
29 |
|
30 #include <plat_priv.h> |
|
31 #include <kernel/monitor.h> |
|
32 #include <e32des8.h> |
|
33 #include <arm.h> |
|
34 #include <crashflash.h> |
|
35 |
|
36 #include <scmdatatypes.h> |
|
37 #include <scmbytestreamutil.h> |
|
38 #include <scmconfig.h> |
|
39 |
|
40 using namespace Debug; |
|
41 |
|
42 IMPORT_C TInt64 CrashTime(); |
|
43 |
|
44 |
|
45 _LIT8(KKernelHeapChunkName, "ekern.exe::SvHeap"); |
|
46 _LIT8(KKernelProcessName, "ekern.exe"); |
|
47 |
|
48 |
|
49 /** |
|
50 * This class handles gathering of the kernel data and writing it to flash |
|
51 * |
|
52 */ |
|
53 class SCMDataSave : MPhysicalWriterImpl |
|
54 { |
|
55 public: |
|
56 enum TRegisterSetType |
|
57 { |
|
58 EUserRegisters = 0, |
|
59 ESupervisorRegisters = 1, |
|
60 EFullCPURegisters = 2, |
|
61 ERegSetNone = 3, |
|
62 ERegLast |
|
63 }; |
|
64 |
|
65 enum TStackType |
|
66 { |
|
67 EUsrStack = 0, |
|
68 ESvrStack = 1, |
|
69 EStackTypeNone = 2, |
|
70 EStackLast |
|
71 }; |
|
72 |
|
73 enum TDumpScope |
|
74 { |
|
75 EThreadSpecific = 0, |
|
76 EProcessSpecific = 1, |
|
77 ESystemWide = 2, |
|
78 EDumpLast |
|
79 }; |
|
80 |
|
81 /** |
|
82 * This structure defines the type of data we wish to dump for a given kernel object |
|
83 */ |
|
84 struct TDataToDump |
|
85 { |
|
86 TBool iMetaData; /**< Dump meta data about object */ |
|
87 TBool iCodeSegs; /**< Dump DProcess code segs (ignored for other objects) */ |
|
88 TStackType iStk; /**< Dump this stack type */ |
|
89 TRegisterSetType iReg; /**< Dump this register set */ |
|
90 |
|
91 TDataToDump() |
|
92 { |
|
93 //upon construction, nothing is set to be dumped |
|
94 iMetaData = EFalse; |
|
95 iCodeSegs = EFalse; |
|
96 iStk = EStackTypeNone; |
|
97 iReg = ERegSetNone; |
|
98 } |
|
99 |
|
100 }; |
|
101 |
|
102 enum TWriteSelect |
|
103 { |
|
104 EWriteFlash = 0, /**< write data to flash */ |
|
105 EWriteComm =1, /**< write data to comm port */ |
|
106 ELast |
|
107 }; |
|
108 |
|
109 public: |
|
110 |
|
111 IMPORT_C SCMDataSave(Monitor* aMonitor, CrashFlash* aFlash); |
|
112 virtual ~SCMDataSave(); |
|
113 |
|
114 |
|
115 TInt LogCrashHeader(const TDesC8& aCategory, TInt aReason, TInt aCrashId, TUint& aSizeDumped); |
|
116 TInt LogThreadData(DThread* aThread, TUint& aSizeDumped); |
|
117 TInt LogProcessData(DProcess* aProcess, TUint& aSizeDumped); |
|
118 TInt LogCodeSegments(DProcess* aProcess, TUint& aSizeDumped); |
|
119 |
|
120 TInt LogThreadUserStack(DThread* aThread, TBool aFullStack, TUint& aSizeDumped); |
|
121 TInt LogThreadSupervisorStack(DThread* aThread, TBool aFullStack, TUint& aSizeDumped); |
|
122 |
|
123 TInt LogRegisters(DThread* aThread, const TRegisterSetType& aRegType, TUint& aSizeDumped); |
|
124 TInt LogCPURegisters(TUint& aSizeDumped); |
|
125 TInt ReadUserRegisters(DThread* aThread, TArmRegSet& aRegs, TUint32& aAvailableRegs); |
|
126 TInt ReadSystemRegisters(DThread* aThread, TArmRegSet& aRegs, TUint32& aAvailableRegs); |
|
127 void ReadCPURegisters(SFullArmRegSet& aRegs); |
|
128 |
|
129 TInt LogMemory(const TUint8* aStartAddress, TInt aLength, const DThread* aThread, TUint& aSizeDumped); |
|
130 TInt LogExceptionStacks(TUint& aSizeDumped); |
|
131 TInt LogTraceBuffer(TInt aSizeToDump, TUint& aSizeDumped); |
|
132 TInt LogLocks(TUint& aSizeDumped); |
|
133 TInt LogRawData(const TDesC8& aData, TUint& aSizeDumped); |
|
134 TInt LogVariantSpecificData(TUint& aSizeDumped); |
|
135 TInt LogRomInfo(TUint& aSizeDumped); |
|
136 |
|
137 TInt LogKernelHeap(TUint& aSizeDumped); |
|
138 TInt FindKernelHeap(TInt32& aHeapLocation, TInt32& aHeapSize); |
|
139 |
|
140 TInt LogConfig(SCMConfiguration& aConfig); |
|
141 TInt ReadConfig(SCMConfiguration& aScmConfig); |
|
142 |
|
143 |
|
144 void Write(const TAny* aSomething, TInt aSize); |
|
145 static void WriteUart(const TUint8* aData, TInt aSize); |
|
146 static void WriteUart(const TDesC8& aDes); |
|
147 virtual void DoPhysicalWrite(TAny* aData, TInt aPos, TInt aLen); |
|
148 |
|
149 void WriteCrashFlash(TInt aPos, TInt& aSize, const TDesC8& aBuffer); |
|
150 |
|
151 TInt GetRegisterType(const TRegisterSetType& aSetType, TInt32& aRegNumber, TUint32& aRegisterType); |
|
152 TInt GetByteCount(); |
|
153 void SetByteCount(TInt aByte); |
|
154 |
|
155 |
|
156 TWriteSelect GetWriteSelect(); |
|
157 void SetWriteSelect(TWriteSelect aWriteSelect); |
|
158 |
|
159 TUint SpaceRemaining(); |
|
160 TUint MaxLogSize(); |
|
161 |
|
162 void SetCrashStartingPoint(TUint32 aStart); |
|
163 TUint32 GetCrashStartingPoint() {return iStartingPointForCrash;} |
|
164 |
|
165 public: |
|
166 |
|
167 /** Offsets header to assist parsing */ |
|
168 TCrashOffsetsHeader iHdr; |
|
169 |
|
170 /** Basic crash info */ |
|
171 TCrashInfoHeader iCrashInf; |
|
172 |
|
173 /** Writer for physical writing */ |
|
174 TCachedByteStreamWriter* iWriter; |
|
175 |
|
176 private: |
|
177 Monitor* iMonitor; //need to use this to map memory and things like that |
|
178 CrashFlash* iFlash; |
|
179 TTraceDump iTrace; |
|
180 |
|
181 TInt iByteCount; |
|
182 |
|
183 //This is a pointer to memory on the heap we can use that is the same size as iFlash.GetFlashBlockSize() |
|
184 HBuf8* iFlashCache; |
|
185 |
|
186 TWriteSelect iWriteSelect; |
|
187 TBool iPerformChecksum; |
|
188 TScmChecksum iChecksum; |
|
189 |
|
190 TUint32 iStartingPointForCrash; |
|
191 }; |
|
192 |
|
193 #endif /*SCMDATASAVE_H*/ |
|