#include "cpu.h" #include "svc.h" #include "i2c_slave.h" #include "debug.h" typedef struct { uint32_t r0, r1, r2, r3, r12, lr, pc, psr; } frame_t; static void __used handle(frame_t *frame) { svc_t svc = *(uint8_t *)(frame->pc - 2); uint32_t arg = frame->r0; switch (svc) { case SYS_I2C_reset: debug("i2c reset %u\n", arg); i2c_reset_supervisor(arg); break; default: debug("unhandled svc(%u, %#10x)\n", svc, arg); break; } } void __irq __naked svc_handler(void) { asm volatile( "mov r0, sp\n\t" "push {lr}\n\t" "bl handle\n\t" "pop {pc}\n\t" ); }