20
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: Declaration of the class CustomUser containing overloaded User static functions.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef CUSTOMUSER_H
|
|
20 |
#define CUSTOMUSER_H
|
|
21 |
|
|
22 |
// INCLUDES
|
|
23 |
#include <u32std.h>
|
30
|
24 |
#include <e32svr.h>
|
20
|
25 |
// CONSTANTS
|
|
26 |
const TInt KATVersionLength = 20;
|
|
27 |
const TInt KATDefaultLogOption = 0;
|
|
28 |
const TInt KATDefaultDebug = 1;
|
|
29 |
const TInt KATDefaultAllocCallStackSize = 40;
|
|
30 |
const TInt KATDefaultFreeCallStackSize = 0;
|
|
31 |
|
|
32 |
// TYPEDEFS
|
|
33 |
typedef TBuf<KATVersionLength> TATVersion;
|
|
34 |
|
|
35 |
// Argument list for SetupThreadHeap function parameters. (currently not used)
|
|
36 |
// When needed, update the argument type directly inside _LIT macro.
|
|
37 |
_LIT( KATArgumentList, "%i%i" ); //etc.
|
|
38 |
|
|
39 |
// CLASS DECLARATION
|
|
40 |
|
|
41 |
/**
|
|
42 |
* Class which overloads the User functions and provides access to
|
|
43 |
* the overloaded functions
|
|
44 |
*/
|
|
45 |
class CustomUser
|
|
46 |
{
|
|
47 |
public: // Enumerations
|
|
48 |
enum TATOptions
|
|
49 |
{
|
|
50 |
/** Acquiring the log filename */
|
|
51 |
ELogFileName = 1,
|
|
52 |
/** Acquiring the version number */
|
|
53 |
EVersion,
|
|
54 |
/** Acquiring logging option */
|
|
55 |
ELogOption,
|
|
56 |
/** Acquiring UDEB/UREL information */
|
|
57 |
EDebug,
|
|
58 |
/** Acquiring max allocation call stack size */
|
|
59 |
EAllocCallStackSize,
|
|
60 |
/** Acquiring max free call stack size */
|
|
61 |
EFreeCallStackSize
|
|
62 |
};
|
|
63 |
|
|
64 |
public:
|
|
65 |
|
|
66 |
/**
|
|
67 |
* Overloaded version of User::Exit()
|
|
68 |
* Terminates the current thread, specifying a reason. All child
|
|
69 |
* threads are terminated and all resources are cleaned up.If the
|
|
70 |
* current thread is the main thread in a process, the process is
|
|
71 |
* also terminated.
|
|
72 |
* @param aReason The reason code.
|
|
73 |
*/
|
|
74 |
IMPORT_C static void Exit( TInt aReason );
|
|
75 |
|
|
76 |
/**
|
|
77 |
* Overloaded version of User::Panic()
|
|
78 |
* Panics the current thread, specifying a category name and panic
|
|
79 |
* number. Keep the length of the category name small;
|
|
80 |
* a length of 16 is ideal.
|
|
81 |
* @param aCategory A reference to the descriptor containing the text
|
|
82 |
* that defines the category for this panic.
|
|
83 |
* @param aReason The panic number.
|
|
84 |
*/
|
|
85 |
IMPORT_C static void Panic( const TDesC& aCategory, TInt aReason );
|
|
86 |
|
|
87 |
/**
|
|
88 |
* Overloaded version of UserHeap::SetupThreadHeap()
|
|
89 |
* Setups the threads heap.
|
|
90 |
* @param aNotFirst Is this first thread using specified heap
|
|
91 |
* @param aInfo Specifies the thread heap properties
|
|
92 |
* @param aFileName The name of the log file
|
|
93 |
* @param aLogOption The logging option for storage server
|
|
94 |
* @param aIsDebug Determines whether a binary is UDEB or UREL
|
|
95 |
* @param aVersion Atool version number
|
|
96 |
* @param aAllocCallStackSize Max number of stored callstack items when memory allocated
|
|
97 |
* @param aFreeCallStackSize Max number of stored callstack items when memory freed
|
|
98 |
* @param aFmt A descriptor containing the format string
|
|
99 |
* @return TInt KErrNone, if the insertion is successful, otherwise
|
|
100 |
* one of the system wide error codes.
|
|
101 |
*/
|
|
102 |
IMPORT_C static TInt SetupThreadHeap(
|
|
103 |
TBool aNotFirst,
|
|
104 |
SStdEpocThreadCreateInfo& aInfo,
|
|
105 |
const TFileName& aFileName,
|
|
106 |
TUint32 aLogOption, TUint32 aIsDebug,
|
|
107 |
const TATVersion& aVersion,
|
|
108 |
TUint32 aAllocCallStackSize,
|
|
109 |
TUint32 aFreeCallStackSize,
|
|
110 |
TRefByValue<const TDesC> aFmt, ... );
|
|
111 |
|
|
112 |
/**
|
|
113 |
* Overloaded version of UserHeap::SetCritical()
|
|
114 |
* Sets up or changes the effect that termination of the current
|
|
115 |
* thread has, either on its owning process, or on the whole system.
|
|
116 |
* The precise effect of thread termination is defined by the following
|
|
117 |
* specific values of the TCritical enum:
|
|
118 |
* ENotCritical
|
|
119 |
* EProcessCritical
|
|
120 |
* EProcessPermanent
|
|
121 |
* ESystemCritical
|
|
122 |
* ESystemPermanent
|
|
123 |
* Notes: The enum value EAllThreadsCritical cannot be set using this
|
|
124 |
* function. It is associated with a process, not a thread, and, if
|
|
125 |
* appropriate, should be set using User::SetProcessCritical().
|
|
126 |
* The states associated with ENotCritical, EProcessCritical,
|
|
127 |
* EProcessPermanent, ESystemCritical and ESystemPermanent are all
|
|
128 |
* mutually exclusive, i.e. the thread can only be in one of these
|
|
129 |
* states at any one time.
|
|
130 |
* @param aCritical The state to be set.
|
|
131 |
* @return TInt KErrNone, if successful; KErrArgument, if
|
|
132 |
* EAllThreadsCritical is passed - this is a state associated with a
|
|
133 |
* process, and you use User::SetProcessCritical() to set it.
|
|
134 |
*/
|
|
135 |
IMPORT_C static TInt SetCritical( User::TCritical aCritical );
|
|
136 |
|
|
137 |
/**
|
|
138 |
* Overloaded version of UserHeap::SetCritical()
|
|
139 |
* Sets up or changes the effect that termination of subsequently
|
|
140 |
* created threads will have, either on the owning process,
|
|
141 |
* or on the whole system. It is important to note that we are not
|
|
142 |
* referring to threads that have already been created, but threads
|
|
143 |
* that will be created subsequent to a call to this function.
|
|
144 |
* The precise effect of thread termination is defined by the following
|
|
145 |
* specific values of the TCritical enum:
|
|
146 |
* ENotCritical
|
|
147 |
* EAllThreadsCritical
|
|
148 |
* ESystemCritical
|
|
149 |
* ESystemPermanent
|
|
150 |
* Notes:
|
|
151 |
* The enum values EProcessCritical and EProcessPermanent cannot be set
|
|
152 |
* using this function. They are states associated with a thread, not a
|
|
153 |
* process, and, if appropriate, should be set using
|
|
154 |
* User::SetCritical(). The states associated with ENotCritical,
|
|
155 |
* EAllThreadsCritical, ESystemCritical and ESystemPermanent are all
|
|
156 |
* mutually exclusive, i.e. the process can only be in one of these
|
|
157 |
* states at any one time.
|
|
158 |
* @param aCritical The state to be set.
|
|
159 |
* @return TInt KErrNone, if successful; KErrArgument, if either
|
|
160 |
* EProcessCritical or EProcessPermanent is passed - these are states
|
|
161 |
* associated with a thread, and you use User::SetCritical()
|
|
162 |
* to set them.
|
|
163 |
*/
|
|
164 |
IMPORT_C static TInt SetProcessCritical( User::TCritical aCritical );
|
|
165 |
|
|
166 |
private: // Private functions
|
|
167 |
|
|
168 |
/**
|
|
169 |
* Factory function for creating RAllocator instances.
|
|
170 |
* @param aNotFirst Is this first thread using specified heap
|
|
171 |
* @param aLogOption The logging option for storage server
|
|
172 |
* @param aFileName The name of the logging file
|
|
173 |
* @param aIsDebug Determines whether a binary is UDEB or UREL
|
|
174 |
* @param aAllocCallStackSize Max number of stored callstack items when memory allocated
|
|
175 |
* @param aFreecallStackSize Max number of stored callstack items when memory freed
|
|
176 |
* @return RAllocator& A reference to created allocator
|
|
177 |
*/
|
|
178 |
static RAllocator& InstallAllocator( TBool aNotFirst,
|
|
179 |
const TFileName& aFileName,
|
|
180 |
TUint32 aLogOption, TUint32 aIsDebug,
|
|
181 |
TUint32 aAllocCallStackSize,
|
|
182 |
TUint32 aFreeCallStackSize );
|
|
183 |
|
|
184 |
/**
|
|
185 |
* Check atool version
|
|
186 |
* @param aVersion - Atool version number.
|
|
187 |
* @param aToolVersion The atool version number
|
|
188 |
* @return KErrNone if correct version found, otherwise one of the system wide
|
|
189 |
* error codes.
|
|
190 |
*/
|
|
191 |
static TInt CheckVersion( const TATVersion& aVersion, TDes& aToolVersion );
|
|
192 |
|
|
193 |
/**
|
|
194 |
* Function for showing incorrect version information (file or debug channel).
|
|
195 |
* @param aLogOption The logging option
|
|
196 |
* @param aFileName The name of the log file
|
|
197 |
* @param aToolVersion The atool version number
|
|
198 |
*/
|
|
199 |
static void ReportIncorrectVersion( const TUint32 aLogOption,
|
|
200 |
const TFileName& aFileName,
|
|
201 |
const TDes& aToolVersion );
|
|
202 |
|
|
203 |
};
|
|
204 |
|
|
205 |
#endif // CUSTOMUSER_H
|
|
206 |
|
|
207 |
// End of File
|