Changeset View
Changeset View
Standalone View
Standalone View
head/sys/amd64/cloudabi32/cloudabi32_sysvec.c
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | |||||
#include <compat/ia32/ia32_util.h> | #include <compat/ia32/ia32_util.h> | ||||
extern const char *cloudabi32_syscallnames[]; | extern const char *cloudabi32_syscallnames[]; | ||||
extern struct sysent cloudabi32_sysent[]; | extern struct sysent cloudabi32_sysent[]; | ||||
extern unsigned long ia32_maxssiz; | extern unsigned long ia32_maxssiz; | ||||
static int | static int | ||||
cloudabi32_fixup_tcb(register_t **stack_base, struct image_params *imgp) | cloudabi32_fixup_tcb(uintptr_t *stack_base, struct image_params *imgp) | ||||
{ | { | ||||
int error; | int error; | ||||
uint32_t args[2]; | uint32_t args[2]; | ||||
/* Place auxiliary vector and TCB on the stack. */ | /* Place auxiliary vector and TCB on the stack. */ | ||||
error = cloudabi32_fixup(stack_base, imgp); | error = cloudabi32_fixup(stack_base, imgp); | ||||
if (error != 0) | if (error != 0) | ||||
return (error); | return (error); | ||||
/* | /* | ||||
* On i386, the TCB is referred to by %gs:0. Reuse the empty | * On i386, the TCB is referred to by %gs:0. Reuse the empty | ||||
* space normally used by the return address (args[0]) to store | * space normally used by the return address (args[0]) to store | ||||
* a single element array, containing a pointer to the TCB. %gs | * a single element array, containing a pointer to the TCB. %gs | ||||
* base will point to this. | * base will point to this. | ||||
* | * | ||||
* Also let the first argument of the entry point (args[1]) | * Also let the first argument of the entry point (args[1]) | ||||
* refer to the auxiliary vector, which is stored right after | * refer to the auxiliary vector, which is stored right after | ||||
* the TCB. | * the TCB. | ||||
*/ | */ | ||||
args[0] = (uintptr_t)*stack_base; | args[0] = *stack_base; | ||||
args[1] = (uintptr_t)*stack_base + | args[1] = *stack_base + | ||||
roundup(sizeof(cloudabi32_tcb_t), sizeof(register_t)); | roundup(sizeof(cloudabi32_tcb_t), sizeof(register_t)); | ||||
*stack_base -= howmany(sizeof(args), sizeof(register_t)); | *stack_base -= roundup2(sizeof(args), sizeof(register_t)); | ||||
return (copyout(args, *stack_base, sizeof(args))); | return (copyout(args, (void *)*stack_base, sizeof(args))); | ||||
} | } | ||||
static void | static void | ||||
cloudabi32_proc_setregs(struct thread *td, struct image_params *imgp, | cloudabi32_proc_setregs(struct thread *td, struct image_params *imgp, | ||||
unsigned long stack) | uintptr_t stack) | ||||
{ | { | ||||
ia32_setregs(td, imgp, stack); | ia32_setregs(td, imgp, stack); | ||||
(void)cpu_set_user_tls(td, TO_PTR(stack)); | (void)cpu_set_user_tls(td, TO_PTR(stack)); | ||||
} | } | ||||
static int | static int | ||||
cloudabi32_fetch_syscall_args(struct thread *td) | cloudabi32_fetch_syscall_args(struct thread *td) | ||||
▲ Show 20 Lines • Show All 141 Lines • Show Last 20 Lines |