diff --git a/plat/linux/include/build.lua b/plat/linux/include/build.lua index bcc2911ae..f6fb7ebd4 100644 --- a/plat/linux/include/build.lua +++ b/plat/linux/include/build.lua @@ -13,6 +13,7 @@ addheader("ack/fcntl.h") addheader("ack/signal.h") addheader("sys/ioctl.h") addheader("sys/types.h") +addheader("sys/wait.h") acklibrary { diff --git a/plat/linux/include/sys/wait.h b/plat/linux/include/sys/wait.h new file mode 100644 index 000000000..1d30dbcdf --- /dev/null +++ b/plat/linux/include/sys/wait.h @@ -0,0 +1,19 @@ +#ifndef _SYS_WAIT_H +#define _SYS_WAIT_H + +#include + +extern pid_t wait(int *__wstatus); +extern pid_t waitpid(pid_t __pid, int *__wstatus, int __options); + +#define WNOHANG (1 << 0) +#define WUNTRACED (1 << 1) +#define WSTOPPED WUNTRACED +#define WEXITED (1 << 2) +#define WCONTINUED (1 << 3) +#define WNOWAIT (1 << 24) +#define __WNOTHREAD (1 << 29) +#define __WALL (1 << 30) +#define __WCLONE (1 << 31) + +#endif diff --git a/plat/linux/libsys/fork.c b/plat/linux/libsys/fork.c new file mode 100644 index 000000000..9be2739b2 --- /dev/null +++ b/plat/linux/libsys/fork.c @@ -0,0 +1,8 @@ +#include +#include +#include "libsys.h" + +pid_t fork(void) +{ + return (pid_t) _syscall(__NR_fork, 0, 0, 0); +} diff --git a/plat/linux/libsys/wait.c b/plat/linux/libsys/wait.c new file mode 100644 index 000000000..2bbd75b43 --- /dev/null +++ b/plat/linux/libsys/wait.c @@ -0,0 +1,7 @@ +#include +#include "libsys.h" + +pid_t wait(int *wstatus) +{ + return (pid_t) _syscall(__NR_waitpid, -1, (quad) wstatus, 0); +} diff --git a/plat/linux/libsys/waitpid.c b/plat/linux/libsys/waitpid.c new file mode 100644 index 000000000..994e86808 --- /dev/null +++ b/plat/linux/libsys/waitpid.c @@ -0,0 +1,7 @@ +#include +#include "libsys.h" + +pid_t waitpid(pid_t pid, int *wstatus, int options) +{ + return (pid_t) _syscall(__NR_waitpid, pid, (quad) wstatus, options); +} diff --git a/plat/linux386/libsys/execl.s b/plat/linux386/libsys/execl.s new file mode 100644 index 000000000..b72b12e0d --- /dev/null +++ b/plat/linux386/libsys/execl.s @@ -0,0 +1,29 @@ +# +! $Source$ +! $State$ +! $Revision$ + +! Declare segments (the order is important). + +.sect .text +.sect .rom +.sect .data +.sect .bss + +.sect .text + +__NR_execve = 11 + +! Perform a execl by invoking Linux's execve system call. + +.define _execl + +_execl: + lea eax, 8(esp) + push (_environ) ! envp + push eax ! argv + push -4(eax) ! pathname + push __NR_execve + call __syscall + add esp, 16 + ret diff --git a/plat/linuxmips/libsys/build.lua b/plat/linuxmips/libsys/build.lua index 2265e6869..dffef4742 100644 --- a/plat/linuxmips/libsys/build.lua +++ b/plat/linuxmips/libsys/build.lua @@ -7,6 +7,7 @@ acklibrary { "plat/linux/libsys/close.c", "plat/linux/libsys/creat.c", "plat/linux/libsys/execve.c", + "plat/linux/libsys/fork.c", "plat/linux/libsys/getpid.c", "plat/linux/libsys/gettimeofday.c", "plat/linux/libsys/ioctl.c", @@ -19,6 +20,8 @@ acklibrary { "plat/linux/libsys/signal.c", "plat/linux/libsys/sigprocmask.c", "plat/linux/libsys/unlink.c", + "plat/linux/libsys/wait.c", + "plat/linux/libsys/waitpid.c", "plat/linux/libsys/write.c", }, deps = { diff --git a/plat/linuxppc/libsys/build.lua b/plat/linuxppc/libsys/build.lua index f12837e6c..8d7086aa0 100644 --- a/plat/linuxppc/libsys/build.lua +++ b/plat/linuxppc/libsys/build.lua @@ -8,6 +8,7 @@ acklibrary { "plat/linux/libsys/_hol0.s", "plat/linux/libsys/close.c", "plat/linux/libsys/creat.c", + "plat/linux/libsys/fork.c", "plat/linux/libsys/execve.c", "plat/linux/libsys/getpid.c", "plat/linux/libsys/gettimeofday.c", @@ -21,6 +22,8 @@ acklibrary { -- omit signal.c "plat/linux/libsys/sigprocmask.c", "plat/linux/libsys/unlink.c", + "plat/linux/libsys/wait.c", + "plat/linux/libsys/waitpid.c", "plat/linux/libsys/write.c", }, deps = {