Port-arm archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
SVC (SWI) for Thumb
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.
00000000 <_sys_write>:
0: efa00004 svc 0x00a00004
4: 2afffffe bcs 0 <__cerror>
4: R_ARM_JUMP24 __cerror
8: e12fff1e bx lr
8: R_ARM_V4BX *ABS*
If the SVC number is 0, the SVC is taken from the ip (r12) register.
But that just isn't good enough since you can't easily access ip
from Thumb and even in Thumb 2, you are restricted to loading a
normal ARM value.
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
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.
Home |
Main Index |
Thread Index |
Old Index