summaryrefslogtreecommitdiff
path: root/firmware/target/sh/debug-sh.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/sh/debug-sh.c')
-rw-r--r--firmware/target/sh/debug-sh.c285
1 files changed, 0 insertions, 285 deletions
diff --git a/firmware/target/sh/debug-sh.c b/firmware/target/sh/debug-sh.c
deleted file mode 100644
index bee4896174..0000000000
--- a/firmware/target/sh/debug-sh.c
+++ /dev/null
@@ -1,285 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 Heikki Hannikainen
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include <stdbool.h>
23#include <string.h>
24
25#include "config.h"
26#include "system.h"
27#include "kernel.h"
28#include "font.h"
29#include "lcd.h"
30#include "button.h"
31#include "powermgmt.h"
32#include "adc.h"
33#include "hwcompat.h" /* ROM_VERSION */
34#include "crc32.h"
35
36#if CONFIG_KEYPAD == RECORDER_PAD
37# define DEBUG_CANCEL BUTTON_OFF
38
39#elif CONFIG_KEYPAD == ONDIO_PAD
40# define DEBUG_CANCEL BUTTON_MENU
41#endif
42
43/* Tool function to read the flash manufacturer and type, if available.
44 Only chips which could be reprogrammed in system will return values.
45 (The mode switch addresses vary between flash manufacturers, hence addr1/2) */
46 /* In IRAM to avoid problems when running directly from Flash */
47static bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device,
48 unsigned addr1, unsigned addr2)
49 ICODE_ATTR __attribute__((noinline));
50static bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device,
51 unsigned addr1, unsigned addr2)
52{
53 unsigned not_manu, not_id; /* read values before switching to ID mode */
54 unsigned manu, id; /* read values when in ID mode */
55
56 volatile unsigned char* flash = (unsigned char*)0x2000000; /* flash mapping */
57 int old_level; /* saved interrupt level */
58
59 not_manu = flash[0]; /* read the normal content */
60 not_id = flash[1]; /* should be 'A' (0x41) and 'R' (0x52) from the "ARCH" marker */
61
62 /* disable interrupts, prevent any stray flash access */
63 old_level = disable_irq_save();
64
65 flash[addr1] = 0xAA; /* enter command mode */
66 flash[addr2] = 0x55;
67 flash[addr1] = 0x90; /* ID command */
68 /* Atmel wants 20ms pause here */
69 /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
70
71 manu = flash[0]; /* read the IDs */
72 id = flash[1];
73
74 flash[0] = 0xF0; /* reset flash (back to normal read mode) */
75 /* Atmel wants 20ms pause here */
76 /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
77
78 restore_irq(old_level); /* enable interrupts again */
79 /* I assume success if the obtained values are different from
80 the normal flash content. This is not perfectly bulletproof, they
81 could theoretically be the same by chance, causing us to fail. */
82 if (not_manu != manu || not_id != id) /* a value has changed */
83 {
84 *p_manufacturer = manu; /* return the results */
85 *p_device = id;
86 return true; /* success */
87 }
88 return false; /* fail */
89}
90
91bool dbg_ports(void)
92{
93 int adc_battery_voltage;
94#ifndef HAVE_LCD_BITMAP
95 int currval = 0;
96 int button;
97#else
98 int adc_battery_level;
99
100 lcd_setfont(FONT_SYSFIXED);
101#endif
102 lcd_clear_display();
103
104 while(1)
105 {
106#ifdef HAVE_LCD_BITMAP
107 lcd_putsf(0, 0, "PADR: %04x", (unsigned short)PADR);
108 lcd_putsf(0, 1, "PBDR: %04x", (unsigned short)PBDR);
109
110 lcd_putsf(0, 2, "AN0: %03x AN4: %03x", adc_read(0), adc_read(4));
111 lcd_putsf(0, 3, "AN1: %03x AN5: %03x", adc_read(1), adc_read(5));
112 lcd_putsf(0, 4, "AN2: %03x AN6: %03x", adc_read(2), adc_read(6));
113 lcd_putsf(0, 5, "AN3: %03x AN7: %03x", adc_read(3), adc_read(7));
114
115 battery_read_info(&adc_battery_voltage, &adc_battery_level);
116 lcd_putsf(0, 6, "Batt: %d.%03dV %d%% ", adc_battery_voltage / 1000,
117 adc_battery_voltage % 1000, adc_battery_level);
118
119 lcd_update();
120
121 while (button_get_w_tmo(HZ/10) != (DEBUG_CANCEL|BUTTON_REL));
122
123 lcd_setfont(FONT_UI);
124
125#else /* !HAVE_LCD_BITMAP */
126
127 if (currval == 0) {
128 lcd_putsf(0, 0, "PADR: %04x", (unsigned short)PADR);
129 } else if (currval == 1) {
130 lcd_putsf(0, 0, "PBDR: %04x", (unsigned short)PBDR);
131 } else {
132 int idx = currval - 2; /* idx < 7 */
133 lcd_putsf(0, 0, "AN%d: %03x", idx, adc_read(idx));
134 }
135
136 battery_read_info(&adc_battery_voltage, NULL);
137 lcd_putsf(0, 1, "Batt: %d.%03dV", adc_battery_voltage / 1000,
138 adc_battery_voltage % 1000);
139 lcd_update();
140
141 button = button_get_w_tmo(HZ/5);
142 switch(button)
143 {
144 case BUTTON_STOP:
145 return false;
146
147 case BUTTON_LEFT:
148 currval--;
149 if(currval < 0)
150 currval = 9;
151 break;
152
153 case BUTTON_RIGHT:
154 currval++;
155 if(currval > 9)
156 currval = 0;
157 break;
158 }
159#endif
160 }
161 return false;
162}
163
164bool dbg_hw_info(void)
165{
166#ifndef HAVE_LCD_BITMAP
167 int button;
168 int currval = 0;
169#else
170 int bitmask = HW_MASK;
171#endif
172 int rom_version = ROM_VERSION;
173 unsigned manu, id; /* flash IDs */
174 bool got_id; /* flag if we managed to get the flash IDs */
175 unsigned rom_crc = 0xffffffff; /* CRC32 of the boot ROM */
176 bool has_bootrom; /* flag for boot ROM present */
177 int oldmode; /* saved memory guard mode */
178
179 oldmode = system_memory_guard(MEMGUARD_NONE); /* disable memory guard */
180
181 /* get flash ROM type */
182 got_id = dbg_flash_id(&manu, &id, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
183 if (!got_id)
184 got_id = dbg_flash_id(&manu, &id, 0x555, 0x2AA); /* try AMD, Macronix */
185
186 /* check if the boot ROM area is a flash mirror */
187 has_bootrom = (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
188 if (has_bootrom) /* if ROM and Flash different */
189 {
190 /* calculate CRC16 checksum of boot ROM */
191 rom_crc = crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff);
192 }
193
194 system_memory_guard(oldmode); /* re-enable memory guard */
195
196 lcd_clear_display();
197
198#ifdef HAVE_LCD_BITMAP
199 lcd_setfont(FONT_SYSFIXED);
200
201 lcd_puts(0, 0, "[Hardware info]");
202
203 lcd_putsf(0, 1, "ROM: %d.%02d", rom_version/100, rom_version%100);
204
205 lcd_putsf(0, 2, "Mask: 0x%04x", bitmask);
206 if (got_id)
207 lcd_putsf(0, 3, "Flash: M=%02x D=%02x", manu, id);
208 else
209 lcd_puts(0, 3, "Flash: M=?? D=??"); /* unknown, sorry */
210
211 if (has_bootrom)
212 {
213 if (rom_crc == 0x56DBA4EE) /* known Version 1 */
214 lcd_puts(0, 4, "Boot ROM: V1");
215 else
216 lcd_putsf(0, 4, "ROMcrc: 0x%08x", rom_crc);
217 }
218 else
219 {
220 lcd_puts(0, 4, "Boot ROM: none");
221 }
222
223 lcd_update();
224
225 /* wait for exit */
226 while (button_get_w_tmo(HZ/10) != (DEBUG_CANCEL|BUTTON_REL));
227
228 lcd_setfont(FONT_UI);
229
230#else /* !HAVE_LCD_BITMAP */
231 lcd_puts(0, 0, "[HW Info]");
232 while(1)
233 {
234 switch(currval)
235 {
236 case 0:
237 lcd_putsf(0, 1, "ROM: %d.%02d",
238 rom_version/100, rom_version%100);
239 break;
240 case 1:
241 if (got_id)
242 lcd_putsf(0, 1, "Flash:%02x,%02x", manu, id);
243 else
244 lcd_puts(0, 1, "Flash:??,??"); /* unknown, sorry */
245 break;
246 case 2:
247 if (has_bootrom)
248 {
249 if (rom_crc == 0x56DBA4EE) /* known Version 1 */
250 lcd_puts(0, 1, "BootROM: V1");
251 else if (rom_crc == 0x358099E8)
252 lcd_puts(0, 1, "BootROM: V2");
253 /* alternative boot ROM found in one single player so far */
254 else
255 lcd_putsf(0, 1, "R: %08x", rom_crc);
256 }
257 else
258 lcd_puts(0, 1, "BootROM: no");
259 }
260
261 lcd_update();
262
263 button = button_get_w_tmo(HZ/10);
264
265 switch(button)
266 {
267 case BUTTON_STOP:
268 return false;
269
270 case BUTTON_LEFT:
271 currval--;
272 if(currval < 0)
273 currval = 2;
274 break;
275
276 case BUTTON_RIGHT:
277 currval++;
278 if(currval > 2)
279 currval = 0;
280 break;
281 }
282 }
283#endif
284 return false;
285}