Added article on ARM System Calls.

All about the OSDev Wiki. Discussions about the organization and general structure of articles and how to use the wiki. Request changes here if you don't know how to use the wiki.
Post Reply
tharkun
Member
Member
Posts: 51
Joined: Sat Mar 21, 2009 1:29 pm
Location: Ireland

Added article on ARM System Calls.

Post 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
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: Added article on ARM System Calls.

Post 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].
tharkun
Member
Member
Posts: 51
Joined: Sat Mar 21, 2009 1:29 pm
Location: Ireland

Re: Added article on ARM System Calls.

Post 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.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: Added article on ARM System Calls.

Post 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.
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: Added article on ARM System Calls.

Post 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.
Post Reply