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