sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32\kernel\arm\cscmdatasave.cpp sl@0: // SCM - Arm portion sl@0: // sl@0: // sl@0: sl@0: #define __INCLUDE_REG_OFFSETS__ // for SP_R13U in nk_plat.h sl@0: sl@0: sl@0: #include "arm_mem.h" sl@0: #include "nk_plat.h" sl@0: #include sl@0: #include sl@0: sl@0: sl@0: /** sl@0: * Reads the CPU registers at the time of the crash sl@0: * @param aRegs struct to store the resulting CPU registers sl@0: */ sl@0: void SCMDataSave::ReadCPURegisters(SFullArmRegSet& aRegs) sl@0: { sl@0: aRegs =*(SFullArmRegSet*)iMonitor->iRegs; sl@0: } sl@0: sl@0: /** sl@0: * Reads the user registers for a given thread - may not be the current thread sl@0: * @param aThread thread whose registers we want to read sl@0: * @param aRegs registers will be written here if available sl@0: * @return KErrArgument if aThread is the current thread or any of the system wide error codes sl@0: */ sl@0: TInt SCMDataSave::ReadUserRegisters(DThread* aThread, TArmRegSet& aRegs, TUint32& aAvailableRegs) sl@0: { sl@0: TFileName filename; sl@0: aThread->TraceAppendFullName(filename, EFalse); sl@0: sl@0: //we retrieve the registers differently for the current thread sl@0: if(aThread == &Kern::CurrentThread()) sl@0: { sl@0: return KErrArgument; sl@0: } sl@0: sl@0: TUint32* stackPointer = (TUint32*)aThread->iNThread.iSavedSP; //Still need to check pointer somehow sl@0: TUint32* stackTop = (TUint32*)((TUint32)aThread->iNThread.iStackBase +(TUint32)aThread->iNThread.iStackSize); sl@0: TArmReg* out = (TArmReg*)(&aRegs); sl@0: sl@0: //Get a pointer to this threads context table sl@0: NThread::TUserContextType type = aThread->iNThread.UserContextType(); sl@0: const TArmContextElement* table = aThread->iNThread.UserContextTables()[type]; sl@0: sl@0: aAvailableRegs = 0; sl@0: for(TInt i = 0; iTraceAppendFullName(filename, EFalse); sl@0: sl@0: TUint32* stackPointer = (TUint32*)aThread->iNThread.iSavedSP; sl@0: TUint32* stackTop = (TUint32*)((TUint32)aThread->iNThread.iStackBase +(TUint32)aThread->iNThread.iStackSize); sl@0: TArmReg* out = (TArmReg*)(&aRegs); sl@0: sl@0: //Get a pointer to this threads context table sl@0: const TArmContextElement* table = aThread->iNThread.UserContextTables()[NThread::EContextKernel]; sl@0: sl@0: aAvailableRegs = 0; sl@0: for(TInt i = 0; i= stackTop) sl@0: continue; sl@0: sl@0: value = stackPointer[value]; sl@0: aAvailableRegs |= (1<iNThread.iStackBase) sl@0: continue; sl@0: sl@0: value = stackTop[-value]; sl@0: aAvailableRegs |= (1<