sl@0: // Copyright (c) 1994-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: // template\template_variant\specific\monitor.cpp sl@0: // Kernel crash debugger - Template specific sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include "variant.h" sl@0: sl@0: // sl@0: // UART code sl@0: // sl@0: void CrashDebugger::InitUart() sl@0: { sl@0: // Wait for last kernel trace to appear sl@0: TTemplate::BootWaitMilliSeconds(100); sl@0: sl@0: // sl@0: // TO DO: (mandatory) sl@0: // sl@0: // Initialise the UART for outputing debug strings. Need to work with the following settings: sl@0: // - 115200Baud sl@0: // - 8 data bits, 1 stop bit sl@0: // - No parity sl@0: // Obtain and use UART linear base address to access the UART registers, e.g. sl@0: // TUint32 debugPortBase = TTemplate::DebugPortAddr(); sl@0: // sl@0: } sl@0: sl@0: void CrashDebugger::UartOut(TUint aChar) sl@0: { sl@0: // sl@0: // TO DO: (mandatory) sl@0: // sl@0: // Output aChar through debug UART sl@0: // Obtain and use UART linear base address to access the UART register, e.g. sl@0: // Should take in consideration software flow control and check if Power is stable as per example below (pseudo-code): sl@0: // sl@0: TUint c=0; sl@0: // TUint32 debugPortBase = TTemplate::DebugPortAddr(); TO DO: (mandatory): Uncomment this sl@0: // while (!(input FIFO empty)) TO DO: (mandatory): Implement sl@0: { sl@0: if (CheckPower()) sl@0: return; sl@0: // c=(read received char); TO DO: (mandatory): Implement sl@0: if (c==19) // XOFF sl@0: { sl@0: FOREVER sl@0: { sl@0: // wait for XON sl@0: // while((input FIFO empty)) TO DO: (mandatory): Implement sl@0: { sl@0: if (CheckPower()) sl@0: return; sl@0: } sl@0: // c=(read received char); TO DO: (mandatory): Implement sl@0: if (c==17) // XON sl@0: break; sl@0: else if (c==3) // Ctrl C sl@0: Leave(KErrCancel); sl@0: } sl@0: } sl@0: sl@0: // coverity[dead_error_condition] sl@0: // The next line should be reachable when this template file is edited for use sl@0: else if (c==3) // Ctrl C sl@0: Leave(KErrCancel); sl@0: } sl@0: sl@0: // while ((output FIFO full)) TO DO: (mandatory): wait for last char to leave the FIFO (Implement) sl@0: CheckPower(); sl@0: // (write aChar to output port - or FIFO); TO DO: (mandatory): Implement sl@0: } sl@0: sl@0: TUint8 CrashDebugger::UartIn() sl@0: { sl@0: // sl@0: // TO DO: (mandatory) sl@0: // sl@0: // Wait for a char to arrive at input port, read it and return its value sl@0: // Use the UART linear base address obtained as in below example to access the UART registers sl@0: // Example below is pseudo-code: sl@0: // sl@0: // TUint32 debugPortBase = TTemplate::DebugPortAddr(); TO DO: (mandatory): Uncomment this sl@0: // while ((input FIFO empty)) TO DO: (mandatory): wait for a character to arrive (Implement) sl@0: { sl@0: if (CheckPower()) sl@0: return 0x0d; sl@0: } sl@0: // return (read received char); TO DO: (mandatory): Implement sl@0: return 0; // EXAMPLE ONLY sl@0: } sl@0: sl@0: TBool CrashDebugger::CheckPower() sl@0: { sl@0: // sl@0: // TO DO: (mandatory) sl@0: // sl@0: // Check if power supply is stable and return ETrue if not sl@0: // sl@0: return EFalse; // EXAMPLE ONLY sl@0: } sl@0: