dbgagents/trkagent/engine/TrkDispatchLayer.cpp
author ravikurupati
Tue, 02 Mar 2010 10:33:16 +0530
changeset 0 c6b0df440bee
permissions -rw-r--r--
Initial contribution of EPL licensed sources
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     1
/*
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     2
* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     3
* All rights reserved.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     4
* This component and the accompanying materials are made available
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     6
* which accompanies this distribution, and is available
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     8
*
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     9
* Initial Contributors:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    11
*
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    12
* Contributors:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    13
*
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    14
* Description: 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    15
*
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    16
*/
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    17
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    18
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    19
#include "TrkEngine.h"
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    20
#include "TrkDispatchLayer.h"
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    21
#include "DateTimeConverter.h"
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    22
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    23
#ifndef __TEXT_SHELL__
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    24
#include "TrkSwInstall.h"
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    25
#endif
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    26
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    27
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    28
// Macros
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    29
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    30
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    31
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    32
// Version Information
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    33
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    34
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    35
#define MAJOR_VERSION_NUMBER	3
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    36
#define MINOR_VERSION_NUMBER	2
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    37
#define BUILD_NUMBER			4
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    38
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    39
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    40
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    41
// Support Information
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    42
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    43
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    44
#define DS_SUPPORT_MASK_00_07	0x7E	// kDSConnect, kDSDisconnect, kDSReset, kDSVersions, kDSSupportMask, kDSCPUType */
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    45
#define DS_SUPPORT_MASK_08_0F	0x00
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    46
#define DS_SUPPORT_MASK_10_17	0x4f	// R/W Memory, R/W Registers, FlushCache
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    47
#define DS_SUPPORT_MASK_18_1F	0x5f	// kDSContinue, kDSStep, kDSStop, kDSSetBreak, kDSClearBreak
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    48
#define DS_SUPPORT_MASK_20_27	0x01	// kDSNotifyFileInput
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    49
#define DS_SUPPORT_MASK_28_2F	0x00
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    50
#define DS_SUPPORT_MASK_30_37	0x00
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    51
#define DS_SUPPORT_MASK_38_3F	0x00
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    52
#define DS_SUPPORT_MASK_40_47	0x0f	// OS Create/Delete Item, OS Read/Write Info
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    53
#define DS_SUPPORT_MASK_48_4F	0x1f	// OS Read/Write/Open/Close/Position File
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    54
#define DS_SUPPORT_MASK_50_57	0x00
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    55
#define DS_SUPPORT_MASK_58_5F	0x00
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    56
#define DS_SUPPORT_MASK_60_67	0x00
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    57
#define DS_SUPPORT_MASK_68_6F	0x00
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    58
#define DS_SUPPORT_MASK_70_77	0x00
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    59
#define DS_SUPPORT_MASK_78_7F	0x00
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    60
#define DS_SUPPORT_MASK_80_87	0x01	// kDSReplyACK
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    61
#define DS_SUPPORT_MASK_88_8F	0x00
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    62
#define DS_SUPPORT_MASK_90_97	0x11	// kDSNotifyStopped, kDSNotifyStopped2
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    63
#define DS_SUPPORT_MASK_98_9F	0x00
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    64
#define DS_SUPPORT_MASK_A0_A7	0x03	// kDSOSNotifyCreated, kDSOSNotifyDeleted
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    65
#define DS_SUPPORT_MASK_A8_AF	0x00
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    66
#define DS_SUPPORT_MASK_B0_B7	0x00
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    67
#define DS_SUPPORT_MASK_B8_BF	0x00
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    68
#define DS_SUPPORT_MASK_C0_C7	0x00
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    69
#define DS_SUPPORT_MASK_C8_CF	0x00
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    70
#define DS_SUPPORT_MASK_D0_D7	0x03	// kDSWriteFile, kDSReadFile
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    71
#define DS_SUPPORT_MASK_D8_DF	0x00
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    72
#define DS_SUPPORT_MASK_E0_E7	0x00
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    73
#define DS_SUPPORT_MASK_E8_EF	0x00
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    74
#define DS_SUPPORT_MASK_F0_F7	0x00
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    75
#define DS_SUPPORT_MASK_F8_FF	0x80	// kDSReplyNAK
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    76
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    77
#define KProcessKilled 0x4B696C6C // "Kill"
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    78
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    79
#ifdef EKA2
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    80
#define EUSER_LIBPATH _L("Z:\\Sys\\Bin\\euser.dll")
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    81
#else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    82
#define EUSER_LIBPATH _L("Z:\\System\\Libs\\euser.dll")
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    83
#endif
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    84
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    85
#ifdef __OEM_TRK__
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    86
#define TRK_TYPE_DESCRIPTION _L8("System TRK")
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    87
#else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    88
#define TRK_TYPE_DESCRIPTION _L8("Application TRK")
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    89
#endif
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    90
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    91
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    92
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    93
// Swap2
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    94
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    95
// Byte-swaps a 2-byte value.  Used to convert to/from little/big endian.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    96
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    97
static TUint16 Swap2(TUint16 aSource)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    98
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    99
	TUint16 dest = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   100
	for (TInt i=0; i<2; i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   101
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   102
		dest <<= 8;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   103
		dest |= aSource & 0xFF;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   104
		aSource >>= 8;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   105
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   106
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   107
	return dest;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   108
} 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   109
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   110
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   111
// Swap4
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   112
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   113
// Byte-swaps a 4-byte value.  Used to convert to/from little/big endian.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   114
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   115
static TUint32 Swap4(TUint32 aSource)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   116
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   117
	TUint32 dest = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   118
	for (TInt i=0; i<4; i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   119
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   120
		dest <<= 8;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   121
		dest |= aSource & 0xFF;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   122
		aSource >>= 8;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   123
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   124
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   125
	return dest;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   126
} 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   127
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   128
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   129
// Swap4xN
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   130
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   131
//	Byte-swaps N 4-byte values *in place*.  Used to convert to/from little/big endian.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   132
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   133
void Swap4xN(TUint32 *aSource, TInt aCount)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   134
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   135
	while (aCount--)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   136
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   137
		TUint32 temp = Swap4(*aSource);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   138
		*aSource++ = temp;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   139
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   140
} 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   141
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   142
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   143
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   144
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   145
// CExitTrapper implementation
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   146
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   147
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   148
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   149
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   150
// CExitTrapper constructor
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   151
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   152
// Accepts CTrkDispatchLayer interface and the process ID of the
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   153
// process to watch
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   154
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   155
CExitTrapper::CExitTrapper(CTrkDispatchLayer *aDispatch, TUint32 aProcessId)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   156
	: CActive(EPriorityStandard),
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   157
	  iProcessId(aProcessId),
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   158
	  iDispatch(aDispatch)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   159
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   160
	CActiveScheduler::Add(this);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   161
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   162
	TInt error = iProcess.Open(iProcessId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   163
	if (KErrNone != error)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   164
		User::Panic(_L("Unable to open process"), __LINE__);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   165
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   166
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   167
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   168
// CExitTrapper destructor
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   169
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   170
CExitTrapper::~CExitTrapper()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   171
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   172
	Cancel();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   173
	Deque();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   174
	iProcess.Close();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   175
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   176
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   177
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   178
// CExitTrapper::Watch
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   179
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   180
// Watch for the process to exit
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   181
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   182
void CExitTrapper::Watch()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   183
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   184
	iProcess.Logon(iStatus);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   185
	SetActive();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   186
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   187
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   188
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   189
// CExitTrapper::RunL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   190
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   191
// Called when the process exits
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   192
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   193
void CExitTrapper::RunL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   194
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   195
	// sometimes this is run when the process has yet to exit
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   196
	if (iProcess.ExitType() == EExitPending)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   197
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   198
		iProcess.LogonCancel(iStatus);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   199
		Watch();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   200
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   201
	else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   202
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   203
		iDispatch->DoNotifyProcessDiedL(iProcessId, iProcess.ExitReason());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   204
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   205
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   206
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   207
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   208
// CExitTrapper::DoCancel
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   209
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   210
// Stop waiting for this process to exit
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   211
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   212
void CExitTrapper::DoCancel()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   213
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   214
	iProcess.LogonCancel(iStatus);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   215
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   216
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   217
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   218
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   219
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   220
// CEventTrapper implementation
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   221
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   222
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   223
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   224
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   225
// CEventTrapper constructor
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   226
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   227
// Accepts CTrkDispatchLayer interface
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   228
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   229
CEventTrapper::CEventTrapper(CTrkDispatchLayer *aDispatch)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   230
	: CActive(CActive::EPriorityStandard),
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   231
	  iDispatch(aDispatch)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   232
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   233
	CActiveScheduler::Add(this);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   234
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   235
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   236
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   237
// CEventTrapper destructor
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   238
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   239
CEventTrapper::~CEventTrapper()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   240
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   241
	Cancel();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   242
	Deque();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   243
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   244
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   245
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   246
// CEventTrapper::Watch
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   247
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   248
// Start listening for events
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   249
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   250
void CEventTrapper::Watch()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   251
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   252
	iDispatch->iKernelDriver.GetEvent(iStatus, iEventInfo);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   253
	SetActive();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   254
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   255
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   256
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   257
// CEventTrapper::RunL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   258
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   259
// Called when an event occurs
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   260
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   261
void CEventTrapper::RunL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   262
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   263
	// determine the type of event and handle accordingly
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   264
	switch (iEventInfo.iEventType)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   265
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   266
		case SEventInfo::EThreadBreakPoint:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   267
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   268
			iDispatch->DoNotifyStoppedL(iEventInfo.iProcessId, iEventInfo.iThreadId, iEventInfo.iCurrentPC, KNullDesC8);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   269
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   270
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   271
		case SEventInfo::EThreadException:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   272
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   273
			TBuf8<100> buf;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   274
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   275
			switch(iEventInfo.iExceptionNumber)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   276
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   277
				case EExcIntegerDivideByZero:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   278
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   279
					buf.Format(_L8("An integer divide by zero exception has occurred."));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   280
					break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   281
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   282
				case EExcIntegerOverflow:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   283
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   284
					buf.Format(_L8("An integer overflow exception has occurred."));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   285
					break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   286
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   287
				case EExcBoundsCheck:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   288
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   289
					buf.Format(_L8("An bounds check exception has occurred."));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   290
					break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   291
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   292
				case EExcInvalidOpCode:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   293
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   294
					buf.Format(_L8("An invalid instruction exception has occurred."));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   295
					break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   296
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   297
				case EExcDoubleFault:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   298
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   299
					buf.Format(_L8("A double fault exception has occurred."));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   300
					break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   301
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   302
				case EExcStackFault:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   303
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   304
					buf.Format(_L8("A stack fault exception has occurred."));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   305
					break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   306
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   307
				case EExcAccessViolation:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   308
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   309
					buf.Format(_L8("An access violation exception has occurred."));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   310
					break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   311
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   312
				case EExcPrivInstruction:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   313
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   314
					buf.Format(_L8("A priveledged instruction exception has occurred."));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   315
					break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   316
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   317
				case EExcAlignment:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   318
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   319
					buf.Format(_L8("An alignment exception has occurred."));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   320
					break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   321
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   322
				case EExcPageFault:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   323
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   324
					buf.Format(_L8("A page fault exception has occurred."));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   325
					break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   326
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   327
				case EExcFloatDenormal:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   328
				case EExcFloatDivideByZero:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   329
				case EExcFloatInexactResult:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   330
				case EExcFloatInvalidOperation:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   331
				case EExcFloatOverflow:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   332
				case EExcFloatStackCheck:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   333
				case EExcFloatUnderflow:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   334
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   335
					buf.Format(_L8("A floating point exception has occurred."));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   336
					break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   337
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   338
				case EExcAbort:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   339
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   340
					buf.Format(_L8("An abort exception has occurred."));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   341
					break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   342
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   343
				case EExcUserInterrupt:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   344
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   345
					buf.Format(_L8("A user interrupt exception has occurred."));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   346
					break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   347
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   348
				case EExcDataAbort:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   349
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   350
					buf.Format(_L8("A data abort exception has occurred."));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   351
					break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   352
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   353
				case EExcCodeAbort:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   354
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   355
					buf.Format(_L8("A code abort exception has occurred."));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   356
					break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   357
				}				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   358
				case EExcGeneral:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   359
				case EExcSingleStep:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   360
				case EExcBreakPoint:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   361
				case EExcKill:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   362
				case EExcMaxNumber:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   363
				case EExcInvalidVector:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   364
				default:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   365
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   366
					buf.Format(_L8("An unknown exception (%d) has occurred."), iEventInfo.iExceptionNumber);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   367
					break;				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   368
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   369
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   370
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   371
			iDispatch->DoNotifyStoppedL(iEventInfo.iProcessId, iEventInfo.iThreadId, iEventInfo.iCurrentPC, buf);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   372
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   373
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   374
		case SEventInfo::EThreadPanic:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   375
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   376
			TBuf8<100> buf;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   377
