Page 1 of 1

Added article on ARM System Calls.

Posted: Sat May 29, 2010 4:10 am
by tharkun
I've added a fairly basic article on ARM System Calls, like the ARM Bare Bones, it's still a work in progress.
So far it features a basic introduction to making system calls on ARM. It also shows how to create system calls.

ARM System Calls

Re: Added article on ARM System Calls.

Posted: Sat May 29, 2010 6:31 am
by Gigasoft
With SWI, LR points to the next instruction, so it should end with MOVS PC, LR, not SUBS PC, LR, #4.

To have SWI work in both ARM and Thumb mode, one can place the system call number in bits 16-23 and fetch it with LDRB R0, [LR,#-2].

Re: Added article on ARM System Calls.

Posted: Sat May 29, 2010 7:16 am
by tharkun
Gigasoft wrote:With SWI, LR points to the next instruction, so it should end with MOVS PC, LR, not SUBS PC, LR, #4.

To have SWI work in both ARM and Thumb mode, one can place the system call number in bits 16-23 and fetch it with LDRB R0, [LR,#-2].
Thanks, I've changed it.

Re: Added article on ARM System Calls.

Posted: Tue Jun 01, 2010 5:55 am
by JamesM
The last section about shifting left 16-bits is unclear. It is unclear as to whether this shift MUST be done in inline assembly or if it can be done in C.

Re: Added article on ARM System Calls.

Posted: Tue Jun 01, 2010 10:03 am
by Gigasoft
You can't get at the return address from C anyway, so you have to use assembly. But then again, there is no guarrantee that LR will contain the return address once it gets to that statement, so preferably the entire SWI handler should be written in assembly.

Note that fetching the entire word and shifting it manually will not work because the address could be unaligned.