245
|
1 |
// Copyright (c) 2004-2010 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 |
// Device driver for kernel side stop mode debugging
|
|
15 |
//
|
|
16 |
|
|
17 |
#ifdef __WINS__
|
|
18 |
#error - this driver cannot be built for emulation
|
|
19 |
#endif
|
|
20 |
|
|
21 |
#include <e32def.h>
|
|
22 |
#include <e32def_private.h>
|
|
23 |
#include <e32cmn.h>
|
|
24 |
#include <e32cmn_private.h>
|
|
25 |
#include <e32ldr.h>
|
|
26 |
#include <u32std.h>
|
|
27 |
#include <kernel/kernel.h>
|
|
28 |
#include <kernel/kern_priv.h>
|
|
29 |
#include <nk_trace.h>
|
|
30 |
#include <arm.h>
|
|
31 |
#include <kernel/cache.h>
|
|
32 |
#include <platform.h>
|
|
33 |
#include <nkern.h>
|
|
34 |
#include <u32hal.h>
|
|
35 |
#include <kernel/kdebug.h>
|
|
36 |
|
|
37 |
|
|
38 |
#include "debug_logging.h"
|
|
39 |
#include "d_debug_functionality.h"
|
|
40 |
#include "debug_utils.h"
|
|
41 |
#include "d_buffer_manager.h"
|
|
42 |
|
|
43 |
|
|
44 |
using namespace Debug;
|
|
45 |
|
|
46 |
|
|
47 |
DStopModeExtension* TheStopModeExtension = NULL;
|
|
48 |
|
|
49 |
/**
|
|
50 |
This value is used as an initialiser for the size of the Stop-Mode Debug API's
|
|
51 |
default request buffer.
|
|
52 |
*/
|
|
53 |
const TInt KRequestBufferSize = 0x200;
|
|
54 |
/**
|
|
55 |
This value is used as an initialiser for the size of the Stop-Mode Debug API's
|
|
56 |
default response buffer.
|
|
57 |
*/
|
|
58 |
const TInt KResponseBufferSize = 0x1000;
|
|
59 |
|
|
60 |
DECLARE_STANDARD_EXTENSION()
|
|
61 |
{
|
|
62 |
__KTRACE_OPT(KBOOT,Kern::Printf("Starting Stop Mode Debugger V2"));
|
|
63 |
|
|
64 |
// get a reference to the DDebuggerInfo and to the DStopModeExtension
|
|
65 |
TSuperPage& superPage = Kern::SuperPage();
|
|
66 |
|
|
67 |
if(!superPage.iDebuggerInfo)
|
|
68 |
{
|
|
69 |
//kdebug has not been installed so create DDebuggerInfo using our stub constructor
|
|
70 |
superPage.iDebuggerInfo = new DDebuggerInfo();
|
|
71 |
}
|
|
72 |
|
|
73 |
if(!TheStopModeExtension)
|
|
74 |
{
|
|
75 |
TheStopModeExtension = new DStopModeExtension();
|
|
76 |
}
|
|
77 |
|
|
78 |
// create the request buffer and store a reference to it
|
|
79 |
TTag tag;
|
|
80 |
tag.iTagId = EBuffersRequest;
|
|
81 |
tag.iType = ETagTypePointer;
|
|
82 |
tag.iSize = KRequestBufferSize;
|
|
83 |
TInt err = TheDBufferManager.CreateBuffer(tag);
|
|
84 |
if(KErrNone != err)
|
|
85 |
{
|
|
86 |
return KErrNone;
|
|
87 |
}
|
|
88 |
|
|
89 |
// create the response buffer and store a reference to it
|
|
90 |
tag.iTagId = EBuffersResponse;
|
|
91 |
tag.iSize = KResponseBufferSize;
|
|
92 |
err = TheDBufferManager.CreateBuffer(tag);
|
|
93 |
if(KErrNone != err)
|
|
94 |
{
|
|
95 |
return KErrNone;
|
|
96 |
}
|
|
97 |
// create the debug functionality buffer and store a reference to it
|
|
98 |
TDebugFunctionality df;
|
|
99 |
TUint dfSize = df.GetStopModeFunctionalityBufSize();
|
|
100 |
tag.iTagId = EBuffersFunctionality;
|
|
101 |
tag.iSize = dfSize;
|
|
102 |
err = TheDBufferManager.CreateBuffer(tag);
|
|
103 |
if(KErrNone != err)
|
|
104 |
{
|
|
105 |
return KErrNone;
|
|
106 |
}
|
|
107 |
|
|
108 |
// fill the functionality buffer with the functionality data and store it in
|
|
109 |
// the super page
|
|
110 |
TPtr8 dfBlockPtr((TUint8*)tag.iValue, dfSize);
|
|
111 |
if(!df.GetStopModeFunctionality(dfBlockPtr))
|
|
112 |
{
|
|
113 |
return KErrNone;
|
|
114 |
}
|
|
115 |
TheStopModeExtension->iFunctionalityBlock = (DFunctionalityBlock*)tag.iValue;
|
|
116 |
|
|
117 |
DStopModeExtension::Install(TheStopModeExtension);
|
|
118 |
|
|
119 |
return KErrNone;
|
|
120 |
}
|
|
121 |
|
|
122 |
/**
|
|
123 |
* This stub constructor is intended to be used in the case where the old deprecated
|
|
124 |
* stop mode api, kdebug, is not in place. It will initialise all values to NULL except
|
|
125 |
* the pointer to the new stop mode api extension. This allows the new stop mode solution
|
|
126 |
* to both co-exist and exist independantly of the existing one *
|
|
127 |
*/
|
|
128 |
DDebuggerInfo::DDebuggerInfo():
|
|
129 |
iObjectOffsetTable(NULL),
|
|
130 |
iObjectOffsetTableCount(NULL),
|
|
131 |
iThreadContextTable(NULL),
|
|
132 |
iStopModeExtension(new DStopModeExtension()),
|
|
133 |
iContainers(NULL),
|
|
134 |
iCodeSegLock(NULL),
|
|
135 |
iCodeSegGlobalList(NULL),
|
|
136 |
iScheduler(NULL),
|
|
137 |
iShadowPages(NULL),
|
|
138 |
iShadowPageCount(0),
|
|
139 |
iCurrentThread(NULL),
|
|
140 |
iEventMask(),
|
|
141 |
iEventHandlerBreakpoint(0),
|
|
142 |
iMemModelObjectOffsetTable(NULL),
|
|
143 |
iMemModelObjectOffsetTableCount(0)
|
|
144 |
{
|
|
145 |
}
|
|
146 |
|
|
147 |
/**
|
|
148 |
* Installs the stop-mode debugger extension
|
|
149 |
* Make the stop-mode API visible to a JTAG debugger, by publishing its
|
|
150 |
* existence in the superpage
|
|
151 |
*/
|
|
152 |
void DStopModeExtension::Install(DStopModeExtension* aExt)
|
|
153 |
{
|
|
154 |
Kern::SuperPage().iDebuggerInfo->iStopModeExtension = aExt;
|
|
155 |
}
|