Port-arm archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: SVC (SWI) for Thumb
On Tue, Aug 13, 2013 at 06:30:14PM -0700, Matt Thomas wrote:
>
> Currently, NetBSD/arm uses a "global" SVC space (see <arm/swi.h) but
> in Thumb mode, the SWI instruction can only hold an 8 bit value and
> we have nearly 512. The 0x00a0000. indicated the NetBSD SVC space.
...
> So my thought is to reserve svc codes in thumb mode, 254 and 255.
> In either case, if the syscall number is less than 254, it's used
> directly with svc.
>
> 255 is for thumb on systems with thumb2 available and any syscall
> number >= 254 is placed in the ip (r12) register via a movw
> instruction. This is simple and straight forward.
>
> 254 is for thumb on systems with just thumb1 and any system call
> number >= 254. The argument in r0 is moved to ip since ip isn't
> easily used. r0 will contain the syscall number - 254. This
> allows for a single addition movs r0, #<syscall - 254> for calls
> less than 510. For syscalls >= 512, this sequence is used.
>
> movs r0, #(syscall - 254)/8
> lsls r0, r0, #3
Shouldn't that be a shift by 8 ?
> adds r0, r0, #((syscall - 254) & 7)
>
> This allows up to 2047 syscalls which is plenty of room for growth.
>
> The SWI handler will do the adjustments needed when it encounters
> a thumb SVC 254 or 255.
Why not just use r0 for thumb v1 and v2 ?
And why not pass the syscall number in a register for all syscalls?
Setting an 8 bit value costs one instruction in userspace, but probably
removes one from the kernel side (does it have to read the swi instruction
word to get the value?).
David
David
--
David Laight: david%l8s.co.uk@localhost
Home |
Main Index |
Thread Index |
Old Index