1 #include "cpu.h" 2 #include "svc.h" 3 #include "i2c_slave.h" 4 #include "debug.h" 5 6 typedef struct { 7 uint32_t r0, r1, r2, r3, r12, lr, pc, psr; 8 } frame_t; 9 10 static void __used handle(frame_t *frame) 11 { 12 svc_t svc = *(uint8_t *)(frame->pc - 2); 13 uint32_t arg = frame->r0; 14 15 switch (svc) { 16 case SYS_I2C_reset: 17 debug("i2c reset %u\n", arg); 18 i2c_reset_supervisor(arg); 19 break; 20 21 default: 22 debug("unhandled svc(%u, %#10x)\n", svc, arg); 23 break; 24 } 25 } 26 27 void __irq __naked svc_handler(void) 28 { 29 asm volatile( 30 "mov r0, sp\n\t" 31 "push {lr}\n\t" 32 "bl handle\n\t" 33 "pop {pc}\n\t" 34 ); 35 }