搜索
bottom↓
回复: 1

请教RTX中关于SVC的调用问题

[复制链接]

出0入0汤圆

发表于 2017-3-31 13:31:51 | 显示全部楼层 |阅读模式

  1. #define __NO_RETURN __declspec(noreturn)

  2. #define osEvent_type       osEvent
  3. #define osEvent_ret_status ret
  4. #define osEvent_ret_value  ret
  5. #define osEvent_ret_msg    ret
  6. #define osEvent_ret_mail   ret

  7. #define osCallback_type    osCallback
  8. #define osCallback_ret     ret

  9. #define SVC_0_1(f,t,...)                                                       \
  10. __svc_indirect(0) t  _##f (t(*)());                                            \
  11.                   t     f (void);                                              \
  12. __attribute__((always_inline))                                                 \
  13. static __inline   t __##f (void) {                                             \
  14.   return _##f(f);                                                              \
  15. }

  16. #define SVC_1_0(f,t,t1,...)                                                    \
  17. __svc_indirect(0) t  _##f (t(*)(t1),t1);                                       \
  18.                   t     f (t1 a1);                                             \
  19. __attribute__((always_inline))                                                 \
  20. static __inline   t __##f (t1 a1) {                                            \
  21.   _##f(f,a1);                                                                  \
  22. }

  23. #define SVC_1_1(f,t,t1,...)                                                    \
  24. __svc_indirect(0) t  _##f (t(*)(t1),t1);                                       \
  25.                   t     f (t1 a1);                                             \
  26. __attribute__((always_inline))                                                 \
  27. static __inline   t __##f (t1 a1) {                                            \
  28.   return _##f(f,a1);                                                           \
  29. }

  30. #define SVC_2_1(f,t,t1,t2,...)                                                 \
  31. __svc_indirect(0) t  _##f (t(*)(t1,t2),t1,t2);                                 \
  32.                   t     f (t1 a1, t2 a2);                                      \
  33. __attribute__((always_inline))                                                 \
  34. static __inline   t __##f (t1 a1, t2 a2) {                                     \
  35.   return _##f(f,a1,a2);                                                        \
  36. }

  37. #define SVC_3_1(f,t,t1,t2,t3,...)                                              \
  38. __svc_indirect(0) t  _##f (t(*)(t1,t2,t3),t1,t2,t3);                           \
  39.                   t     f (t1 a1, t2 a2, t3 a3);                               \
  40. __attribute__((always_inline))                                                 \
  41. static __inline   t __##f (t1 a1, t2 a2, t3 a3) {                              \
  42.   return _##f(f,a1,a2,a3);                                                     \
  43. }

  44. #define SVC_4_1(f,t,t1,t2,t3,t4,...)                                           \
  45. __svc_indirect(0) t  _##f (t(*)(t1,t2,t3,t4),t1,t2,t3,t4);                     \
  46.                   t     f (t1 a1, t2 a2, t3 a3, t4 a4);                        \
  47. __attribute__((always_inline))                                                 \
  48. static __inline   t __##f (t1 a1, t2 a2, t3 a3, t4 a4) {                       \
  49.   return _##f(f,a1,a2,a3,a4);                                                  \
  50. }

  51. #define SVC_1_2 SVC_1_1
  52. #define SVC_1_3 SVC_1_1
  53. #define SVC_2_3 SVC_2_1
复制代码


如上代码,只是知道这段代码的意思是在非特权等级下通过SVC来调用内核代码,但是不晓得其中原理是什么,还请各位高手指点一下!多谢。

阿莫论坛20周年了!感谢大家的支持与爱护!!

月入3000的是反美的。收入3万是亲美的。收入30万是移民美国的。收入300万是取得绿卡后回国,教唆那些3000来反美的!

出0入25汤圆

发表于 2017-5-25 15:28:14 | 显示全部楼层

Keil帮助中__svc_indirect条目下有有说明,大概是:
t  _##f (t(*)(t1),t1); 被__svc_indirect(0)修饰了,所以当使用_##f(f,a1);调用_##f时,会将函数f的地址存入R12寄存器中,然后执行SVC 0触发SVC_Handler,在SVC_Handler中通过R12寄存器调用真正的功能函数f

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-4-25 15:06

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表