//			buf.Format(_L8("Thread 0x%x has panicked.\nCategory: %S\nReason: %d"), iEventInfo.iThreadId, &iEventInfo.iPanicCategory, iEventInfo.iExceptionNumber);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   378
			buf.Format(_L8("Thread 0x%x has panicked. Category: %S; Reason: %d"), iEventInfo.iThreadId, &iEventInfo.iPanicCategory, iEventInfo.iPanicReason);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   379
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   380
			iDispatch->DoNotifyStoppedL(iEventInfo.iProcessId, iEventInfo.iThreadId, iEventInfo.iCurrentPC, buf, true, iEventInfo.iExceptionNumber);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   381
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   382
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   383
		case SEventInfo::EProcessPanic:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   384
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   385
			TBuf8<100> buf;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   386
			buf.Format(_L8("Process 0x%x has panicked.\nCategory: %S\nReason: %d"), iEventInfo.iProcessId, &iEventInfo.iPanicCategory, iEventInfo.iExceptionNumber);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   387
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   388
			iDispatch->DoNotifyStoppedL(iEventInfo.iProcessId, iEventInfo.iThreadId, iEventInfo.iCurrentPC, buf);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   389
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   390
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   391
		case SEventInfo::ELibraryLoaded:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   392
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   393
			// a library has been loaded.  we get statically linked library loaded notifications
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   394
			// the very first time the process is created.  we want to ignore these because we
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   395
			// handle static libs in another way.  if the process the library was loaded for is
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   396
			// not being debugging, just resume the thread and ignore the event.  if the process
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   397
			// is being debugged but it hasn't yet been created, then this must be a static lib
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   398
			// and we ignore it.  note that we do not bother resuming the thread since it has not
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   399
			// been started yet!
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   400
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   401
			TBool created = EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   402
			TBool found = EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   403
					
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   404
			for (TInt i=0; i<iDispatch->iDebugProcessList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   405
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   406
				if (iDispatch->iDebugProcessList[i]->ProcessId() == iEventInfo.iProcessId)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   407
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   408
					created = iDispatch->iDebugProcessList[i]->iReadyForLibraryLoadNotification;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   409
					found = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   410
					break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   411
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   412
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   413
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   414
		#ifndef EKA2
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   415
			if (!iEventInfo.iCodeAddress)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   416
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   417
				TBuf<KMaxPath> libName;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   418
				libName.Copy(iEventInfo.iFileName);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   419
				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   420
				RLibrary lib;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   421
				TInt err = lib.LoadRomLibrary(libName, KNullDesC);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   422
				if (KErrNone == err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   423
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   424
					iEventInfo.iCodeAddress = (TUint32)lib.EntryPoint();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   425
					lib.Close();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   426
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   427
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   428
		#endif
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   429
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   430
			if (!created || !iEventInfo.iCodeAddress || !found)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   431
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   432
				iDispatch->iKernelDriver.ResumeThread(iEventInfo.iThreadId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   433
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   434
			else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   435
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   436
				iDispatch->DoNotifyLibraryLoadedL(iEventInfo.iFileName, iEventInfo.iProcessId, iEventInfo.iThreadId, iEventInfo.iCodeAddress, iEventInfo.iDataAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   437
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   438
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   439
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   440
		case SEventInfo::ELibraryUnloaded:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   441
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   442
			TBool found = EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   443
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   444
			for (TInt i=0; i<iDispatch->iDebugProcessList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   445
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   446
				if (iDispatch->iDebugProcessList[i]->ProcessId() == iEventInfo.iProcessId)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   447
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   448
					found = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   449
					break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   450
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   451
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   452
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   453
			if (!found)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   454
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   455
				iDispatch->iKernelDriver.ResumeThread(iEventInfo.iThreadId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   456
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   457
			else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   458
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   459
				iDispatch->DoNotifyLibraryUnloadedL(iEventInfo.iFileName, iEventInfo.iProcessId, iEventInfo.iThreadId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   460
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   461
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   462
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   463
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   464
		case SEventInfo::EUserTrace:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   465
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   466
			iDispatch->DoNotifyUserTraceL(iEventInfo.iTraceData);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   467
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   468
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   469
		case SEventInfo::EProcessAdded:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   470
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   471
			iDispatch->DoNotifyProcessAddedL(iEventInfo.iFileName, iEventInfo.iProcessId, 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   472
											 iEventInfo.iThreadId, iEventInfo.iUid, 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   473
											 iEventInfo.iCodeAddress, iEventInfo.iDataAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   474
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   475
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   476
		case SEventInfo::EUnknown:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   477
		default:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   478
			User::Panic(_L("Unknown event type"), __LINE__);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   479
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   480
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   481
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   482
	// reset the values
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   483
	iEventInfo.Reset();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   484
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   485
	// keep listening for more events
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   486
	Watch();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   487
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   488
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   489
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   490
// CEventTrapper::DoCancel
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   491
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   492
// Stop listening for events
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   493
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   494
void CEventTrapper::DoCancel()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   495
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   496
	iDispatch->iKernelDriver.CancelGetEvent();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   497
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   498
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   499
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   500
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   501
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   502
// CDebugProcess implementation
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   503
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   504
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   505
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   506
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   507
// CDebugProcess::NewL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   508
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   509
// Accepts CTrkDispatchLayer interface and the process ID and main
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   510
// thread ID of a process being debugged
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   511
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   512
CDebugProcess* CDebugProcess::NewL(CTrkDispatchLayer *aDispatch, TUint32 aProcessId, TUint32 aMainThreadId)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   513
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   514
	CDebugProcess* self = new(ELeave) CDebugProcess();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   515
	self->ConstructL(aDispatch, aProcessId, aMainThreadId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   516
	return self;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   517
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   518
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   519
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   520
// CDebugProcess::ConstructL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   521
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   522
// Accepts CTrkDispatchLayer interface and the process ID and main
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   523
// thread ID of a process being debugged
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   524
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   525
void CDebugProcess::ConstructL(CTrkDispatchLayer *aDispatch, TUint32 aProcessId, TUint32 aMainThreadId)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   526
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   527
	iProcessId = aProcessId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   528
	iMainThreadId = aMainThreadId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   529
	iReadyForLibraryLoadNotification = EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   530
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   531
	// start waiting for this process to exit
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   532
	iExitTrapper = new(ELeave) CExitTrapper(aDispatch, aProcessId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   533
	iExitTrapper->Watch();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   534
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   535
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   536
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   537
// CDebugProcess destructor
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   538
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   539
CDebugProcess::~CDebugProcess()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   540
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   541
	SafeDelete(iExitTrapper);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   542
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   543
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   544
#ifndef __TEXT_SHELL__
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   545
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   546
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   547
// CPhoneInfo implementation
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   548
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   549
CPhoneInfo::CPhoneInfo():
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   550
           CActive(EPriorityStandard),
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   551
           iPhoneIdV1Pckg(iPhoneIdV1),
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   552
           iDispatchLayer(NULL)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   553
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   554
    CActiveScheduler::Add(this);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   555
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   556
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   557
CPhoneInfo* CPhoneInfo::NewL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   558
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   559
    CPhoneInfo* self = new(ELeave) CPhoneInfo();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   560
    CleanupStack::PushL(self);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   561
    self->ConstructL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   562
    CleanupStack::Pop();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   563
    return self;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   564
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   565
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   566
void CPhoneInfo::ConstructL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   567
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   568
    iTelephony = CTelephony::NewL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   569
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   570
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   571
CPhoneInfo::~CPhoneInfo() 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   572
{ 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   573
    Cancel();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   574
    Deque();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   575
    SafeDelete(iTelephony);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   576
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   577
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   578
void CPhoneInfo::GetPhoneName(CTrkDispatchLayer* aDispatchLayer)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   579
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   580
    iDispatchLayer = aDispatchLayer;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   581
    iTelephony->GetPhoneId(iStatus, iPhoneIdV1Pckg);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   582
    SetActive();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   583
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   584
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   585
void CPhoneInfo::RunL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   586
{   
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   587
    if(iStatus == KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   588
	{          
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   589
        iDispatchLayer->UpdatePhoneNameInfo(iPhoneIdV1.iModel);              
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   590
    }
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   591
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   592
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   593
void CPhoneInfo::DoCancel()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   594
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   595
	iTelephony->CancelAsync(CTelephony::EGetPhoneIdCancel);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   596
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   597
#endif
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   598
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   599
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   600
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   601
// CTrkDispatchLayer implementation
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   602
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   603
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   604
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   605
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   606
// CTrkDispatchLayer constructor
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   607
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   608
CTrkDispatchLayer::CTrkDispatchLayer()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   609
	: iEngine(NULL),
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   610
	  iFramingLayer(NULL),
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   611
#ifndef __TEXT_SHELL__
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   612
	  iPhoneInfo(NULL),
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   613
#endif
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   614
	  iFileState(EFileUnknown),
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   615
	  iDebugProcessList(1),
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   616
	  iProcessList(1),
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   617
	  iThreadList(1),
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   618
	  iSuspendedThreadList(1),
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   619
	  iEventTrapper(NULL),
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   620
	  iIsConnected(EFalse),
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   621
	  iPhoneNameInfoAvailable(EFalse)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   622
	  
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   623
#ifdef __OEM_TRK__	  
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   624
	  ,iUseTcbServer(EFalse)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   625
#endif	  
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   626
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   627
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   628
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   629
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   630
// CTrkDispatchLayer::NewL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   631
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   632
CTrkDispatchLayer* CTrkDispatchLayer::NewL(CTrkCommPort *aPort, CTrkEngine* aEngine)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   633
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   634
	CTrkDispatchLayer* self = new(ELeave) CTrkDispatchLayer();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   635
	self->ConstructL(aPort, aEngine);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   636
	return self;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   637
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   638
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   639
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   640
// CTrkDispatchLayer destructor
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   641
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   642
CTrkDispatchLayer::~CTrkDispatchLayer()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   643
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   644
	SafeDelete(iFramingLayer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   645
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   646
	SafeDelete(iInputBuffer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   647
	SafeDelete(iReplyBuffer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   648
#ifndef __TEXT_SHELL__
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   649
	SafeDelete(iPhoneInfo);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   650
#endif
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   651
	// just in case a disconnect never happened
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   652
	SafeDelete(iEventTrapper);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   653
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   654
#ifndef __WINS__
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   655
	iKernelDriver.Close();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   656
#endif
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   657
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   658
    CloseTcbServer();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   659
	iProcessList.Close();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   660
	iThreadList.Close();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   661
	iSuspendedThreadList.Close();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   662
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   663
	iDebugProcessList.ResetAndDestroy();	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   664
	iDebugProcessList.Close();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   665
	//Notify the server that Debugging is ended
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   666
    if (iEngine)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   667
        iEngine->DebuggingEnded();  
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   668
        
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   669
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   670
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   671
// CTrkDispathcLayer::CloseTcbServer()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   672
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   673
void CTrkDispatchLayer::CloseTcbServer()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   674
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   675
#ifdef __OEM_TRK__  
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   676
    //Shutdown the tcb server.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   677
    if (iUseTcbServer)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   678
    {
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   679
        iTrkTcbSession.ShutDownServer();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   680
        iTrkTcbSession.Close();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   681
        iUseTcbServer = EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   682
    }
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   683
#endif  
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   684
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   685
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   686
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   687
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   688
// CTrkDispatchLayer::ConstructL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   689
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   690
void CTrkDispatchLayer::ConstructL(CTrkCommPort *aPort, CTrkEngine* aEngine)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   691
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   692
	iEngine = aEngine;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   693
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   694
	// create the framing layer interface
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   695
	iFramingLayer = new CTrkFramingLayer(aPort);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   696
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   697
	// At a minimum, we assume that the host debugger supports 3.3 version of the protocol
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   698
	// From 3.0 to 3.3, TRK is backwards compatible. Starting with version 3.4, TRK sends 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   699
	// process created notifications as part of notify created event. Unless the host 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   700
	// debugger sets the supported protocol version to 3.4, we are not going to send this 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   701
	// new notification. Going forward, we should check for the protocol version before 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   702
	// we send new notifications. 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   703
	iHostVersion.iMajor = DS_PROTOCOL_MAJOR_VERSION_3;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   704
	iHostVersion.iMinor = DS_PROTOCOL_MINOR_VERSION_3;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   705
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   706
	//To find the sw version runnning in the phone
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   707
	FindPhoneSWVersion();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   708
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   709
	// On techview, this functionality is not available for some reason.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   710
	// This needs to be investigated further, but this functionality is not critical for techview platform right now.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   711
#ifdef __S60__
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   712
	// To find the name of the phone.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   713
	TRAPD(err1, FindPhoneNameL());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   714
	if (err1 != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   715
#endif	   
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   716
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   717
	    iPhoneNameInfoAvailable = EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   718
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   719
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   720
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   721
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   722
// CTrkDispathLayer::FindPhoneSWVersion()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   723
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   724
// Finds out the software version of the phone
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   725
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   726
void CTrkDispatchLayer::FindPhoneSWVersion()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   727
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   728
#ifndef __TEXT_SHELL__
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   729
    TBuf<KSysUtilVersionTextLength> version;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   730
    if (SysUtil::GetSWVersion( version ) == KErrNone ) 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   731
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   732
        iPhoneVersion.Copy(version);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   733
	}                
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   734
#endif
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   735
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   736
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   737
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   738
// CTrkDispathLayer::FindPhoneName()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   739
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   740
// Finds the name of the phone 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   741
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   742
void CTrkDispatchLayer::FindPhoneNameL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   743
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   744
#ifndef __TEXT_SHELL__
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   745
    iPhoneInfo = CPhoneInfo::NewL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   746
    iPhoneInfo->GetPhoneName(this);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   747
#endif             
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   748
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   749
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   750
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   751
// CTrkDispatchLayer::Listen
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   752
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   753
// Start listening to the communications port for messages from the host debugger
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   754
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   755
void CTrkDispatchLayer::Listen()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   756
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   757
	iFramingLayer->Listen(this);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   758
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   759
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   760
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   761
// CTrkDispatchLayer::StopListening
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   762
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   763
// Stop listening to the communications port for messages from the host debugger
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   764
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   765
void CTrkDispatchLayer::StopListening()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   766
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   767
	// just in case the user quit MetroTrk while something was being debugged.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   768
	RProcess process;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   769
	for (TInt i=0; i<iDebugProcessList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   770
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   771
		if (KErrNone == process.Open(iDebugProcessList[i]->ProcessId()))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   772
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   773
		#ifdef EKA2
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   774
			process.Kill(KErrNone);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   775
		#else	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   776
			process.Kill(KProcessKilled);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   777
		#endif
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   778
			process.Close();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   779
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   780
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   781
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   782
	iFramingLayer->StopListening();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   783
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   784
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   785
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   786
// CTrkDispatchLayer::GetVersionInfo
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   787
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   788
// Get the current version of MetroTrk
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   789
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   790
void CTrkDispatchLayer::GetVersionInfo(TInt &aMajorVersion, TInt &aMinorVersion, TInt &aMajorAPIVersion, TInt &aMinorAPIVersion, TInt &aBuildNumber)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   791
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   792
	aMajorVersion = MAJOR_VERSION_NUMBER;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   793
	aMinorVersion = MINOR_VERSION_NUMBER;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   794
	aMajorAPIVersion = DS_PROTOCOL_MAJOR_VERSION;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   795
	aMinorAPIVersion = DS_PROTOCOL_MINOR_VERSION;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   796
	aBuildNumber = BUILD_NUMBER;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   797
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   798
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   799
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   800
// CTrkDispatchLayer::HandleMsg
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   801
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   802
// Handle a command sent by the host debugger
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   803
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   804
void CTrkDispatchLayer::HandleMsg(const TDesC8& aMsg)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   805
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   806
	TInt error = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   807
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   808
	// reset the input buffer and set it to the new unframed message
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   809
	SafeDelete(iInputBuffer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   810
	iInputBuffer = aMsg.Alloc();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   811
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   812
	if (!iInputBuffer)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   813
		User::Panic(_L("Failed to allocate input buffer"), __LINE__);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   814
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   815
	TRAP(error, DispatchMsgL());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   816
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   817
	if (error < 0)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   818
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   819
		// its a symbian os error
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   820
		error = kDSReplyOsError;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   821
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   822
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   823
	// handle errors raised during command execution
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   824
	switch(error)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   825
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   826
		// no error and ack was sent by handler
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   827
 		case kDSReplyNoError:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   828
 			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   829
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   830
		// there was a problem with the packet received
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   831
		case kDSReplyPacketSizeError:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   832
		case kDSReplyEscapeError:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   833
		case kDSReplyBadFCS:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   834
		case kDSReplyOverflow:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   835
		case kDSReplySequenceMissing:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   836
			iFramingLayer->RespondErr(kDSReplyNAK, error);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   837
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   838
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   839
		// command and format were OK, but failed for some other reason
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   840
 		default:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   841
			iFramingLayer->RespondErr(kDSReplyACK, error);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   842
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   843
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   844
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   845
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   846
// CTrkDispatchLayer::DispatchMsgL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   847
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   848
// Handle the command sent by the host debugger
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   849
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   850
void CTrkDispatchLayer::DispatchMsgL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   851
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   852
	// make sure the input buffer is setup
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   853
	User::LeaveIfNull(iInputBuffer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   854
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   855
	// iInputBuffer holds the unframed message from the host
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   856
	switch (iInputBuffer->Ptr()[0])
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   857
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   858
		case kDSPing:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   859
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   860
			// nothing to do
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   861
			iFramingLayer->RespondOkL(KNullDesC8);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   862
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   863
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   864
		case kDSConnect:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   865
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   866
			DoConnectL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   867
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   868
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   869
		case kDSDisconnect:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   870
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   871
			DoDisconnectL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   872
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   873
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   874
		case kDSVersions:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   875
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   876
			DoVersionsL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   877
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   878
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   879
		case kDSVersions2:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   880
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   881
			DoVersions2L();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   882
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   883
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   884
		case kDSVersions3:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   885
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   886
			DoVersions3L();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   887
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   888
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   889
		case kDSHostVersions:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   890
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   891
			DoHostVersionsL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   892
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   893
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   894
		case kDSSupportMask:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   895
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   896
			DoSupportMaskL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   897
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   898
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   899
		case kDSCPUType:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   900
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   901
			DoCPUTypeL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   902
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   903
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   904
		case kDSReadMemory:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   905
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   906
			DoReadMemoryL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   907
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   908
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   909
		case kDSWriteMemory:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   910
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   911
			DoWriteMemoryL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   912
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   913
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   914
		case kDSReadRegisters:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   915
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   916
			DoReadRegistersL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   917
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   918
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   919
		case kDSWriteRegisters:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   920
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   921
			DoWriteRegistersL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   922
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   923
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   924
		case kDSContinue:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   925
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   926
			DoContinueL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   927
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   928
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   929
		case kDSStep:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   930
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   931
			DoStepL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   932
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   933
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   934
		case kDSStop:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   935
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   936
			DoStopL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   937
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   938
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   939
		case kDSSetBreak:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   940
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   941
			DoSetBreakL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   942
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   943
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   944
		case kDSClearBreak:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   945
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   946
			DoClearBreakL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   947
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   948
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   949
		case kDSModifyBreakThread:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   950
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   951
			DoModifyBreakThreadL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   952
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   953
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   954
		case kDSOSCreateItem:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   955
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   956
			DoCreateItemL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   957
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   958
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   959
		case kDSOSDeleteItem:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   960
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   961
			DoDeleteItemL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   962
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   963
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   964
		case kDSOSReadInfo:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   965
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   966
			DoReadInfoL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   967
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   968
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   969
		case kDSOSWriteInfo:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   970
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   971
			DoWriteInfoL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   972
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   973
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   974
		case kDSOSWriteFile:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   975
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   976
			DoWriteFileL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   977
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   978
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   979
		case kDSOSReadFile:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   980
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   981
			DoReadFileL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   982
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   983
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   984
		case kDSOSOpenFile:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   985
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   986
			DoOpenFileL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   987
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   988
		}	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   989
		case kDSOSCloseFile:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   990
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   991
			DoCloseFileL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   992
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   993
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   994
		case kDSOSPositionFile:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   995
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   996
			DoPositionFileL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   997
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   998
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   999
		case kDSOSInstallFile:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1000
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1001
			DoInstallFileL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1002
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1003
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1004
		case kDSOSInstallFile2:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1005
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1006
			DoInstallFile2L();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1007
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1008
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1009
		case kDSOSPhoneSWVersion:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1010
	    {		    
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1011
		    DoGetPhoneSWVersionL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1012
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1013
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1014
		case kDSOSPhoneName:		    
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1015
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1016
		    DoGetPhoneNameL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1017
		    break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1018
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1019
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1020
		case kDSReplyACK:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1021
		case kDSReplyNAK:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1022
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1023
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1024
		case kDSReset:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1025
		case kDSFillMemory:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1026
		case kDSCopyMemory:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1027
		case kDSFlushCache:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1028
		case kDSDownload:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1029
		case kDSNotifyFileInput:			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1030
		default:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1031
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1032
			// unsupported command
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1033
			iFramingLayer->RespondErr(kDSReplyACK, kDSReplyUnsupportedCommandError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1034
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1035
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1036
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1037
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1038
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1039
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1040
// CTrkDispatchLayer::DoConnectL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1041
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1042
// The host debugger is starting a new debug session
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1043
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1044
void CTrkDispatchLayer::DoConnectL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1045
{	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1046
	// make sure we got here from DispatchMsgL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1047
	TUint8 command = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1048
	GetDataFromBufferL(&command, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1049
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1050
	if (kDSConnect != command)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1051
		User::Leave(kDSReplyError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1052
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1053
	// if we're already connected for some reason, we need to cleanup so we're ready
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1054
	// for a new debug session
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1055
	if (iIsConnected)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1056
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1057
		// reset the sequence ids for the next debug session
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1058
		iFramingLayer->ResetSequenceIDs();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1059
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1060
		//stop listening for events
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1061
		SafeDelete(iEventTrapper);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1062
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1063
		// let the kernel side driver cleanup
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1064
		iKernelDriver.Close();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1065
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1066
		iIsConnected = EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1067
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1068
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1069
	// reset the lists so that they are ready for use
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1070
	iProcessList.Reset();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1071
	iThreadList.Reset();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1072
	iSuspendedThreadList.Reset();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1073
	iDebugProcessList.ResetAndDestroy();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1074
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1075
	TMetroTrkDriverInfo info;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1076
#ifndef EKA2
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1077
	RLibrary euser;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1078
	User::LeaveIfError(euser.Load(EUSER_LIBPATH));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1079
	CleanupClosePushL(euser);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1080
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1081
	info.iPanic1Address = (TUint32)euser.Lookup(812);			// RThread::Panic
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1082
	info.iPanic2Address = (TUint32)euser.Lookup(813);			// RProcess::Panic
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1083
	info.iException1Address = (TUint32)euser.Lookup(868);		// RThread::RaiseException
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1084
	info.iException2Address = (TUint32)euser.Lookup(520);		// User::HandleException
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1085
	info.iLibraryLoadedAddress = (TUint32)euser.Lookup(636);	// UserSvr::LibraryLoaded
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1086
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1087
	// calculate the end address of the user library.  breakpoints and stepping will not
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1088
	// be allowed from the start of ROM to the end of the user library since stopping a
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1089
	// kernel thread could end up freezing the target
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1090
	RFs fs;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1091
	User::LeaveIfError(fs.Connect());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1092
	CleanupClosePushL(fs);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1093
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1094
	RFile file;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1095
	User::LeaveIfError(file.Open(fs, EUSER_LIBPATH, EFileStream|EFileRead|EFileShareReadersOnly));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1096
	CleanupClosePushL(file);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1097
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1098
	TInt size;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1099
	User::LeaveIfError(file.Size(size));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1100
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1101
	info.iUserLibraryEnd = (TUint32)euser.EntryPoint() + size;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1102
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1103
	CleanupStack::PopAndDestroy(); // file
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1104
	CleanupStack::PopAndDestroy(); // fs
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1105
	CleanupStack::PopAndDestroy(); // euser
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1106
#endif	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1107
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1108
	// start the kernel side driver
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1109
	User::LeaveIfError(iKernelDriver.Open(info));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1110
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1111
	// start listening for events
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1112
	iEventTrapper = new(ELeave) CEventTrapper(this);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1113
	iEventTrapper->Watch();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1114
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1115
	iIsConnected = ETrue;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1116
#ifdef __S60__	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1117
	// now close close crash logger
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1118
	CloseCrashLogger();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1119
#endif	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1120
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1121
	if (iEngine)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1122
		iEngine->DebuggingStarted();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1123
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1124
	iFramingLayer->RespondOkL(KNullDesC8);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1125
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1126
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1127
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1128
// CTrkDispatchLayer::DoDisconnectL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1129
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1130
// The host debugger is stopping the current debug session
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1131
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1132
void CTrkDispatchLayer::DoDisconnectL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1133
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1134
	// make sure we got here from DispatchMsgL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1135
	TUint8 command = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1136
	GetDataFromBufferL(&command, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1137
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1138
	if (kDSDisconnect != command)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1139
		User::Leave(kDSReplyError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1140
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1141
	// make sure we're connected
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1142
	if (!iIsConnected)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1143
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1144
		User::Leave(KErrCouldNotDisconnect);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1145
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1146
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1147
	//stop listening for events
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1148
	SafeDelete(iEventTrapper);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1149
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1150
	iIsConnected = EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1151
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1152
	iFramingLayer->RespondOkL(KNullDesC8);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1153
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1154
	// let the kernel side driver cleanup
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1155
	iKernelDriver.Close();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1156
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1157
	//Shutdown the tcb server.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1158
	CloseTcbServer();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1159
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1160
	// send the callback to the trk server
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1161
	if (iEngine)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1162
		iEngine->DebuggingEnded();	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1163
        
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1164
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1165
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1166
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1167
// CTrkDispatchLayer::DoVersionsL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1168
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1169
// The host debugger is requesting MetroTrk version information
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1170
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1171
void CTrkDispatchLayer::DoVersionsL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1172
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1173
	// make sure we got here from DispatchMsgL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1174
	TUint8 command = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1175
	GetDataFromBufferL(&command, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1176
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1177
	if (kDSVersions != command)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1178
		User::Leave(kDSReplyError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1179
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1180
	TUint8 kernelMajorVersion = MAJOR_VERSION_NUMBER;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1181
	TUint8 kernelMinorVersion = MINOR_VERSION_NUMBER;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1182
	TUint8 protocolMajorVersion = DS_PROTOCOL_MAJOR_VERSION;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1183
	TUint8 protocolMinorVersion = DS_PROTOCOL_MINOR_VERSION;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1184
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1185
	AddToReplyBufferL(kernelMajorVersion, true);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1186
	AddToReplyBufferL(kernelMinorVersion);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1187
	AddToReplyBufferL(protocolMajorVersion);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1188
	AddToReplyBufferL(protocolMinorVersion);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1189
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1190
	RespondOkL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1191
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1192
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1193
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1194
// CTrkDispatchLayer::DoVersionsL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1195
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1196
// The host debugger is requesting MetroTrk version information
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1197
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1198
void CTrkDispatchLayer::DoVersions2L()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1199
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1200
	// make sure we got here from DispatchMsgL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1201
	TUint8 command = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1202
	GetDataFromBufferL(&command, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1203
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1204
	if (kDSVersions2 != command)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1205
		User::Leave(kDSReplyError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1206
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1207
	TUint8 kernelMajorVersion = MAJOR_VERSION_NUMBER;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1208
	TUint8 kernelMinorVersion = MINOR_VERSION_NUMBER;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1209
	TUint8 protocolMajorVersion = DS_PROTOCOL_MAJOR_VERSION;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1210
	TUint8 protocolMinorVersion = DS_PROTOCOL_MINOR_VERSION;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1211
	TUint8 buildNumber = BUILD_NUMBER;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1212
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1213
	AddToReplyBufferL(kernelMajorVersion, true);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1214
	AddToReplyBufferL(kernelMinorVersion);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1215
	AddToReplyBufferL(protocolMajorVersion);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1216
	AddToReplyBufferL(protocolMinorVersion);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1217
	AddToReplyBufferL(buildNumber);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1218
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1219
	RespondOkL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1220
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1221
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1222
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1223
// CTrkDispatchLayer::DoVersions3L
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1224
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1225
// The host debugger is requesting MetroTrk version information
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1226
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1227
void CTrkDispatchLayer::DoVersions3L()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1228
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1229
	// make sure we got here from DispatchMsgL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1230
	TUint8 command = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1231
	GetDataFromBufferL(&command, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1232
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1233
	if (kDSVersions3 != command)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1234
		User::Leave(kDSReplyError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1235
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1236
	TUint8 kernelMajorVersion = MAJOR_VERSION_NUMBER;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1237
	TUint8 kernelMinorVersion = MINOR_VERSION_NUMBER;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1238
	TUint8 protocolMajorVersion = DS_PROTOCOL_MAJOR_VERSION;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1239
	TUint8 protocolMinorVersion = DS_PROTOCOL_MINOR_VERSION;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1240
	TUint8 buildNumber = BUILD_NUMBER;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1241
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1242
	AddToReplyBufferL(kernelMajorVersion, true);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1243
	AddToReplyBufferL(kernelMinorVersion);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1244
	AddToReplyBufferL(protocolMajorVersion);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1245
	AddToReplyBufferL(protocolMinorVersion);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1246
	AddToReplyBufferL(buildNumber);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1247
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1248
	TUint16 len = TRK_TYPE_DESCRIPTION.Length();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1249
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1250
	AddToReplyBufferL(len);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1251
	AddToReplyBufferL(TRK_TYPE_DESCRIPTION);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1252
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1253
	RespondOkL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1254
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1255
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1256
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1257
// CTrkDispatchLayer::DoHostVersionsL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1258
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1259
// The host debugger is sending the supported protocol version
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1260
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1261
void CTrkDispatchLayer::DoHostVersionsL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1262
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1263
	// make sure we got here from DispatchMsgL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1264
	TUint8 command = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1265
	GetDataFromBufferL(&command, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1266
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1267
	if (kDSHostVersions != command)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1268
		User::Leave(kDSReplyError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1269
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1270
	GetDataFromBufferL(&iHostVersion.iMajor, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1271
	GetDataFromBufferL(&iHostVersion.iMinor, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1272
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1273
	iFramingLayer->RespondOkL(KNullDesC8);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1274
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1275
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1276
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1277
// CTrkDispatchLayer::DoSupportMaskL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1278
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1279
// The host debugger is requesting MetroTrk capabilities
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1280
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1281
void CTrkDispatchLayer::DoSupportMaskL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1282
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1283
	// make sure we got here from DispatchMsgL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1284
	TUint8 command = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1285
	GetDataFromBufferL(&command, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1286
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1287
	if (kDSSupportMask != command)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1288
		User::Leave(kDSReplyError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1289
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1290
	TBuf8<32> supportMask;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1291
	TUint8 level = DS_PROTOCOL_RTOS;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1292
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1293
	supportMask.Zero();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1294
	supportMask.Append(DS_SUPPORT_MASK_00_07);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1295
	supportMask.Append(DS_SUPPORT_MASK_08_0F);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1296
	supportMask.Append(DS_SUPPORT_MASK_10_17);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1297
	supportMask.Append(DS_SUPPORT_MASK_18_1F);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1298
	supportMask.Append(DS_SUPPORT_MASK_20_27);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1299
	supportMask.Append(DS_SUPPORT_MASK_28_2F);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1300
	supportMask.Append(DS_SUPPORT_MASK_30_37);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1301
	supportMask.Append(DS_SUPPORT_MASK_38_3F);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1302
	supportMask.Append(DS_SUPPORT_MASK_40_47);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1303
	supportMask.Append(DS_SUPPORT_MASK_48_4F);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1304
	supportMask.Append(DS_SUPPORT_MASK_50_57);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1305
	supportMask.Append(DS_SUPPORT_MASK_58_5F);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1306
	supportMask.Append(DS_SUPPORT_MASK_60_67);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1307
	supportMask.Append(DS_SUPPORT_MASK_68_6F);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1308
	supportMask.Append(DS_SUPPORT_MASK_70_77);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1309
	supportMask.Append(DS_SUPPORT_MASK_78_7F);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1310
	supportMask.Append(DS_SUPPORT_MASK_80_87);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1311
	supportMask.Append(DS_SUPPORT_MASK_88_8F);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1312
	supportMask.Append(DS_SUPPORT_MASK_90_97);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1313
	supportMask.Append(DS_SUPPORT_MASK_98_9F);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1314
	supportMask.Append(DS_SUPPORT_MASK_A0_A7);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1315
	supportMask.Append(DS_SUPPORT_MASK_A8_AF);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1316
	supportMask.Append(DS_SUPPORT_MASK_B0_B7);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1317
	supportMask.Append(DS_SUPPORT_MASK_B8_BF);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1318
	supportMask.Append(DS_SUPPORT_MASK_C0_C7);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1319
	supportMask.Append(DS_SUPPORT_MASK_C8_CF);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1320
	supportMask.Append(DS_SUPPORT_MASK_D0_D7);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1321
	supportMask.Append(DS_SUPPORT_MASK_D8_DF);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1322
	supportMask.Append(DS_SUPPORT_MASK_E0_E7);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1323
	supportMask.Append(DS_SUPPORT_MASK_E8_EF);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1324
	supportMask.Append(DS_SUPPORT_MASK_F0_F7);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1325
	supportMask.Append(DS_SUPPORT_MASK_F8_FF);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1326
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1327
	AddToReplyBufferL(supportMask, true);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1328
	AddToReplyBufferL(level);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1329
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1330
	RespondOkL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1331
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1332
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1333
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1334
// CTrkDispatchLayer::DoCPUTypeL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1335
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1336
// The host debugger is requesting cpu information
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1337
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1338
void CTrkDispatchLayer::DoCPUTypeL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1339
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1340
	// make sure we got here from DispatchMsgL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1341
	TUint8 command = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1342
	GetDataFromBufferL(&command, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1343
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1344
	if (kDSCPUType != command)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1345
		User::Leave(kDSReplyError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1346
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1347
	TUint8 cpuMajor = DS_CPU_MAJOR_ARM;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1348
	TUint8 cpuMinor = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1349
	TUint8 bigEndian = iFramingLayer->IsBigEndian() ? 1 : 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1350
	TUint8 defaultTypeSize = 4;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1351
	TUint8 fpTypeSize = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1352
	TUint8 extended1TypeSize = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1353
	TUint8 extended2TypeSize = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1354
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1355
	AddToReplyBufferL(cpuMajor, true);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1356
	AddToReplyBufferL(cpuMinor);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1357
	AddToReplyBufferL(bigEndian);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1358
	AddToReplyBufferL(defaultTypeSize);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1359
	AddToReplyBufferL(fpTypeSize);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1360
	AddToReplyBufferL(extended1TypeSize);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1361
	AddToReplyBufferL(extended2TypeSize);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1362
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1363
	RespondOkL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1364
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1365
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1366
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1367
// CTrkDispatchLayer::DoReadMemoryL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1368
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1369
// Read memory from the target device and return to the host
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1370
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1371
void CTrkDispatchLayer::DoReadMemoryL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1372
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1373
	// make sure we're connected
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1374
	if (!iIsConnected)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1375
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1376
		User::Leave(KErrGeneral);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1377
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1378
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1379
	// make sure we got here from DispatchMsgL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1380
	TUint8 command = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1381
	GetDataFromBufferL(&command, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1382
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1383
	if (kDSReadMemory != command)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1384
		User::Leave(kDSReplyError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1385
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1386
 	// get the options
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1387
	TUint8 options = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1388
	GetDataFromBufferL(&options, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1389
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1390
	if ((options & DS_MSG_MEMORY_EXTENDED) != 0)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1391
		User::Leave(kDSReplyUnsupportedOptionError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1392
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1393
	// get the length to read
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1394
	TUint16 length = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1395
	GetDataFromBufferL(&length, 2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1396
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1397
	if (length > DS_MAXREADWRITELENGTH)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1398
		User::Leave(kDSReplyParameterError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1399
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1400
	// get the start address
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1401
	TUint32 address = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1402
	GetDataFromBufferL(&address, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1403
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1404
	// get the process id
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1405
	TUint32 processId = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1406
	GetDataFromBufferL(&processId, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1407
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1408
	// get the thread id
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1409
	TUint32 threadId = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1410
	GetDataFromBufferL(&threadId, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1411
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1412
	// allocate enough room for the data
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1413
	HBufC8 *data = HBufC8::NewLC(length);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1414
	TPtr8 ptr(data->Des());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1415
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1416
	TInt err = iKernelDriver.ReadMemory(threadId, address, length, ptr);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1417
	if (KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1418
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1419
		CleanupStack::PopAndDestroy(data);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1420
		User::Leave(err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1421
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1422
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1423
	AddToReplyBufferL(length, true);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1424
	AddToReplyBufferL(ptr);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1425
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1426
	RespondOkL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1427
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1428
	CleanupStack::PopAndDestroy(data);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1429
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1430
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1431
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1432
// CTrkDispatchLayer::DoWriteMemoryL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1433
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1434
// Write memory from the host to the target device
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1435
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1436
void CTrkDispatchLayer::DoWriteMemoryL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1437
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1438
	// make sure we're connected
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1439
	if (!iIsConnected)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1440
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1441
		User::Leave(KErrGeneral);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1442
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1443
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1444
	// make sure we got here from DispatchMsgL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1445
	TUint8 command = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1446
	GetDataFromBufferL(&command, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1447
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1448
	if (kDSWriteMemory != command)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1449
		User::Leave(kDSReplyError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1450
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1451
 	// get the options
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1452
	TUint8 options = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1453
	GetDataFromBufferL(&options, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1454
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1455
	if ((options & DS_MSG_MEMORY_EXTENDED) != 0)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1456
		User::Leave(kDSReplyUnsupportedOptionError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1457
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1458
	// get the length to write
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1459
	TUint16 length = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1460
	GetDataFromBufferL(&length, 2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1461
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1462
	if (length > DS_MAXREADWRITELENGTH)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1463
		User::Leave(kDSReplyParameterError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1464
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1465
	// get the start address
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1466
	TUint32 address = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1467
	GetDataFromBufferL(&address, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1468
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1469
	// get the process id
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1470
	TUint32 processId = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1471
	GetDataFromBufferL(&processId, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1472
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1473
	// get the thread id
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1474
	TUint32 threadId = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1475
	GetDataFromBufferL(&threadId, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1476
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1477
	User::LeaveIfError(iKernelDriver.WriteMemory(threadId, address, length, *iInputBuffer));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1478
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1479
	AddToReplyBufferL(length, true);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1480
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1481
	RespondOkL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1482
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1483
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1484
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1485
// CTrkDispatchLayer::DoReadRegistersL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1486
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1487
// Read registers from the target device and return to the host
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1488
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1489
void CTrkDispatchLayer::DoReadRegistersL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1490
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1491
	// make sure we're connected
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1492
	if (!iIsConnected)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1493
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1494
		User::Leave(KErrGeneral);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1495
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1496
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1497
	// make sure we got here from DispatchMsgL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1498
	TUint8 command = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1499
	GetDataFromBufferL(&command, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1500
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1501
	if (kDSReadRegisters != command)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1502
		User::Leave(kDSReplyError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1503
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1504
	// get the options
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1505
	TUint8 options = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1506
	GetDataFromBufferL(&options, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1507
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1508
	if (DS_MSG_REGISTERS_TYPE(options) != kDSRegistersDefault)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1509
		User::Leave(kDSReplyUnsupportedOptionError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1510
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1511
	// get the first register
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1512
	TInt16 firstRegister = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1513
	GetDataFromBufferL(&firstRegister, 2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1514
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1515
	// get the last register
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1516
	TInt16 lastRegister = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1517
	GetDataFromBufferL(&lastRegister, 2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1518
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1519
	if ((firstRegister < 0) || (lastRegister > 16))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1520
		User::Leave(kDSReplyInvalidRegisterRange);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1521
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1522
	// get the process id
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1523
	TUint32 processId = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1524
	GetDataFromBufferL(&processId, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1525
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1526
	// get the thread id
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1527
	TUint32 threadId = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1528
	GetDataFromBufferL(&threadId, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1529
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1530
	// allocate enough space to hold the values
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1531
	HBufC8 *values = HBufC8::NewLC((lastRegister - firstRegister + 1) * 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1532
	TPtr8 ptr(values->Des());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1533
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1534
	TInt err = iKernelDriver.ReadRegisters(threadId, firstRegister, lastRegister, ptr);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1535
	if (KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1536
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1537
		CleanupStack::PopAndDestroy(values);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1538
		User::Leave(err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1539
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1540
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1541
	for (int i=0; i<=lastRegister - firstRegister; i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1542
		AddToReplyBufferL(*(TUint32 *)&ptr.Ptr()[i*4], i==0 ? true : false);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1543
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1544
	RespondOkL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1545
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1546
	CleanupStack::PopAndDestroy(values);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1547
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1548
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1549
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1550
// CTrkDispatchLayer::DoWriteRegistersL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1551
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1552
// Write registers from the host to the target device
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1553
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1554
void CTrkDispatchLayer::DoWriteRegistersL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1555
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1556
	// make sure we're connected
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1557
	if (!iIsConnected)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1558
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1559
		User::Leave(KErrGeneral);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1560
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1561
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1562
	// make sure we got here from DispatchMsgL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1563
	TUint8 command = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1564
	GetDataFromBufferL(&command, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1565
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1566
	if (kDSWriteRegisters != command)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1567
		User::Leave(kDSReplyError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1568
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1569
	// get the options
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1570
	TUint8 options = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1571
	GetDataFromBufferL(&options, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1572
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1573
	if (DS_MSG_REGISTERS_TYPE(options) != kDSRegistersDefault)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1574
		User::Leave(kDSReplyUnsupportedOptionError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1575
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1576
	// get the first register
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1577
	TInt16 firstRegister = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1578
	GetDataFromBufferL(&firstRegister, 2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1579
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1580
	// get the last register
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1581
	TInt16 lastRegister = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1582
	GetDataFromBufferL(&lastRegister, 2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1583
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1584
	if ((firstRegister < 0) || (lastRegister > 16))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1585
		User::Leave(kDSReplyInvalidRegisterRange);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1586
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1587
	// get the process id
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1588
	TUint32 processId = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1589
	GetDataFromBufferL(&processId, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1590
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1591
	// get the thread id
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1592
	TUint32 threadId = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1593
	GetDataFromBufferL(&threadId, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1594
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1595
	// MetroTrk register values come in as big endian so we may need to swap them
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1596
	if (!iFramingLayer->IsBigEndian())
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1597
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1598
		Swap4xN((TUint32 *)iInputBuffer->Ptr(), lastRegister-firstRegister + 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1599
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1600
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1601
	User::LeaveIfError(iKernelDriver.WriteRegisters(threadId, firstRegister, lastRegister, *iInputBuffer));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1602
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1603
	iFramingLayer->RespondOkL(KNullDesC8);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1604
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1605
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1606
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1607
// CTrkDispatchLayer::DoContinueL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1608
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1609
// Resume thread execution
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1610
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1611
void CTrkDispatchLayer::DoContinueL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1612
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1613
	// make sure we're connected
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1614
	if (!iIsConnected)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1615
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1616
		User::Leave(KErrGeneral);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1617
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1618
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1619
	// make sure we got here from DispatchMsgL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1620
	TUint8 command = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1621
	GetDataFromBufferL(&command, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1622
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1623
	if (kDSContinue != command)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1624
		User::Leave(kDSReplyError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1625
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1626
	// get the process id
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1627
	TUint32 processId = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1628
	GetDataFromBufferL(&processId, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1629
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1630
	// get the thread id
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1631
	TUint32 threadId = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1632
	GetDataFromBufferL(&threadId, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1633
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1634
	// see if this thread is in the the suspended threads list
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1635
	// if so, remove it and resume.  otherwise we need to handle
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1636
	// the special case of the first time a thread is resumed
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1637
	TInt index = iSuspendedThreadList.Find(threadId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1638
	if (index >= 0)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1639
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1640
		iSuspendedThreadList.Remove(index);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1641
		User::LeaveIfError(iKernelDriver.ResumeThread(threadId));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1642
		iFramingLayer->RespondOkL(KNullDesC8);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1643
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1644
	else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1645
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1646
		// if it's not in the suspended list then this is the first time it has been
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1647
		// resumed (the process has just been created).  see if there are statically
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1648
		// linked libraries that we need to report to the host debugger.  if so, we
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1649
		// don't really want to resume yet.  let the host debugger set any breakpoints
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1650
		// in the libraries first.  it will call resume again once it's done.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1651
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1652
		// since we never mark it as suspended, we'll actually get here when the host
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1653
		// debugger calls resume the second time.  we really don't want to mark it as
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1654
		// suspended because then the host debugger will try to draw the thread window
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1655
		TBool found = EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1656
		for (TInt i=0; i<iDebugProcessList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1657
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1658
			if (iDebugProcessList[i]->ProcessId() == processId)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1659
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1660
				found = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1661
				// if we're already marked it as ready, just resume and return
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1662
				if (iDebugProcessList[i]->iReadyForLibraryLoadNotification)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1663
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1664
					User::LeaveIfError(iKernelDriver.ResumeThread(threadId));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1665
					iFramingLayer->RespondOkL(KNullDesC8);		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1666
					return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1667
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1668
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1669
				iDebugProcessList[i]->iReadyForLibraryLoadNotification = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1670
				break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1671
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1672
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1673
		// For RUN mode, we created the process but we didn't put it into the list
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1674
		// therefore we do not want to notify the host debugger about static libraries
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1675
		// so just resume and return  (see DoCreateExeL)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1676
		// The host debugger will soon disconnect in this mode
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1677
		if (!found)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1678
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1679
			User::LeaveIfError(iKernelDriver.ResumeThread(threadId));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1680
			iFramingLayer->RespondOkL(KNullDesC8);		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1681
			return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1682
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1683
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1684
		// the process has been created and the host debugger is listening for messages
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1685
		// see if there are any statically linked libraries for this process.  if so, let
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1686
		// the host debugger know about them now. note that the host debugger will send
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1687
		// another resume command once it's handled the static libraries.  if there are
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1688
		// not static libraries for this process, we really do need to resume the thread.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1689
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1690
		TInt err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1691
		TInt i = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1692
		for (i=0; KErrNone==err; i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1693
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1694
			SEventInfo info;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1695
			info.iProcessId = processId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1696
			info.iThreadId = threadId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1697
			err = iKernelDriver.GetStaticLibraryInfo(i, info);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1698
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1699
			if (KErrNone == err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1700
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1701
				DoNotifyLibraryLoadedL(info.iFileName, info.iProcessId, 0xFFFFFFFF, info.iCodeAddress, info.iDataAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1702
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1703
			//else if (0 == i)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1704
			//{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1705
				// there are no static libraries for this process
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1706
				//User::LeaveIfError(iKernelDriver.ResumeThread(threadId));			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1707
			//}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1708
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1709
		//Always resume the thread instead of asking the host debugger to resume when sending the last static library notification.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1710
		User::LeaveIfError(iKernelDriver.ResumeThread(threadId));			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1711
		iFramingLayer->RespondOkL(KNullDesC8);		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1712
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1713
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1714
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1715
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1716
// CTrkDispatchLayer::DoStepL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1717
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1718
// Execute one instruction in a thread
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1719
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1720
void CTrkDispatchLayer::DoStepL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1721
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1722
	// make sure we're connected
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1723
	if (!iIsConnected)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1724
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1725
		User::Leave(KErrGeneral);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1726
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1727
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1728
	// make sure we got here from DispatchMsgL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1729
	TUint8 command = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1730
	GetDataFromBufferL(&command, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1731
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1732
	if (kDSStep != command)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1733
		User::Leave(kDSReplyError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1734
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1735
	// get the options
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1736
	TUint8 options = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1737
	GetDataFromBufferL(&options, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1738
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1739
	// we only support stepping out of a range of instructions
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1740
	if ((kDSStepIntoRange != options) && (kDSStepOverRange != options))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1741
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1742
		User::Leave(kDSReplyUnsupportedOptionError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1743
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1744
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1745
	// get the range start address
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1746
	TUint32 startAddress = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1747
	GetDataFromBufferL(&startAddress, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1748
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1749
	// get the range stop address
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1750
	TUint32 stopAddress = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1751
	GetDataFromBufferL(&stopAddress, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1752
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1753
	// get the process id
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1754
	TUint32 processId = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1755
	GetDataFromBufferL(&processId, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1756
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1757
	// get the thread id
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1758
	TUint32 threadId = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1759
	GetDataFromBufferL(&threadId, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1760
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1761
	User::LeaveIfError(iKernelDriver.StepRange(threadId, startAddress, stopAddress, (kDSStepIntoRange == options)));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1762
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1763
	iFramingLayer->RespondOkL(KNullDesC8);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1764
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1765
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1766
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1767
// CTrkDispatchLayer::DoStopL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1768
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1769
// Stop the execution of a thread
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1770
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1771
void CTrkDispatchLayer::DoStopL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1772
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1773
	// make sure we're connected
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1774
	if (!iIsConnected)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1775
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1776
		User::Leave(KErrGeneral);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1777
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1778
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1779
	// make sure we got here from DispatchMsgL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1780
	TUint8 command = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1781
	GetDataFromBufferL(&command, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1782
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1783
	if (kDSStop != command)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1784
		User::Leave(kDSReplyError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1785
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1786
	// get the options
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1787
	TUint8 options = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1788
	GetDataFromBufferL(&options, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1789
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1790
	TUint32 processId = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1791
	TUint32 threadId = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1792
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1793
	switch(options)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1794
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1795
		case kDSStopThread:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1796
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1797
			// get the process id
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1798
			GetDataFromBufferL(&processId, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1799
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1800
			// get the thread id
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1801
			GetDataFromBufferL(&threadId, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1802
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1803
			User::LeaveIfError(iKernelDriver.SuspendThread(threadId));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1804
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1805
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1806
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1807
		case kDSStopSystem:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1808
		case kDSStopProcess:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1809
		default:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1810
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1811
			User::Leave(kDSReplyUnsupportedOptionError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1812
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1813
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1814
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1815
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1816
	iFramingLayer->RespondOkL(KNullDesC8);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1817
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1818
	TBuf8<4> currentPC;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1819
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1820
	User::LeaveIfError(iKernelDriver.ReadRegisters(threadId, 15, 15, currentPC));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1821
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1822
	DoNotifyStoppedL(processId, threadId, *(TUint32 *)currentPC.Ptr(), KNullDesC8);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1823
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1824
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1825
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1826
// CTrkDispatchLayer::DoSetBreakL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1827
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1828
// Set a breakpoint
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1829
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1830
void CTrkDispatchLayer::DoSetBreakL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1831
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1832
	// make sure we're connected
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1833
	if (!iIsConnected)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1834
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1835
		User::Leave(KErrGeneral);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1836
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1837
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1838
	// make sure we got here from DispatchMsgL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1839
	TUint8 command = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1840
	GetDataFromBufferL(&command, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1841
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1842
	if (kDSSetBreak != command)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1843
		User::Leave(kDSReplyError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1844
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1845
	// get the options - unused
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1846
	TUint8 options = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1847
	GetDataFromBufferL(&options, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1848
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1849
	// get the mode
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1850
	TUint8 thumbMode = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1851
	GetDataFromBufferL(&thumbMode, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1852
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1853
	// get the address
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1854
	TUint32 address = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1855
	GetDataFromBufferL(&address, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1856
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1857
	// get the length
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1858
	TUint32 length = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1859
	GetDataFromBufferL(&length, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1860
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1861
	// get the count
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1862
	TUint32 count = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1863
	GetDataFromBufferL(&count, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1864
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1865
	// get the process id
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1866
	TUint32 processId = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1867
	GetDataFromBufferL(&processId, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1868
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1869
	// get the thread id
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1870
	TUint32 threadId = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1871
	GetDataFromBufferL(&threadId, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1872
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1873
	TInt32 breakId = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1874
	User::LeaveIfError(iKernelDriver.SetBreak(processId, threadId, address, thumbMode, breakId));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1875
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1876
	// return the id of this breakpoint to the host debugger
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1877
	AddToReplyBufferL((TUint32)breakId, true);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1878
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1879
	RespondOkL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1880
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1881
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1882
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1883
// CTrkDispatchLayer::DoClearBreakL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1884
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1885
// Clear a breakpoint
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1886
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1887
void CTrkDispatchLayer::DoClearBreakL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1888
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1889
	// make sure we're connected
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1890
	if (!iIsConnected)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1891
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1892
		User::Leave(KErrGeneral);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1893
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1894
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1895
	// make sure we got here from DispatchMsgL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1896
	TUint8 command = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1897
	GetDataFromBufferL(&command, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1898
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1899
	if (kDSClearBreak != command)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1900
		User::Leave(kDSReplyError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1901
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1902
	// get the breakpoint id
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1903
	TUint32 breakId = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1904
	GetDataFromBufferL(&breakId, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1905
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1906
	User::LeaveIfError(iKernelDriver.ClearBreak(breakId));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1907
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1908
	iFramingLayer->RespondOkL(KNullDesC8);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1909
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1910
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1911
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1912
// CTrkDispatchLayer::DoModifyBreakThreadL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1913
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1914
// Change the thread(s) that a breakpoint is associated with
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1915
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1916
void CTrkDispatchLayer::DoModifyBreakThreadL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1917
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1918
	// make sure we're connected
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1919
	if (!iIsConnected)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1920
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1921
		User::Leave(KErrGeneral);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1922
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1923
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1924
	// make sure we got here from DispatchMsgL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1925
	TUint8 command = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1926
	GetDataFromBufferL(&command, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1927
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1928
	if (kDSModifyBreakThread != command)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1929
		User::Leave(kDSReplyError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1930
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1931
	// get the breakpoint id
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1932
	TUint32 breakId = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1933
	GetDataFromBufferL(&breakId, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1934
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1935
	// get the thread id
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1936
	TUint32 threadId = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1937
	GetDataFromBufferL(&threadId, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1938
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1939
	User::LeaveIfError(iKernelDriver.ChangeBreakThread(threadId, breakId));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1940
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1941
	iFramingLayer->RespondOkL(KNullDesC8);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1942
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1943
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1944
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1945
// CTrkDispatchLayer::DoCreateItemL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1946
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1947
// Create a new OS item on the target device
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1948
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1949
void CTrkDispatchLayer::DoCreateItemL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1950
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1951
	// make sure we're connected
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1952
	if (!iIsConnected)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1953
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1954
		User::Leave(KErrGeneral);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1955
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1956
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1957
	// make sure we got here from DispatchMsgL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1958
	TUint8 command = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1959
	GetDataFromBufferL(&command, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1960
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1961
	if (kDSOSCreateItem != command)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1962
		User::Leave(kDSReplyError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1963
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1964
	// get the item type
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1965
	TUint16 type = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1966
	GetDataFromBufferL(&type, 2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1967
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1968
	switch(type)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1969
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1970
		case kDSOSProcessItem:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1971
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1972
			DoCreateProcessL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1973
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1974
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1975
		case kDSOSProcRunItem:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1976
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1977
			DoCreateProcessL(ETrue);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1978
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1979
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1980
		case kDSOSProcAttachItem:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1981
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1982
			DoAttachProcessL(kDSOSProcAttachItem);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1983
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1984
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1985
		case kDSOSProcAttach2Item:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1986
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1987
			DoAttachProcessL(kDSOSProcAttach2Item);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1988
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1989
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1990
		case kDSOSProcAttach3Item:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1991
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1992
			DoAttachProcessL(kDSOSProcAttach3Item);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1993
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1994
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1995
		case kDSOSThreadItem:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1996
		case kDSOSDLLItem:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1997
		case kDSOSAppItem:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1998
		case kDSOSMemBlockItem:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1999
		case kDSOSThreadAttachItem:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2000
		default:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2001
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2002
			User::Leave(kDSReplyUnsupportedOptionError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2003
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2004
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2005
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2006
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2007
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2008
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2009
// CTrkDispatchLayer::DoDeleteItemL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2010
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2011
// Delete an OS item from the target device
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2012
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2013
void CTrkDispatchLayer::DoDeleteItemL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2014
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2015
	// make sure we're connected
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2016
	if (!iIsConnected)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2017
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2018
		User::Leave(KErrGeneral);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2019
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2020
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2021
	// make sure we got here from DispatchMsgL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2022
	TUint8 command = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2023
	GetDataFromBufferL(&command, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2024
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2025
	if (kDSOSDeleteItem != command)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2026
		User::Leave(kDSReplyError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2027
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2028
	// get the item type
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2029
	TUint16 type = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2030
	GetDataFromBufferL(&type, 2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2031
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2032
	switch(type)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2033
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2034
		case kDSOSProcessItem:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2035
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2036
			DoKillProcessL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2037
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2038
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2039
		case kDSOSProcAttachItem:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2040
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2041
		    DoDetachProcessL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2042
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2043
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2044
		case kDSOSThreadItem:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2045
		case kDSOSDLLItem:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2046
		case kDSOSAppItem:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2047
		case kDSOSMemBlockItem:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2048
		case kDSOSThreadAttachItem:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2049
		default:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2050
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2051
			User::Leave(kDSReplyUnsupportedOptionError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2052
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2053
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2054
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2055
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2056
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2057
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2058
// CTrkDispatchLayer::DoReadInfoL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2059
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2060
// Read OS information from the target device
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2061
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2062
void CTrkDispatchLayer::DoReadInfoL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2063
{	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2064
	// make sure we're connected
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2065
	if (!iIsConnected)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2066
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2067
		User::Leave(KErrGeneral);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2068
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2069
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2070
	// make sure we got here from DispatchMsgL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2071
	TUint8 command = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2072
	GetDataFromBufferL(&command, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2073
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2074
	if (kDSOSReadInfo != command)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2075
		User::Leave(kDSReplyError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2076
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2077
	// get the type of info requested
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2078
	TUint16 type = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2079
	GetDataFromBufferL(&type, 2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2080
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2081
	// get the start index
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2082
	TUint32 index = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2083
	GetDataFromBufferL(&index, 4);	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2084
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2085
	switch(type)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2086
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2087
		case kDSOSProcessList:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2088
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2089
			DoReadProcessListL(index);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2090
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2091
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2092
		case kDSOSThreadList:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2093
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2094
			DoReadThreadListL(index);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2095
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2096
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2097
		case kDSOSDLLInfo:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2098
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2099
			TUint16 nameLength = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2100
			GetDataFromBufferL(&nameLength, 2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2101
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2102
			// make sure the length of the message is correct
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2103
			if (iInputBuffer->Length() != nameLength)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2104
				User::Leave(kDSReplyPacketSizeError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2105
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2106
			TBuf8<KMaxFileName> fileName;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2107
			fileName.Copy(*iInputBuffer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2108
			fileName.ZeroTerminate();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2109
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2110
			DoReadLibraryInfoL(fileName);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2111
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2112
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2113
		case kDSOSProcessInfo:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2114
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2115
			TUint32 uid3 = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2116
			GetDataFromBufferL(&uid3, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2117
			TUint16 nameLength = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2118
			GetDataFromBufferL(&nameLength, 2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2119
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2120
			// make sure the length of the message is correct
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2121
			if (iInputBuffer->Length() != nameLength)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2122
				User::Leave(kDSReplyPacketSizeError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2123
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2124
			TBuf8<KMaxFileName> fileName;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2125
			fileName.Copy(*iInputBuffer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2126
			fileName.ZeroTerminate();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2127
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2128
			DoReadProcessInfoL(uid3, fileName);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2129
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2130
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2131
		case kDSOSProcessState:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2132
		case kDSOSThreadState:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2133
		case kDSOSDLLList:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2134
		case kDSOSDLLState:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2135
		default:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2136
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2137
			User::Leave(kDSReplyUnsupportedOptionError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2138
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2139
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2140
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2141
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2142
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2143
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2144
// CTrkDispatchLayer::DoWriteInfoL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2145
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2146
// Set options for the Trk
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2147
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2148
void CTrkDispatchLayer::DoWriteInfoL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2149
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2150
	// make sure we got here from DispatchMsgL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2151
	TUint8 command = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2152
	GetDataFromBufferL(&command, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2153
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2154
	if (kDSOSWriteInfo != command)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2155
		User::Leave(kDSReplyError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2156
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2157
	// get the type of info requested
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2158
	TUint16 type = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2159
	GetDataFromBufferL(&type, 2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2160
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2161
	// get the start index
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2162
	TUint32 index = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2163
	GetDataFromBufferL(&index, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2164
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2165
	// no options supported yet.  might add something for auto-target libraries later
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2166
	User::Leave(kDSReplyUnsupportedOptionError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2167
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2168
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2169
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2170
// CTrkDispatchLayer::DoOpenFileL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2171
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2172
// Open or create a file on the target
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2173
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2174
void CTrkDispatchLayer::DoOpenFileL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2175
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2176
	// make sure we got here from DispatchMsgL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2177
	TUint8 command = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2178
	GetDataFromBufferL(&command, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2179
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2180
	if (kDSOSOpenFile != command)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2181
		User::Leave(kDSReplyError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2182
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2183
	// get the file mode(s)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2184
	TUint8 modes = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2185
	GetDataFromBufferL(&modes, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2186
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2187
	if ((modes & kDSFileOpenAppend) || (modes & kDSFileOpenCreate))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2188
		modes |= kDSFileOpenWrite;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2189
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2190
	TUint16 nameLength = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2191
	GetDataFromBufferL(&nameLength, 2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2192
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2193
	// make sure the length of the message is correct
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2194
	if (iInputBuffer->Length() != nameLength)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2195
		User::Leave(kDSReplyPacketSizeError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2196
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2197
	TBuf<KMaxPath> fullpath;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2198
	fullpath.Copy(*iInputBuffer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2199
	fullpath.ZeroTerminate();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2200
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2201
	TUint mode = EFileShareExclusive;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2202
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2203
	// get the file mode(s)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2204
	if (modes & kDSFileOpenRead)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2205
		mode |= EFileRead;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2206
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2207
	if (modes & kDSFileOpenWrite)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2208
		mode |= EFileWrite;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2209
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2210
	if (modes & kDSFileOpenAppend)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2211
		mode |= EFileWrite;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2212
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2213
	if (modes & kDSFileOpenCreate)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2214
		mode |= EFileWrite;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2215
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2216
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2217
	//for getting the modification date
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2218
	TTime time;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2219
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2220
	OpenFileL(fullpath, mode, time);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2221
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2222
	TDateTime dateTime = time.DateTime();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2223
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2224
	TDateTimeConverter winTime(dateTime);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2225
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2226
	TUint32 timestamp = winTime.GetWinTimeDate();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2227
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2228
	TUint32 handle = 1;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2229
	TUint8 err = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2230
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2231
	AddToReplyBufferL(err, true);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2232
	AddToReplyBufferL(handle);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2233
	AddToReplyBufferL(timestamp);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2234
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2235
	RespondOkL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2236
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2237
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2238
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2239
// CTrkDispatchLayer::OpenFileL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2240
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2241
// Open a file on the target, if plat security is enabled, uses TrkTcbServer to open the file.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2242
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2243
void CTrkDispatchLayer::OpenFileL(const TDesC& aFullPath, TUint aMode, TTime& aTime)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2244
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2245
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2246
#ifdef __OEM_TRK__	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2247
	//Check to see if TCB capability is enforced, if so, connect to the tcb server as well.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2248
	if (!iUseTcbServer && PlatSec::IsCapabilityEnforced(ECapabilityTCB))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2249
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2250
		if (!iTrkTcbSession.Connect())
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2251
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2252
			iUseTcbServer = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2253
		}	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2254
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2255
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2256
	if (iUseTcbServer)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2257
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2258
		User::LeaveIfError(iTrkTcbSession.OpenFile(aFullPath, aMode, aTime));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2259
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2260
	else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2261
#endif	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2262
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2263
	#ifndef __OEM_TRK__
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2264
		if (IsRestrictedFolder(aFullPath))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2265
			User::Leave(KErrAccessDenied);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2266
	#endif
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2267
		// connect to the file server
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2268
		User::LeaveIfError(iFs.Connect());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2269
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2270
		TInt error = iFs.MkDirAll(aFullPath);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2271
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2272
		if ((KErrNone != error) && (KErrAlreadyExists != error))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2273
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2274
			iFs.Close();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2275
			User::Leave(error);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2276
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2277
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2278
		error = iFile.Open(iFs, aFullPath, aMode);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2279
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2280
		if (KErrNone != error)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2281
			User::LeaveIfError(iFile.Replace(iFs, aFullPath, aMode));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2282
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2283
		User::LeaveIfError(iFile.Modified(aTime));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2284
		iFileState = EFileOpened;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2285
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2286
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2287
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2288
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2289
// CTrkDispatchLayer::DoReadFileL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2290
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2291
// Read data from a file on the target
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2292
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2293
void CTrkDispatchLayer::DoReadFileL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2294
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2295
	// make sure we got here from DispatchMsgL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2296
	TUint8 command = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2297
	GetDataFromBufferL(&command, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2298
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2299
	if (kDSOSReadFile != command)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2300
		User::Leave(kDSReplyError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2301
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2302
	// make sure the length of the message is correct
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2303
	if (iInputBuffer->Length() != 6)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2304
		User::Leave(kDSReplyPacketSizeError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2305
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2306
	// remove the handle
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2307
	iInputBuffer->Des().Delete(0, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2308
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2309
	// get the length
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2310
	TUint8 err = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2311
	TUint16 length = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2312
	GetDataFromBufferL(&length, 2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2313
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2314
	// allocate a buffer large enough for the data
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2315
	HBufC8 *buffer = HBufC8::NewLC(length);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2316
	TPtr8 ptr(buffer->Des());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2317
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2318
	//	CleanupStack::PushL(buffer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2319
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2320
	TInt error = ReadFileL(length, ptr);	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2321
	if (KErrNone != error)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2322
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2323
		CleanupStack::PopAndDestroy(buffer);	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2324
		User::Leave(error);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2325
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2326
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2327
	length = buffer->Length();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2328
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2329
	AddToReplyBufferL(err, true);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2330
	AddToReplyBufferL(length);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2331
//	AddToReplyBufferL(buffer[0], length);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2332
	AddToReplyBufferL(ptr);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2333
	RespondOkL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2334
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2335
	CleanupStack::PopAndDestroy(buffer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2336
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2337
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2338
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2339
// CTrkDispatchLayer::ReadFileL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2340
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2341
// Reads data from a file on the target
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2342
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2343
TInt CTrkDispatchLayer::ReadFileL(TUint16 aLength, TPtr8& aData)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2344
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2345
	TInt error = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2346
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2347
#ifdef __OEM_TRK__
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2348
	if (iUseTcbServer)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2349
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2350
		User::LeaveIfError(iTrkTcbSession.ReadFile(aLength, aData));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2351
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2352
	else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2353
#endif	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2354
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2355
		iFileState = EFileReading;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2356
		error = iFile.Read(aData);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2357
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2358
	return error;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2359
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2360
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2361
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2362
// CTrkDispatchLayer::DoWriteFileL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2363
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2364
// Write data to a file on the target
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2365
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2366
void CTrkDispatchLayer::DoWriteFileL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2367
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2368
	// make sure we got here from DispatchMsgL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2369
	TUint8 command = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2370
	GetDataFromBufferL(&command, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2371
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2372
	if (kDSOSWriteFile != command)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2373
		User::Leave(kDSReplyError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2374
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2375
	// get the length
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2376
	TUint32 handle = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2377
	GetDataFromBufferL(&handle, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2378
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2379
	if (handle != 1)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2380
		User::Leave(kDSReplyParameterError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2381
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2382
	// get the length
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2383
	TUint8 err = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2384
	TUint16 length = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2385
	GetDataFromBufferL(&length, 2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2386
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2387
	// make sure the length of the message is correct
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2388
	if (iInputBuffer->Length() != length)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2389
		User::Leave(kDSReplyPacketSizeError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2390
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2391
	WriteFileL(*iInputBuffer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2392
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2393
	length = iInputBuffer->Length();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2394
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2395
	AddToReplyBufferL(err, true);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2396
	AddToReplyBufferL(length);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2397
	RespondOkL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2398
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2399
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2400
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2401
// CTrkDispatchLayer::WriteFileL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2402
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2403
// Write data to a file on the target. If plat sec is enabled, uses Trk Tcb Server.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2404
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2405
void CTrkDispatchLayer::WriteFileL(TDesC8& aData)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2406
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2407
#ifdef __OEM_TRK__
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2408
	if (iUseTcbServer)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2409
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2410
		User::LeaveIfError(iTrkTcbSession.WriteFile(aData));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2411
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2412
	else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2413
#endif	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2414
	{	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2415
		if (iFileState == EFileOpened)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2416
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2417
			iFile.SetSize(0);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2418
			iFileState = EFileWriting;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2419
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2420
		User::LeaveIfError(iFile.Write(aData));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2421
		User::LeaveIfError(iFile.Flush());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2422
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2423
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2424
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2425
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2426
// CTrkDispatchLayer::DoPositionFileL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2427
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2428
// Change the current file position of a file on the target
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2429
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2430
void CTrkDispatchLayer::DoPositionFileL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2431
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2432
	// make sure we got here from DispatchMsgL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2433
	TUint8 command = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2434
	GetDataFromBufferL(&command, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2435
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2436
	if (kDSOSPositionFile != command)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2437
		User::Leave(kDSReplyError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2438
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2439
	// make sure the length of the message is correct
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2440
	if (iInputBuffer->Length() != 9)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2441
		User::Leave(kDSReplyPacketSizeError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2442
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2443
	// get the positioning mode
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2444
	TUint8 mode = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2445
	GetDataFromBufferL(&mode, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2446
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2447
	// remove the handle
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2448
	iInputBuffer->Des().Delete(0, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2449
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2450
	TUint8 err = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2451
	TUint32 offset = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2452
	GetDataFromBufferL(&offset, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2453
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2454
	TSeek seek;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2455
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2456
	// convert mode to native parameter and set the position accordingly
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2457
	switch(mode)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2458
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2459
		default:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2460
		case kDSFileSeekSet:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2461
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2462
			seek = ESeekStart;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2463
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2464
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2465
		case kDSFileSeekCur:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2466
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2467
			seek = ESeekCurrent;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2468
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2469
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2470
		case kDSFileSeekEnd:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2471
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2472
			seek = ESeekEnd;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2473
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2474
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2475
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2476
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2477
	PositionFileL(seek, (TInt &)offset);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2478
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2479
	AddToReplyBufferL(err, true);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2480
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2481
	RespondOkL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2482
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2483
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2484
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2485
// CTrkDispatchLayer::PositionFileL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2486
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2487
// Change the current file position of a file on the target. If plat sec is enabled,
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2488
// uses Trk Tcb Server.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2489
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2490
void CTrkDispatchLayer::PositionFileL(TSeek aSeek, TInt& aOffset)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2491
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2492
#ifdef __OEM_TRK__
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2493
	if (iUseTcbServer)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2494
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2495
		User::LeaveIfError(iTrkTcbSession.PositionFile(aSeek, aOffset));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2496
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2497
	else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2498
#endif	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2499
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2500
		User::LeaveIfError(iFile.Seek(aSeek, aOffset));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2501
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2502
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2503
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2504
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2505
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2506
// CTrkDispatchLayer::DoCloseFileL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2507
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2508
// Close a file on the target
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2509
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2510
void CTrkDispatchLayer::DoCloseFileL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2511
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2512
	// make sure we got here from DispatchMsgL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2513
	TUint8 command = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2514
	GetDataFromBufferL(&command, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2515
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2516
	if (kDSOSCloseFile != command)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2517
		User::Leave(kDSReplyError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2518
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2519
	// make sure the length of the message is correct
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2520
	if (iInputBuffer->Length() != 8)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2521
		User::Leave(kDSReplyPacketSizeError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2522
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2523
	// remove the handle
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2524
	iInputBuffer->Des().Delete(0, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2525
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2526
	TUint8 err = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2527
	TUint32 timestamp = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2528
	GetDataFromBufferL(&timestamp, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2529
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2530
	TDateTimeConverter epocTime(timestamp);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2531
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2532
	CloseFileL(epocTime.GetEpocTimeDate());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2533
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2534
	AddToReplyBufferL(err, true);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2535
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2536
	RespondOkL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2537
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2538
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2539
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2540
// CTrkDispatchLayer::CloseFileL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2541
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2542
// Close a file on the target. If plat sec is enabled, uses Trk Tcb Server.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2543
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2544
void CTrkDispatchLayer::CloseFileL(const TTime& aModifiedTime)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2545
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2546
#ifdef __OEM_TRK__
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2547
	if (iUseTcbServer)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2548
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2549
		User::LeaveIfError(iTrkTcbSession.CloseFile(aModifiedTime));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2550
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2551
	else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2552
#endif	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2553
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2554
		User::LeaveIfError(iFile.SetModified(aModifiedTime));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2555
		User::LeaveIfError(iFile.Flush());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2556
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2557
		iFile.Close();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2558
		iFs.Close();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2559
		iFileState = EFileClosed;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2560
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2561
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2562
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2563
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2564
// CTrkDispatchLayer::DoInstallFileL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2565
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2566
// Install the application, supplied as a SIS file.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2567
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2568
void CTrkDispatchLayer::DoInstallFileL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2569
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2570
	// make sure we're connected
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2571
	if (!iIsConnected)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2572
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2573
		User::Leave(KErrGeneral);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2574
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2575
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2576
#ifndef __TEXT_SHELL__
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2577
	// make sure we got here from DispatchMsgL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2578
	TUint8 command = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2579
	GetDataFromBufferL(&command, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2580
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2581
	if (kDSOSInstallFile != command)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2582
		User::Leave(kDSReplyError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2583
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2584
	// get the installation drive
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2585
	TUint8 drive = 'C';
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2586
	GetDataFromBufferL(&drive, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2587
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2588
	TChar installDrive(drive);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2589
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2590
	TUint16 nameLength = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2591
	GetDataFromBufferL(&nameLength, 2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2592
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2593
	// make sure the length of the message is correct
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2594
	if (iInputBuffer->Length() != nameLength)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2595
		User::Leave(kDSReplyPacketSizeError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2596
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2597
	TBuf<KMaxPath> fullpath;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2598
	fullpath.Copy(*iInputBuffer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2599
	fullpath.ZeroTerminate();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2600
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2601
	TUint8 err = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2602
	// Temporarily disable the lib loaded event before launching the SW Installer.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2603
	// This is necessary when launching the SIS installer since  launching the 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2604
	// installer causes several libraries to be loaded. The driver suspends the 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2605
	// thread thats loaded the library. This suspension might potentially cause 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2606
	// a deadlock as the event handling active object will never get a chance to 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2607
	// run as the Install function below blocks until the installation is completed.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2608
	User::LeaveIfError(iKernelDriver.DisableLibLoadedEvent());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2609
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2610
	// now launch the installer
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2611
	User::LeaveIfError(CTrkSwInstall::SilentInstallL(fullpath, installDrive));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2612
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2613
	// now enable the lib loaded event
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2614
	iKernelDriver.EnableLibLoadedEvent();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2615
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2616
	AddToReplyBufferL(err, true);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2617
	RespondOkL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2618
#else 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2619
	User::LeaveIfError(-1); 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2620
#endif
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2621
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2622
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2623
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2624
// CTrkDispatchLayer::DoInstallFileL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2625
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2626
// Install the application, supplied as a SIS file.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2627
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2628
void CTrkDispatchLayer::DoInstallFile2L()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2629
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2630
	// make sure we're connected
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2631
	if (!iIsConnected)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2632
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2633
		User::Leave(KErrGeneral);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2634
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2635
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2636
#ifndef __TEXT_SHELL__
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2637
	// make sure we got here from DispatchMsgL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2638
	TUint8 command = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2639
	GetDataFromBufferL(&command, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2640
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2641
	if (kDSOSInstallFile2 != command)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2642
		User::Leave(kDSReplyError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2643
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2644
	TUint16 nameLength = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2645
	GetDataFromBufferL(&nameLength, 2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2646
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2647
	// make sure the length of the message is correct
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2648
	if (iInputBuffer->Length() != nameLength)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2649
		User::Leave(kDSReplyPacketSizeError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2650
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2651
	TBuf<KMaxPath> fullpath;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2652
	fullpath.Copy(*iInputBuffer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2653
	fullpath.ZeroTerminate();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2654
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2655
	TUint8 err = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2656
	// Temporarily disable the lib loaded event before launching the SW Installer.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2657
	// This is necessary when launching the SIS installer since  launching the 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2658
	// installer causes several libraries to be loaded. The driver suspends the 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2659
	// thread thats loaded the library. This suspension might potentially cause 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2660
	// a deadlock as the event handling active object will never get a chance to 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2661
	// run as the Install function below blocks until the installation is completed.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2662
	User::LeaveIfError(iKernelDriver.DisableLibLoadedEvent());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2663
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2664
	// now launch the installer
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2665
	User::LeaveIfError(CTrkSwInstall::Install(fullpath));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2666
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2667
	// now enable the lib loaded event
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2668
	iKernelDriver.EnableLibLoadedEvent();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2669
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2670
	AddToReplyBufferL(err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2671
	RespondOkL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2672
#else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2673
	User::LeaveIfError(-1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2674
#endif
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2675
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2676
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2677
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2678
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2679
// CTrkDispathLayer::DoGetPhoneSWVesionL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2680
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2681
// sends  the software version of the phone to reply buffer
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2682
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2683
void CTrkDispatchLayer::DoGetPhoneSWVersionL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2684
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2685
    // make sure we got here from DispatchMsgL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2686
    
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2687
	TUint8 command = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2688
	GetDataFromBufferL(&command, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2689
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2690
	if (kDSOSPhoneSWVersion != command)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2691
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2692
		User::Leave(kDSReplyError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2693
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2694
#ifndef __TEXT_SHELL__
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2695
	if (iPhoneVersion.Size()>0 )
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2696
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2697
		TUint16 versionNameLength = iPhoneVersion.Length();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2698
		AddToReplyBufferL(versionNameLength, ETrue); 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2699
		AddToReplyBufferL(iPhoneVersion);       
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2700
		RespondOkL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2701
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2702
	else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2703
#endif	    
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2704
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2705
		User::Leave(KErrGeneral);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2706
	}    
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2707
                
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2708
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2709
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2710
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2711
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2712
//CTrkDispathLayer::DoGetPhoneNameL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2713
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2714
//sends the phone model name to the reply buffer
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2715
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2716
void CTrkDispatchLayer::DoGetPhoneNameL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2717
{    
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2718
    TUint8 command = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2719
    GetDataFromBufferL(&command, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2720
    
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2721
    if (kDSOSPhoneName != command)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2722
    {
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2723
    	User::Leave(kDSReplyError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2724
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2725
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2726
#ifndef __TEXT_SHELL__
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2727
    if (iPhoneNameInfoAvailable)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2728
    {
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2729
     	TUint16 phoneModelLen = iPhoneModel.Length();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2730
     	AddToReplyBufferL(phoneModelLen, true);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2731
     	AddToReplyBufferL(iPhoneModel);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2732
        RespondOkL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2733
    }    
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2734
    else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2735
#endif
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2736
    {
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2737
        User::Leave(KErrGeneral);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2738
    }
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2739
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2740
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2741
//To Update the phone model name 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2742
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2743
//callback function from the CPhoneInfo
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2744
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2745
void CTrkDispatchLayer::UpdatePhoneNameInfo(TDesC16& aPhoneModel)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2746
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2747
#ifndef __TEXT_SHELL__
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2748
    iPhoneModel.Copy(aPhoneModel);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2749
    iPhoneNameInfoAvailable = ETrue;    
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2750
#endif
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2751
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2752
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2753
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2754
// CTrkDispatchLayer::DoCreateProcessL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2755
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2756
// Create a new process on the target device
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2757
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2758
void CTrkDispatchLayer::DoCreateProcessL(TBool aRun)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2759
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2760
	// remove the options - currently unused
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2761
	iInputBuffer->Des().Delete(0, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2762
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2763
	// get the length of the data
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2764
	TUint16 length = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2765
	GetDataFromBufferL(&length, 2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2766
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2767
	// make sure the length of the message is correct
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2768
	if (iInputBuffer->Length() != length)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2769
		User::Leave(kDSReplyPacketSizeError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2770
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2771
	// extract the filename and path, command line args, and working directory
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2772
	TPtrC8 exec8(iInputBuffer->Ptr());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2773
	TPtrC8 args8(exec8.Ptr() + exec8.Length() + 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2774
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2775
	// convert the filename and args to unicode descriptors
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2776
	HBufC* exec = HBufC::NewLC(exec8.Length());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2777
	exec->Des().Copy(exec8);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2778
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2779
	HBufC* args = HBufC::NewLC(args8.Length());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2780
	args->Des().Copy(args8);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2781
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2782
	// open the file and get the type (app, exe, etc.)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2783
	RFs fs;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2784
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2785
	// connect to the file server
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2786
	User::LeaveIfError(fs.Connect());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2787
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2788
	TEntry entry;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2789
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2790
	User::LeaveIfError(fs.Entry(*exec, entry));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2791
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2792
	fs.Close();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2793
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2794
	TCreateProcessData data;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2795
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2796
	switch(entry[0].iUid)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2797
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2798
		case 0x1000007a:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2799
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2800
			// EXE
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2801
			DoCreateExeL(*exec, *args, data, aRun);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2802
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2803
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2804
		default:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2805
			User::Leave(KErrGeneral);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2806
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2807
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2808
	CleanupStack::PopAndDestroy(args);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2809
	CleanupStack::PopAndDestroy(exec);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2810
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2811
	AddToReplyBufferL(data.iProcessId, true);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2812
	AddToReplyBufferL(data.iMainThreadId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2813
	if (!aRun)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2814
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2815
		AddToReplyBufferL(data.iCodeAddr);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2816
		AddToReplyBufferL(data.iDataAddr);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2817
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2818
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2819
	RespondOkL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2820
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2821
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2822
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2823
// CTrkDispatchLayer::DoCreateExeL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2824
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2825
// Create a new executable on the target device
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2826
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2827
void CTrkDispatchLayer::DoCreateExeL(const TDesC& aPath, const TDesC& aArgs, TCreateProcessData& aData, TBool aRun)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2828
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2829
	RProcess process;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2830
	User::LeaveIfError(process.Create(aPath, aArgs));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2831
	CleanupClosePushL(process);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2832
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2833
	aData.iProcessId = process.Id();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2834
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2835
	HBufC* threadName = HBufC::NewLC(KMaxFullName);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2836
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2837
	*threadName = process.Name();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2838
	_LIT(KMainThreadSuffix, "::Main");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2839
	threadName->Des().Append(KMainThreadSuffix);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2840
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2841
	// this function should be (indirectly) called when the debuggee
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2842
	// has been created but not yet resumed.  So it should have a main
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2843
	// thread whose name ends with "::Main", and so the following call
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2844
	// should not fail.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2845
	RThread thread;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2846
	User::LeaveIfError(thread.Open(*threadName));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2847
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2848
	aData.iMainThreadId = thread.Id();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2849
	thread.Close();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2850
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2851
	if (!aRun)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2852
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2853
		CDebugProcess *proc = CDebugProcess::NewL(this, aData.iProcessId, aData.iMainThreadId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2854
		iDebugProcessList.Append(proc);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2855
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2856
		User::LeaveIfError(iKernelDriver.GetProcessAddresses(aData.iMainThreadId, aData.iCodeAddr, aData.iDataAddr));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2857
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2858
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2859
	CleanupStack::PopAndDestroy(threadName);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2860
	CleanupStack::PopAndDestroy(); // process
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2861
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2862
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2863
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2864
// CTrkDispatchLayer::DoKillProcessL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2865
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2866
// Kill an existing process
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2867
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2868
void CTrkDispatchLayer::DoKillProcessL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2869
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2870
	// get the process id
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2871
	TUint32 processId = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2872
	GetDataFromBufferL(&processId, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2873
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2874
	RProcess process;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2875
	User::LeaveIfError(process.Open(processId));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2876
#ifdef EKA2
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2877
	process.Kill(KErrNone);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2878
#else	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2879
	process.Kill(KProcessKilled);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2880
#endif
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2881
	process.Close();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2882
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2883
	iFramingLayer->RespondOkL(KNullDesC8);	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2884
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2885
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2886
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2887
// CTrkDispatchLayer::DoAttachProcessL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2888
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2889
// Create a new process on the target device
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2890
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2891
void CTrkDispatchLayer::DoAttachProcessL(DSOSItemTypes aAttachType)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2892
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2893
	// remove the options - currently unused
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2894
	iInputBuffer->Des().Delete(0, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2895
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2896
	// get the length of the data
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2897
	TUint32 processId = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2898
	GetDataFromBufferL(&processId, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2899
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2900
	RProcess process;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2901
	User::LeaveIfError(process.Open(processId));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2902
	CleanupClosePushL(process);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2903
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2904
	// do not allow attaching to a system, protected, or the MetroTrk process because
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2905
	// if the user were to stop the wrong thread, the whole system could stop
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2906
#ifdef EKA2
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2907
	if ((TUint)processId == RProcess().Id())
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2908
#else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2909
	if (process.System() || process.Protected() || ((TUint)processId == RProcess().Id()))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2910
#endif
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2911
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2912
		User::Leave(kDSReplyUnsupportedOptionError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2913
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2914
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2915
	TMetroTrkTaskInfo threadInfo(processId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2916
	User::LeaveIfError(iKernelDriver.GetThreadInfo(0, threadInfo));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2917
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2918
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2919
	TUint32 codeAddr;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2920
	TUint32 dataAddr;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2921
	User::LeaveIfError(iKernelDriver.GetProcessAddresses(threadInfo.iId, codeAddr, dataAddr));	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2922
	//this is necessary to get the process died notifications and also any other event for this process
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2923
	CDebugProcess *proc = CDebugProcess::NewL(this, processId, threadInfo.iId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2924
	// For processes that we are attaching, we need to set this flag to true.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2925
	// otherwise library load notifications for this process will be ignored
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2926
	proc->iReadyForLibraryLoadNotification = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2927
	iDebugProcessList.Append(proc);	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2928
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2929
	AddToReplyBufferL(threadInfo.iId, true);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2930
	if (aAttachType == kDSOSProcAttach3Item)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2931
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2932
		// now get the UID3 for this process
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2933
		// and add it to the reply
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2934
		TMetroTrkProcUidInfo procUidInfo(processId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2935
		User::LeaveIfError(iKernelDriver.GetProcUidInfo(procUidInfo));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2936
		AddToReplyBufferL(procUidInfo.iUid3);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2937
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2938
	if (aAttachType == kDSOSProcAttach3Item || aAttachType == kDSOSProcAttach2Item)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2939
	{				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2940
		AddToReplyBufferL(codeAddr);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2941
		AddToReplyBufferL(dataAddr);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2942
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2943
		TBuf8<KMaxFullName> procName;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2944
		procName.Copy(process.Name());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2945
		TUint16 nameLength = procName.Length();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2946
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2947
		AddToReplyBufferL(nameLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2948
		AddToReplyBufferL(procName);		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2949
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2950
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2951
	CleanupStack::PopAndDestroy(); // process
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2952
	RespondOkL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2953
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2954
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2955
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2956
// CTrkDispatchLayer::DoDetachProcessL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2957
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2958
// To detach the process from the list of processes
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2959
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2960
void CTrkDispatchLayer::DoDetachProcessL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2961
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2962
    TUint32 processId = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2963
    GetDataFromBufferL(&processId, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2964
    
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2965
    RProcess process;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2966
    User::LeaveIfError(process.Open(processId));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2967
    
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2968
	for (TInt i=0 ; i<iDebugProcessList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2969
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2970
		if(iDebugProcessList[i]->ProcessId()== processId) 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2971
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2972
			SafeDelete(iDebugProcessList[i]);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2973
			iDebugProcessList.Remove(i);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2974
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2975
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2976
    User::LeaveIfError(iKernelDriver.DetachProcess(processId));    
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2977
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2978
    iFramingLayer->RespondOkL(KNullDesC8);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2979
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2980
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2981
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2982
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2983
// CTrkDispatchLayer::DoReadProcessListL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2984
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2985
// Return a list of the current processes to the host debugger
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2986
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2987
void CTrkDispatchLayer::DoReadProcessListL(TInt32 aIndex)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2988
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2989
	// remove the options - unused
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2990
	iInputBuffer->Des().Delete(0, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2991
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2992
	// remove the filter - unused
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2993
	iInputBuffer->Des().Delete(0, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2994
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2995
	// an index of zero means we start fresh.  and index other than zero means
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2996
	// we were not able to return all of the processes in the last round due to
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2997
	// message size limitations, so we need to pick up where we left off
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2998
	if (aIndex == 0)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2999
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3000
		DoReBuildProcessList();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3001
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3002
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3003
	TInt32 totalCount = iProcessList.Count();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3004
	TInt32 returnedCount = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3005
	TInt32 bytesRemaining = MAXMESSAGESIZE_V2 - 30; // minus the framing bytes
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3006
	TInt32 restOfMsgSize = sizeof(TUint32) // process id
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3007
						 + sizeof(TUint32) // priority
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3008
						 + sizeof(TUint8); // NULL character
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3009
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3010
	for (TInt32 i=aIndex; i<totalCount; i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3011
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3012
		// make sure there is enough room left in the message
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3013
		if (bytesRemaining >= (iProcessList[i].iName.Length() + restOfMsgSize))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3014
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3015
			returnedCount++;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3016
			bytesRemaining -= (iProcessList[i].iName.Length() + restOfMsgSize);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3017
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3018
		else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3019
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3020
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3021
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3022
	// add values for returnedCount and totalCount
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3023
	AddToReplyBufferL((TUint32)returnedCount, true);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3024
	AddToReplyBufferL((TUint32)totalCount);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3025
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3026
	for (TInt32 i=aIndex; i<(aIndex + returnedCount); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3027
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3028
		// add this process info to the buffer
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3029
		AddToReplyBufferL(iProcessList[i].iId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3030
		AddToReplyBufferL(iProcessList[i].iPriority);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3031
		AddToReplyBufferL(iProcessList[i].iName);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3032
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3033
		// host expects the name to be a null terminated string
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3034
		AddToReplyBufferL((TUint8)0);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3035
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3036
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3037
	RespondOkL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3038
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3039
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3040
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3041
// CTrkDispatchLayer::DoReadThreadListL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3042
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3043
// Return a list of the current threads for a process to the host debugger
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3044
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3045
void CTrkDispatchLayer::DoReadThreadListL(TInt32 aIndex)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3046
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3047
	// remove the options - unused
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3048
	iInputBuffer->Des().Delete(0, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3049
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3050
	// get the process id
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3051
	TUint32 processId = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3052
	GetDataFromBufferL(&processId, 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3053
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3054
	// an index of zero means we start fresh.  and index other than zero means
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3055
	// we were not able to return all of the threads in the last round due to
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3056
	// message size limitations, so we need to pick up where we left off
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3057
	if (aIndex == 0)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3058
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3059
		DoReBuildThreadList(processId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3060
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3061
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3062
	TInt32 totalCount = iThreadList.Count();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3063
	TInt32 returnedCount = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3064
	TInt32 bytesRemaining = MAXMESSAGESIZE_V2 - 30; // minus the framing bytes
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3065
	TInt32 restOfMsgSize = sizeof(TUint32) // process id
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3066
						 + sizeof(TUint32) // priority
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3067
						 + sizeof(TUint8)  // state
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3068
						 + sizeof(TUint8); // NULL character
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3069
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3070
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3071
	for (TInt32 i=aIndex; i<totalCount; i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3072
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3073
		// make sure there is enough room left in the message
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3074
		if (bytesRemaining >= (iThreadList[i].iName.Length() + restOfMsgSize))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3075
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3076
			returnedCount++;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3077
			bytesRemaining -= (iThreadList[i].iName.Length() + restOfMsgSize);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3078
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3079
		else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3080
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3081
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3082
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3083
	// add values for returnedCount and totalCount
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3084
	AddToReplyBufferL((TUint32)returnedCount, true);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3085
	AddToReplyBufferL((TUint32)totalCount);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3086
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3087
	for (TInt32 i=aIndex; i<(aIndex + returnedCount); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3088
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3089
		// add this thread info to the buffer
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3090
		AddToReplyBufferL(iThreadList[i].iId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3091
		AddToReplyBufferL(iThreadList[i].iPriority);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3092
		AddToReplyBufferL(IsThreadSuspended(iThreadList[i].iId));		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3093
		AddToReplyBufferL(iThreadList[i].iName);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3094
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3095
		// host expects the name to be a null terminated string
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3096
		AddToReplyBufferL((TUint8)0);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3097
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3098
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3099
	RespondOkL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3100
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3101
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3102
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3103
// CTrkDispatchLayer::DoReBuildProcessList
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3104
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3105
// Build a list of the current processes
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3106
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3107
void CTrkDispatchLayer::DoReBuildProcessList()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3108
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3109
	TInt err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3110
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3111
	// reset the process list
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3112
	iProcessList.Reset();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3113
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3114
	// fill up the process list
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3115
	for (TInt i=0; KErrNone==err; i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3116
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3117
		TMetroTrkTaskInfo processInfo(0);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3118
		err = iKernelDriver.GetProcessInfo(i, processInfo);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3119
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3120
		//Get a Handle to the process
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3121
		RProcess proc;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3122
		if(KErrNone == err && KErrNone == proc.Open(TProcessId(processInfo.iId)))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3123
		{			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3124
			//Only display currently running processes
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3125
			if(EExitPending == proc.ExitType())
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3126
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3127
				iProcessList.Append(processInfo);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3128
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3129
			proc.Close();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3130
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3131
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3132
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3133
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3134
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3135
// CTrkDispatchLayer::DoReBuildThreadList
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3136
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3137
// Build a list of the current threads for a process
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3138
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3139
void CTrkDispatchLayer::DoReBuildThreadList(TUint32 aProcessId)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3140
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3141
	TInt err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3142
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3143
	// reset the thread list
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3144
	iThreadList.Reset();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3145
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3146
	// fill up the thread list
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3147
	for (TInt i=0; KErrNone==err; i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3148
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3149
		TMetroTrkTaskInfo threadInfo(aProcessId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3150
		err = iKernelDriver.GetThreadInfo(i, threadInfo);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3151
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3152
		//Get a Handle to the thread
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3153
		RThread thread;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3154
		if(KErrNone == err && KErrNone == thread.Open(TThreadId(threadInfo.iId)))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3155
		{			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3156
			//Only display currently running processes
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3157
			if(EExitPending == thread.ExitType())
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3158
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3159
				iThreadList.Append(threadInfo);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3160
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3161
			thread.Close();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3162
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3163
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3164
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3165
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3166
// CTrkDispatchLayer::DoNotifyStoppedL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3167
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3168
// Notify the host debugger that a thread has stopped
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3169
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3170
// START_PANIC
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3171
//void CTrkDispatchLayer::DoNotifyStoppedL(TUint32 aProcessId, TUint32 aThreadId, TUint32 aCurrentPC, const TDesC8 &aDescription)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3172
void CTrkDispatchLayer::DoNotifyStoppedL(TUint32 aProcessId, TUint32 aThreadId, TUint32 aCurrentPC, const TDesC8 &aDescription, TBool aAddException, const TUint16 aExceptionNumber)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3173
// END_PANIC
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3174
{	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3175
	// add this thread to the suspended threads list
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3176
	iSuspendedThreadList.Append(aThreadId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3177
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3178
//	TUint8 event = (aAddException==true) ? kDSNotifyStopped2 : kDSNotifyStopped;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3179
	TUint8 event = kDSNotifyStopped;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3180
	TUint16 descLength = aDescription.Length();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3181
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3182
	AddToReplyBufferL(event, true);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3183
	AddToReplyBufferL(aCurrentPC);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3184
	AddToReplyBufferL(aProcessId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3185
	AddToReplyBufferL(aThreadId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3186
	AddToReplyBufferL(descLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3187
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3188
	if (descLength)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3189
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3190
		AddToReplyBufferL(aDescription);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3191
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3192
		// host expects the string to be a null terminated string
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3193
		AddToReplyBufferL((TUint8)0);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3194
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3195
	// START_PANIC
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3196
	if (aAddException)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3197
		AddToReplyBufferL(aExceptionNumber);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3198
	// END_PANIC
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3199
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3200
	InformEventL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3201
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3202
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3203
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3204
// CTrkDispatchLayer::DoNotifyProcessDiedL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3205
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3206
// Notify the host debugger that a process has exited
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3207
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3208
void CTrkDispatchLayer::DoNotifyProcessDiedL(TUint32 aProcessId, TInt aExitCode)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3209
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3210
	// remove this process from our list
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3211
	for (TInt i=0; i<iDebugProcessList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3212
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3213
		if (iDebugProcessList[i]->ProcessId() == aProcessId)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3214
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3215
			SafeDelete(iDebugProcessList[i]);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3216
			iDebugProcessList.Remove(i);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3217
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3218
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3219
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3220
	TUint8 event = kDSOSNotifyDeleted;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3221
	TUint16 type = kDSOSProcessItem;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3222
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3223
	AddToReplyBufferL(event, true);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3224
	AddToReplyBufferL(type);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3225
	AddToReplyBufferL((TUint32)aExitCode);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3226
	AddToReplyBufferL(aProcessId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3227
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3228
	InformEventL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3229
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3230
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3231
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3232
// CTrkDispatchLayer::DoNotifyLibraryLoadedL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3233
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3234
// Notify the host debugger that a library in now loaded
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3235
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3236
void CTrkDispatchLayer::DoNotifyLibraryLoadedL(TDesC8 &aName, TUint32 aProcessId, TUint32 aThreadId, TUint32 aCodeBaseAddress, TUint32 aDataBaseAddress)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3237
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3238
	TUint8 event = kDSOSNotifyCreated;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3239
	TUint16 type = kDSOSDLLItem;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3240
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3241
	TUint16 nameLength = aName.Length();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3242
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3243
	AddToReplyBufferL(event, true);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3244
	AddToReplyBufferL(type);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3245
	AddToReplyBufferL(aProcessId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3246
	AddToReplyBufferL(aThreadId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3247
	AddToReplyBufferL(aCodeBaseAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3248
	AddToReplyBufferL(aDataBaseAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3249
	AddToReplyBufferL(nameLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3250
	AddToReplyBufferL(aName);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3251
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3252
	InformEventL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3253
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3254
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3255
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3256
// CTrkDispatchLayer::DoNotifyLibraryUnloadedL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3257
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3258
// Notify the host debugger that a library has been unloaded
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3259
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3260
void CTrkDispatchLayer::DoNotifyLibraryUnloadedL(TDesC8 &aName, TUint32 aProcessId, TUint32 aThreadId)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3261
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3262
	TUint8 event = kDSOSNotifyDeleted;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3263
	TUint16 type = kDSOSDLLItem;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3264
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3265
	TUint16 nameLength = aName.Length();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3266
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3267
	AddToReplyBufferL(event, true);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3268
	AddToReplyBufferL(type);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3269
	AddToReplyBufferL(aProcessId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3270
	AddToReplyBufferL(aThreadId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3271
	AddToReplyBufferL(nameLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3272
	AddToReplyBufferL(aName);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3273
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3274
	InformEventL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3275
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3276
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3277
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3278
// CTrkDispatchLayer::GetDataFromBufferL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3279
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3280
// Notify the host debugger that trace data has been recieved
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3281
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3282
void CTrkDispatchLayer::DoNotifyUserTraceL(TDesC8 &aTrace)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3283
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3284
	if (iIsConnected)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3285
		iFramingLayer->SendRawMsgL(aTrace);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3286
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3287
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3288
void CTrkDispatchLayer::DoNotifyProcessAddedL(TDesC8 &aName, TUint32 aProcessId, TUint32 aThreadId, TUint32 aUid, TUint32 aCodeBaseAddress, TUint32 aDataBaseAddress)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3289
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3290
	// check to see if the host supported protocol handles this event, 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3291
	// otherwise just resume the thread. If not, this thread would get suspended indefinitely.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3292
	if (iHostVersion.iMajor < 3 || (iHostVersion.iMajor == 3  && iHostVersion.iMinor <= 3))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3293
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3294
		iKernelDriver.ResumeThread(aThreadId);				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3295
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3296
	else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3297
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3298
		TUint8 event = kDSOSNotifyCreated;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3299
		TUint16 type = kDSOSProcessItem;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3300
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3301
		TUint16 nameLength = aName.Length();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3302
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3303
		AddToReplyBufferL(event, true);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3304
		AddToReplyBufferL(type);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3305
		AddToReplyBufferL(aProcessId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3306
		AddToReplyBufferL(aThreadId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3307
		AddToReplyBufferL(aUid);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3308
		AddToReplyBufferL(aCodeBaseAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3309
		AddToReplyBufferL(aDataBaseAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3310
		AddToReplyBufferL(nameLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3311
		AddToReplyBufferL(aName);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3312
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3313
		InformEventL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3314
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3315
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3316
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3317
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3318
// CTrkDispatchLayer::DoReadLibraryInfoL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3319
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3320
void CTrkDispatchLayer::DoReadLibraryInfoL(TDesC8& aFileName)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3321
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3322
	TMetroTrkLibInfo libInfo(aFileName.Length(), &aFileName);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3323
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3324
	TInt err = iKernelDriver.GetLibraryInfo(libInfo);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3325
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3326
	if (err == KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3327
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3328
		AddToReplyBufferL(libInfo.iCodeAddress, true);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3329
		AddToReplyBufferL(libInfo.iDataAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3330
		AddToReplyBufferL(libInfo.iAttachProcessId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3331
		AddToReplyBufferL(libInfo.iAttachThreadId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3332
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3333
		RespondOkL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3334
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3335
	else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3336
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3337
		User::Leave(err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3338
	}			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3339
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3340
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3341
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3342
// CTrkDispatchLayer::DoReadProcessInfoL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3343
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3344
void CTrkDispatchLayer::DoReadProcessInfoL(TUint32 aUid, TDesC8& aFileName)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3345
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3346
	TMetroTrkExeInfo exeInfo(aUid, aFileName.Length(), &aFileName);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3347
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3348
	TInt err = iKernelDriver.GetExeInfo(exeInfo);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3349
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3350
	if (err == KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3351
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3352
		AddToReplyBufferL(exeInfo.iProcessID, true);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3353
		AddToReplyBufferL(exeInfo.iThreadID);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3354
		AddToReplyBufferL(exeInfo.iCodeAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3355
		AddToReplyBufferL(exeInfo.iDataAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3356
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3357
		RespondOkL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3358
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3359
	else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3360
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3361
		User::Leave(err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3362
	}			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3363
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3364
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3365
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3366
// CTrkDispatchLayer::GetDataFromBufferL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3367
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3368
// Get data from the input buffer
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3369
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3370
void CTrkDispatchLayer::GetDataFromBufferL(TAny* aData, TInt aLength)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3371
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3372
	if (aLength > iInputBuffer->Length())
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3373
		User::Leave(kDSReplyPacketSizeError);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3374
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3375
	if (iFramingLayer->IsBigEndian())
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3376
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3377
		Mem::Copy(aData, iInputBuffer->Ptr(), aLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3378
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3379
	else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3380
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3381
		TUint8 *p = (TUint8 *)aData;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3382
		for (int i=aLength-1, j=0; i>=0; i--, j++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3383
			p[j] = iInputBuffer->Ptr()[i];
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3384
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3385
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3386
	// now remove it from the buffer
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3387
	iInputBuffer->Des().Delete(0, aLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3388
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3389
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3390
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3391
// CTrkDispatchLayer::AddToReplyBufferL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3392
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3393
// Add data to the buffer which will be sent back to the host as a reply
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3394
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3395
void CTrkDispatchLayer::AddToReplyBufferL(TUint8 aData, TBool aReset)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3396
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3397
	if (aReset)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3398
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3399
		// free the memory associated with the old reply buffer and allocate a new one
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3400
		SafeDelete(iReplyBuffer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3401
		iReplyBuffer = HBufC8::New(sizeof(TUint8));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3402
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3403
	else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3404
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3405
		// reallocate to make enough room for the new data
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3406
		iReplyBuffer = iReplyBuffer->ReAlloc(iReplyBuffer->Length() + sizeof(TUint8));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3407
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3408
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3409
	// make sure the above worked
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3410
	if (!iReplyBuffer)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3411
		User::Leave(KErrNoMemory);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3412
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3413
	iReplyBuffer->Des().Append(aData);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3414
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3415
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3416
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3417
// CTrkDispatchLayer::AddToReplyBufferL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3418
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3419
// Add data to the buffer which will be sent back to the host as a reply
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3420
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3421
void CTrkDispatchLayer::AddToReplyBufferL(TUint16 aData, TBool aReset)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3422
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3423
	TUint16 temp = aData;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3424
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3425
	if (aReset)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3426
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3427
		// free the memory associated with the old reply buffer and allocate a new one
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3428
		SafeDelete(iReplyBuffer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3429
		iReplyBuffer = HBufC8::New(sizeof(TUint16));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3430
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3431
	else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3432
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3433
		// reallocate to make enough room for the new data
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3434
		iReplyBuffer = iReplyBuffer->ReAlloc(iReplyBuffer->Length() + sizeof(TUint16));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3435
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3436
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3437
	// make sure the above worked
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3438
	if (!iReplyBuffer)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3439
		User::Leave(KErrNoMemory);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3440
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3441
	// the host expects all values except for raw data to be returned in big endian format
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3442
	if (!iFramingLayer->IsBigEndian())
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3443
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3444
		temp = Swap2(aData);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3445
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3446
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3447
	iReplyBuffer->Des().Append((TUint8 *)&temp, sizeof(TUint16));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3448
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3449
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3450
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3451
// CTrkDispatchLayer::AddToReplyBufferL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3452
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3453
// Add data to the buffer which will be sent back to the host as a reply
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3454
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3455
void CTrkDispatchLayer::AddToReplyBufferL(TUint32 aData, TBool aReset)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3456
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3457
	TUint32 temp = aData;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3458
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3459
	if (aReset)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3460
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3461
		// free the memory associated with the old reply buffer and allocate a new one
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3462
		SafeDelete(iReplyBuffer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3463
		iReplyBuffer = HBufC8::New(sizeof(TUint32));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3464
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3465
	else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3466
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3467
		// reallocate to make enough room for the new data
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3468
		iReplyBuffer = iReplyBuffer->ReAlloc(iReplyBuffer->Length() + sizeof(TUint32));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3469
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3470
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3471
	// make sure the above worked
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3472
	if (!iReplyBuffer)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3473
		User::Leave(KErrNoMemory);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3474
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3475
	// the host expects all values except for raw data to be returned in big endian format
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3476
	if (!iFramingLayer->IsBigEndian())
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3477
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3478
		temp = Swap4(aData);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3479
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3480
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3481
	iReplyBuffer->Des().Append((TUint8 *)&temp, sizeof(TUint32));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3482
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3483
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3484
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3485
// CTrkDispatchLayer::AddToReplyBufferL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3486
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3487
// Add data to the buffer which will be sent back to the host as a reply
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3488
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3489
void CTrkDispatchLayer::AddToReplyBufferL(const TDesC8 &aData, TBool aReset)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3490
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3491
	if (aReset)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3492
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3493
		// free the memory associated with the old reply buffer and allocate a new one
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3494
		SafeDelete(iReplyBuffer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3495
		iReplyBuffer = HBufC8::New(aData.Length());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3496
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3497
	else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3498
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3499
		// reallocate to make enough room for the new data
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3500
		iReplyBuffer = iReplyBuffer->ReAlloc(iReplyBuffer->Length() + aData.Length());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3501
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3502
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3503
	// make sure the above worked
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3504
	if (!iReplyBuffer)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3505
		User::Leave(KErrNoMemory);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3506
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3507
	iReplyBuffer->Des().Append(aData);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3508
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3509
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3510
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3511
// CTrkDispatchLayer::IsThreadSuspended
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3512
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3513
// Determines whether or not a thread is suspended
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3514
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3515
TUint8 CTrkDispatchLayer::IsThreadSuspended(TUint32 aThreadId)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3516
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3517
	if (iSuspendedThreadList.Find(aThreadId) >= 0)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3518
		return 1;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3519
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3520
	return 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3521
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3522
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3523
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3524
// CTrkDispatchLayer::IsRestrictedFolder
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3525
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3526
// Check to see if the path is any of the data caged paths like \sys\ or \private\ or \resource\
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3527
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3528
TBool CTrkDispatchLayer::IsRestrictedFolder(const TDesC& aPath)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3529
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3530
	_LIT(KSYS, "\\sys\\");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3531
	_LIT(KRESOURCE, "\\resource\\");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3532
	_LIT(KPRIVATE, "\\private\\");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3533
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3534
	if ( (aPath.FindC(KSYS)>=0) || (aPath.FindC(KRESOURCE)>=0) || (aPath.FindC(KPRIVATE)>=0) )
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3535
		return ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3536
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3537
	return EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3538
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3539
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3540
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3541
TInt CTrkDispatchLayer::CloseCrashLogger()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3542
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3543
    TInt err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3544
    
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3545
    //The old mobile crash file name is "d_exc_mc.exe" and the new one is "mc_useragent.exe"    
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3546
    //This is the string that needs to be passed to the RProcess::Open call to get a handle.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3547
    //The complete process name actually includes the UID info as well.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3548
    //Instead of hard coding the process name, its better to just 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3549
    //search for the process and find it that way.      
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3550
    //_LIT16(KCrashLoggerName, "mc_useragent.exe[1020e519]0001");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3551
    _LIT16(KOldCrashLoggerName, "d_exc_mc*");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3552
    _LIT16(KCrashLoggerName, "mc_useragent*");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3553
    
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3554
    err = TerminateProcess(KOldCrashLoggerName);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3555
    err = TerminateProcess(KCrashLoggerName);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3556
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3557
    return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3558
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3559
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3560
TInt CTrkDispatchLayer::TerminateProcess(const TDesC& aProcessName)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3561
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3562
    TFindProcess find(aProcessName);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3563
    TFullName name; 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3564
        
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3565
    TInt err = find.Next(name);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3566
    if (KErrNone == err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3567
    {   
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3568
        RProcess process;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3569
        err = process.Open(find);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3570
    
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3571
        if (KErrNone == err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3572
        {
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3573
            process.Kill(KErrNone);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3574
        }
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3575
    }
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3576
    return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3577
}