Arm Swi 分析(1)

2,052 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,052
On SlideShare
0
From Embeds
0
Number of Embeds
73
Actions
Shares
0
Downloads
17
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Arm Swi 分析(1)

  1. 1. ARM SWI 分析 何文智 Stanley.Ho 根據 ADS 的 SVC 範例程式,裏面主要共有(1)ahandle.s(2)chandle.c(3)main.c(4)svc.h 主要是介紹應如何使用 SVC(SWI)的功能來做軟體中斷 main.c 內容列表如下 函式說明: Install_Handler() : 改變原本 vector SWI 0x08 的內容,變成我們所需要的 Branch routine 命令 main() : 呼叫 Install_Handler()及執行 SWI(0),SWI(1),SWI(2),SWI(3)命令 #include <stdio.h> #include svc.h unsigned *svc_vec = (unsigned *)0x08; extern void SVC_Handler(void); unsigned Install_Handler( unsigned routine, unsigned *vector ){ unsigned vec, old_vec; vec = (routine - (unsigned)vector - 8) >> 2; //算出routine跟vector的徧移值 /* Branch instructions contain a signed 2’s complement 24 bit offset. This is shifted left two bits, sign extended to 32 bits, and added to the PC. The instruction can therefore specify a branch of +</stdio.h>

×