From: Matthias Kruk Date: Sat, 23 Nov 2019 06:37:49 +0000 (+0900) Subject: Move fork() and execfve() syscalls from core to klibc X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=6d3ae2b15b0cfbe941897e41c6e5aabe41bf2391;p=corax Move fork() and execfve() syscalls from core to klibc --- diff --git a/kernel/core/syscall.S b/kernel/core/syscall.S index 075f9d7..61717ef 100644 --- a/kernel/core/syscall.S +++ b/kernel/core/syscall.S @@ -226,29 +226,6 @@ cxsendrecv: popl %ebx ret -.global fork -fork: - pushl %ebx - - movl $SYS_FORK, %eax - int $SYSCALL_POSIX - - popl %ebx - ret - -.global execfve -execfve: - pushl %ebx - - movl $SYS_EXECFVE, %eax - movl 8(%esp), %ebx - movl 12(%esp), %ecx - movl 16(%esp), %edx - int $SYSCALL_POSIX - - popl %ebx - ret - .global sleep sleep: pushl %ebx diff --git a/kernel/klibc/Makefile b/kernel/klibc/Makefile index 515ccae..5c90aca 100644 --- a/kernel/klibc/Makefile +++ b/kernel/klibc/Makefile @@ -1,5 +1,5 @@ OUTPUT = klibc.a -OBJECTS = string.o spinlock.o mutex.o +OBJECTS = string.o spinlock.o mutex.o posixcall.o PHONY = clean INCLUDES = -I../include -I../../include -I../.. CFLAGS = -m32 -Wall -nostdlib -nodefaultlibs -nostartfiles -ffreestanding $(INCLUDES) diff --git a/kernel/klibc/posixcall.S b/kernel/klibc/posixcall.S new file mode 100644 index 0000000..0b455c2 --- /dev/null +++ b/kernel/klibc/posixcall.S @@ -0,0 +1,34 @@ +#define _ASSEMBLY_SOURCE + +#include +#include + +#if FEATURE(POSIX) + + .section .text + + .global fork + .global execfve + +fork: + pushl %ebx + + movl $SYS_FORK, %eax + int $SYSCALL_POSIX + + popl %ebx + ret + +execfve: + pushl %ebx + + movl $SYS_EXECFVE, %eax + movl 8(%esp), %ebx + movl 12(%esp), %ecx + movl 16(%esp), %edx + int $SYSCALL_POSIX + + popl %ebx + ret + +#endif /* FEATURE(POSIX) */