芯片解密|单片机解密|IC解密|芯片破解|芯片复制| PCB抄板|软件开发

飞芯科技-芯片解密|单片机解密|IC解密|芯片破解|芯片复制| PCB抄板|软件开发

芯片复制ARM SVC模式源码

芯片复制采用svc模式可以将SDK(API)和Application分离, 也可以省略很多重复的代码,比如在bootload中用到了usb, 然后在application中想复用的话,可以用svc
原理: 类似软件中断,中添加了一个软件中断源,通过中断源表明调用的函数接口

芯片复制源程序如下:

  1. #ifndef NRF_SVC__
  2. #define NRF_SVC__

  3. #ifdef SVCALL_AS_NORMAL_FUNCTION
  4. #define SVCALL(number, return_type, signature) return_type signature
  5. #else

  6. #ifndef SVCALL
  7. #if defined (__CC_ARM)
  8. #define SVCALL(number, return_type, signature) return_type __svc(number) signature
  9. #elif defined (__GNUC__)
  10. #define SVCALL(number, return_type, signature) \
  11.   _Pragma("GCC diagnostic ignored \"-Wunused-function\"") \
  12.   _Pragma("GCC diagnostic push") \
  13.   _Pragma("GCC diagnostic ignored \"-Wreturn-type\"") \
  14.   __attribute__((naked)) static return_type signature \
  15.   { \
  16.     __asm( \
  17.         "svc %0\n" \
  18.         "bx r14" : : "I" (number) : "r0" \
  19.     ); \
  20.   }    \
  21.   _Pragma("GCC diagnostic pop")
  22. #elif defined (__ICCARM__)
  23. #define PRAGMA(x) _Pragma(#x)
  24. #define SVCALL(number, return_type, signature) \
  25. PRAGMA(swi_number = number) \
  26. __swi return_type signature;
  27. #else
  28. #define SVCALL(number, return_type, signature) return_type signature  
  29. #endif
  30. #endif  // SVCALL

  31. #endif  // SVCALL_AS_NORMAL_FUNCTION
  32. #endif  // NRF_SVC__

  33. void C_SVC_Handler(uint8_t svc_num, uint32_t * p_svc_args)
  34. {
  35.     switch (svc_num)
  36.     {
  37.         case NRF_SEC_SVC_HASH:
  38.             p_svc_args[0] = nrf_sec_hash((nrf_sec_data_t *)     p_svc_args[0],
  39.                                          (uint8_t *)            p_svc_args[1],
  40.                                          (nrf_sec_hash_func_t)  p_svc_args[2]);
  41.             break;

  42.         case NRF_SEC_SVC_VERIFY:
  43.             p_svc_args[0] = nrf_sec_verify((nrf_sec_data_t *)           p_svc_args[0],
  44.                                            (nrf_sec_ecc_point_t *)      p_svc_args[1],
  45.                                            (nrf_sec_ecc_signature_t *)  p_svc_args[2],
  46.                                            (nrf_sec_algo_t)             p_svc_args[3]);
  47.             break;
  48.         
  49.         default:
  50.             p_svc_args[0] = NRF_ERROR_SVC_HANDLER_MISSING;
  51.             break;
  52.     }
  53. }



联系方式

地址:石家庄市新华区民族路77号华强广场D座2009
电话:0311-88816616/87087811
手机:13315190088
传真:0311-67901001
联系人:张工
网址:www.feixindz.com
邮箱:feixindz@163.com
微信:xinpianjiemi
QQ:527263666/568069805

在线客服
热线电话

企业微信