Changeset View
Changeset View
Standalone View
Standalone View
head/sys/arm64/cloudabi64/cloudabi64_sysvec.c
Show All 21 Lines | |||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
* SUCH DAMAGE. | * SUCH DAMAGE. | ||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/imgact.h> | |||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/proc.h> | #include <sys/proc.h> | ||||
#include <sys/sysent.h> | #include <sys/sysent.h> | ||||
#include <vm/vm.h> | #include <vm/vm.h> | ||||
#include <vm/pmap.h> | #include <vm/pmap.h> | ||||
#include <machine/frame.h> | #include <machine/frame.h> | ||||
#include <machine/pcb.h> | #include <machine/pcb.h> | ||||
#include <machine/vmparam.h> | #include <machine/vmparam.h> | ||||
#include <compat/cloudabi/cloudabi_util.h> | #include <compat/cloudabi/cloudabi_util.h> | ||||
#include <compat/cloudabi64/cloudabi64_syscall.h> | #include <compat/cloudabi64/cloudabi64_syscall.h> | ||||
#include <compat/cloudabi64/cloudabi64_util.h> | #include <compat/cloudabi64/cloudabi64_util.h> | ||||
extern const char *cloudabi64_syscallnames[]; | extern const char *cloudabi64_syscallnames[]; | ||||
extern struct sysent cloudabi64_sysent[]; | extern struct sysent cloudabi64_sysent[]; | ||||
static void | |||||
cloudabi64_proc_setregs(struct thread *td, struct image_params *imgp, | |||||
unsigned long stack) | |||||
{ | |||||
struct trapframe *regs; | |||||
exec_setregs(td, imgp, stack); | |||||
/* | |||||
* The stack now contains a pointer to the TCB and the auxiliary | |||||
* vector. Let x0 point to the auxiliary vector, and set | |||||
* tpidr_el0 to the TCB. | |||||
*/ | |||||
regs = td->td_frame; | |||||
regs->tf_x[0] = td->td_retval[0] = | |||||
stack + roundup(sizeof(cloudabi64_tcb_t), sizeof(register_t)); | |||||
(void)cpu_set_user_tls(td, (void *)stack); | |||||
} | |||||
static int | static int | ||||
cloudabi64_fetch_syscall_args(struct thread *td, struct syscall_args *sa) | cloudabi64_fetch_syscall_args(struct thread *td, struct syscall_args *sa) | ||||
{ | { | ||||
struct trapframe *frame = td->td_frame; | struct trapframe *frame = td->td_frame; | ||||
int i; | int i; | ||||
/* Obtain system call number. */ | /* Obtain system call number. */ | ||||
sa->code = frame->tf_x[8]; | sa->code = frame->tf_x[8]; | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | cloudabi64_schedtail(struct thread *td) | ||||
* when creating a new thread. | * when creating a new thread. | ||||
*/ | */ | ||||
if ((td->td_pflags & TDP_FORKING) != 0) { | if ((td->td_pflags & TDP_FORKING) != 0) { | ||||
frame->tf_x[0] = CLOUDABI_PROCESS_CHILD; | frame->tf_x[0] = CLOUDABI_PROCESS_CHILD; | ||||
frame->tf_x[1] = td->td_tid; | frame->tf_x[1] = td->td_tid; | ||||
} | } | ||||
} | } | ||||
void | int | ||||
cloudabi64_thread_setregs(struct thread *td, | cloudabi64_thread_setregs(struct thread *td, | ||||
const cloudabi64_threadattr_t *attr) | const cloudabi64_threadattr_t *attr, uint64_t tcb) | ||||
{ | { | ||||
struct trapframe *frame; | struct trapframe *frame; | ||||
stack_t stack; | stack_t stack; | ||||
/* Perform standard register initialization. */ | /* Perform standard register initialization. */ | ||||
stack.ss_sp = (void *)attr->stack; | stack.ss_sp = (void *)attr->stack; | ||||
stack.ss_size = attr->stack_size; | stack.ss_size = attr->stack_size; | ||||
cpu_set_upcall_kse(td, (void *)attr->entry_point, NULL, &stack); | cpu_set_upcall_kse(td, (void *)attr->entry_point, NULL, &stack); | ||||
/* | /* | ||||
* Pass in the thread ID of the new thread and the argument | * Pass in the thread ID of the new thread and the argument | ||||
* pointer provided by the parent thread in as arguments to the | * pointer provided by the parent thread in as arguments to the | ||||
* entry point. | * entry point. | ||||
*/ | */ | ||||
frame = td->td_frame; | frame = td->td_frame; | ||||
frame->tf_x[0] = td->td_tid; | frame->tf_x[0] = td->td_tid; | ||||
frame->tf_x[1] = attr->argument; | frame->tf_x[1] = attr->argument; | ||||
/* Set up TLS. */ | |||||
return (cpu_set_user_tls(td, (void *)tcb)); | |||||
} | } | ||||
static struct sysentvec cloudabi64_elf_sysvec = { | static struct sysentvec cloudabi64_elf_sysvec = { | ||||
.sv_size = CLOUDABI64_SYS_MAXSYSCALL, | .sv_size = CLOUDABI64_SYS_MAXSYSCALL, | ||||
.sv_table = cloudabi64_sysent, | .sv_table = cloudabi64_sysent, | ||||
.sv_fixup = cloudabi64_fixup, | .sv_fixup = cloudabi64_fixup, | ||||
.sv_name = "CloudABI ELF64", | .sv_name = "CloudABI ELF64", | ||||
.sv_coredump = elf64_coredump, | .sv_coredump = elf64_coredump, | ||||
.sv_pagesize = PAGE_SIZE, | .sv_pagesize = PAGE_SIZE, | ||||
.sv_minuser = VM_MIN_ADDRESS, | .sv_minuser = VM_MIN_ADDRESS, | ||||
.sv_maxuser = VM_MAXUSER_ADDRESS, | .sv_maxuser = VM_MAXUSER_ADDRESS, | ||||
.sv_usrstack = USRSTACK, | .sv_usrstack = USRSTACK, | ||||
.sv_stackprot = VM_PROT_READ | VM_PROT_WRITE, | .sv_stackprot = VM_PROT_READ | VM_PROT_WRITE, | ||||
.sv_copyout_strings = cloudabi64_copyout_strings, | .sv_copyout_strings = cloudabi64_copyout_strings, | ||||
.sv_setregs = cloudabi64_proc_setregs, | |||||
.sv_flags = SV_ABI_CLOUDABI | SV_CAPSICUM | SV_LP64, | .sv_flags = SV_ABI_CLOUDABI | SV_CAPSICUM | SV_LP64, | ||||
.sv_set_syscall_retval = cloudabi64_set_syscall_retval, | .sv_set_syscall_retval = cloudabi64_set_syscall_retval, | ||||
.sv_fetch_syscall_args = cloudabi64_fetch_syscall_args, | .sv_fetch_syscall_args = cloudabi64_fetch_syscall_args, | ||||
.sv_syscallnames = cloudabi64_syscallnames, | .sv_syscallnames = cloudabi64_syscallnames, | ||||
.sv_schedtail = cloudabi64_schedtail, | .sv_schedtail = cloudabi64_schedtail, | ||||
}; | }; | ||||
INIT_SYSENTVEC(elf_sysvec, &cloudabi64_elf_sysvec); | INIT_SYSENTVEC(elf_sysvec, &cloudabi64_elf_sysvec); | ||||
Elf64_Brandinfo cloudabi64_brand = { | Elf64_Brandinfo cloudabi64_brand = { | ||||
.brand = ELFOSABI_CLOUDABI, | .brand = ELFOSABI_CLOUDABI, | ||||
.machine = EM_AARCH64, | .machine = EM_AARCH64, | ||||
.sysvec = &cloudabi64_elf_sysvec, | .sysvec = &cloudabi64_elf_sysvec, | ||||
.flags = BI_CAN_EXEC_DYN, | .flags = BI_CAN_EXEC_DYN, | ||||
.compat_3_brand = "CloudABI", | .compat_3_brand = "CloudABI", | ||||
}; | }; |