stm32: Move rdi handling to common stm32 code.

This commit is contained in:
Uwe Bonnes 2017-09-20 11:08:34 +02:00
parent 98ab873784
commit ce1ef6e41b
2 changed files with 54 additions and 54 deletions

View File

@ -304,57 +304,3 @@ static void setup_vbus_irq(void)
exti15_10_isr();
}
#ifdef ENABLE_DEBUG
enum {
RDI_SYS_OPEN = 0x01,
RDI_SYS_WRITE = 0x05,
RDI_SYS_ISTTY = 0x09,
};
int rdi_write(int fn, const char *buf, size_t len)
{
(void)fn;
if (debug_bmp)
return len - usbuart_debug_write(buf, len);
return 0;
}
struct ex_frame {
union {
int syscall;
int retval;
};
const int *params;
uint32_t r2, r3, r12, lr, pc;
};
void debug_monitor_handler_c(struct ex_frame *sp)
{
/* Return to after breakpoint instruction */
sp->pc += 2;
switch (sp->syscall) {
case RDI_SYS_OPEN:
sp->retval = 1;
break;
case RDI_SYS_WRITE:
sp->retval = rdi_write(sp->params[0], (void*)sp->params[1], sp->params[2]);
break;
case RDI_SYS_ISTTY:
sp->retval = 1;
break;
default:
sp->retval = -1;
}
}
asm(".globl debug_monitor_handler\n"
".thumb_func\n"
"debug_monitor_handler: \n"
" mov r0, sp\n"
" b debug_monitor_handler_c\n");
#endif

View File

@ -250,3 +250,57 @@ void USBUSART_TIM_ISR(void)
/* process FIFO */
usbuart_run();
}
#ifdef ENABLE_DEBUG
enum {
RDI_SYS_OPEN = 0x01,
RDI_SYS_WRITE = 0x05,
RDI_SYS_ISTTY = 0x09,
};
int rdi_write(int fn, const char *buf, size_t len)
{
(void)fn;
if (debug_bmp)
return len - usbuart_debug_write(buf, len);
return 0;
}
struct ex_frame {
union {
int syscall;
int retval;
};
const int *params;
uint32_t r2, r3, r12, lr, pc;
};
void debug_monitor_handler_c(struct ex_frame *sp)
{
/* Return to after breakpoint instruction */
sp->pc += 2;
switch (sp->syscall) {
case RDI_SYS_OPEN:
sp->retval = 1;
break;
case RDI_SYS_WRITE:
sp->retval = rdi_write(sp->params[0], (void*)sp->params[1], sp->params[2]);
break;
case RDI_SYS_ISTTY:
sp->retval = 1;
break;
default:
sp->retval = -1;
}
}
asm(".globl debug_monitor_handler\n"
".thumb_func\n"
"debug_monitor_handler: \n"
" mov r0, sp\n"
" b debug_monitor_handler_c\n");
#endif