git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into prog-loader
[lunaix-os.git]
/
lunaix-os
/
kernel
/
loader
/
exec.c
diff --git
a/lunaix-os/kernel/loader/exec.c
b/lunaix-os/kernel/loader/exec.c
index 1c206d2566c3d99f31ab63ecbfc793b5d403f47a..331cacca5283df528a73b79b2e1d0dca65275061 100644
(file)
--- a/
lunaix-os/kernel/loader/exec.c
+++ b/
lunaix-os/kernel/loader/exec.c
@@
-7,6
+7,7
@@
#include <lunaix/spike.h>
#include <lunaix/status.h>
#include <lunaix/syscall.h>
#include <lunaix/spike.h>
#include <lunaix/status.h>
#include <lunaix/syscall.h>
+#include <lunaix/syscall_utils.h>
#include <klibc/string.h>
#include <klibc/string.h>
@@
-47,10
+48,10
@@
__exec_remap_heap(struct ld_param* param, struct proc_mm* pvms)
struct mmap_param map_param = { .pvms = pvms,
.vms_mnt = param->vms_mnt,
struct mmap_param map_param = { .pvms = pvms,
.vms_mnt = param->vms_mnt,
- .flags = MAP_ANON | MAP_PRIVATE
| MAP_FIXED
,
+ .flags = MAP_ANON | MAP_PRIVATE,
.type = REGION_TYPE_HEAP,
.proct = PROT_READ | PROT_WRITE,
.type = REGION_TYPE_HEAP,
.proct = PROT_READ | PROT_WRITE,
- .mlen =
DEFAULT_HEAP_PAGES *
PG_SIZE };
+ .mlen = PG_SIZE };
int status = 0;
struct mm_region* heap;
if ((status = mem_map(NULL, &heap, param->info.end, NULL, &map_param))) {
int status = 0;
struct mm_region* heap;
if ((status = mem_map(NULL, &heap, param->info.end, NULL, &map_param))) {
@@
-60,6
+61,8
@@
__exec_remap_heap(struct ld_param* param, struct proc_mm* pvms)
heap->region_copied = __heap_copied;
mm_index((void**)&pvms->heap, heap);
heap->region_copied = __heap_copied;
mm_index((void**)&pvms->heap, heap);
+
+ return status;
}
int
}
int
@@
-112,15
+115,17
@@
exec_load(struct ld_param* param,
if (envp)
memcpy(arg_start + sz_argv, (void*)envp, sz_envp);
if (envp)
memcpy(arg_start + sz_argv, (void*)envp, sz_envp);
- struct usr_exec_param* param = mapped;
- *param = (struct usr_exec_param){ .argc = argv_len,
- .argv = arg_start,
- .envc = envp_len,
- .envp = arg_start + sz_argv,
- .info = param->info };
ptr_t* ustack = (ptr_t*)USTACK_TOP;
ptr_t* ustack = (ptr_t*)USTACK_TOP;
+ struct usr_exec_param* exec_param = mapped;
+
ustack[-1] = (ptr_t)mapped;
param->info.stack_top = &ustack[-1];
ustack[-1] = (ptr_t)mapped;
param->info.stack_top = &ustack[-1];
+
+ *exec_param = (struct usr_exec_param){ .argc = argv_len,
+ .argv = arg_start,
+ .envc = envp_len,
+ .envp = arg_start + sz_argv,
+ .info = param->info };
} else {
// TODO need to find a way to inject argv and envp remotely
fail("not implemented");
} else {
// TODO need to find a way to inject argv and envp remotely
fail("not implemented");
@@
-177,15
+182,16
@@
__DEFINE_LXSYSCALL3(int,
schedule();
fail("should not reach");
}
schedule();
fail("should not reach");
}
+ goto done;
}
}
-
isr_param* intr_ctx = &__current->intr_ctx
;
-
intr_ctx
->esp = ldparam.info.stack_top;
-
intr_ctx
->eip = ldparam.info.entry;
+
volatile struct exec_param* execp = __current->intr_ctx.execp
;
+
execp
->esp = ldparam.info.stack_top;
+
execp
->eip = ldparam.info.entry;
// we will jump to new entry point (_u_start) upon syscall's
// return so execve 'will not return' from the perspective of it's invoker
done:
// we will jump to new entry point (_u_start) upon syscall's
// return so execve 'will not return' from the perspective of it's invoker
done:
- return
errno
;
+ return
DO_STATUS(errno)
;
}
\ No newline at end of file
}
\ No newline at end of file