6b13f685e
김민수
BSP 최초 추가
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
|
#include <common.h>
#include <cli.h>
#include <command.h>
#include <linux/ctype.h>
#include <net.h>
#include <bedbug/type.h>
#include <bedbug/bedbug.h>
#include <bedbug/regs.h>
#include <bedbug/ppc.h>
DECLARE_GLOBAL_DATA_PTR;
extern void show_regs __P ((struct pt_regs *));
extern int run_command __P ((const char *, int));
ulong dis_last_addr = 0;
ulong dis_last_len = 20;
CPU_DEBUG_CTX bug_ctx;
int bedbug_puts (const char *str)
{
printf ("%s\r
", str);
return 0;
}
void bedbug_init (void)
{
#if defined(CONFIG_4xx)
void bedbug405_init (void);
bedbug405_init ();
#elif defined(CONFIG_8xx)
void bedbug860_init (void);
bedbug860_init ();
#endif
#if defined(CONFIG_MPC824X) || defined(CONFIG_MPC8260)
void bedbug603e_init (void);
bedbug603e_init ();
#endif
return;
}
int do_bedbug_dis (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
{
ulong addr;
ulong len;
addr = dis_last_addr;
len = dis_last_len;
if (argc < 2)
return CMD_RET_USAGE;
if ((flag & CMD_FLAG_REPEAT) == 0) {
addr = simple_strtoul (argv[1], NULL, 16);
if (argc > 2)
len = simple_strtoul (argv[2], NULL, 16);
}
disppc ((unsigned char *) addr, 0, len, bedbug_puts, F_RADHEX);
dis_last_addr = addr + (len * 4);
dis_last_len = len;
return 0;
}
U_BOOT_CMD (ds, 3, 1, do_bedbug_dis,
"disassemble memory",
"ds <address> [# instructions]");
int do_bedbug_asm (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
{
long mem_addr;
unsigned long instr;
char prompt[15];
int asm_err;
int rcode = 0;
if (argc < 2)
return CMD_RET_USAGE;
printf ("
Enter '.' when done
");
mem_addr = simple_strtoul (argv[1], NULL, 16);
while (1) {
putc ('
');
disppc ((unsigned char *) mem_addr, 0, 1, bedbug_puts,
F_RADHEX);
sprintf (prompt, "%08lx: ", mem_addr);
cli_readline(prompt);
if (console_buffer[0] && strcmp (console_buffer, ".")) {
if ((instr =
asmppc (mem_addr, console_buffer,
&asm_err)) != 0) {
*(unsigned long *) mem_addr = instr;
mem_addr += 4;
} else {
printf ("*** Error: %s ***
",
asm_error_str (asm_err));
rcode = 1;
}
} else {
break;
}
}
return rcode;
} /* do_bedbug_asm */
U_BOOT_CMD (as, 2, 0, do_bedbug_asm,
"assemble memory", "as <address>");
/* ======================================================================
* Used to set a break point from the interpreter. Simply calls into the
* CPU-specific break point set routine.
* ====================================================================== */
int do_bedbug_break (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
{
/* -------------------------------------------------- */
if (bug_ctx.do_break)
(*bug_ctx.do_break) (cmdtp, flag, argc, argv);
return 0;
} /* do_bedbug_break */
U_BOOT_CMD (break, 3, 0, do_bedbug_break,
"set or clear a breakpoint",
" - Set or clear a breakpoint
"
"break <address> - Break at an address
"
"break off <bp#> - Disable breakpoint.
"
"break show - List breakpoints.");
/* ======================================================================
* Called from the debug interrupt routine. Simply calls the CPU-specific
* breakpoint handling routine.
* ====================================================================== */
void do_bedbug_breakpoint (struct pt_regs *regs)
{
/* -------------------------------------------------- */
if (bug_ctx.break_isr)
(*bug_ctx.break_isr) (regs);
return;
} /* do_bedbug_breakpoint */
/* ======================================================================
* Called from the CPU-specific breakpoint handling routine. Enter a
* mini main loop until the stopped flag is cleared from the breakpoint
* context.
*
* This handles the parts of the debugger that are common to all CPU's.
* ====================================================================== */
void bedbug_main_loop (unsigned long addr, struct pt_regs *regs)
{
int len;
int flag;
int rc = 0;
char prompt_str[20];
static char lastcommand[CONFIG_SYS_CBSIZE] = { 0 };
if (bug_ctx.clear)
(*bug_ctx.clear) (bug_ctx.current_bp);
printf ("Breakpoint %d: ", bug_ctx.current_bp);
disppc ((unsigned char *) addr, 0, 1, bedbug_puts, F_RADHEX);
bug_ctx.stopped = 1;
bug_ctx.regs = regs;
sprintf (prompt_str, "BEDBUG.%d =>", bug_ctx.current_bp);
while (bug_ctx.stopped) {
len = cli_readline(prompt_str);
flag = 0;
if (len > 0)
strcpy (lastcommand, console_buffer);
else if (len == 0)
flag |= CMD_FLAG_REPEAT;
if (len == -1)
printf ("<INTERRUPT>
");
else
rc = run_command_repeatable(lastcommand, flag);
if (rc <= 0) {
lastcommand[0] = 0;
}
}
bug_ctx.regs = NULL;
bug_ctx.current_bp = 0;
return;
}
int do_bedbug_continue (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
{
if (!bug_ctx.stopped) {
printf ("Not at a breakpoint
");
return 1;
}
bug_ctx.stopped = 0;
return 0;
}
U_BOOT_CMD (continue, 1, 0, do_bedbug_continue,
"continue from a breakpoint",
"");
int do_bedbug_step (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
{
unsigned long addr;
if (!bug_ctx.stopped) {
printf ("Not at a breakpoint
");
return 1;
}
if (!find_next_address((unsigned char *) &addr, false, bug_ctx.regs))
return 1;
if (bug_ctx.set)
(*bug_ctx.set) (bug_ctx.current_bp, addr);
bug_ctx.stopped = 0;
return 0;
}
U_BOOT_CMD (step, 1, 1, do_bedbug_step,
"single step execution.",
"");
int do_bedbug_next (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
{
unsigned long addr;
if (!bug_ctx.stopped) {
printf ("Not at a breakpoint
");
return 1;
}
if (!find_next_address((unsigned char *) &addr, true, bug_ctx.regs))
return 1;
if (bug_ctx.set)
(*bug_ctx.set) (bug_ctx.current_bp, addr);
bug_ctx.stopped = 0;
return 0;
}
U_BOOT_CMD (next, 1, 1, do_bedbug_next,
"single step execution, stepping over subroutines.",
"");
int do_bedbug_stack (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
{
unsigned long sp;
unsigned long func;
int depth;
int skip = 1;
unsigned long top;
if (!bug_ctx.stopped) {
printf ("Not at a breakpoint
");
return 1;
}
top = gd->bd->bi_memstart + gd->bd->bi_memsize;
depth = 0;
printf ("Depth PC
");
printf ("----- --------
");
printf ("%5d %08lx
", depth++, bug_ctx.regs->nip);
sp = bug_ctx.regs->gpr[1];
func = *(unsigned long *) (sp + 4);
while ((func < top) && (sp < top)) {
if (!skip)
printf ("%5d %08lx
", depth++, func);
else
--skip;
sp = *(unsigned long *) sp;
func = *(unsigned long *) (sp + 4);
}
return 0;
}
U_BOOT_CMD (where, 1, 1, do_bedbug_stack,
"Print the running stack.",
"");
int do_bedbug_rdump (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
{
if (!bug_ctx.stopped) {
printf ("Not at a breakpoint
");
return 1;
}
show_regs (bug_ctx.regs);
return 0;
}
U_BOOT_CMD (rdump, 1, 1, do_bedbug_rdump,
"Show registers.", "");
|