]>
git.ipfire.org Git - people/ms/u-boot.git/blob - arch/blackfin/lib/kgdb.c
2 * U-boot - architecture specific kgdb code
4 * Copyright 2009 Analog Devices Inc.
6 * Licensed under the GPL-2 or later.
13 #include <asm/processor.h>
14 #include <asm/mach-common/bits/core.h>
16 #include <asm/deferred.h>
17 #include <asm/traps.h>
18 #include <asm/signal.h>
20 void kgdb_enter(struct pt_regs
*regs
, kgdb_data
*kdp
)
22 /* disable interrupts */
25 /* reply to host that an exception has occurred */
26 kdp
->sigval
= kgdb_trap(regs
);
28 /* send the PC and the Stack Pointer */
30 kdp
->regs
[0].num
= BFIN_PC
;
31 kdp
->regs
[0].val
= regs
->pc
;
33 kdp
->regs
[1].num
= BFIN_SP
;
34 kdp
->regs
[1].val
= (unsigned long)regs
;
38 void kgdb_exit(struct pt_regs
*regs
, kgdb_data
*kdp
)
40 if (kdp
->extype
& KGDBEXIT_WITHADDR
)
41 printf("KGDBEXIT_WITHADDR\n");
43 switch (kdp
->extype
& KGDBEXIT_TYPEMASK
) {
45 printf("KGDBEXIT_KILL:\n");
47 case KGDBEXIT_CONTINUE
:
48 /* Make sure the supervisor single step bit is clear */
52 /* set the supervisor single step bit */
56 printf("KGDBEXIT : %d\n", kdp
->extype
);
59 /* enable interrupts */
63 int kgdb_trap(struct pt_regs
*regs
)
65 /* ipend doesn't get filled in properly */
66 switch (regs
->seqstat
& EXCAUSE
) {
73 case VEC_EXCPT04
... VEC_EXCPT15
:
103 * getregs - gets the pt_regs, and gives them to kgdb's buffer
105 int kgdb_getregs(struct pt_regs
*regs
, char *buf
, int max
)
107 unsigned long *gdb_regs
= (unsigned long *)buf
;
109 if (max
< NUMREGBYTES
)
110 kgdb_error(KGDBERR_NOSPACE
);
112 if ((unsigned long)gdb_regs
& 3)
113 kgdb_error(KGDBERR_ALIGNFAULT
);
115 gdb_regs
[BFIN_R0
] = regs
->r0
;
116 gdb_regs
[BFIN_R1
] = regs
->r1
;
117 gdb_regs
[BFIN_R2
] = regs
->r2
;
118 gdb_regs
[BFIN_R3
] = regs
->r3
;
119 gdb_regs
[BFIN_R4
] = regs
->r4
;
120 gdb_regs
[BFIN_R5
] = regs
->r5
;
121 gdb_regs
[BFIN_R6
] = regs
->r6
;
122 gdb_regs
[BFIN_R7
] = regs
->r7
;
123 gdb_regs
[BFIN_P0
] = regs
->p0
;
124 gdb_regs
[BFIN_P1
] = regs
->p1
;
125 gdb_regs
[BFIN_P2
] = regs
->p2
;
126 gdb_regs
[BFIN_P3
] = regs
->p3
;
127 gdb_regs
[BFIN_P4
] = regs
->p4
;
128 gdb_regs
[BFIN_P5
] = regs
->p5
;
129 gdb_regs
[BFIN_SP
] = (unsigned long)regs
;
130 gdb_regs
[BFIN_FP
] = regs
->fp
;
131 gdb_regs
[BFIN_I0
] = regs
->i0
;
132 gdb_regs
[BFIN_I1
] = regs
->i1
;
133 gdb_regs
[BFIN_I2
] = regs
->i2
;
134 gdb_regs
[BFIN_I3
] = regs
->i3
;
135 gdb_regs
[BFIN_M0
] = regs
->m0
;
136 gdb_regs
[BFIN_M1
] = regs
->m1
;
137 gdb_regs
[BFIN_M2
] = regs
->m2
;
138 gdb_regs
[BFIN_M3
] = regs
->m3
;
139 gdb_regs
[BFIN_B0
] = regs
->b0
;
140 gdb_regs
[BFIN_B1
] = regs
->b1
;
141 gdb_regs
[BFIN_B2
] = regs
->b2
;
142 gdb_regs
[BFIN_B3
] = regs
->b3
;
143 gdb_regs
[BFIN_L0
] = regs
->l0
;
144 gdb_regs
[BFIN_L1
] = regs
->l1
;
145 gdb_regs
[BFIN_L2
] = regs
->l2
;
146 gdb_regs
[BFIN_L3
] = regs
->l3
;
147 gdb_regs
[BFIN_A0_DOT_X
] = regs
->a0x
;
148 gdb_regs
[BFIN_A0_DOT_W
] = regs
->a0w
;
149 gdb_regs
[BFIN_A1_DOT_X
] = regs
->a1x
;
150 gdb_regs
[BFIN_A1_DOT_W
] = regs
->a1w
;
151 gdb_regs
[BFIN_ASTAT
] = regs
->astat
;
152 gdb_regs
[BFIN_RETS
] = regs
->rets
;
153 gdb_regs
[BFIN_LC0
] = regs
->lc0
;
154 gdb_regs
[BFIN_LT0
] = regs
->lt0
;
155 gdb_regs
[BFIN_LB0
] = regs
->lb0
;
156 gdb_regs
[BFIN_LC1
] = regs
->lc1
;
157 gdb_regs
[BFIN_LT1
] = regs
->lt1
;
158 gdb_regs
[BFIN_LB1
] = regs
->lb1
;
159 gdb_regs
[BFIN_CYCLES
] = 0;
160 gdb_regs
[BFIN_CYCLES2
] = 0;
161 gdb_regs
[BFIN_USP
] = regs
->usp
;
162 gdb_regs
[BFIN_SEQSTAT
] = regs
->seqstat
;
163 gdb_regs
[BFIN_SYSCFG
] = regs
->syscfg
;
164 gdb_regs
[BFIN_RETI
] = regs
->pc
;
165 gdb_regs
[BFIN_RETX
] = regs
->retx
;
166 gdb_regs
[BFIN_RETN
] = regs
->retn
;
167 gdb_regs
[BFIN_RETE
] = regs
->rete
;
168 gdb_regs
[BFIN_PC
] = regs
->pc
;
169 gdb_regs
[BFIN_CC
] = 0;
170 gdb_regs
[BFIN_EXTRA1
] = 0;
171 gdb_regs
[BFIN_EXTRA2
] = 0;
172 gdb_regs
[BFIN_EXTRA3
] = 0;
173 gdb_regs
[BFIN_IPEND
] = regs
->ipend
;
179 * putreg - put kgdb's reg (regno) into the pt_regs
181 void kgdb_putreg(struct pt_regs
*regs
, int regno
, char *buf
, int length
)
183 unsigned long *ptr
= (unsigned long *)buf
;
185 if (regno
< 0 || regno
> BFIN_NUM_REGS
)
186 kgdb_error(KGDBERR_BADPARAMS
);
189 kgdb_error(KGDBERR_NOSPACE
);
191 if ((unsigned long)ptr
& 3)
192 kgdb_error(KGDBERR_ALIGNFAULT
);
238 regs
->reserved
= *ptr
;
348 kgdb_error(KGDBERR_BADPARAMS
);
352 void kgdb_putregs(struct pt_regs
*regs
, char *buf
, int length
)
354 unsigned long *gdb_regs
= (unsigned long *)buf
;
356 if (length
!= BFIN_NUM_REGS
)
357 kgdb_error(KGDBERR_NOSPACE
);
359 if ((unsigned long)gdb_regs
& 3)
360 kgdb_error(KGDBERR_ALIGNFAULT
);
362 regs
->r0
= gdb_regs
[BFIN_R0
];
363 regs
->r1
= gdb_regs
[BFIN_R1
];
364 regs
->r2
= gdb_regs
[BFIN_R2
];
365 regs
->r3
= gdb_regs
[BFIN_R3
];
366 regs
->r4
= gdb_regs
[BFIN_R4
];
367 regs
->r5
= gdb_regs
[BFIN_R5
];
368 regs
->r6
= gdb_regs
[BFIN_R6
];
369 regs
->r7
= gdb_regs
[BFIN_R7
];
370 regs
->p0
= gdb_regs
[BFIN_P0
];
371 regs
->p1
= gdb_regs
[BFIN_P1
];
372 regs
->p2
= gdb_regs
[BFIN_P2
];
373 regs
->p3
= gdb_regs
[BFIN_P3
];
374 regs
->p4
= gdb_regs
[BFIN_P4
];
375 regs
->p5
= gdb_regs
[BFIN_P5
];
376 regs
->fp
= gdb_regs
[BFIN_FP
];
377 /* regs->sp = gdb_regs[BFIN_ ]; */
378 regs
->i0
= gdb_regs
[BFIN_I0
];
379 regs
->i1
= gdb_regs
[BFIN_I1
];
380 regs
->i2
= gdb_regs
[BFIN_I2
];
381 regs
->i3
= gdb_regs
[BFIN_I3
];
382 regs
->m0
= gdb_regs
[BFIN_M0
];
383 regs
->m1
= gdb_regs
[BFIN_M1
];
384 regs
->m2
= gdb_regs
[BFIN_M2
];
385 regs
->m3
= gdb_regs
[BFIN_M3
];
386 regs
->b0
= gdb_regs
[BFIN_B0
];
387 regs
->b1
= gdb_regs
[BFIN_B1
];
388 regs
->b2
= gdb_regs
[BFIN_B2
];
389 regs
->b3
= gdb_regs
[BFIN_B3
];
390 regs
->l0
= gdb_regs
[BFIN_L0
];
391 regs
->l1
= gdb_regs
[BFIN_L1
];
392 regs
->l2
= gdb_regs
[BFIN_L2
];
393 regs
->l3
= gdb_regs
[BFIN_L3
];
394 regs
->a0x
= gdb_regs
[BFIN_A0_DOT_X
];
395 regs
->a0w
= gdb_regs
[BFIN_A0_DOT_W
];
396 regs
->a1x
= gdb_regs
[BFIN_A1_DOT_X
];
397 regs
->a1w
= gdb_regs
[BFIN_A1_DOT_W
];
398 regs
->rets
= gdb_regs
[BFIN_RETS
];
399 regs
->lc0
= gdb_regs
[BFIN_LC0
];
400 regs
->lt0
= gdb_regs
[BFIN_LT0
];
401 regs
->lb0
= gdb_regs
[BFIN_LB0
];
402 regs
->lc1
= gdb_regs
[BFIN_LC1
];
403 regs
->lt1
= gdb_regs
[BFIN_LT1
];
404 regs
->lb1
= gdb_regs
[BFIN_LB1
];
405 regs
->usp
= gdb_regs
[BFIN_USP
];
406 regs
->syscfg
= gdb_regs
[BFIN_SYSCFG
];
407 regs
->retx
= gdb_regs
[BFIN_PC
];
408 regs
->retn
= gdb_regs
[BFIN_RETN
];
409 regs
->rete
= gdb_regs
[BFIN_RETE
];
410 regs
->pc
= gdb_regs
[BFIN_PC
];
412 #if 0 /* can't change these */
413 regs
->astat
= gdb_regs
[BFIN_ASTAT
];
414 regs
->seqstat
= gdb_regs
[BFIN_SEQSTAT
];
415 regs
->ipend
= gdb_regs
[BFIN_IPEND
];
420 void kgdb_breakpoint(int argc
, char *argv
[])
422 asm volatile ("excpt 0x1\n");