Files
mckernel/executer/user/arch/arm64/archdep.S
Shiratori, Takehiro 8356ef6c96 arm64: uti: Add arch-dependent helper for context switch
arm64 performs context-switch in kernel space instead of user space as in
x86_64.

Change-Id: Ib119b9ff014effb970183ee86cfac67fab773cba
Futjitsu: POSTK_DEBUG_ARCH_DEP_99
2019-03-22 06:52:21 +00:00

42 lines
773 B
ArmAsm

/* archdep.S COPYRIGHT FUJITSU LIMITED 2017-2019 */
#include <sys/syscall.h>
/*
* int switch_ctx(int fd, unsigned long cmd, void **param, void *lctx,
* void *rctx);
* <register> : <argument>
* x0 : int fd
* x1 : unsigned long cmd
* x2 : void **param
* x3 : void *lctx
* x4 : void *rctx
*
* Save and switch the context including TLS.
*/
.global switch_ctx
switch_ctx:
/* send ioctl(fd, cmd, param) */
mov w8, #__NR_ioctl
svc #0x0
/* if (syscall_ret < 0 && -4095(-MAX_ERRNO) <= syscall_ret) goto 1f; */
cmp x0, #0xfffffffffffff000
b.hi 1f
/* if (syscall_ret != 0) goto 2f; */
cmp x0, #0x0
b.ne 2f
/* function_ret = 0 */
mov x0, #0x0
ret
/* error case */
1:
/* function_ret = -1 */
mov x0, #0xffffffffffffffff
2:
ret