diff options
Diffstat (limited to 'arch/sandbox/os/common.c')
-rw-r--r-- | arch/sandbox/os/common.c | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c index 5074a06c80..92b7dbb2c7 100644 --- a/arch/sandbox/os/common.c +++ b/arch/sandbox/os/common.c @@ -45,6 +45,7 @@ #include <errno.h> #include <signal.h> #include <sys/select.h> +#include <sys/wait.h> /* * ...except the ones needed to connect with barebox */ @@ -124,14 +125,6 @@ void __attribute__((noreturn)) reset_cpu(unsigned long addr) exit(0); } -void enable_interrupts(void) -{ -} - -void disable_interrupt(void) -{ -} - int linux_read(int fd, void *buf, size_t count) { ssize_t ret; @@ -193,6 +186,27 @@ off_t linux_lseek(int fd, off_t offset) return lseek(fd, offset, SEEK_SET); } +int linux_execve(const char * filename, char *const argv[], char *const envp[]) +{ + pid_t pid, tpid; + int execve_status; + + pid = fork(); + + if (pid == -1) { + perror("linux_execve"); + return pid; + } else if (pid == 0) { + exit(execve(filename, argv, envp)); + } else { + do { + tpid = wait(&execve_status); + } while(tpid != pid); + + return execve_status; + } +} + extern void start_barebox(void); extern void mem_malloc_init(void *start, void *end); @@ -270,7 +284,7 @@ int main(int argc, char *argv[]) printf("unable to get malloc space\n"); exit(1); } - mem_malloc_init(ram, ram + malloc_size); + mem_malloc_init(ram, ram + malloc_size - 1); while (1) { int option_index = 0; |