|
1 /* |
|
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * ne1_tb\specific\monitor.cpp |
|
16 * Kernel crash debugger - NE1_TBVariant specific |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 #include <kernel/monitor.h> |
|
23 #include "variant.h" |
|
24 #include "uart/uart16550_ne.h" |
|
25 |
|
26 // A copy of TNaviEngine::DoDebugOutput |
|
27 static TUint DebugPortAddr() |
|
28 { |
|
29 TUint debugPort; |
|
30 switch (Kern::SuperPage().iDebugPort) |
|
31 { |
|
32 case Arm::EDebugPortJTAG: debugPort = 0; break; //indicates JTAG debugging |
|
33 case 0x101: |
|
34 case 1: debugPort=KHwBaseUart1; break; |
|
35 case 2: debugPort=KHwBaseUart2; break; |
|
36 default: debugPort=KHwBaseUart0; break; |
|
37 } |
|
38 return debugPort; |
|
39 } |
|
40 |
|
41 |
|
42 // |
|
43 // UART code |
|
44 // |
|
45 void CrashDebugger::InitUart() |
|
46 { |
|
47 // Initialise the UART for standard debug output |
|
48 TUint32 baseAddr = DebugPortAddr(); |
|
49 if (baseAddr) // baseAddr is NULL in case of jtag logging |
|
50 { |
|
51 TUint32 dp = Kern::SuperPage().iDebugPort; |
|
52 TBool highSpeed = (dp==0x100 || dp==0x101); |
|
53 |
|
54 // Baud Rate = 115200; 8 bits, no parity, 1 stop bit |
|
55 *((volatile TInt*) (baseAddr+K16550LCROffset)) = 0x83; |
|
56 *((volatile TInt*) (baseAddr+K16550BDLoOffset)) = highSpeed ? KBaudRateDiv_230400 : KBaudRateDiv_default; |
|
57 *((volatile TInt*) (baseAddr+K16550BDHiOffset)) = 0; |
|
58 *((volatile TInt*) (baseAddr+K16550LCROffset)) = 3; |
|
59 |
|
60 // Set the FIFO control register (FCR) to polled mode & don't use interrupts |
|
61 *((volatile TInt*) (baseAddr+K16550FCROffset)) = 0; |
|
62 *((volatile TInt*) (baseAddr+K16550FCROffset)) = 1; |
|
63 *((volatile TInt*) (baseAddr+K16550IEROffset)) = 0; |
|
64 } |
|
65 } |
|
66 |
|
67 void CrashDebugger::UartOut(TUint aChar) |
|
68 { |
|
69 TUint debugPort = DebugPortAddr(); |
|
70 volatile TUint32& LSR = *(volatile TUint32*)(debugPort + 0x14); |
|
71 volatile TUint32& TXHR = *(volatile TUint32*)(debugPort + 0x00); |
|
72 volatile TUint32& RXHR = *(volatile TUint32*)(debugPort + 0x00); |
|
73 while (LSR & 1) |
|
74 { |
|
75 if (CheckPower()) |
|
76 return; |
|
77 TUint32 c = RXHR; |
|
78 if (c==19) // XOFF |
|
79 { |
|
80 FOREVER |
|
81 { |
|
82 // wait for XON |
|
83 while (!(LSR & 1)) |
|
84 { |
|
85 if (CheckPower()) |
|
86 return; |
|
87 } |
|
88 c = RXHR; |
|
89 if (c==17) // XON |
|
90 break; |
|
91 else if (c==3) // Ctrl C |
|
92 Leave(KErrCancel); |
|
93 } |
|
94 } |
|
95 else if (c==3) // Ctrl C |
|
96 Leave(KErrCancel); |
|
97 } |
|
98 while (!(LSR & 32)) |
|
99 CheckPower(); |
|
100 TXHR = aChar; |
|
101 } |
|
102 |
|
103 TUint8 CrashDebugger::UartIn() |
|
104 { |
|
105 TUint debugPort = DebugPortAddr(); |
|
106 volatile TUint32& LSR = *(volatile TUint32*)(debugPort + 0x14); |
|
107 volatile TUint32& RXHR = *(volatile TUint32*)(debugPort + 0x00); |
|
108 while (!(LSR & 1)) |
|
109 { |
|
110 if (CheckPower()) |
|
111 return (TUint8)0x0d; |
|
112 } |
|
113 return (TUint8)RXHR; |
|
114 } |
|
115 |
|
116 TBool CrashDebugger::CheckPower() |
|
117 { |
|
118 // |
|
119 // TO DO: (mandatory) |
|
120 // |
|
121 // Check if power supply is stable and return ETrue if not |
|
122 // |
|
123 return EFalse; // EXAMPLE ONLY |
|
124 } |
|
125 |