diff options
author | ed <ed@FreeBSD.org> | 2016-10-12 12:17:41 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2016-10-12 12:17:41 +0000 |
commit | cd04fbc5e631c6b3e80a14eb7044c3be35fba2d2 (patch) | |
tree | 3ca9a0abae801f8646949bec9130ff7ff712b5ca /sys | |
parent | 82a188c72f465e7dca16363000c51faf4b1cb5f3 (diff) | |
download | FreeBSD-src-cd04fbc5e631c6b3e80a14eb7044c3be35fba2d2.zip FreeBSD-src-cd04fbc5e631c6b3e80a14eb7044c3be35fba2d2.tar.gz |
MFC r303818, r303833, r303941, r304478, r304481, r304483, r304484, r304554,
r304555, r304556, r304557, r304558, r304559, r304561, r304563, r304564,
r304565, r304615, r304742, r304743, r304744, r304745, r304748, r304886,
r304991, r305928, r305938, r305987, r306185:
Bring CloudABI support back in sync with HEAD.
- Add support for running 32-bit executables on amd64, armv6 and i386.
- As these new architectures require the use of the vDSO, merge back
vDSO support for 64-bit executables running on amd64 and arm64 as
well. This has the advantage that support for vDSO-less execution
can be phased out when 11.0 becomes unsupported, as opposed to 11.x.
This change has been tested by running the cloudlibc unit tests on all
supported architectures, which seems to work fine.
Diffstat (limited to 'sys')
56 files changed, 8718 insertions, 652 deletions
diff --git a/sys/amd64/cloudabi32/cloudabi32_sysvec.c b/sys/amd64/cloudabi32/cloudabi32_sysvec.c new file mode 100644 index 0000000..5cf73ab --- /dev/null +++ b/sys/amd64/cloudabi32/cloudabi32_sysvec.c @@ -0,0 +1,231 @@ +/*- + * Copyright (c) 2015-2016 Nuxi, https://nuxi.nl/ + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/param.h> +#include <sys/imgact.h> +#include <sys/kernel.h> +#include <sys/proc.h> +#include <sys/sysent.h> + +#include <vm/vm.h> +#include <vm/pmap.h> + +#include <machine/frame.h> +#include <machine/pcb.h> +#include <machine/vmparam.h> + +#include <compat/cloudabi/cloudabi_util.h> + +#include <compat/cloudabi32/cloudabi32_syscall.h> +#include <compat/cloudabi32/cloudabi32_util.h> + +#include <compat/ia32/ia32_signal.h> +#include <compat/ia32/ia32_util.h> + +extern const char *cloudabi32_syscallnames[]; +extern struct sysent cloudabi32_sysent[]; + +extern unsigned long ia32_maxssiz; + +static int +cloudabi32_fixup_tcb(register_t **stack_base, struct image_params *imgp) +{ + int error; + uint32_t args[2]; + + /* Place auxiliary vector and TCB on the stack. */ + error = cloudabi32_fixup(stack_base, imgp); + if (error != 0) + return (error); + + /* + * On i386, the TCB is referred to by %gs:0. Reuse the empty + * space normally used by the return address (args[0]) to store + * a single element array, containing a pointer to the TCB. %gs + * base will point to this. + * + * Also let the first argument of the entry point (args[1]) + * refer to the auxiliary vector, which is stored right after + * the TCB. + */ + args[0] = (uintptr_t)*stack_base; + args[1] = (uintptr_t)*stack_base + + roundup(sizeof(cloudabi32_tcb_t), sizeof(register_t)); + *stack_base -= howmany(sizeof(args), sizeof(register_t)); + return (copyout(args, *stack_base, sizeof(args))); +} + +static void +cloudabi32_proc_setregs(struct thread *td, struct image_params *imgp, + unsigned long stack) +{ + + ia32_setregs(td, imgp, stack); + (void)cpu_set_user_tls(td, (void *)stack); +} + +static int +cloudabi32_fetch_syscall_args(struct thread *td, struct syscall_args *sa) +{ + struct trapframe *frame = td->td_frame; + int error; + + /* Obtain system call number. */ + sa->code = frame->tf_rax; + if (sa->code >= CLOUDABI32_SYS_MAXSYSCALL) + return (ENOSYS); + sa->callp = &cloudabi32_sysent[sa->code]; + sa->narg = sa->callp->sy_narg; + + /* + * Fetch system call arguments. + * + * The vDSO has already made sure that the arguments are + * eight-byte aligned. Pointers and size_t parameters are + * zero-extended. This makes it possible to copy in the + * arguments directly. As long as the call doesn't use 32-bit + * data structures, we can just invoke the same system call + * implementation used by 64-bit processes. + */ + error = copyin((void *)frame->tf_rcx, sa->args, + sa->narg * sizeof(sa->args[0])); + if (error != 0) + return (error); + + /* Default system call return values. */ + td->td_retval[0] = 0; + td->td_retval[1] = 0; + return (0); +} + +static void +cloudabi32_set_syscall_retval(struct thread *td, int error) +{ + struct trapframe *frame = td->td_frame; + + switch (error) { + case 0: + /* + * System call succeeded. + * + * Simply copy out the 64-bit return values into the + * same buffer provided for system call arguments. The + * vDSO will copy them to the right spot, truncating + * pointers and size_t values to 32 bits. + */ + frame->tf_rax = copyout(td->td_retval, (void *)frame->tf_rcx, + sizeof(td->td_retval)) == 0 ? 0 : CLOUDABI_EFAULT; + break; + case ERESTART: + /* Restart system call. */ + frame->tf_rip -= frame->tf_err; + frame->tf_r10 = frame->tf_rcx; + set_pcb_flags(td->td_pcb, PCB_FULL_IRET); + break; + case EJUSTRETURN: + break; + default: + /* System call returned an error. */ + frame->tf_rax = cloudabi_convert_errno(error); + break; + } +} + +static void +cloudabi32_schedtail(struct thread *td) +{ + struct trapframe *frame = td->td_frame; + register_t retval[2]; + + /* Return values for processes returning from fork. */ + if ((td->td_pflags & TDP_FORKING) != 0) { + retval[0] = CLOUDABI_PROCESS_CHILD; + retval[1] = td->td_tid; + copyout(retval, (void *)frame->tf_rcx, sizeof(retval)); + } +} + +int +cloudabi32_thread_setregs(struct thread *td, + const cloudabi32_threadattr_t *attr, uint32_t tcb) +{ + stack_t stack; + uint32_t args[3]; + void *frameptr; + int error; + + /* Perform standard register initialization. */ + stack.ss_sp = TO_PTR(attr->stack); + stack.ss_size = attr->stack_size - sizeof(args); + cpu_set_upcall(td, TO_PTR(attr->entry_point), NULL, &stack); + + /* + * Copy the arguments for the thread entry point onto the stack + * (args[1] and args[2]). Similar to process startup, use the + * otherwise unused return address (args[0]) for TLS. + */ + args[0] = tcb; + args[1] = td->td_tid; + args[2] = attr->argument; + frameptr = (void *)td->td_frame->tf_rsp; + error = copyout(args, frameptr, sizeof(args)); + if (error != 0) + return (error); + + return (cpu_set_user_tls(td, frameptr)); +} + +static struct sysentvec cloudabi32_elf_sysvec = { + .sv_size = CLOUDABI32_SYS_MAXSYSCALL, + .sv_table = cloudabi32_sysent, + .sv_fixup = cloudabi32_fixup_tcb, + .sv_name = "CloudABI ELF32", + .sv_coredump = elf32_coredump, + .sv_pagesize = IA32_PAGE_SIZE, + .sv_minuser = FREEBSD32_MINUSER, + .sv_maxuser = FREEBSD32_MAXUSER, + .sv_stackprot = VM_PROT_READ | VM_PROT_WRITE, + .sv_copyout_strings = cloudabi32_copyout_strings, + .sv_setregs = cloudabi32_proc_setregs, + .sv_fixlimit = ia32_fixlimit, + .sv_maxssiz = &ia32_maxssiz, + .sv_flags = SV_ABI_CLOUDABI | SV_CAPSICUM | SV_IA32 | SV_ILP32, + .sv_set_syscall_retval = cloudabi32_set_syscall_retval, + .sv_fetch_syscall_args = cloudabi32_fetch_syscall_args, + .sv_syscallnames = cloudabi32_syscallnames, + .sv_schedtail = cloudabi32_schedtail, +}; + +INIT_SYSENTVEC(elf_sysvec, &cloudabi32_elf_sysvec); + +Elf32_Brandinfo cloudabi32_brand = { + .brand = ELFOSABI_CLOUDABI, + .machine = EM_386, + .sysvec = &cloudabi32_elf_sysvec, + .compat_3_brand = "CloudABI", +}; diff --git a/sys/amd64/cloudabi64/cloudabi64_sysvec.c b/sys/amd64/cloudabi64/cloudabi64_sysvec.c index 08d85a2..f1b3863 100644 --- a/sys/amd64/cloudabi64/cloudabi64_sysvec.c +++ b/sys/amd64/cloudabi64/cloudabi64_sysvec.c @@ -171,9 +171,9 @@ cloudabi64_thread_setregs(struct thread *td, return (error); /* Perform standard register initialization. */ - stack.ss_sp = (void *)attr->stack; + stack.ss_sp = TO_PTR(attr->stack); stack.ss_size = tcbptr - attr->stack; - cpu_set_upcall(td, (void *)attr->entry_point, NULL, &stack); + cpu_set_upcall(td, TO_PTR(attr->entry_point), NULL, &stack); /* * Pass in the thread ID of the new thread and the argument @@ -196,7 +196,6 @@ static struct sysentvec cloudabi64_elf_sysvec = { .sv_pagesize = PAGE_SIZE, .sv_minuser = VM_MIN_ADDRESS, .sv_maxuser = VM_MAXUSER_ADDRESS, - .sv_usrstack = USRSTACK, .sv_stackprot = VM_PROT_READ | VM_PROT_WRITE, .sv_copyout_strings = cloudabi64_copyout_strings, .sv_setregs = cloudabi64_proc_setregs, diff --git a/sys/amd64/conf/NOTES b/sys/amd64/conf/NOTES index bf10762..a7095e3 100644 --- a/sys/amd64/conf/NOTES +++ b/sys/amd64/conf/NOTES @@ -618,6 +618,9 @@ options COMPAT_FREEBSD32 # Emulate spx device for client side of SVR3 local X interface #XXX#options SPX_HACK +# Enable 32-bit runtime support for CloudABI binaries. +options COMPAT_CLOUDABI32 + # Enable 64-bit runtime support for CloudABI binaries. options COMPAT_CLOUDABI64 diff --git a/sys/arm/cloudabi32/cloudabi32_sysvec.c b/sys/arm/cloudabi32/cloudabi32_sysvec.c new file mode 100644 index 0000000..040dcc3 --- /dev/null +++ b/sys/arm/cloudabi32/cloudabi32_sysvec.c @@ -0,0 +1,193 @@ +/*- + * Copyright (c) 2015-2016 Nuxi, https://nuxi.nl/ + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/param.h> +#include <sys/imgact.h> +#include <sys/kernel.h> +#include <sys/proc.h> +#include <sys/sysent.h> + +#include <vm/vm.h> +#include <vm/pmap.h> + +#include <machine/frame.h> +#include <machine/pcb.h> +#include <machine/vmparam.h> + +#include <compat/cloudabi/cloudabi_util.h> + +#include <compat/cloudabi32/cloudabi32_syscall.h> +#include <compat/cloudabi32/cloudabi32_util.h> + +extern const char *cloudabi32_syscallnames[]; +extern struct sysent cloudabi32_sysent[]; + +static void +cloudabi32_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 r0 point to the auxiliary vector, and set + * tpidrurw to the TCB. + */ + regs = td->td_frame; + regs->tf_r0 = td->td_retval[0] = + stack + roundup(sizeof(cloudabi32_tcb_t), sizeof(register_t)); + (void)cpu_set_user_tls(td, (void *)stack); +} + +static int +cloudabi32_fetch_syscall_args(struct thread *td, struct syscall_args *sa) +{ + struct trapframe *frame = td->td_frame; + int error; + + /* Obtain system call number. */ + sa->code = frame->tf_r12; + if (sa->code >= CLOUDABI32_SYS_MAXSYSCALL) + return (ENOSYS); + sa->callp = &cloudabi32_sysent[sa->code]; + sa->narg = sa->callp->sy_narg; + + /* Fetch system call arguments from registers and the stack. */ + sa->args[0] = frame->tf_r0; + sa->args[1] = frame->tf_r1; + sa->args[2] = frame->tf_r2; + sa->args[3] = frame->tf_r3; + if (sa->narg > 4) { + error = copyin((void *)td->td_frame->tf_usr_sp, &sa->args[4], + (sa->narg - 4) * sizeof(register_t)); + if (error != 0) + return (error); + } + + /* Default system call return values. */ + td->td_retval[0] = 0; + td->td_retval[1] = frame->tf_r1; + return (0); +} + +static void +cloudabi32_set_syscall_retval(struct thread *td, int error) +{ + struct trapframe *frame = td->td_frame; + + switch (error) { + case 0: + /* System call succeeded. */ + frame->tf_r0 = td->td_retval[0]; + frame->tf_r1 = td->td_retval[1]; + frame->tf_spsr &= ~PSR_C; + break; + case ERESTART: + /* Restart system call. */ + frame->tf_pc -= 4; + break; + case EJUSTRETURN: + break; + default: + /* System call returned an error. */ + frame->tf_r0 = cloudabi_convert_errno(error); + frame->tf_spsr |= PSR_C; + break; + } +} + +static void +cloudabi32_schedtail(struct thread *td) +{ + struct trapframe *frame = td->td_frame; + + /* + * Initial register values for processes returning from fork. + * Make sure that we only set these values when forking, not + * when creating a new thread. + */ + if ((td->td_pflags & TDP_FORKING) != 0) { + frame->tf_r0 = CLOUDABI_PROCESS_CHILD; + frame->tf_r1 = td->td_tid; + } +} + +int +cloudabi32_thread_setregs(struct thread *td, + const cloudabi32_threadattr_t *attr, uint32_t tcb) +{ + struct trapframe *frame; + stack_t stack; + + /* Perform standard register initialization. */ + stack.ss_sp = TO_PTR(attr->stack); + stack.ss_size = attr->stack_size; + cpu_set_upcall(td, TO_PTR(attr->entry_point), NULL, &stack); + + /* + * Pass in the thread ID of the new thread and the argument + * pointer provided by the parent thread in as arguments to the + * entry point. + */ + frame = td->td_frame; + frame->tf_r0 = td->td_tid; + frame->tf_r1 = attr->argument; + + /* Set up TLS. */ + return (cpu_set_user_tls(td, (void *)tcb)); +} + +static struct sysentvec cloudabi32_elf_sysvec = { + .sv_size = CLOUDABI32_SYS_MAXSYSCALL, + .sv_table = cloudabi32_sysent, + .sv_fixup = cloudabi32_fixup, + .sv_name = "CloudABI ELF32", + .sv_coredump = elf32_coredump, + .sv_pagesize = PAGE_SIZE, + .sv_minuser = VM_MIN_ADDRESS, + .sv_maxuser = VM_MAXUSER_ADDRESS, + .sv_stackprot = VM_PROT_READ | VM_PROT_WRITE, + .sv_copyout_strings = cloudabi32_copyout_strings, + .sv_setregs = cloudabi32_proc_setregs, + .sv_flags = SV_ABI_CLOUDABI | SV_CAPSICUM | SV_ILP32, + .sv_set_syscall_retval = cloudabi32_set_syscall_retval, + .sv_fetch_syscall_args = cloudabi32_fetch_syscall_args, + .sv_syscallnames = cloudabi32_syscallnames, + .sv_schedtail = cloudabi32_schedtail, +}; + +INIT_SYSENTVEC(elf_sysvec, &cloudabi32_elf_sysvec); + +Elf32_Brandinfo cloudabi32_brand = { + .brand = ELFOSABI_CLOUDABI, + .machine = EM_ARM, + .sysvec = &cloudabi32_elf_sysvec, + .compat_3_brand = "CloudABI", +}; diff --git a/sys/arm64/cloudabi64/cloudabi64_sysvec.c b/sys/arm64/cloudabi64/cloudabi64_sysvec.c index cf3e594..79b1046 100644 --- a/sys/arm64/cloudabi64/cloudabi64_sysvec.c +++ b/sys/arm64/cloudabi64/cloudabi64_sysvec.c @@ -139,9 +139,9 @@ cloudabi64_thread_setregs(struct thread *td, stack_t stack; /* Perform standard register initialization. */ - stack.ss_sp = (void *)attr->stack; + stack.ss_sp = TO_PTR(attr->stack); stack.ss_size = attr->stack_size; - cpu_set_upcall(td, (void *)attr->entry_point, NULL, &stack); + cpu_set_upcall(td, TO_PTR(attr->entry_point), NULL, &stack); /* * Pass in the thread ID of the new thread and the argument @@ -165,7 +165,6 @@ static struct sysentvec cloudabi64_elf_sysvec = { .sv_pagesize = PAGE_SIZE, .sv_minuser = VM_MIN_ADDRESS, .sv_maxuser = VM_MAXUSER_ADDRESS, - .sv_usrstack = USRSTACK, .sv_stackprot = VM_PROT_READ | VM_PROT_WRITE, .sv_copyout_strings = cloudabi64_copyout_strings, .sv_setregs = cloudabi64_proc_setregs, diff --git a/sys/compat/cloudabi/cloudabi_clock.c b/sys/compat/cloudabi/cloudabi_clock.c index b26d98e..ce53a11 100644 --- a/sys/compat/cloudabi/cloudabi_clock.c +++ b/sys/compat/cloudabi/cloudabi_clock.c @@ -117,7 +117,7 @@ cloudabi_sys_clock_res_get(struct thread *td, error = cloudabi_convert_timespec(&ts, &cts); if (error != 0) return (error); - td->td_retval[0] = cts; + memcpy(td->td_retval, &cts, sizeof(cts)); return (0); } @@ -129,6 +129,6 @@ cloudabi_sys_clock_time_get(struct thread *td, int error; error = cloudabi_clock_time_get(td, uap->clock_id, &ts); - td->td_retval[0] = ts; + memcpy(td->td_retval, &ts, sizeof(ts)); return (error); } diff --git a/sys/compat/cloudabi/cloudabi_thread.c b/sys/compat/cloudabi/cloudabi_thread.c index dd54e89..e70549b 100644 --- a/sys/compat/cloudabi/cloudabi_thread.c +++ b/sys/compat/cloudabi/cloudabi_thread.c @@ -60,14 +60,6 @@ cloudabi_sys_thread_exit(struct thread *td, } int -cloudabi_sys_thread_tcb_set(struct thread *td, - struct cloudabi_sys_thread_tcb_set_args *uap) -{ - - return (cpu_set_user_tls(td, uap->tcb)); -} - -int cloudabi_sys_thread_yield(struct thread *td, struct cloudabi_sys_thread_yield_args *uap) { diff --git a/sys/compat/cloudabi/cloudabi_util.h b/sys/compat/cloudabi/cloudabi_util.h index c0a02aa..6eb65aa 100644 --- a/sys/compat/cloudabi/cloudabi_util.h +++ b/sys/compat/cloudabi/cloudabi_util.h @@ -33,6 +33,7 @@ #include <contrib/cloudabi/cloudabi_types_common.h> struct file; +struct sysentvec; struct thread; struct timespec; @@ -76,4 +77,8 @@ int cloudabi_futex_lock_wrlock(struct thread *, cloudabi_lock_t *, cloudabi_scope_t, cloudabi_clockid_t, cloudabi_timestamp_t, cloudabi_timestamp_t); +/* vDSO setup and teardown. */ +void cloudabi_vdso_init(struct sysentvec *, char *, char *); +void cloudabi_vdso_destroy(struct sysentvec *); + #endif diff --git a/sys/compat/cloudabi/cloudabi_vdso.c b/sys/compat/cloudabi/cloudabi_vdso.c new file mode 100644 index 0000000..27c3d36 --- /dev/null +++ b/sys/compat/cloudabi/cloudabi_vdso.c @@ -0,0 +1,88 @@ +/*- + * Copyright (c) 2016 Nuxi, https://nuxi.nl/ + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <sys/lock.h> +#include <sys/sysent.h> +#include <sys/rwlock.h> + +#include <vm/vm.h> +#include <vm/pmap.h> +#include <vm/vm_extern.h> +#include <vm/vm_object.h> +#include <vm/vm_page.h> +#include <vm/vm_pager.h> + +#include <compat/cloudabi/cloudabi_util.h> + +void +cloudabi_vdso_init(struct sysentvec *sv, char *begin, char *end) +{ + vm_page_t m; + vm_object_t obj; + vm_offset_t addr; + size_t i, pages, pages_length, vdso_length; + + /* Determine the number of pages needed to store the vDSO. */ + vdso_length = end - begin; + pages = howmany(vdso_length, PAGE_SIZE); + pages_length = pages * PAGE_SIZE; + + /* Allocate a VM object and fill it with the vDSO. */ + obj = vm_pager_allocate(OBJT_PHYS, 0, pages_length, + VM_PROT_DEFAULT, 0, NULL); + addr = kva_alloc(PAGE_SIZE); + for (i = 0; i < pages; ++i) { + VM_OBJECT_WLOCK(obj); + m = vm_page_grab(obj, i, VM_ALLOC_NOBUSY | VM_ALLOC_ZERO); + m->valid = VM_PAGE_BITS_ALL; + VM_OBJECT_WUNLOCK(obj); + + pmap_qenter(addr, &m, 1); + memcpy((void *)addr, begin + i * PAGE_SIZE, + MIN(vdso_length - i * PAGE_SIZE, PAGE_SIZE)); + pmap_qremove(addr, 1); + } + kva_free(addr, PAGE_SIZE); + + /* + * Place the vDSO at the top of the address space. The user + * stack can start right below it. + */ + sv->sv_shared_page_base = sv->sv_maxuser - pages_length; + sv->sv_shared_page_len = pages_length; + sv->sv_shared_page_obj = obj; + sv->sv_usrstack = sv->sv_shared_page_base; +} + +void +cloudabi_vdso_destroy(struct sysentvec *sv) +{ + + vm_object_deallocate(sv->sv_shared_page_obj); +} diff --git a/sys/compat/cloudabi/cloudabi_vdso.lds b/sys/compat/cloudabi/cloudabi_vdso.lds new file mode 100644 index 0000000..807c488 --- /dev/null +++ b/sys/compat/cloudabi/cloudabi_vdso.lds @@ -0,0 +1,51 @@ +/* + * Linker script for the vDSO for CloudABI. + * Based on sys/amd64/linux/linux_vdso.lds.s + * + * $FreeBSD$ + */ + +SECTIONS +{ + . = . + SIZEOF_HEADERS; + + .hash : { *(.hash) } :text + .gnu.hash : { *(.gnu.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .gnu.version : { *(.gnu.version) } + .gnu.version_d : { *(.gnu.version_d) } + .gnu.version_r : { *(.gnu.version_r) } + + .note : { *(.note.*) } :text :note + + .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr + .eh_frame : { KEEP (*(.eh_frame)) } :text + + .dynamic : { *(.dynamic) } :text :dynamic + + .rodata : { *(.rodata*) } :text + .data : { + *(.data*) + *(.sdata*) + *(.got.plt) *(.got) + *(.gnu.linkonce.d.*) + *(.bss*) + *(.dynbss*) + *(.gnu.linkonce.b.*) + } + + .altinstructions : { *(.altinstructions) } + .altinstr_replacement : { *(.altinstr_replacement) } + + . = ALIGN(0x100); + .text : { *(.test .text*) } :text =0x90909090 +} + +PHDRS +{ + text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */ + dynamic PT_DYNAMIC FLAGS(4); /* PF_R */ + note PT_NOTE FLAGS(4); /* PF_R */ + eh_frame_hdr PT_GNU_EH_FRAME; +} diff --git a/sys/compat/cloudabi32/Makefile b/sys/compat/cloudabi32/Makefile new file mode 100644 index 0000000..5d1ff52 --- /dev/null +++ b/sys/compat/cloudabi32/Makefile @@ -0,0 +1,14 @@ +# $FreeBSD$ + +all: + @echo "make sysent only" + +sysent: cloudabi32_sysent.c cloudabi32_syscall.h cloudabi32_proto.h \ + cloudabi32_syscalls.c cloudabi32_systrace_args.c + +cloudabi32_sysent.c cloudabi32_syscall.h cloudabi32_proto.h \ + cloudabi32_syscalls.c cloudabi32_systrace_args.c: \ + ../../kern/makesyscalls.sh ../../contrib/cloudabi/syscalls32.master \ + syscalls.conf + sh ../../kern/makesyscalls.sh ../../contrib/cloudabi/syscalls32.master \ + syscalls.conf diff --git a/sys/compat/cloudabi32/cloudabi32_fd.c b/sys/compat/cloudabi32/cloudabi32_fd.c new file mode 100644 index 0000000..1754c48 --- /dev/null +++ b/sys/compat/cloudabi32/cloudabi32_fd.c @@ -0,0 +1,145 @@ +/*- + * Copyright (c) 2015 Nuxi, https://nuxi.nl/ + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/param.h> +#include <sys/kernel.h> +#include <sys/limits.h> +#include <sys/malloc.h> +#include <sys/syscallsubr.h> +#include <sys/systm.h> +#include <sys/uio.h> + +#include <contrib/cloudabi/cloudabi32_types.h> + +#include <compat/cloudabi32/cloudabi32_proto.h> +#include <compat/cloudabi32/cloudabi32_util.h> + +/* Copies in 32-bit iovec structures from userspace. */ +static int +cloudabi32_copyinuio(const cloudabi32_iovec_t *iovp, size_t iovcnt, + struct uio **uiop) +{ + cloudabi32_iovec_t iovobj; + struct uio *uio; + struct iovec *iov; + size_t i; + int error; + + /* Allocate uio and iovecs. */ + if (iovcnt > UIO_MAXIOV) + return (EINVAL); + uio = malloc(sizeof(struct uio) + iovcnt * sizeof(struct iovec), + M_IOV, M_WAITOK); + iov = (struct iovec *)(uio + 1); + + /* Initialize uio. */ + uio->uio_iov = iov; + uio->uio_iovcnt = iovcnt; + uio->uio_segflg = UIO_USERSPACE; + uio->uio_offset = -1; + uio->uio_resid = 0; + + /* Copy in iovecs. */ + for (i = 0; i < iovcnt; i++) { + error = copyin(&iovp[i], &iovobj, sizeof(iovobj)); + if (error != 0) { + free(uio, M_IOV); + return (error); + } + iov[i].iov_base = TO_PTR(iovobj.iov_base); + iov[i].iov_len = iovobj.iov_len; + if (iov[i].iov_len > INT32_MAX - uio->uio_resid) { + free(uio, M_IOV); + return (EINVAL); + } + uio->uio_resid += iov[i].iov_len; + } + + *uiop = uio; + return (0); +} + +int +cloudabi32_sys_fd_pread(struct thread *td, + struct cloudabi32_sys_fd_pread_args *uap) +{ + struct uio *uio; + int error; + + error = cloudabi32_copyinuio(uap->iov, uap->iovcnt, &uio); + if (error != 0) + return (error); + error = kern_preadv(td, uap->fd, uio, uap->offset); + free(uio, M_IOV); + return (error); +} + +int +cloudabi32_sys_fd_pwrite(struct thread *td, + struct cloudabi32_sys_fd_pwrite_args *uap) +{ + struct uio *uio; + int error; + + error = cloudabi32_copyinuio(TO_PTR(uap->iov), uap->iovcnt, &uio); + if (error != 0) + return (error); + error = kern_pwritev(td, uap->fd, uio, uap->offset); + free(uio, M_IOV); + return (error); +} + +int +cloudabi32_sys_fd_read(struct thread *td, + struct cloudabi32_sys_fd_read_args *uap) +{ + struct uio *uio; + int error; + + error = cloudabi32_copyinuio(uap->iov, uap->iovcnt, &uio); + if (error != 0) + return (error); + error = kern_readv(td, uap->fd, uio); + free(uio, M_IOV); + return (error); +} + +int +cloudabi32_sys_fd_write(struct thread *td, + struct cloudabi32_sys_fd_write_args *uap) +{ + struct uio *uio; + int error; + + error = cloudabi32_copyinuio(TO_PTR(uap->iov), uap->iovcnt, &uio); + if (error != 0) + return (error); + error = kern_writev(td, uap->fd, uio); + free(uio, M_IOV); + return (error); +} diff --git a/sys/compat/cloudabi32/cloudabi32_module.c b/sys/compat/cloudabi32/cloudabi32_module.c new file mode 100644 index 0000000..3e4e4a7 --- /dev/null +++ b/sys/compat/cloudabi32/cloudabi32_module.c @@ -0,0 +1,167 @@ +/*- + * Copyright (c) 2015 Nuxi, https://nuxi.nl/ + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/param.h> +#include <sys/imgact.h> +#include <sys/kernel.h> +#include <sys/module.h> +#include <sys/proc.h> +#include <sys/smp.h> +#include <sys/sysctl.h> +#include <sys/sysent.h> +#include <sys/systm.h> + +#include <contrib/cloudabi/cloudabi32_types.h> + +#include <compat/cloudabi/cloudabi_util.h> + +#include <compat/cloudabi32/cloudabi32_util.h> + +extern char _binary_cloudabi32_vdso_o_start[]; +extern char _binary_cloudabi32_vdso_o_end[]; + +register_t * +cloudabi32_copyout_strings(struct image_params *imgp) +{ + struct image_args *args; + uintptr_t begin; + size_t len; + + /* Copy out program arguments. */ + args = imgp->args; + len = args->begin_envv - args->begin_argv; + begin = rounddown2(imgp->sysent->sv_usrstack - len, sizeof(register_t)); + copyout(args->begin_argv, (void *)begin, len); + return ((register_t *)begin); +} + +int +cloudabi32_fixup(register_t **stack_base, struct image_params *imgp) +{ + char canarybuf[64]; + Elf32_Auxargs *args; + struct thread *td; + void *argdata, *canary; + size_t argdatalen; + int error; + + /* + * CloudABI executables do not store the FreeBSD OS release + * number in their header. Set the OS release number to the + * latest version of FreeBSD, so that system calls behave as if + * called natively. + */ + td = curthread; + td->td_proc->p_osrel = __FreeBSD_version; + + /* Store canary for stack smashing protection. */ + argdata = *stack_base; + arc4rand(canarybuf, sizeof(canarybuf), 0); + *stack_base -= howmany(sizeof(canarybuf), sizeof(register_t)); + canary = *stack_base; + error = copyout(canarybuf, canary, sizeof(canarybuf)); + if (error != 0) + return (error); + + /* + * Compute length of program arguments. As the argument data is + * binary safe, we had to add a trailing null byte in + * exec_copyin_data_fds(). Undo this by reducing the length. + */ + args = (Elf32_Auxargs *)imgp->auxargs; + argdatalen = imgp->args->begin_envv - imgp->args->begin_argv; + if (argdatalen > 0) + --argdatalen; + + /* Write out an auxiliary vector. */ + cloudabi32_auxv_t auxv[] = { +#define VAL(type, val) { .a_type = (type), .a_val = (val) } +#define PTR(type, ptr) { .a_type = (type), .a_ptr = (uintptr_t)(ptr) } + PTR(CLOUDABI_AT_ARGDATA, argdata), + VAL(CLOUDABI_AT_ARGDATALEN, argdatalen), + VAL(CLOUDABI_AT_BASE, args->base), + PTR(CLOUDABI_AT_CANARY, canary), + VAL(CLOUDABI_AT_CANARYLEN, sizeof(canarybuf)), + VAL(CLOUDABI_AT_NCPUS, mp_ncpus), + VAL(CLOUDABI_AT_PAGESZ, args->pagesz), + PTR(CLOUDABI_AT_PHDR, args->phdr), + VAL(CLOUDABI_AT_PHNUM, args->phnum), + VAL(CLOUDABI_AT_TID, td->td_tid), + PTR(CLOUDABI_AT_SYSINFO_EHDR, + imgp->proc->p_sysent->sv_shared_page_base), +#undef VAL +#undef PTR + { .a_type = CLOUDABI_AT_NULL }, + }; + *stack_base -= howmany(sizeof(auxv), sizeof(register_t)); + error = copyout(auxv, *stack_base, sizeof(auxv)); + if (error != 0) + return (error); + + /* Reserve space for storing the TCB. */ + *stack_base -= howmany(sizeof(cloudabi32_tcb_t), sizeof(register_t)); + return (0); +} + +static int +cloudabi32_modevent(module_t mod, int type, void *data) +{ + + switch (type) { + case MOD_LOAD: + cloudabi_vdso_init(cloudabi32_brand.sysvec, + _binary_cloudabi32_vdso_o_start, + _binary_cloudabi32_vdso_o_end); + if (elf32_insert_brand_entry(&cloudabi32_brand) < 0) { + printf("Failed to add CloudABI ELF brand handler\n"); + return (EINVAL); + } + return (0); + case MOD_UNLOAD: + if (elf32_brand_inuse(&cloudabi32_brand)) + return (EBUSY); + if (elf32_remove_brand_entry(&cloudabi32_brand) < 0) { + printf("Failed to remove CloudABI ELF brand handler\n"); + return (EINVAL); + } + cloudabi_vdso_destroy(cloudabi32_brand.sysvec); + return (0); + default: + return (EOPNOTSUPP); + } +} + +static moduledata_t cloudabi32_module = { + "cloudabi32", + cloudabi32_modevent, + NULL +}; + +DECLARE_MODULE_TIED(cloudabi32, cloudabi32_module, SI_SUB_EXEC, SI_ORDER_ANY); +MODULE_DEPEND(cloudabi32, cloudabi, 1, 1, 1); +FEATURE(cloudabi32, "CloudABI 32bit support"); diff --git a/sys/compat/cloudabi32/cloudabi32_poll.c b/sys/compat/cloudabi32/cloudabi32_poll.c new file mode 100644 index 0000000..5215580 --- /dev/null +++ b/sys/compat/cloudabi32/cloudabi32_poll.c @@ -0,0 +1,408 @@ +/*- + * Copyright (c) 2015 Nuxi, https://nuxi.nl/ + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/param.h> +#include <sys/proc.h> +#include <sys/syscallsubr.h> + +#include <contrib/cloudabi/cloudabi32_types.h> + +#include <compat/cloudabi/cloudabi_util.h> + +#include <compat/cloudabi32/cloudabi32_proto.h> +#include <compat/cloudabi32/cloudabi32_util.h> + +/* Converts a FreeBSD signal number to a CloudABI signal number. */ +static cloudabi_signal_t +convert_signal(int sig) +{ + static const cloudabi_signal_t signals[] = { + [SIGABRT] = CLOUDABI_SIGABRT, + [SIGALRM] = CLOUDABI_SIGALRM, + [SIGBUS] = CLOUDABI_SIGBUS, + [SIGCHLD] = CLOUDABI_SIGCHLD, + [SIGCONT] = CLOUDABI_SIGCONT, + [SIGFPE] = CLOUDABI_SIGFPE, + [SIGHUP] = CLOUDABI_SIGHUP, + [SIGILL] = CLOUDABI_SIGILL, + [SIGINT] = CLOUDABI_SIGINT, + [SIGKILL] = CLOUDABI_SIGKILL, + [SIGPIPE] = CLOUDABI_SIGPIPE, + [SIGQUIT] = CLOUDABI_SIGQUIT, + [SIGSEGV] = CLOUDABI_SIGSEGV, + [SIGSTOP] = CLOUDABI_SIGSTOP, + [SIGSYS] = CLOUDABI_SIGSYS, + [SIGTERM] = CLOUDABI_SIGTERM, + [SIGTRAP] = CLOUDABI_SIGTRAP, + [SIGTSTP] = CLOUDABI_SIGTSTP, + [SIGTTIN] = CLOUDABI_SIGTTIN, + [SIGTTOU] = CLOUDABI_SIGTTOU, + [SIGURG] = CLOUDABI_SIGURG, + [SIGUSR1] = CLOUDABI_SIGUSR1, + [SIGUSR2] = CLOUDABI_SIGUSR2, + [SIGVTALRM] = CLOUDABI_SIGVTALRM, + [SIGXCPU] = CLOUDABI_SIGXCPU, + [SIGXFSZ] = CLOUDABI_SIGXFSZ, + }; + + /* Convert unknown signals to SIGABRT. */ + if (sig < 0 || sig >= nitems(signals) || signals[sig] == 0) + return (SIGABRT); + return (signals[sig]); +} + +struct cloudabi32_kevent_args { + const cloudabi32_subscription_t *in; + cloudabi32_event_t *out; + bool once; +}; + +/* Converts CloudABI's subscription objects to FreeBSD's struct kevent. */ +static int +cloudabi32_kevent_copyin(void *arg, struct kevent *kevp, int count) +{ + cloudabi32_subscription_t sub; + struct cloudabi32_kevent_args *args; + cloudabi_timestamp_t ts; + int error; + + args = arg; + while (count-- > 0) { + /* TODO(ed): Copy in multiple entries at once. */ + error = copyin(args->in++, &sub, sizeof(sub)); + if (error != 0) + return (error); + + memset(kevp, 0, sizeof(*kevp)); + kevp->udata = TO_PTR(sub.userdata); + switch (sub.type) { + case CLOUDABI_EVENTTYPE_CLOCK: + kevp->filter = EVFILT_TIMER; + kevp->ident = sub.clock.identifier; + kevp->fflags = NOTE_NSECONDS; + if ((sub.clock.flags & + CLOUDABI_SUBSCRIPTION_CLOCK_ABSTIME) != 0 && + sub.clock.timeout > 0) { + /* Convert absolute timestamp to a relative. */ + error = cloudabi_clock_time_get(curthread, + sub.clock.clock_id, &ts); + if (error != 0) + return (error); + ts = ts > sub.clock.timeout ? 0 : + sub.clock.timeout - ts; + } else { + /* Relative timestamp. */ + ts = sub.clock.timeout; + } + kevp->data = ts > INTPTR_MAX ? INTPTR_MAX : ts; + break; + case CLOUDABI_EVENTTYPE_FD_READ: + kevp->filter = EVFILT_READ; + kevp->ident = sub.fd_readwrite.fd; + if ((sub.fd_readwrite.flags & + CLOUDABI_SUBSCRIPTION_FD_READWRITE_POLL) != 0) + kevp->fflags = NOTE_FILE_POLL; + break; + case CLOUDABI_EVENTTYPE_FD_WRITE: + kevp->filter = EVFILT_WRITE; + kevp->ident = sub.fd_readwrite.fd; + break; + case CLOUDABI_EVENTTYPE_PROC_TERMINATE: + kevp->filter = EVFILT_PROCDESC; + kevp->ident = sub.proc_terminate.fd; + kevp->fflags = NOTE_EXIT; + break; + } + if (args->once) { + /* Ignore flags. Simply use oneshot mode. */ + kevp->flags = EV_ADD | EV_ONESHOT; + } else { + /* Translate flags. */ + if ((sub.flags & CLOUDABI_SUBSCRIPTION_ADD) != 0) + kevp->flags |= EV_ADD; + if ((sub.flags & CLOUDABI_SUBSCRIPTION_CLEAR) != 0) + kevp->flags |= EV_CLEAR; + if ((sub.flags & CLOUDABI_SUBSCRIPTION_DELETE) != 0) + kevp->flags |= EV_DELETE; + if ((sub.flags & CLOUDABI_SUBSCRIPTION_DISABLE) != 0) + kevp->flags |= EV_DISABLE; + if ((sub.flags & CLOUDABI_SUBSCRIPTION_ENABLE) != 0) + kevp->flags |= EV_ENABLE; + if ((sub.flags & CLOUDABI_SUBSCRIPTION_ONESHOT) != 0) + kevp->flags |= EV_ONESHOT; + } + ++kevp; + } + return (0); +} + +/* Converts FreeBSD's struct kevent to CloudABI's event objects. */ +static int +cloudabi32_kevent_copyout(void *arg, struct kevent *kevp, int count) +{ + cloudabi32_event_t ev; + struct cloudabi32_kevent_args *args; + int error; + + args = arg; + while (count-- > 0) { + /* Convert fields that should always be present. */ + memset(&ev, 0, sizeof(ev)); + ev.userdata = (uintptr_t)kevp->udata; + switch (kevp->filter) { + case EVFILT_TIMER: + ev.type = CLOUDABI_EVENTTYPE_CLOCK; + ev.clock.identifier = kevp->ident; + break; + case EVFILT_READ: + ev.type = CLOUDABI_EVENTTYPE_FD_READ; + ev.fd_readwrite.fd = kevp->ident; + break; + case EVFILT_WRITE: + ev.type = CLOUDABI_EVENTTYPE_FD_WRITE; + ev.fd_readwrite.fd = kevp->ident; + break; + case EVFILT_PROCDESC: + ev.type = CLOUDABI_EVENTTYPE_PROC_TERMINATE; + ev.proc_terminate.fd = kevp->ident; + break; + } + + if ((kevp->flags & EV_ERROR) == 0) { + /* Success. */ + switch (kevp->filter) { + case EVFILT_READ: + case EVFILT_WRITE: + ev.fd_readwrite.nbytes = kevp->data; + if ((kevp->flags & EV_EOF) != 0) { + ev.fd_readwrite.flags |= + CLOUDABI_EVENT_FD_READWRITE_HANGUP; + } + break; + case EVFILT_PROCDESC: + if (WIFSIGNALED(kevp->data)) { + /* Process got signalled. */ + ev.proc_terminate.signal = + convert_signal(WTERMSIG(kevp->data)); + ev.proc_terminate.exitcode = 0; + } else { + /* Process exited. */ + ev.proc_terminate.signal = 0; + ev.proc_terminate.exitcode = + WEXITSTATUS(kevp->data); + } + break; + } + } else { + /* Error. */ + ev.error = cloudabi_convert_errno(kevp->data); + } + ++kevp; + + /* TODO(ed): Copy out multiple entries at once. */ + error = copyout(&ev, args->out++, sizeof(ev)); + if (error != 0) + return (error); + } + return (0); +} + +int +cloudabi32_sys_poll(struct thread *td, struct cloudabi32_sys_poll_args *uap) +{ + struct cloudabi32_kevent_args args = { + .in = uap->in, + .out = uap->out, + .once = true, + }; + struct kevent_copyops copyops = { + .k_copyin = cloudabi32_kevent_copyin, + .k_copyout = cloudabi32_kevent_copyout, + .arg = &args, + }; + + /* + * Bandaid to support CloudABI futex constructs that are not + * implemented through FreeBSD's kqueue(). + */ + if (uap->nsubscriptions == 1) { + cloudabi32_subscription_t sub; + cloudabi32_event_t ev = {}; + int error; + + error = copyin(uap->in, &sub, sizeof(sub)); + if (error != 0) + return (error); + ev.userdata = sub.userdata; + ev.type = sub.type; + if (sub.type == CLOUDABI_EVENTTYPE_CONDVAR) { + /* Wait on a condition variable. */ + ev.condvar.condvar = sub.condvar.condvar; + ev.error = cloudabi_convert_errno( + cloudabi_futex_condvar_wait( + td, TO_PTR(sub.condvar.condvar), + sub.condvar.condvar_scope, + TO_PTR(sub.condvar.lock), + sub.condvar.lock_scope, + CLOUDABI_CLOCK_MONOTONIC, UINT64_MAX, 0)); + td->td_retval[0] = 1; + return (copyout(&ev, uap->out, sizeof(ev))); + } else if (sub.type == CLOUDABI_EVENTTYPE_LOCK_RDLOCK) { + /* Acquire a read lock. */ + ev.lock.lock = sub.lock.lock; + ev.error = cloudabi_convert_errno( + cloudabi_futex_lock_rdlock( + td, TO_PTR(sub.lock.lock), + sub.lock.lock_scope, CLOUDABI_CLOCK_MONOTONIC, + UINT64_MAX, 0)); + td->td_retval[0] = 1; + return (copyout(&ev, uap->out, sizeof(ev))); + } else if (sub.type == CLOUDABI_EVENTTYPE_LOCK_WRLOCK) { + /* Acquire a write lock. */ + ev.lock.lock = sub.lock.lock; + ev.error = cloudabi_convert_errno( + cloudabi_futex_lock_wrlock( + td, TO_PTR(sub.lock.lock), + sub.lock.lock_scope, CLOUDABI_CLOCK_MONOTONIC, + UINT64_MAX, 0)); + td->td_retval[0] = 1; + return (copyout(&ev, uap->out, sizeof(ev))); + } + } else if (uap->nsubscriptions == 2) { + cloudabi32_subscription_t sub[2]; + cloudabi32_event_t ev[2] = {}; + int error; + + error = copyin(uap->in, &sub, sizeof(sub)); + if (error != 0) + return (error); + ev[0].userdata = sub[0].userdata; + ev[0].type = sub[0].type; + ev[1].userdata = sub[1].userdata; + ev[1].type = sub[1].type; + if (sub[0].type == CLOUDABI_EVENTTYPE_CONDVAR && + sub[1].type == CLOUDABI_EVENTTYPE_CLOCK && + sub[1].clock.flags == CLOUDABI_SUBSCRIPTION_CLOCK_ABSTIME) { + /* Wait for a condition variable with timeout. */ + ev[0].condvar.condvar = sub[0].condvar.condvar; + ev[1].clock.identifier = sub[1].clock.identifier; + error = cloudabi_futex_condvar_wait( + td, TO_PTR(sub[0].condvar.condvar), + sub[0].condvar.condvar_scope, + TO_PTR(sub[0].condvar.lock), + sub[0].condvar.lock_scope, sub[1].clock.clock_id, + sub[1].clock.timeout, sub[1].clock.precision); + if (error == ETIMEDOUT) { + td->td_retval[0] = 1; + return (copyout(&ev[1], uap->out, + sizeof(ev[1]))); + } + + ev[0].error = cloudabi_convert_errno(error); + td->td_retval[0] = 1; + return (copyout(&ev[0], uap->out, sizeof(ev[0]))); + } else if (sub[0].type == CLOUDABI_EVENTTYPE_LOCK_RDLOCK && + sub[1].type == CLOUDABI_EVENTTYPE_CLOCK && + sub[1].clock.flags == CLOUDABI_SUBSCRIPTION_CLOCK_ABSTIME) { + /* Acquire a read lock with a timeout. */ + ev[0].lock.lock = sub[0].lock.lock; + ev[1].clock.identifier = sub[1].clock.identifier; + error = cloudabi_futex_lock_rdlock( + td, TO_PTR(sub[0].lock.lock), + sub[0].lock.lock_scope, sub[1].clock.clock_id, + sub[1].clock.timeout, sub[1].clock.precision); + if (error == ETIMEDOUT) { + td->td_retval[0] = 1; + return (copyout(&ev[1], uap->out, + sizeof(ev[1]))); + } + + ev[0].error = cloudabi_convert_errno(error); + td->td_retval[0] = 1; + return (copyout(&ev[0], uap->out, sizeof(ev[0]))); + } else if (sub[0].type == CLOUDABI_EVENTTYPE_LOCK_WRLOCK && + sub[1].type == CLOUDABI_EVENTTYPE_CLOCK && + sub[1].clock.flags == CLOUDABI_SUBSCRIPTION_CLOCK_ABSTIME) { + /* Acquire a write lock with a timeout. */ + ev[0].lock.lock = sub[0].lock.lock; + ev[1].clock.identifier = sub[1].clock.identifier; + error = cloudabi_futex_lock_wrlock( + td, TO_PTR(sub[0].lock.lock), + sub[0].lock.lock_scope, sub[1].clock.clock_id, + sub[1].clock.timeout, sub[1].clock.precision); + if (error == ETIMEDOUT) { + td->td_retval[0] = 1; + return (copyout(&ev[1], uap->out, + sizeof(ev[1]))); + } + + ev[0].error = cloudabi_convert_errno(error); + td->td_retval[0] = 1; + return (copyout(&ev[0], uap->out, sizeof(ev[0]))); + } + } + + return (kern_kevent_anonymous(td, uap->nsubscriptions, ©ops)); +} + +int +cloudabi32_sys_poll_fd(struct thread *td, + struct cloudabi32_sys_poll_fd_args *uap) +{ + struct cloudabi32_kevent_args args = { + .in = uap->in, + .out = uap->out, + .once = false, + }; + struct kevent_copyops copyops = { + .k_copyin = cloudabi32_kevent_copyin, + .k_copyout = cloudabi32_kevent_copyout, + .arg = &args, + }; + cloudabi32_subscription_t subtimo; + struct timespec timeout; + int error; + + if (uap->timeout != NULL) { + /* Poll with a timeout. */ + error = copyin(uap->timeout, &subtimo, sizeof(subtimo)); + if (error != 0) + return (error); + if (subtimo.type != CLOUDABI_EVENTTYPE_CLOCK || + subtimo.clock.flags != 0) + return (EINVAL); + timeout.tv_sec = subtimo.clock.timeout / 1000000000; + timeout.tv_nsec = subtimo.clock.timeout % 1000000000; + return (kern_kevent(td, uap->fd, uap->nin, uap->nout, ©ops, + &timeout)); + } else { + /* Poll without a timeout. */ + return (kern_kevent(td, uap->fd, uap->nin, uap->nout, ©ops, + NULL)); + } +} diff --git a/sys/compat/cloudabi32/cloudabi32_proto.h b/sys/compat/cloudabi32/cloudabi32_proto.h new file mode 100644 index 0000000..3f028d5 --- /dev/null +++ b/sys/compat/cloudabi32/cloudabi32_proto.h @@ -0,0 +1,465 @@ +/* + * System call prototypes. + * + * DO NOT EDIT-- this file is automatically generated. + * $FreeBSD$ + * created from FreeBSD: head/sys/contrib/cloudabi/syscalls32.master 304563 2016-08-21 15:56:19Z ed + */ + +#ifndef _CLOUDABI32_SYSPROTO_H_ +#define _CLOUDABI32_SYSPROTO_H_ + +#include <sys/signal.h> +#include <sys/acl.h> +#include <sys/cpuset.h> +#include <sys/_ffcounter.h> +#include <sys/_semaphore.h> +#include <sys/ucontext.h> +#include <sys/wait.h> + +#include <bsm/audit_kevents.h> + +struct proc; + +struct thread; + +#define PAD_(t) (sizeof(register_t) <= sizeof(t) ? \ + 0 : sizeof(register_t) - sizeof(t)) + +#if BYTE_ORDER == LITTLE_ENDIAN +#define PADL_(t) 0 +#define PADR_(t) PAD_(t) +#else +#define PADL_(t) PAD_(t) +#define PADR_(t) 0 +#endif + +struct cloudabi_sys_clock_res_get_args { + char clock_id_l_[PADL_(cloudabi_clockid_t)]; cloudabi_clockid_t clock_id; char clock_id_r_[PADR_(cloudabi_clockid_t)]; +}; +struct cloudabi_sys_clock_time_get_args { + char clock_id_l_[PADL_(cloudabi_clockid_t)]; cloudabi_clockid_t clock_id; char clock_id_r_[PADR_(cloudabi_clockid_t)]; + char precision_l_[PADL_(cloudabi_timestamp_t)]; cloudabi_timestamp_t precision; char precision_r_[PADR_(cloudabi_timestamp_t)]; +}; +struct cloudabi_sys_condvar_signal_args { + char condvar_l_[PADL_(cloudabi_condvar_t *)]; cloudabi_condvar_t * condvar; char condvar_r_[PADR_(cloudabi_condvar_t *)]; + char scope_l_[PADL_(cloudabi_scope_t)]; cloudabi_scope_t scope; char scope_r_[PADR_(cloudabi_scope_t)]; + char nwaiters_l_[PADL_(cloudabi_nthreads_t)]; cloudabi_nthreads_t nwaiters; char nwaiters_r_[PADR_(cloudabi_nthreads_t)]; +}; +struct cloudabi_sys_fd_close_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; +}; +struct cloudabi_sys_fd_create1_args { + char type_l_[PADL_(cloudabi_filetype_t)]; cloudabi_filetype_t type; char type_r_[PADR_(cloudabi_filetype_t)]; +}; +struct cloudabi_sys_fd_create2_args { + char type_l_[PADL_(cloudabi_filetype_t)]; cloudabi_filetype_t type; char type_r_[PADR_(cloudabi_filetype_t)]; +}; +struct cloudabi_sys_fd_datasync_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; +}; +struct cloudabi_sys_fd_dup_args { + char from_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t from; char from_r_[PADR_(cloudabi_fd_t)]; +}; +struct cloudabi32_sys_fd_pread_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char iov_l_[PADL_(const cloudabi32_iovec_t *)]; const cloudabi32_iovec_t * iov; char iov_r_[PADR_(const cloudabi32_iovec_t *)]; + char iovcnt_l_[PADL_(size_t)]; size_t iovcnt; char iovcnt_r_[PADR_(size_t)]; + char offset_l_[PADL_(cloudabi_filesize_t)]; cloudabi_filesize_t offset; char offset_r_[PADR_(cloudabi_filesize_t)]; +}; +struct cloudabi32_sys_fd_pwrite_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char iov_l_[PADL_(const cloudabi32_ciovec_t *)]; const cloudabi32_ciovec_t * iov; char iov_r_[PADR_(const cloudabi32_ciovec_t *)]; + char iovcnt_l_[PADL_(size_t)]; size_t iovcnt; char iovcnt_r_[PADR_(size_t)]; + char offset_l_[PADL_(cloudabi_filesize_t)]; cloudabi_filesize_t offset; char offset_r_[PADR_(cloudabi_filesize_t)]; +}; +struct cloudabi32_sys_fd_read_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char iov_l_[PADL_(const cloudabi32_iovec_t *)]; const cloudabi32_iovec_t * iov; char iov_r_[PADR_(const cloudabi32_iovec_t *)]; + char iovcnt_l_[PADL_(size_t)]; size_t iovcnt; char iovcnt_r_[PADR_(size_t)]; +}; +struct cloudabi_sys_fd_replace_args { + char from_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t from; char from_r_[PADR_(cloudabi_fd_t)]; + char to_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t to; char to_r_[PADR_(cloudabi_fd_t)]; +}; +struct cloudabi_sys_fd_seek_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char offset_l_[PADL_(cloudabi_filedelta_t)]; cloudabi_filedelta_t offset; char offset_r_[PADR_(cloudabi_filedelta_t)]; + char whence_l_[PADL_(cloudabi_whence_t)]; cloudabi_whence_t whence; char whence_r_[PADR_(cloudabi_whence_t)]; +}; +struct cloudabi_sys_fd_stat_get_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char buf_l_[PADL_(cloudabi_fdstat_t *)]; cloudabi_fdstat_t * buf; char buf_r_[PADR_(cloudabi_fdstat_t *)]; +}; +struct cloudabi_sys_fd_stat_put_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char buf_l_[PADL_(const cloudabi_fdstat_t *)]; const cloudabi_fdstat_t * buf; char buf_r_[PADR_(const cloudabi_fdstat_t *)]; + char flags_l_[PADL_(cloudabi_fdsflags_t)]; cloudabi_fdsflags_t flags; char flags_r_[PADR_(cloudabi_fdsflags_t)]; +}; +struct cloudabi_sys_fd_sync_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; +}; +struct cloudabi32_sys_fd_write_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char iov_l_[PADL_(const cloudabi32_ciovec_t *)]; const cloudabi32_ciovec_t * iov; char iov_r_[PADR_(const cloudabi32_ciovec_t *)]; + char iovcnt_l_[PADL_(size_t)]; size_t iovcnt; char iovcnt_r_[PADR_(size_t)]; +}; +struct cloudabi_sys_file_advise_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char offset_l_[PADL_(cloudabi_filesize_t)]; cloudabi_filesize_t offset; char offset_r_[PADR_(cloudabi_filesize_t)]; + char len_l_[PADL_(cloudabi_filesize_t)]; cloudabi_filesize_t len; char len_r_[PADR_(cloudabi_filesize_t)]; + char advice_l_[PADL_(cloudabi_advice_t)]; cloudabi_advice_t advice; char advice_r_[PADR_(cloudabi_advice_t)]; +}; +struct cloudabi_sys_file_allocate_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char offset_l_[PADL_(cloudabi_filesize_t)]; cloudabi_filesize_t offset; char offset_r_[PADR_(cloudabi_filesize_t)]; + char len_l_[PADL_(cloudabi_filesize_t)]; cloudabi_filesize_t len; char len_r_[PADR_(cloudabi_filesize_t)]; +}; +struct cloudabi_sys_file_create_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; + char pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)]; + char type_l_[PADL_(cloudabi_filetype_t)]; cloudabi_filetype_t type; char type_r_[PADR_(cloudabi_filetype_t)]; +}; +struct cloudabi_sys_file_link_args { + char fd1_l_[PADL_(cloudabi_lookup_t)]; cloudabi_lookup_t fd1; char fd1_r_[PADR_(cloudabi_lookup_t)]; + char path1_l_[PADL_(const char *)]; const char * path1; char path1_r_[PADR_(const char *)]; + char path1len_l_[PADL_(size_t)]; size_t path1len; char path1len_r_[PADR_(size_t)]; + char fd2_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd2; char fd2_r_[PADR_(cloudabi_fd_t)]; + char path2_l_[PADL_(const char *)]; const char * path2; char path2_r_[PADR_(const char *)]; + char path2len_l_[PADL_(size_t)]; size_t path2len; char path2len_r_[PADR_(size_t)]; +}; +struct cloudabi_sys_file_open_args { + char dirfd_l_[PADL_(cloudabi_lookup_t)]; cloudabi_lookup_t dirfd; char dirfd_r_[PADR_(cloudabi_lookup_t)]; + char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; + char pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)]; + char oflags_l_[PADL_(cloudabi_oflags_t)]; cloudabi_oflags_t oflags; char oflags_r_[PADR_(cloudabi_oflags_t)]; + char fds_l_[PADL_(const cloudabi_fdstat_t *)]; const cloudabi_fdstat_t * fds; char fds_r_[PADR_(const cloudabi_fdstat_t *)]; +}; +struct cloudabi_sys_file_readdir_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char buf_l_[PADL_(void *)]; void * buf; char buf_r_[PADR_(void *)]; + char nbyte_l_[PADL_(size_t)]; size_t nbyte; char nbyte_r_[PADR_(size_t)]; + char cookie_l_[PADL_(cloudabi_dircookie_t)]; cloudabi_dircookie_t cookie; char cookie_r_[PADR_(cloudabi_dircookie_t)]; +}; +struct cloudabi_sys_file_readlink_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; + char pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)]; + char buf_l_[PADL_(char *)]; char * buf; char buf_r_[PADR_(char *)]; + char bufsize_l_[PADL_(size_t)]; size_t bufsize; char bufsize_r_[PADR_(size_t)]; +}; +struct cloudabi_sys_file_rename_args { + char oldfd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t oldfd; char oldfd_r_[PADR_(cloudabi_fd_t)]; + char old_l_[PADL_(const char *)]; const char * old; char old_r_[PADR_(const char *)]; + char oldlen_l_[PADL_(size_t)]; size_t oldlen; char oldlen_r_[PADR_(size_t)]; + char newfd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t newfd; char newfd_r_[PADR_(cloudabi_fd_t)]; + char new_l_[PADL_(const char *)]; const char * new; char new_r_[PADR_(const char *)]; + char newlen_l_[PADL_(size_t)]; size_t newlen; char newlen_r_[PADR_(size_t)]; +}; +struct cloudabi_sys_file_stat_fget_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char buf_l_[PADL_(cloudabi_filestat_t *)]; cloudabi_filestat_t * buf; char buf_r_[PADR_(cloudabi_filestat_t *)]; +}; +struct cloudabi_sys_file_stat_fput_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char buf_l_[PADL_(const cloudabi_filestat_t *)]; const cloudabi_filestat_t * buf; char buf_r_[PADR_(const cloudabi_filestat_t *)]; + char flags_l_[PADL_(cloudabi_fsflags_t)]; cloudabi_fsflags_t flags; char flags_r_[PADR_(cloudabi_fsflags_t)]; +}; +struct cloudabi_sys_file_stat_get_args { + char fd_l_[PADL_(cloudabi_lookup_t)]; cloudabi_lookup_t fd; char fd_r_[PADR_(cloudabi_lookup_t)]; + char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; + char pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)]; + char buf_l_[PADL_(cloudabi_filestat_t *)]; cloudabi_filestat_t * buf; char buf_r_[PADR_(cloudabi_filestat_t *)]; +}; +struct cloudabi_sys_file_stat_put_args { + char fd_l_[PADL_(cloudabi_lookup_t)]; cloudabi_lookup_t fd; char fd_r_[PADR_(cloudabi_lookup_t)]; + char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; + char pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)]; + char buf_l_[PADL_(const cloudabi_filestat_t *)]; const cloudabi_filestat_t * buf; char buf_r_[PADR_(const cloudabi_filestat_t *)]; + char flags_l_[PADL_(cloudabi_fsflags_t)]; cloudabi_fsflags_t flags; char flags_r_[PADR_(cloudabi_fsflags_t)]; +}; +struct cloudabi_sys_file_symlink_args { + char path1_l_[PADL_(const char *)]; const char * path1; char path1_r_[PADR_(const char *)]; + char path1len_l_[PADL_(size_t)]; size_t path1len; char path1len_r_[PADR_(size_t)]; + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char path2_l_[PADL_(const char *)]; const char * path2; char path2_r_[PADR_(const char *)]; + char path2len_l_[PADL_(size_t)]; size_t path2len; char path2len_r_[PADR_(size_t)]; +}; +struct cloudabi_sys_file_unlink_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; + char pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)]; + char flags_l_[PADL_(cloudabi_ulflags_t)]; cloudabi_ulflags_t flags; char flags_r_[PADR_(cloudabi_ulflags_t)]; +}; +struct cloudabi_sys_lock_unlock_args { + char lock_l_[PADL_(cloudabi_lock_t *)]; cloudabi_lock_t * lock; char lock_r_[PADR_(cloudabi_lock_t *)]; + char scope_l_[PADL_(cloudabi_scope_t)]; cloudabi_scope_t scope; char scope_r_[PADR_(cloudabi_scope_t)]; +}; +struct cloudabi_sys_mem_advise_args { + char addr_l_[PADL_(void *)]; void * addr; char addr_r_[PADR_(void *)]; + char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; + char advice_l_[PADL_(cloudabi_advice_t)]; cloudabi_advice_t advice; char advice_r_[PADR_(cloudabi_advice_t)]; +}; +struct cloudabi_sys_mem_lock_args { + char addr_l_[PADL_(const void *)]; const void * addr; char addr_r_[PADR_(const void *)]; + char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; +}; +struct cloudabi_sys_mem_map_args { + char addr_l_[PADL_(void *)]; void * addr; char addr_r_[PADR_(void *)]; + char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; + char prot_l_[PADL_(cloudabi_mprot_t)]; cloudabi_mprot_t prot; char prot_r_[PADR_(cloudabi_mprot_t)]; + char flags_l_[PADL_(cloudabi_mflags_t)]; cloudabi_mflags_t flags; char flags_r_[PADR_(cloudabi_mflags_t)]; + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char off_l_[PADL_(cloudabi_filesize_t)]; cloudabi_filesize_t off; char off_r_[PADR_(cloudabi_filesize_t)]; +}; +struct cloudabi_sys_mem_protect_args { + char addr_l_[PADL_(void *)]; void * addr; char addr_r_[PADR_(void *)]; + char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; + char prot_l_[PADL_(cloudabi_mprot_t)]; cloudabi_mprot_t prot; char prot_r_[PADR_(cloudabi_mprot_t)]; +}; +struct cloudabi_sys_mem_sync_args { + char addr_l_[PADL_(void *)]; void * addr; char addr_r_[PADR_(void *)]; + char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; + char flags_l_[PADL_(cloudabi_msflags_t)]; cloudabi_msflags_t flags; char flags_r_[PADR_(cloudabi_msflags_t)]; +}; +struct cloudabi_sys_mem_unlock_args { + char addr_l_[PADL_(const void *)]; const void * addr; char addr_r_[PADR_(const void *)]; + char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; +}; +struct cloudabi_sys_mem_unmap_args { + char addr_l_[PADL_(void *)]; void * addr; char addr_r_[PADR_(void *)]; + char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; +}; +struct cloudabi32_sys_poll_args { + char in_l_[PADL_(const cloudabi32_subscription_t *)]; const cloudabi32_subscription_t * in; char in_r_[PADR_(const cloudabi32_subscription_t *)]; + char out_l_[PADL_(cloudabi32_event_t *)]; cloudabi32_event_t * out; char out_r_[PADR_(cloudabi32_event_t *)]; + char nsubscriptions_l_[PADL_(size_t)]; size_t nsubscriptions; char nsubscriptions_r_[PADR_(size_t)]; +}; +struct cloudabi32_sys_poll_fd_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char in_l_[PADL_(const cloudabi32_subscription_t *)]; const cloudabi32_subscription_t * in; char in_r_[PADR_(const cloudabi32_subscription_t *)]; + char nin_l_[PADL_(size_t)]; size_t nin; char nin_r_[PADR_(size_t)]; + char out_l_[PADL_(cloudabi32_event_t *)]; cloudabi32_event_t * out; char out_r_[PADR_(cloudabi32_event_t *)]; + char nout_l_[PADL_(size_t)]; size_t nout; char nout_r_[PADR_(size_t)]; + char timeout_l_[PADL_(const cloudabi32_subscription_t *)]; const cloudabi32_subscription_t * timeout; char timeout_r_[PADR_(const cloudabi32_subscription_t *)]; +}; +struct cloudabi_sys_proc_exec_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char data_l_[PADL_(const void *)]; const void * data; char data_r_[PADR_(const void *)]; + char datalen_l_[PADL_(size_t)]; size_t datalen; char datalen_r_[PADR_(size_t)]; + char fds_l_[PADL_(const cloudabi_fd_t *)]; const cloudabi_fd_t * fds; char fds_r_[PADR_(const cloudabi_fd_t *)]; + char fdslen_l_[PADL_(size_t)]; size_t fdslen; char fdslen_r_[PADR_(size_t)]; +}; +struct cloudabi_sys_proc_exit_args { + char rval_l_[PADL_(cloudabi_exitcode_t)]; cloudabi_exitcode_t rval; char rval_r_[PADR_(cloudabi_exitcode_t)]; +}; +struct cloudabi_sys_proc_fork_args { + register_t dummy; +}; +struct cloudabi_sys_proc_raise_args { + char sig_l_[PADL_(cloudabi_signal_t)]; cloudabi_signal_t sig; char sig_r_[PADR_(cloudabi_signal_t)]; +}; +struct cloudabi_sys_random_get_args { + char buf_l_[PADL_(void *)]; void * buf; char buf_r_[PADR_(void *)]; + char nbyte_l_[PADL_(size_t)]; size_t nbyte; char nbyte_r_[PADR_(size_t)]; +}; +struct cloudabi_sys_sock_accept_args { + char sock_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t sock; char sock_r_[PADR_(cloudabi_fd_t)]; + char buf_l_[PADL_(cloudabi_sockstat_t *)]; cloudabi_sockstat_t * buf; char buf_r_[PADR_(cloudabi_sockstat_t *)]; +}; +struct cloudabi_sys_sock_bind_args { + char sock_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t sock; char sock_r_[PADR_(cloudabi_fd_t)]; + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; + char pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)]; +}; +struct cloudabi_sys_sock_connect_args { + char sock_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t sock; char sock_r_[PADR_(cloudabi_fd_t)]; + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; + char pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)]; +}; +struct cloudabi_sys_sock_listen_args { + char sock_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t sock; char sock_r_[PADR_(cloudabi_fd_t)]; + char backlog_l_[PADL_(cloudabi_backlog_t)]; cloudabi_backlog_t backlog; char backlog_r_[PADR_(cloudabi_backlog_t)]; +}; +struct cloudabi32_sys_sock_recv_args { + char sock_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t sock; char sock_r_[PADR_(cloudabi_fd_t)]; + char in_l_[PADL_(const cloudabi32_recv_in_t *)]; const cloudabi32_recv_in_t * in; char in_r_[PADR_(const cloudabi32_recv_in_t *)]; + char out_l_[PADL_(cloudabi32_recv_out_t *)]; cloudabi32_recv_out_t * out; char out_r_[PADR_(cloudabi32_recv_out_t *)]; +}; +struct cloudabi32_sys_sock_send_args { + char sock_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t sock; char sock_r_[PADR_(cloudabi_fd_t)]; + char in_l_[PADL_(const cloudabi32_send_in_t *)]; const cloudabi32_send_in_t * in; char in_r_[PADR_(const cloudabi32_send_in_t *)]; + char out_l_[PADL_(cloudabi32_send_out_t *)]; cloudabi32_send_out_t * out; char out_r_[PADR_(cloudabi32_send_out_t *)]; +}; +struct cloudabi_sys_sock_shutdown_args { + char sock_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t sock; char sock_r_[PADR_(cloudabi_fd_t)]; + char how_l_[PADL_(cloudabi_sdflags_t)]; cloudabi_sdflags_t how; char how_r_[PADR_(cloudabi_sdflags_t)]; +}; +struct cloudabi_sys_sock_stat_get_args { + char sock_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t sock; char sock_r_[PADR_(cloudabi_fd_t)]; + char buf_l_[PADL_(cloudabi_sockstat_t *)]; cloudabi_sockstat_t * buf; char buf_r_[PADR_(cloudabi_sockstat_t *)]; + char flags_l_[PADL_(cloudabi_ssflags_t)]; cloudabi_ssflags_t flags; char flags_r_[PADR_(cloudabi_ssflags_t)]; +}; +struct cloudabi32_sys_thread_create_args { + char attr_l_[PADL_(cloudabi32_threadattr_t *)]; cloudabi32_threadattr_t * attr; char attr_r_[PADR_(cloudabi32_threadattr_t *)]; +}; +struct cloudabi_sys_thread_exit_args { + char lock_l_[PADL_(cloudabi_lock_t *)]; cloudabi_lock_t * lock; char lock_r_[PADR_(cloudabi_lock_t *)]; + char scope_l_[PADL_(cloudabi_scope_t)]; cloudabi_scope_t scope; char scope_r_[PADR_(cloudabi_scope_t)]; +}; +struct cloudabi_sys_thread_yield_args { + register_t dummy; +}; +int cloudabi_sys_clock_res_get(struct thread *, struct cloudabi_sys_clock_res_get_args *); +int cloudabi_sys_clock_time_get(struct thread *, struct cloudabi_sys_clock_time_get_args *); +int cloudabi_sys_condvar_signal(struct thread *, struct cloudabi_sys_condvar_signal_args *); +int cloudabi_sys_fd_close(struct thread *, struct cloudabi_sys_fd_close_args *); +int cloudabi_sys_fd_create1(struct thread *, struct cloudabi_sys_fd_create1_args *); +int cloudabi_sys_fd_create2(struct thread *, struct cloudabi_sys_fd_create2_args *); +int cloudabi_sys_fd_datasync(struct thread *, struct cloudabi_sys_fd_datasync_args *); +int cloudabi_sys_fd_dup(struct thread *, struct cloudabi_sys_fd_dup_args *); +int cloudabi32_sys_fd_pread(struct thread *, struct cloudabi32_sys_fd_pread_args *); +int cloudabi32_sys_fd_pwrite(struct thread *, struct cloudabi32_sys_fd_pwrite_args *); +int cloudabi32_sys_fd_read(struct thread *, struct cloudabi32_sys_fd_read_args *); +int cloudabi_sys_fd_replace(struct thread *, struct cloudabi_sys_fd_replace_args *); +int cloudabi_sys_fd_seek(struct thread *, struct cloudabi_sys_fd_seek_args *); +int cloudabi_sys_fd_stat_get(struct thread *, struct cloudabi_sys_fd_stat_get_args *); +int cloudabi_sys_fd_stat_put(struct thread *, struct cloudabi_sys_fd_stat_put_args *); +int cloudabi_sys_fd_sync(struct thread *, struct cloudabi_sys_fd_sync_args *); +int cloudabi32_sys_fd_write(struct thread *, struct cloudabi32_sys_fd_write_args *); +int cloudabi_sys_file_advise(struct thread *, struct cloudabi_sys_file_advise_args *); +int cloudabi_sys_file_allocate(struct thread *, struct cloudabi_sys_file_allocate_args *); +int cloudabi_sys_file_create(struct thread *, struct cloudabi_sys_file_create_args *); +int cloudabi_sys_file_link(struct thread *, struct cloudabi_sys_file_link_args *); +int cloudabi_sys_file_open(struct thread *, struct cloudabi_sys_file_open_args *); +int cloudabi_sys_file_readdir(struct thread *, struct cloudabi_sys_file_readdir_args *); +int cloudabi_sys_file_readlink(struct thread *, struct cloudabi_sys_file_readlink_args *); +int cloudabi_sys_file_rename(struct thread *, struct cloudabi_sys_file_rename_args *); +int cloudabi_sys_file_stat_fget(struct thread *, struct cloudabi_sys_file_stat_fget_args *); +int cloudabi_sys_file_stat_fput(struct thread *, struct cloudabi_sys_file_stat_fput_args *); +int cloudabi_sys_file_stat_get(struct thread *, struct cloudabi_sys_file_stat_get_args *); +int cloudabi_sys_file_stat_put(struct thread *, struct cloudabi_sys_file_stat_put_args *); +int cloudabi_sys_file_symlink(struct thread *, struct cloudabi_sys_file_symlink_args *); +int cloudabi_sys_file_unlink(struct thread *, struct cloudabi_sys_file_unlink_args *); +int cloudabi_sys_lock_unlock(struct thread *, struct cloudabi_sys_lock_unlock_args *); +int cloudabi_sys_mem_advise(struct thread *, struct cloudabi_sys_mem_advise_args *); +int cloudabi_sys_mem_lock(struct thread *, struct cloudabi_sys_mem_lock_args *); +int cloudabi_sys_mem_map(struct thread *, struct cloudabi_sys_mem_map_args *); +int cloudabi_sys_mem_protect(struct thread *, struct cloudabi_sys_mem_protect_args *); +int cloudabi_sys_mem_sync(struct thread *, struct cloudabi_sys_mem_sync_args *); +int cloudabi_sys_mem_unlock(struct thread *, struct cloudabi_sys_mem_unlock_args *); +int cloudabi_sys_mem_unmap(struct thread *, struct cloudabi_sys_mem_unmap_args *); +int cloudabi32_sys_poll(struct thread *, struct cloudabi32_sys_poll_args *); +int cloudabi32_sys_poll_fd(struct thread *, struct cloudabi32_sys_poll_fd_args *); +int cloudabi_sys_proc_exec(struct thread *, struct cloudabi_sys_proc_exec_args *); +int cloudabi_sys_proc_exit(struct thread *, struct cloudabi_sys_proc_exit_args *); +int cloudabi_sys_proc_fork(struct thread *, struct cloudabi_sys_proc_fork_args *); +int cloudabi_sys_proc_raise(struct thread *, struct cloudabi_sys_proc_raise_args *); +int cloudabi_sys_random_get(struct thread *, struct cloudabi_sys_random_get_args *); +int cloudabi_sys_sock_accept(struct thread *, struct cloudabi_sys_sock_accept_args *); +int cloudabi_sys_sock_bind(struct thread *, struct cloudabi_sys_sock_bind_args *); +int cloudabi_sys_sock_connect(struct thread *, struct cloudabi_sys_sock_connect_args *); +int cloudabi_sys_sock_listen(struct thread *, struct cloudabi_sys_sock_listen_args *); +int cloudabi32_sys_sock_recv(struct thread *, struct cloudabi32_sys_sock_recv_args *); +int cloudabi32_sys_sock_send(struct thread *, struct cloudabi32_sys_sock_send_args *); +int cloudabi_sys_sock_shutdown(struct thread *, struct cloudabi_sys_sock_shutdown_args *); +int cloudabi_sys_sock_stat_get(struct thread *, struct cloudabi_sys_sock_stat_get_args *); +int cloudabi32_sys_thread_create(struct thread *, struct cloudabi32_sys_thread_create_args *); +int cloudabi_sys_thread_exit(struct thread *, struct cloudabi_sys_thread_exit_args *); +int cloudabi_sys_thread_yield(struct thread *, struct cloudabi_sys_thread_yield_args *); + +#ifdef COMPAT_43 + + +#endif /* COMPAT_43 */ + + +#ifdef COMPAT_FREEBSD4 + + +#endif /* COMPAT_FREEBSD4 */ + + +#ifdef COMPAT_FREEBSD6 + + +#endif /* COMPAT_FREEBSD6 */ + + +#ifdef COMPAT_FREEBSD7 + + +#endif /* COMPAT_FREEBSD7 */ + + +#ifdef COMPAT_FREEBSD10 + + +#endif /* COMPAT_FREEBSD10 */ + +#define CLOUDABI32_SYS_AUE_cloudabi_sys_clock_res_get AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_clock_time_get AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_condvar_signal AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_fd_close AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_fd_create1 AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_fd_create2 AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_fd_datasync AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_fd_dup AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi32_sys_fd_pread AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi32_sys_fd_pwrite AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi32_sys_fd_read AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_fd_replace AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_fd_seek AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_fd_stat_get AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_fd_stat_put AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_fd_sync AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi32_sys_fd_write AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_advise AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_allocate AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_create AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_link AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_open AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_readdir AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_readlink AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_rename AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_stat_fget AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_stat_fput AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_stat_get AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_stat_put AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_symlink AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_unlink AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_lock_unlock AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_mem_advise AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_mem_lock AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_mem_map AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_mem_protect AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_mem_sync AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_mem_unlock AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_mem_unmap AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi32_sys_poll AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi32_sys_poll_fd AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_proc_exec AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_proc_exit AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_proc_fork AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_proc_raise AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_random_get AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_sock_accept AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_sock_bind AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_sock_connect AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_sock_listen AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi32_sys_sock_recv AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi32_sys_sock_send AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_sock_shutdown AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_sock_stat_get AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi32_sys_thread_create AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_thread_exit AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_thread_yield AUE_NULL + +#undef PAD_ +#undef PADL_ +#undef PADR_ + +#endif /* !_CLOUDABI32_SYSPROTO_H_ */ diff --git a/sys/compat/cloudabi32/cloudabi32_sock.c b/sys/compat/cloudabi32/cloudabi32_sock.c new file mode 100644 index 0000000..24ed32c --- /dev/null +++ b/sys/compat/cloudabi32/cloudabi32_sock.c @@ -0,0 +1,148 @@ +/*- + * Copyright (c) 2015 Nuxi, https://nuxi.nl/ + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/param.h> +#include <sys/kernel.h> +#include <sys/malloc.h> +#include <sys/proc.h> +#include <sys/socket.h> +#include <sys/syscallsubr.h> +#include <sys/systm.h> +#include <sys/uio.h> + +#include <contrib/cloudabi/cloudabi32_types.h> + +#include <compat/cloudabi/cloudabi_util.h> + +#include <compat/cloudabi32/cloudabi32_proto.h> +#include <compat/cloudabi32/cloudabi32_util.h> + +static MALLOC_DEFINE(M_SOCKET, "socket", "CloudABI socket"); + +int +cloudabi32_sys_sock_recv(struct thread *td, + struct cloudabi32_sys_sock_recv_args *uap) +{ + struct sockaddr_storage ss; + cloudabi32_recv_in_t ri; + cloudabi32_recv_out_t ro = {}; + cloudabi32_iovec_t iovobj; + struct msghdr msghdr = {}; + const cloudabi32_iovec_t *user_iov; + size_t i; + int error; + + error = copyin(uap->in, &ri, sizeof(ri)); + if (error != 0) + return (error); + + /* Convert results in cloudabi_recv_in_t to struct msghdr. */ + if (ri.ri_datalen > UIO_MAXIOV) + return (EINVAL); + msghdr.msg_iovlen = ri.ri_datalen; + msghdr.msg_iov = malloc(msghdr.msg_iovlen * sizeof(struct iovec), + M_SOCKET, M_WAITOK); + user_iov = TO_PTR(ri.ri_data); + for (i = 0; i < msghdr.msg_iovlen; i++) { + error = copyin(&user_iov[i], &iovobj, sizeof(iovobj)); + if (error != 0) { + free(msghdr.msg_iov, M_SOCKET); + return (error); + } + msghdr.msg_iov[i].iov_base = TO_PTR(iovobj.iov_base); + msghdr.msg_iov[i].iov_len = iovobj.iov_len; + } + msghdr.msg_name = &ss; + msghdr.msg_namelen = sizeof(ss); + if (ri.ri_flags & CLOUDABI_MSG_PEEK) + msghdr.msg_flags |= MSG_PEEK; + if (ri.ri_flags & CLOUDABI_MSG_WAITALL) + msghdr.msg_flags |= MSG_WAITALL; + + /* TODO(ed): Add file descriptor passing. */ + error = kern_recvit(td, uap->sock, &msghdr, UIO_SYSSPACE, NULL); + free(msghdr.msg_iov, M_SOCKET); + if (error != 0) + return (error); + + /* Convert results in msghdr to cloudabi_recv_out_t. */ + ro.ro_datalen = td->td_retval[0]; + cloudabi_convert_sockaddr((struct sockaddr *)&ss, + MIN(msghdr.msg_namelen, sizeof(ss)), &ro.ro_peername); + td->td_retval[0] = 0; + return (copyout(&ro, uap->out, sizeof(ro))); +} + +int +cloudabi32_sys_sock_send(struct thread *td, + struct cloudabi32_sys_sock_send_args *uap) +{ + cloudabi32_send_in_t si; + cloudabi32_send_out_t so = {}; + cloudabi32_ciovec_t iovobj; + struct msghdr msghdr = {}; + const cloudabi32_ciovec_t *user_iov; + size_t i; + int error, flags; + + error = copyin(uap->in, &si, sizeof(si)); + if (error != 0) + return (error); + + /* Convert results in cloudabi_send_in_t to struct msghdr. */ + if (si.si_datalen > UIO_MAXIOV) + return (EINVAL); + msghdr.msg_iovlen = si.si_datalen; + msghdr.msg_iov = malloc(msghdr.msg_iovlen * sizeof(struct iovec), + M_SOCKET, M_WAITOK); + user_iov = TO_PTR(si.si_data); + for (i = 0; i < msghdr.msg_iovlen; i++) { + error = copyin(&user_iov[i], &iovobj, sizeof(iovobj)); + if (error != 0) { + free(msghdr.msg_iov, M_SOCKET); + return (error); + } + msghdr.msg_iov[i].iov_base = TO_PTR(iovobj.iov_base); + msghdr.msg_iov[i].iov_len = iovobj.iov_len; + } + + flags = MSG_NOSIGNAL; + if (si.si_flags & CLOUDABI_MSG_EOR) + flags |= MSG_EOR; + + /* TODO(ed): Add file descriptor passing. */ + error = kern_sendit(td, uap->sock, &msghdr, flags, NULL, UIO_USERSPACE); + free(msghdr.msg_iov, M_SOCKET); + if (error != 0) + return (error); + + /* Convert results in msghdr to cloudabi_send_out_t. */ + so.so_datalen = td->td_retval[0]; + td->td_retval[0] = 0; + return (copyout(&so, uap->out, sizeof(so))); +} diff --git a/sys/compat/cloudabi32/cloudabi32_syscall.h b/sys/compat/cloudabi32/cloudabi32_syscall.h new file mode 100644 index 0000000..4cba6fd --- /dev/null +++ b/sys/compat/cloudabi32/cloudabi32_syscall.h @@ -0,0 +1,66 @@ +/* + * System call numbers. + * + * DO NOT EDIT-- this file is automatically generated. + * $FreeBSD$ + * created from FreeBSD: head/sys/contrib/cloudabi/syscalls32.master 304563 2016-08-21 15:56:19Z ed + */ + +#define CLOUDABI32_SYS_cloudabi_sys_clock_res_get 0 +#define CLOUDABI32_SYS_cloudabi_sys_clock_time_get 1 +#define CLOUDABI32_SYS_cloudabi_sys_condvar_signal 2 +#define CLOUDABI32_SYS_cloudabi_sys_fd_close 3 +#define CLOUDABI32_SYS_cloudabi_sys_fd_create1 4 +#define CLOUDABI32_SYS_cloudabi_sys_fd_create2 5 +#define CLOUDABI32_SYS_cloudabi_sys_fd_datasync 6 +#define CLOUDABI32_SYS_cloudabi_sys_fd_dup 7 +#define CLOUDABI32_SYS_cloudabi32_sys_fd_pread 8 +#define CLOUDABI32_SYS_cloudabi32_sys_fd_pwrite 9 +#define CLOUDABI32_SYS_cloudabi32_sys_fd_read 10 +#define CLOUDABI32_SYS_cloudabi_sys_fd_replace 11 +#define CLOUDABI32_SYS_cloudabi_sys_fd_seek 12 +#define CLOUDABI32_SYS_cloudabi_sys_fd_stat_get 13 +#define CLOUDABI32_SYS_cloudabi_sys_fd_stat_put 14 +#define CLOUDABI32_SYS_cloudabi_sys_fd_sync 15 +#define CLOUDABI32_SYS_cloudabi32_sys_fd_write 16 +#define CLOUDABI32_SYS_cloudabi_sys_file_advise 17 +#define CLOUDABI32_SYS_cloudabi_sys_file_allocate 18 +#define CLOUDABI32_SYS_cloudabi_sys_file_create 19 +#define CLOUDABI32_SYS_cloudabi_sys_file_link 20 +#define CLOUDABI32_SYS_cloudabi_sys_file_open 21 +#define CLOUDABI32_SYS_cloudabi_sys_file_readdir 22 +#define CLOUDABI32_SYS_cloudabi_sys_file_readlink 23 +#define CLOUDABI32_SYS_cloudabi_sys_file_rename 24 +#define CLOUDABI32_SYS_cloudabi_sys_file_stat_fget 25 +#define CLOUDABI32_SYS_cloudabi_sys_file_stat_fput 26 +#define CLOUDABI32_SYS_cloudabi_sys_file_stat_get 27 +#define CLOUDABI32_SYS_cloudabi_sys_file_stat_put 28 +#define CLOUDABI32_SYS_cloudabi_sys_file_symlink 29 +#define CLOUDABI32_SYS_cloudabi_sys_file_unlink 30 +#define CLOUDABI32_SYS_cloudabi_sys_lock_unlock 31 +#define CLOUDABI32_SYS_cloudabi_sys_mem_advise 32 +#define CLOUDABI32_SYS_cloudabi_sys_mem_lock 33 +#define CLOUDABI32_SYS_cloudabi_sys_mem_map 34 +#define CLOUDABI32_SYS_cloudabi_sys_mem_protect 35 +#define CLOUDABI32_SYS_cloudabi_sys_mem_sync 36 +#define CLOUDABI32_SYS_cloudabi_sys_mem_unlock 37 +#define CLOUDABI32_SYS_cloudabi_sys_mem_unmap 38 +#define CLOUDABI32_SYS_cloudabi32_sys_poll 39 +#define CLOUDABI32_SYS_cloudabi32_sys_poll_fd 40 +#define CLOUDABI32_SYS_cloudabi_sys_proc_exec 41 +#define CLOUDABI32_SYS_cloudabi_sys_proc_exit 42 +#define CLOUDABI32_SYS_cloudabi_sys_proc_fork 43 +#define CLOUDABI32_SYS_cloudabi_sys_proc_raise 44 +#define CLOUDABI32_SYS_cloudabi_sys_random_get 45 +#define CLOUDABI32_SYS_cloudabi_sys_sock_accept 46 +#define CLOUDABI32_SYS_cloudabi_sys_sock_bind 47 +#define CLOUDABI32_SYS_cloudabi_sys_sock_connect 48 +#define CLOUDABI32_SYS_cloudabi_sys_sock_listen 49 +#define CLOUDABI32_SYS_cloudabi32_sys_sock_recv 50 +#define CLOUDABI32_SYS_cloudabi32_sys_sock_send 51 +#define CLOUDABI32_SYS_cloudabi_sys_sock_shutdown 52 +#define CLOUDABI32_SYS_cloudabi_sys_sock_stat_get 53 +#define CLOUDABI32_SYS_cloudabi32_sys_thread_create 54 +#define CLOUDABI32_SYS_cloudabi_sys_thread_exit 55 +#define CLOUDABI32_SYS_cloudabi_sys_thread_yield 56 +#define CLOUDABI32_SYS_MAXSYSCALL 57 diff --git a/sys/compat/cloudabi32/cloudabi32_syscalls.c b/sys/compat/cloudabi32/cloudabi32_syscalls.c new file mode 100644 index 0000000..56a46fb --- /dev/null +++ b/sys/compat/cloudabi32/cloudabi32_syscalls.c @@ -0,0 +1,67 @@ +/* + * System call names. + * + * DO NOT EDIT-- this file is automatically generated. + * $FreeBSD$ + * created from FreeBSD: head/sys/contrib/cloudabi/syscalls32.master 304563 2016-08-21 15:56:19Z ed + */ + +const char *cloudabi32_syscallnames[] = { + "cloudabi_sys_clock_res_get", /* 0 = cloudabi_sys_clock_res_get */ + "cloudabi_sys_clock_time_get", /* 1 = cloudabi_sys_clock_time_get */ + "cloudabi_sys_condvar_signal", /* 2 = cloudabi_sys_condvar_signal */ + "cloudabi_sys_fd_close", /* 3 = cloudabi_sys_fd_close */ + "cloudabi_sys_fd_create1", /* 4 = cloudabi_sys_fd_create1 */ + "cloudabi_sys_fd_create2", /* 5 = cloudabi_sys_fd_create2 */ + "cloudabi_sys_fd_datasync", /* 6 = cloudabi_sys_fd_datasync */ + "cloudabi_sys_fd_dup", /* 7 = cloudabi_sys_fd_dup */ + "cloudabi32_sys_fd_pread", /* 8 = cloudabi32_sys_fd_pread */ + "cloudabi32_sys_fd_pwrite", /* 9 = cloudabi32_sys_fd_pwrite */ + "cloudabi32_sys_fd_read", /* 10 = cloudabi32_sys_fd_read */ + "cloudabi_sys_fd_replace", /* 11 = cloudabi_sys_fd_replace */ + "cloudabi_sys_fd_seek", /* 12 = cloudabi_sys_fd_seek */ + "cloudabi_sys_fd_stat_get", /* 13 = cloudabi_sys_fd_stat_get */ + "cloudabi_sys_fd_stat_put", /* 14 = cloudabi_sys_fd_stat_put */ + "cloudabi_sys_fd_sync", /* 15 = cloudabi_sys_fd_sync */ + "cloudabi32_sys_fd_write", /* 16 = cloudabi32_sys_fd_write */ + "cloudabi_sys_file_advise", /* 17 = cloudabi_sys_file_advise */ + "cloudabi_sys_file_allocate", /* 18 = cloudabi_sys_file_allocate */ + "cloudabi_sys_file_create", /* 19 = cloudabi_sys_file_create */ + "cloudabi_sys_file_link", /* 20 = cloudabi_sys_file_link */ + "cloudabi_sys_file_open", /* 21 = cloudabi_sys_file_open */ + "cloudabi_sys_file_readdir", /* 22 = cloudabi_sys_file_readdir */ + "cloudabi_sys_file_readlink", /* 23 = cloudabi_sys_file_readlink */ + "cloudabi_sys_file_rename", /* 24 = cloudabi_sys_file_rename */ + "cloudabi_sys_file_stat_fget", /* 25 = cloudabi_sys_file_stat_fget */ + "cloudabi_sys_file_stat_fput", /* 26 = cloudabi_sys_file_stat_fput */ + "cloudabi_sys_file_stat_get", /* 27 = cloudabi_sys_file_stat_get */ + "cloudabi_sys_file_stat_put", /* 28 = cloudabi_sys_file_stat_put */ + "cloudabi_sys_file_symlink", /* 29 = cloudabi_sys_file_symlink */ + "cloudabi_sys_file_unlink", /* 30 = cloudabi_sys_file_unlink */ + "cloudabi_sys_lock_unlock", /* 31 = cloudabi_sys_lock_unlock */ + "cloudabi_sys_mem_advise", /* 32 = cloudabi_sys_mem_advise */ + "cloudabi_sys_mem_lock", /* 33 = cloudabi_sys_mem_lock */ + "cloudabi_sys_mem_map", /* 34 = cloudabi_sys_mem_map */ + "cloudabi_sys_mem_protect", /* 35 = cloudabi_sys_mem_protect */ + "cloudabi_sys_mem_sync", /* 36 = cloudabi_sys_mem_sync */ + "cloudabi_sys_mem_unlock", /* 37 = cloudabi_sys_mem_unlock */ + "cloudabi_sys_mem_unmap", /* 38 = cloudabi_sys_mem_unmap */ + "cloudabi32_sys_poll", /* 39 = cloudabi32_sys_poll */ + "cloudabi32_sys_poll_fd", /* 40 = cloudabi32_sys_poll_fd */ + "cloudabi_sys_proc_exec", /* 41 = cloudabi_sys_proc_exec */ + "cloudabi_sys_proc_exit", /* 42 = cloudabi_sys_proc_exit */ + "cloudabi_sys_proc_fork", /* 43 = cloudabi_sys_proc_fork */ + "cloudabi_sys_proc_raise", /* 44 = cloudabi_sys_proc_raise */ + "cloudabi_sys_random_get", /* 45 = cloudabi_sys_random_get */ + "cloudabi_sys_sock_accept", /* 46 = cloudabi_sys_sock_accept */ + "cloudabi_sys_sock_bind", /* 47 = cloudabi_sys_sock_bind */ + "cloudabi_sys_sock_connect", /* 48 = cloudabi_sys_sock_connect */ + "cloudabi_sys_sock_listen", /* 49 = cloudabi_sys_sock_listen */ + "cloudabi32_sys_sock_recv", /* 50 = cloudabi32_sys_sock_recv */ + "cloudabi32_sys_sock_send", /* 51 = cloudabi32_sys_sock_send */ + "cloudabi_sys_sock_shutdown", /* 52 = cloudabi_sys_sock_shutdown */ + "cloudabi_sys_sock_stat_get", /* 53 = cloudabi_sys_sock_stat_get */ + "cloudabi32_sys_thread_create", /* 54 = cloudabi32_sys_thread_create */ + "cloudabi_sys_thread_exit", /* 55 = cloudabi_sys_thread_exit */ + "cloudabi_sys_thread_yield", /* 56 = cloudabi_sys_thread_yield */ +}; diff --git a/sys/compat/cloudabi32/cloudabi32_sysent.c b/sys/compat/cloudabi32/cloudabi32_sysent.c new file mode 100644 index 0000000..187e384 --- /dev/null +++ b/sys/compat/cloudabi32/cloudabi32_sysent.c @@ -0,0 +1,75 @@ +/* + * System call switch table. + * + * DO NOT EDIT-- this file is automatically generated. + * $FreeBSD$ + * created from FreeBSD: head/sys/contrib/cloudabi/syscalls32.master 304563 2016-08-21 15:56:19Z ed + */ + +#include <sys/sysent.h> +#include <sys/sysproto.h> +#include <contrib/cloudabi/cloudabi32_types.h> +#include <compat/cloudabi32/cloudabi32_proto.h> + +#define AS(name) (sizeof(struct name) / sizeof(register_t)) + +/* The casts are bogus but will do for now. */ +struct sysent cloudabi32_sysent[] = { + { AS(cloudabi_sys_clock_res_get_args), (sy_call_t *)cloudabi_sys_clock_res_get, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 0 = cloudabi_sys_clock_res_get */ + { AS(cloudabi_sys_clock_time_get_args), (sy_call_t *)cloudabi_sys_clock_time_get, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 1 = cloudabi_sys_clock_time_get */ + { AS(cloudabi_sys_condvar_signal_args), (sy_call_t *)cloudabi_sys_condvar_signal, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 2 = cloudabi_sys_condvar_signal */ + { AS(cloudabi_sys_fd_close_args), (sy_call_t *)cloudabi_sys_fd_close, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 3 = cloudabi_sys_fd_close */ + { AS(cloudabi_sys_fd_create1_args), (sy_call_t *)cloudabi_sys_fd_create1, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 4 = cloudabi_sys_fd_create1 */ + { AS(cloudabi_sys_fd_create2_args), (sy_call_t *)cloudabi_sys_fd_create2, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 5 = cloudabi_sys_fd_create2 */ + { AS(cloudabi_sys_fd_datasync_args), (sy_call_t *)cloudabi_sys_fd_datasync, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 6 = cloudabi_sys_fd_datasync */ + { AS(cloudabi_sys_fd_dup_args), (sy_call_t *)cloudabi_sys_fd_dup, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 7 = cloudabi_sys_fd_dup */ + { AS(cloudabi32_sys_fd_pread_args), (sy_call_t *)cloudabi32_sys_fd_pread, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 8 = cloudabi32_sys_fd_pread */ + { AS(cloudabi32_sys_fd_pwrite_args), (sy_call_t *)cloudabi32_sys_fd_pwrite, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 9 = cloudabi32_sys_fd_pwrite */ + { AS(cloudabi32_sys_fd_read_args), (sy_call_t *)cloudabi32_sys_fd_read, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 10 = cloudabi32_sys_fd_read */ + { AS(cloudabi_sys_fd_replace_args), (sy_call_t *)cloudabi_sys_fd_replace, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 11 = cloudabi_sys_fd_replace */ + { AS(cloudabi_sys_fd_seek_args), (sy_call_t *)cloudabi_sys_fd_seek, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 12 = cloudabi_sys_fd_seek */ + { AS(cloudabi_sys_fd_stat_get_args), (sy_call_t *)cloudabi_sys_fd_stat_get, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 13 = cloudabi_sys_fd_stat_get */ + { AS(cloudabi_sys_fd_stat_put_args), (sy_call_t *)cloudabi_sys_fd_stat_put, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 14 = cloudabi_sys_fd_stat_put */ + { AS(cloudabi_sys_fd_sync_args), (sy_call_t *)cloudabi_sys_fd_sync, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 15 = cloudabi_sys_fd_sync */ + { AS(cloudabi32_sys_fd_write_args), (sy_call_t *)cloudabi32_sys_fd_write, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 16 = cloudabi32_sys_fd_write */ + { AS(cloudabi_sys_file_advise_args), (sy_call_t *)cloudabi_sys_file_advise, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 17 = cloudabi_sys_file_advise */ + { AS(cloudabi_sys_file_allocate_args), (sy_call_t *)cloudabi_sys_file_allocate, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 18 = cloudabi_sys_file_allocate */ + { AS(cloudabi_sys_file_create_args), (sy_call_t *)cloudabi_sys_file_create, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 19 = cloudabi_sys_file_create */ + { AS(cloudabi_sys_file_link_args), (sy_call_t *)cloudabi_sys_file_link, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 20 = cloudabi_sys_file_link */ + { AS(cloudabi_sys_file_open_args), (sy_call_t *)cloudabi_sys_file_open, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 21 = cloudabi_sys_file_open */ + { AS(cloudabi_sys_file_readdir_args), (sy_call_t *)cloudabi_sys_file_readdir, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 22 = cloudabi_sys_file_readdir */ + { AS(cloudabi_sys_file_readlink_args), (sy_call_t *)cloudabi_sys_file_readlink, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 23 = cloudabi_sys_file_readlink */ + { AS(cloudabi_sys_file_rename_args), (sy_call_t *)cloudabi_sys_file_rename, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 24 = cloudabi_sys_file_rename */ + { AS(cloudabi_sys_file_stat_fget_args), (sy_call_t *)cloudabi_sys_file_stat_fget, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 25 = cloudabi_sys_file_stat_fget */ + { AS(cloudabi_sys_file_stat_fput_args), (sy_call_t *)cloudabi_sys_file_stat_fput, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 26 = cloudabi_sys_file_stat_fput */ + { AS(cloudabi_sys_file_stat_get_args), (sy_call_t *)cloudabi_sys_file_stat_get, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 27 = cloudabi_sys_file_stat_get */ + { AS(cloudabi_sys_file_stat_put_args), (sy_call_t *)cloudabi_sys_file_stat_put, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 28 = cloudabi_sys_file_stat_put */ + { AS(cloudabi_sys_file_symlink_args), (sy_call_t *)cloudabi_sys_file_symlink, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 29 = cloudabi_sys_file_symlink */ + { AS(cloudabi_sys_file_unlink_args), (sy_call_t *)cloudabi_sys_file_unlink, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 30 = cloudabi_sys_file_unlink */ + { AS(cloudabi_sys_lock_unlock_args), (sy_call_t *)cloudabi_sys_lock_unlock, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 31 = cloudabi_sys_lock_unlock */ + { AS(cloudabi_sys_mem_advise_args), (sy_call_t *)cloudabi_sys_mem_advise, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 32 = cloudabi_sys_mem_advise */ + { AS(cloudabi_sys_mem_lock_args), (sy_call_t *)cloudabi_sys_mem_lock, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 33 = cloudabi_sys_mem_lock */ + { AS(cloudabi_sys_mem_map_args), (sy_call_t *)cloudabi_sys_mem_map, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 34 = cloudabi_sys_mem_map */ + { AS(cloudabi_sys_mem_protect_args), (sy_call_t *)cloudabi_sys_mem_protect, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 35 = cloudabi_sys_mem_protect */ + { AS(cloudabi_sys_mem_sync_args), (sy_call_t *)cloudabi_sys_mem_sync, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 36 = cloudabi_sys_mem_sync */ + { AS(cloudabi_sys_mem_unlock_args), (sy_call_t *)cloudabi_sys_mem_unlock, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 37 = cloudabi_sys_mem_unlock */ + { AS(cloudabi_sys_mem_unmap_args), (sy_call_t *)cloudabi_sys_mem_unmap, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 38 = cloudabi_sys_mem_unmap */ + { AS(cloudabi32_sys_poll_args), (sy_call_t *)cloudabi32_sys_poll, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 39 = cloudabi32_sys_poll */ + { AS(cloudabi32_sys_poll_fd_args), (sy_call_t *)cloudabi32_sys_poll_fd, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 40 = cloudabi32_sys_poll_fd */ + { AS(cloudabi_sys_proc_exec_args), (sy_call_t *)cloudabi_sys_proc_exec, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 41 = cloudabi_sys_proc_exec */ + { AS(cloudabi_sys_proc_exit_args), (sy_call_t *)cloudabi_sys_proc_exit, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 42 = cloudabi_sys_proc_exit */ + { 0, (sy_call_t *)cloudabi_sys_proc_fork, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 43 = cloudabi_sys_proc_fork */ + { AS(cloudabi_sys_proc_raise_args), (sy_call_t *)cloudabi_sys_proc_raise, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 44 = cloudabi_sys_proc_raise */ + { AS(cloudabi_sys_random_get_args), (sy_call_t *)cloudabi_sys_random_get, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 45 = cloudabi_sys_random_get */ + { AS(cloudabi_sys_sock_accept_args), (sy_call_t *)cloudabi_sys_sock_accept, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 46 = cloudabi_sys_sock_accept */ + { AS(cloudabi_sys_sock_bind_args), (sy_call_t *)cloudabi_sys_sock_bind, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 47 = cloudabi_sys_sock_bind */ + { AS(cloudabi_sys_sock_connect_args), (sy_call_t *)cloudabi_sys_sock_connect, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 48 = cloudabi_sys_sock_connect */ + { AS(cloudabi_sys_sock_listen_args), (sy_call_t *)cloudabi_sys_sock_listen, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 49 = cloudabi_sys_sock_listen */ + { AS(cloudabi32_sys_sock_recv_args), (sy_call_t *)cloudabi32_sys_sock_recv, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 50 = cloudabi32_sys_sock_recv */ + { AS(cloudabi32_sys_sock_send_args), (sy_call_t *)cloudabi32_sys_sock_send, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 51 = cloudabi32_sys_sock_send */ + { AS(cloudabi_sys_sock_shutdown_args), (sy_call_t *)cloudabi_sys_sock_shutdown, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 52 = cloudabi_sys_sock_shutdown */ + { AS(cloudabi_sys_sock_stat_get_args), (sy_call_t *)cloudabi_sys_sock_stat_get, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 53 = cloudabi_sys_sock_stat_get */ + { AS(cloudabi32_sys_thread_create_args), (sy_call_t *)cloudabi32_sys_thread_create, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 54 = cloudabi32_sys_thread_create */ + { AS(cloudabi_sys_thread_exit_args), (sy_call_t *)cloudabi_sys_thread_exit, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 55 = cloudabi_sys_thread_exit */ + { 0, (sy_call_t *)cloudabi_sys_thread_yield, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 56 = cloudabi_sys_thread_yield */ +}; diff --git a/sys/compat/cloudabi32/cloudabi32_systrace_args.c b/sys/compat/cloudabi32/cloudabi32_systrace_args.c new file mode 100644 index 0000000..0ba5ec5 --- /dev/null +++ b/sys/compat/cloudabi32/cloudabi32_systrace_args.c @@ -0,0 +1,1702 @@ +/* + * System call argument to DTrace register array converstion. + * + * DO NOT EDIT-- this file is automatically generated. + * $FreeBSD$ + * This file is part of the DTrace syscall provider. + */ + +static void +systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) +{ + int64_t *iarg = (int64_t *) uarg; + switch (sysnum) { + /* cloudabi_sys_clock_res_get */ + case 0: { + struct cloudabi_sys_clock_res_get_args *p = params; + iarg[0] = p->clock_id; /* cloudabi_clockid_t */ + *n_args = 1; + break; + } + /* cloudabi_sys_clock_time_get */ + case 1: { + struct cloudabi_sys_clock_time_get_args *p = params; + iarg[0] = p->clock_id; /* cloudabi_clockid_t */ + iarg[1] = p->precision; /* cloudabi_timestamp_t */ + *n_args = 2; + break; + } + /* cloudabi_sys_condvar_signal */ + case 2: { + struct cloudabi_sys_condvar_signal_args *p = params; + uarg[0] = (intptr_t) p->condvar; /* cloudabi_condvar_t * */ + iarg[1] = p->scope; /* cloudabi_scope_t */ + iarg[2] = p->nwaiters; /* cloudabi_nthreads_t */ + *n_args = 3; + break; + } + /* cloudabi_sys_fd_close */ + case 3: { + struct cloudabi_sys_fd_close_args *p = params; + iarg[0] = p->fd; /* cloudabi_fd_t */ + *n_args = 1; + break; + } + /* cloudabi_sys_fd_create1 */ + case 4: { + struct cloudabi_sys_fd_create1_args *p = params; + iarg[0] = p->type; /* cloudabi_filetype_t */ + *n_args = 1; + break; + } + /* cloudabi_sys_fd_create2 */ + case 5: { + struct cloudabi_sys_fd_create2_args *p = params; + iarg[0] = p->type; /* cloudabi_filetype_t */ + *n_args = 1; + break; + } + /* cloudabi_sys_fd_datasync */ + case 6: { + struct cloudabi_sys_fd_datasync_args *p = params; + iarg[0] = p->fd; /* cloudabi_fd_t */ + *n_args = 1; + break; + } + /* cloudabi_sys_fd_dup */ + case 7: { + struct cloudabi_sys_fd_dup_args *p = params; + iarg[0] = p->from; /* cloudabi_fd_t */ + *n_args = 1; + break; + } + /* cloudabi32_sys_fd_pread */ + case 8: { + struct cloudabi32_sys_fd_pread_args *p = params; + iarg[0] = p->fd; /* cloudabi_fd_t */ + uarg[1] = (intptr_t) p->iov; /* const cloudabi32_iovec_t * */ + uarg[2] = p->iovcnt; /* size_t */ + iarg[3] = p->offset; /* cloudabi_filesize_t */ + *n_args = 4; + break; + } + /* cloudabi32_sys_fd_pwrite */ + case 9: { + struct cloudabi32_sys_fd_pwrite_args *p = params; + iarg[0] = p->fd; /* cloudabi_fd_t */ + uarg[1] = (intptr_t) p->iov; /* const cloudabi32_ciovec_t * */ + uarg[2] = p->iovcnt; /* size_t */ + iarg[3] = p->offset; /* cloudabi_filesize_t */ + *n_args = 4; + break; + } + /* cloudabi32_sys_fd_read */ + case 10: { + struct cloudabi32_sys_fd_read_args *p = params; + iarg[0] = p->fd; /* cloudabi_fd_t */ + uarg[1] = (intptr_t) p->iov; /* const cloudabi32_iovec_t * */ + uarg[2] = p->iovcnt; /* size_t */ + *n_args = 3; + break; + } + /* cloudabi_sys_fd_replace */ + case 11: { + struct cloudabi_sys_fd_replace_args *p = params; + iarg[0] = p->from; /* cloudabi_fd_t */ + iarg[1] = p->to; /* cloudabi_fd_t */ + *n_args = 2; + break; + } + /* cloudabi_sys_fd_seek */ + case 12: { + struct cloudabi_sys_fd_seek_args *p = params; + iarg[0] = p->fd; /* cloudabi_fd_t */ + iarg[1] = p->offset; /* cloudabi_filedelta_t */ + iarg[2] = p->whence; /* cloudabi_whence_t */ + *n_args = 3; + break; + } + /* cloudabi_sys_fd_stat_get */ + case 13: { + struct cloudabi_sys_fd_stat_get_args *p = params; + iarg[0] = p->fd; /* cloudabi_fd_t */ + uarg[1] = (intptr_t) p->buf; /* cloudabi_fdstat_t * */ + *n_args = 2; + break; + } + /* cloudabi_sys_fd_stat_put */ + case 14: { + struct cloudabi_sys_fd_stat_put_args *p = params; + iarg[0] = p->fd; /* cloudabi_fd_t */ + uarg[1] = (intptr_t) p->buf; /* const cloudabi_fdstat_t * */ + iarg[2] = p->flags; /* cloudabi_fdsflags_t */ + *n_args = 3; + break; + } + /* cloudabi_sys_fd_sync */ + case 15: { + struct cloudabi_sys_fd_sync_args *p = params; + iarg[0] = p->fd; /* cloudabi_fd_t */ + *n_args = 1; + break; + } + /* cloudabi32_sys_fd_write */ + case 16: { + struct cloudabi32_sys_fd_write_args *p = params; + iarg[0] = p->fd; /* cloudabi_fd_t */ + uarg[1] = (intptr_t) p->iov; /* const cloudabi32_ciovec_t * */ + uarg[2] = p->iovcnt; /* size_t */ + *n_args = 3; + break; + } + /* cloudabi_sys_file_advise */ + case 17: { + struct cloudabi_sys_file_advise_args *p = params; + iarg[0] = p->fd; /* cloudabi_fd_t */ + iarg[1] = p->offset; /* cloudabi_filesize_t */ + iarg[2] = p->len; /* cloudabi_filesize_t */ + iarg[3] = p->advice; /* cloudabi_advice_t */ + *n_args = 4; + break; + } + /* cloudabi_sys_file_allocate */ + case 18: { + struct cloudabi_sys_file_allocate_args *p = params; + iarg[0] = p->fd; /* cloudabi_fd_t */ + iarg[1] = p->offset; /* cloudabi_filesize_t */ + iarg[2] = p->len; /* cloudabi_filesize_t */ + *n_args = 3; + break; + } + /* cloudabi_sys_file_create */ + case 19: { + struct cloudabi_sys_file_create_args *p = params; + iarg[0] = p->fd; /* cloudabi_fd_t */ + uarg[1] = (intptr_t) p->path; /* const char * */ + uarg[2] = p->pathlen; /* size_t */ + iarg[3] = p->type; /* cloudabi_filetype_t */ + *n_args = 4; + break; + } + /* cloudabi_sys_file_link */ + case 20: { + struct cloudabi_sys_file_link_args *p = params; + iarg[0] = p->fd1; /* cloudabi_lookup_t */ + uarg[1] = (intptr_t) p->path1; /* const char * */ + uarg[2] = p->path1len; /* size_t */ + iarg[3] = p->fd2; /* cloudabi_fd_t */ + uarg[4] = (intptr_t) p->path2; /* const char * */ + uarg[5] = p->path2len; /* size_t */ + *n_args = 6; + break; + } + /* cloudabi_sys_file_open */ + case 21: { + struct cloudabi_sys_file_open_args *p = params; + iarg[0] = p->dirfd; /* cloudabi_lookup_t */ + uarg[1] = (intptr_t) p->path; /* const char * */ + uarg[2] = p->pathlen; /* size_t */ + iarg[3] = p->oflags; /* cloudabi_oflags_t */ + uarg[4] = (intptr_t) p->fds; /* const cloudabi_fdstat_t * */ + *n_args = 5; + break; + } + /* cloudabi_sys_file_readdir */ + case 22: { + struct cloudabi_sys_file_readdir_args *p = params; + iarg[0] = p->fd; /* cloudabi_fd_t */ + uarg[1] = (intptr_t) p->buf; /* void * */ + uarg[2] = p->nbyte; /* size_t */ + iarg[3] = p->cookie; /* cloudabi_dircookie_t */ + *n_args = 4; + break; + } + /* cloudabi_sys_file_readlink */ + case 23: { + struct cloudabi_sys_file_readlink_args *p = params; + iarg[0] = p->fd; /* cloudabi_fd_t */ + uarg[1] = (intptr_t) p->path; /* const char * */ + uarg[2] = p->pathlen; /* size_t */ + uarg[3] = (intptr_t) p->buf; /* char * */ + uarg[4] = p->bufsize; /* size_t */ + *n_args = 5; + break; + } + /* cloudabi_sys_file_rename */ + case 24: { + struct cloudabi_sys_file_rename_args *p = params; + iarg[0] = p->oldfd; /* cloudabi_fd_t */ + uarg[1] = (intptr_t) p->old; /* const char * */ + uarg[2] = p->oldlen; /* size_t */ + iarg[3] = p->newfd; /* cloudabi_fd_t */ + uarg[4] = (intptr_t) p->new; /* const char * */ + uarg[5] = p->newlen; /* size_t */ + *n_args = 6; + break; + } + /* cloudabi_sys_file_stat_fget */ + case 25: { + struct cloudabi_sys_file_stat_fget_args *p = params; + iarg[0] = p->fd; /* cloudabi_fd_t */ + uarg[1] = (intptr_t) p->buf; /* cloudabi_filestat_t * */ + *n_args = 2; + break; + } + /* cloudabi_sys_file_stat_fput */ + case 26: { + struct cloudabi_sys_file_stat_fput_args *p = params; + iarg[0] = p->fd; /* cloudabi_fd_t */ + uarg[1] = (intptr_t) p->buf; /* const cloudabi_filestat_t * */ + iarg[2] = p->flags; /* cloudabi_fsflags_t */ + *n_args = 3; + break; + } + /* cloudabi_sys_file_stat_get */ + case 27: { + struct cloudabi_sys_file_stat_get_args *p = params; + iarg[0] = p->fd; /* cloudabi_lookup_t */ + uarg[1] = (intptr_t) p->path; /* const char * */ + uarg[2] = p->pathlen; /* size_t */ + uarg[3] = (intptr_t) p->buf; /* cloudabi_filestat_t * */ + *n_args = 4; + break; + } + /* cloudabi_sys_file_stat_put */ + case 28: { + struct cloudabi_sys_file_stat_put_args *p = params; + iarg[0] = p->fd; /* cloudabi_lookup_t */ + uarg[1] = (intptr_t) p->path; /* const char * */ + uarg[2] = p->pathlen; /* size_t */ + uarg[3] = (intptr_t) p->buf; /* const cloudabi_filestat_t * */ + iarg[4] = p->flags; /* cloudabi_fsflags_t */ + *n_args = 5; + break; + } + /* cloudabi_sys_file_symlink */ + case 29: { + struct cloudabi_sys_file_symlink_args *p = params; + uarg[0] = (intptr_t) p->path1; /* const char * */ + uarg[1] = p->path1len; /* size_t */ + iarg[2] = p->fd; /* cloudabi_fd_t */ + uarg[3] = (intptr_t) p->path2; /* const char * */ + uarg[4] = p->path2len; /* size_t */ + *n_args = 5; + break; + } + /* cloudabi_sys_file_unlink */ + case 30: { + struct cloudabi_sys_file_unlink_args *p = params; + iarg[0] = p->fd; /* cloudabi_fd_t */ + uarg[1] = (intptr_t) p->path; /* const char * */ + uarg[2] = p->pathlen; /* size_t */ + iarg[3] = p->flags; /* cloudabi_ulflags_t */ + *n_args = 4; + break; + } + /* cloudabi_sys_lock_unlock */ + case 31: { + struct cloudabi_sys_lock_unlock_args *p = params; + uarg[0] = (intptr_t) p->lock; /* cloudabi_lock_t * */ + iarg[1] = p->scope; /* cloudabi_scope_t */ + *n_args = 2; + break; + } + /* cloudabi_sys_mem_advise */ + case 32: { + struct cloudabi_sys_mem_advise_args *p = params; + uarg[0] = (intptr_t) p->addr; /* void * */ + uarg[1] = p->len; /* size_t */ + iarg[2] = p->advice; /* cloudabi_advice_t */ + *n_args = 3; + break; + } + /* cloudabi_sys_mem_lock */ + case 33: { + struct cloudabi_sys_mem_lock_args *p = params; + uarg[0] = (intptr_t) p->addr; /* const void * */ + uarg[1] = p->len; /* size_t */ + *n_args = 2; + break; + } + /* cloudabi_sys_mem_map */ + case 34: { + struct cloudabi_sys_mem_map_args *p = params; + uarg[0] = (intptr_t) p->addr; /* void * */ + uarg[1] = p->len; /* size_t */ + iarg[2] = p->prot; /* cloudabi_mprot_t */ + iarg[3] = p->flags; /* cloudabi_mflags_t */ + iarg[4] = p->fd; /* cloudabi_fd_t */ + iarg[5] = p->off; /* cloudabi_filesize_t */ + *n_args = 6; + break; + } + /* cloudabi_sys_mem_protect */ + case 35: { + struct cloudabi_sys_mem_protect_args *p = params; + uarg[0] = (intptr_t) p->addr; /* void * */ + uarg[1] = p->len; /* size_t */ + iarg[2] = p->prot; /* cloudabi_mprot_t */ + *n_args = 3; + break; + } + /* cloudabi_sys_mem_sync */ + case 36: { + struct cloudabi_sys_mem_sync_args *p = params; + uarg[0] = (intptr_t) p->addr; /* void * */ + uarg[1] = p->len; /* size_t */ + iarg[2] = p->flags; /* cloudabi_msflags_t */ + *n_args = 3; + break; + } + /* cloudabi_sys_mem_unlock */ + case 37: { + struct cloudabi_sys_mem_unlock_args *p = params; + uarg[0] = (intptr_t) p->addr; /* const void * */ + uarg[1] = p->len; /* size_t */ + *n_args = 2; + break; + } + /* cloudabi_sys_mem_unmap */ + case 38: { + struct cloudabi_sys_mem_unmap_args *p = params; + uarg[0] = (intptr_t) p->addr; /* void * */ + uarg[1] = p->len; /* size_t */ + *n_args = 2; + break; + } + /* cloudabi32_sys_poll */ + case 39: { + struct cloudabi32_sys_poll_args *p = params; + uarg[0] = (intptr_t) p->in; /* const cloudabi32_subscription_t * */ + uarg[1] = (intptr_t) p->out; /* cloudabi32_event_t * */ + uarg[2] = p->nsubscriptions; /* size_t */ + *n_args = 3; + break; + } + /* cloudabi32_sys_poll_fd */ + case 40: { + struct cloudabi32_sys_poll_fd_args *p = params; + iarg[0] = p->fd; /* cloudabi_fd_t */ + uarg[1] = (intptr_t) p->in; /* const cloudabi32_subscription_t * */ + uarg[2] = p->nin; /* size_t */ + uarg[3] = (intptr_t) p->out; /* cloudabi32_event_t * */ + uarg[4] = p->nout; /* size_t */ + uarg[5] = (intptr_t) p->timeout; /* const cloudabi32_subscription_t * */ + *n_args = 6; + break; + } + /* cloudabi_sys_proc_exec */ + case 41: { + struct cloudabi_sys_proc_exec_args *p = params; + iarg[0] = p->fd; /* cloudabi_fd_t */ + uarg[1] = (intptr_t) p->data; /* const void * */ + uarg[2] = p->datalen; /* size_t */ + uarg[3] = (intptr_t) p->fds; /* const cloudabi_fd_t * */ + uarg[4] = p->fdslen; /* size_t */ + *n_args = 5; + break; + } + /* cloudabi_sys_proc_exit */ + case 42: { + struct cloudabi_sys_proc_exit_args *p = params; + iarg[0] = p->rval; /* cloudabi_exitcode_t */ + *n_args = 1; + break; + } + /* cloudabi_sys_proc_fork */ + case 43: { + *n_args = 0; + break; + } + /* cloudabi_sys_proc_raise */ + case 44: { + struct cloudabi_sys_proc_raise_args *p = params; + iarg[0] = p->sig; /* cloudabi_signal_t */ + *n_args = 1; + break; + } + /* cloudabi_sys_random_get */ + case 45: { + struct cloudabi_sys_random_get_args *p = params; + uarg[0] = (intptr_t) p->buf; /* void * */ + uarg[1] = p->nbyte; /* size_t */ + *n_args = 2; + break; + } + /* cloudabi_sys_sock_accept */ + case 46: { + struct cloudabi_sys_sock_accept_args *p = params; + iarg[0] = p->sock; /* cloudabi_fd_t */ + uarg[1] = (intptr_t) p->buf; /* cloudabi_sockstat_t * */ + *n_args = 2; + break; + } + /* cloudabi_sys_sock_bind */ + case 47: { + struct cloudabi_sys_sock_bind_args *p = params; + iarg[0] = p->sock; /* cloudabi_fd_t */ + iarg[1] = p->fd; /* cloudabi_fd_t */ + uarg[2] = (intptr_t) p->path; /* const char * */ + uarg[3] = p->pathlen; /* size_t */ + *n_args = 4; + break; + } + /* cloudabi_sys_sock_connect */ + case 48: { + struct cloudabi_sys_sock_connect_args *p = params; + iarg[0] = p->sock; /* cloudabi_fd_t */ + iarg[1] = p->fd; /* cloudabi_fd_t */ + uarg[2] = (intptr_t) p->path; /* const char * */ + uarg[3] = p->pathlen; /* size_t */ + *n_args = 4; + break; + } + /* cloudabi_sys_sock_listen */ + case 49: { + struct cloudabi_sys_sock_listen_args *p = params; + iarg[0] = p->sock; /* cloudabi_fd_t */ + iarg[1] = p->backlog; /* cloudabi_backlog_t */ + *n_args = 2; + break; + } + /* cloudabi32_sys_sock_recv */ + case 50: { + struct cloudabi32_sys_sock_recv_args *p = params; + iarg[0] = p->sock; /* cloudabi_fd_t */ + uarg[1] = (intptr_t) p->in; /* const cloudabi32_recv_in_t * */ + uarg[2] = (intptr_t) p->out; /* cloudabi32_recv_out_t * */ + *n_args = 3; + break; + } + /* cloudabi32_sys_sock_send */ + case 51: { + struct cloudabi32_sys_sock_send_args *p = params; + iarg[0] = p->sock; /* cloudabi_fd_t */ + uarg[1] = (intptr_t) p->in; /* const cloudabi32_send_in_t * */ + uarg[2] = (intptr_t) p->out; /* cloudabi32_send_out_t * */ + *n_args = 3; + break; + } + /* cloudabi_sys_sock_shutdown */ + case 52: { + struct cloudabi_sys_sock_shutdown_args *p = params; + iarg[0] = p->sock; /* cloudabi_fd_t */ + iarg[1] = p->how; /* cloudabi_sdflags_t */ + *n_args = 2; + break; + } + /* cloudabi_sys_sock_stat_get */ + case 53: { + struct cloudabi_sys_sock_stat_get_args *p = params; + iarg[0] = p->sock; /* cloudabi_fd_t */ + uarg[1] = (intptr_t) p->buf; /* cloudabi_sockstat_t * */ + iarg[2] = p->flags; /* cloudabi_ssflags_t */ + *n_args = 3; + break; + } + /* cloudabi32_sys_thread_create */ + case 54: { + struct cloudabi32_sys_thread_create_args *p = params; + uarg[0] = (intptr_t) p->attr; /* cloudabi32_threadattr_t * */ + *n_args = 1; + break; + } + /* cloudabi_sys_thread_exit */ + case 55: { + struct cloudabi_sys_thread_exit_args *p = params; + uarg[0] = (intptr_t) p->lock; /* cloudabi_lock_t * */ + iarg[1] = p->scope; /* cloudabi_scope_t */ + *n_args = 2; + break; + } + /* cloudabi_sys_thread_yield */ + case 56: { + *n_args = 0; + break; + } + default: + *n_args = 0; + break; + }; +} +static void +systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) +{ + const char *p = NULL; + switch (sysnum) { + /* cloudabi_sys_clock_res_get */ + case 0: + switch(ndx) { + case 0: + p = "cloudabi_clockid_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_clock_time_get */ + case 1: + switch(ndx) { + case 0: + p = "cloudabi_clockid_t"; + break; + case 1: + p = "cloudabi_timestamp_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_condvar_signal */ + case 2: + switch(ndx) { + case 0: + p = "cloudabi_condvar_t *"; + break; + case 1: + p = "cloudabi_scope_t"; + break; + case 2: + p = "cloudabi_nthreads_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_fd_close */ + case 3: + switch(ndx) { + case 0: + p = "cloudabi_fd_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_fd_create1 */ + case 4: + switch(ndx) { + case 0: + p = "cloudabi_filetype_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_fd_create2 */ + case 5: + switch(ndx) { + case 0: + p = "cloudabi_filetype_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_fd_datasync */ + case 6: + switch(ndx) { + case 0: + p = "cloudabi_fd_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_fd_dup */ + case 7: + switch(ndx) { + case 0: + p = "cloudabi_fd_t"; + break; + default: + break; + }; + break; + /* cloudabi32_sys_fd_pread */ + case 8: + switch(ndx) { + case 0: + p = "cloudabi_fd_t"; + break; + case 1: + p = "const cloudabi32_iovec_t *"; + break; + case 2: + p = "size_t"; + break; + case 3: + p = "cloudabi_filesize_t"; + break; + default: + break; + }; + break; + /* cloudabi32_sys_fd_pwrite */ + case 9: + switch(ndx) { + case 0: + p = "cloudabi_fd_t"; + break; + case 1: + p = "const cloudabi32_ciovec_t *"; + break; + case 2: + p = "size_t"; + break; + case 3: + p = "cloudabi_filesize_t"; + break; + default: + break; + }; + break; + /* cloudabi32_sys_fd_read */ + case 10: + switch(ndx) { + case 0: + p = "cloudabi_fd_t"; + break; + case 1: + p = "const cloudabi32_iovec_t *"; + break; + case 2: + p = "size_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_fd_replace */ + case 11: + switch(ndx) { + case 0: + p = "cloudabi_fd_t"; + break; + case 1: + p = "cloudabi_fd_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_fd_seek */ + case 12: + switch(ndx) { + case 0: + p = "cloudabi_fd_t"; + break; + case 1: + p = "cloudabi_filedelta_t"; + break; + case 2: + p = "cloudabi_whence_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_fd_stat_get */ + case 13: + switch(ndx) { + case 0: + p = "cloudabi_fd_t"; + break; + case 1: + p = "cloudabi_fdstat_t *"; + break; + default: + break; + }; + break; + /* cloudabi_sys_fd_stat_put */ + case 14: + switch(ndx) { + case 0: + p = "cloudabi_fd_t"; + break; + case 1: + p = "const cloudabi_fdstat_t *"; + break; + case 2: + p = "cloudabi_fdsflags_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_fd_sync */ + case 15: + switch(ndx) { + case 0: + p = "cloudabi_fd_t"; + break; + default: + break; + }; + break; + /* cloudabi32_sys_fd_write */ + case 16: + switch(ndx) { + case 0: + p = "cloudabi_fd_t"; + break; + case 1: + p = "const cloudabi32_ciovec_t *"; + break; + case 2: + p = "size_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_file_advise */ + case 17: + switch(ndx) { + case 0: + p = "cloudabi_fd_t"; + break; + case 1: + p = "cloudabi_filesize_t"; + break; + case 2: + p = "cloudabi_filesize_t"; + break; + case 3: + p = "cloudabi_advice_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_file_allocate */ + case 18: + switch(ndx) { + case 0: + p = "cloudabi_fd_t"; + break; + case 1: + p = "cloudabi_filesize_t"; + break; + case 2: + p = "cloudabi_filesize_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_file_create */ + case 19: + switch(ndx) { + case 0: + p = "cloudabi_fd_t"; + break; + case 1: + p = "const char *"; + break; + case 2: + p = "size_t"; + break; + case 3: + p = "cloudabi_filetype_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_file_link */ + case 20: + switch(ndx) { + case 0: + p = "cloudabi_lookup_t"; + break; + case 1: + p = "const char *"; + break; + case 2: + p = "size_t"; + break; + case 3: + p = "cloudabi_fd_t"; + break; + case 4: + p = "const char *"; + break; + case 5: + p = "size_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_file_open */ + case 21: + switch(ndx) { + case 0: + p = "cloudabi_lookup_t"; + break; + case 1: + p = "const char *"; + break; + case 2: + p = "size_t"; + break; + case 3: + p = "cloudabi_oflags_t"; + break; + case 4: + p = "const cloudabi_fdstat_t *"; + break; + default: + break; + }; + break; + /* cloudabi_sys_file_readdir */ + case 22: + switch(ndx) { + case 0: + p = "cloudabi_fd_t"; + break; + case 1: + p = "void *"; + break; + case 2: + p = "size_t"; + break; + case 3: + p = "cloudabi_dircookie_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_file_readlink */ + case 23: + switch(ndx) { + case 0: + p = "cloudabi_fd_t"; + break; + case 1: + p = "const char *"; + break; + case 2: + p = "size_t"; + break; + case 3: + p = "char *"; + break; + case 4: + p = "size_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_file_rename */ + case 24: + switch(ndx) { + case 0: + p = "cloudabi_fd_t"; + break; + case 1: + p = "const char *"; + break; + case 2: + p = "size_t"; + break; + case 3: + p = "cloudabi_fd_t"; + break; + case 4: + p = "const char *"; + break; + case 5: + p = "size_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_file_stat_fget */ + case 25: + switch(ndx) { + case 0: + p = "cloudabi_fd_t"; + break; + case 1: + p = "cloudabi_filestat_t *"; + break; + default: + break; + }; + break; + /* cloudabi_sys_file_stat_fput */ + case 26: + switch(ndx) { + case 0: + p = "cloudabi_fd_t"; + break; + case 1: + p = "const cloudabi_filestat_t *"; + break; + case 2: + p = "cloudabi_fsflags_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_file_stat_get */ + case 27: + switch(ndx) { + case 0: + p = "cloudabi_lookup_t"; + break; + case 1: + p = "const char *"; + break; + case 2: + p = "size_t"; + break; + case 3: + p = "cloudabi_filestat_t *"; + break; + default: + break; + }; + break; + /* cloudabi_sys_file_stat_put */ + case 28: + switch(ndx) { + case 0: + p = "cloudabi_lookup_t"; + break; + case 1: + p = "const char *"; + break; + case 2: + p = "size_t"; + break; + case 3: + p = "const cloudabi_filestat_t *"; + break; + case 4: + p = "cloudabi_fsflags_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_file_symlink */ + case 29: + switch(ndx) { + case 0: + p = "const char *"; + break; + case 1: + p = "size_t"; + break; + case 2: + p = "cloudabi_fd_t"; + break; + case 3: + p = "const char *"; + break; + case 4: + p = "size_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_file_unlink */ + case 30: + switch(ndx) { + case 0: + p = "cloudabi_fd_t"; + break; + case 1: + p = "const char *"; + break; + case 2: + p = "size_t"; + break; + case 3: + p = "cloudabi_ulflags_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_lock_unlock */ + case 31: + switch(ndx) { + case 0: + p = "cloudabi_lock_t *"; + break; + case 1: + p = "cloudabi_scope_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_mem_advise */ + case 32: + switch(ndx) { + case 0: + p = "void *"; + break; + case 1: + p = "size_t"; + break; + case 2: + p = "cloudabi_advice_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_mem_lock */ + case 33: + switch(ndx) { + case 0: + p = "const void *"; + break; + case 1: + p = "size_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_mem_map */ + case 34: + switch(ndx) { + case 0: + p = "void *"; + break; + case 1: + p = "size_t"; + break; + case 2: + p = "cloudabi_mprot_t"; + break; + case 3: + p = "cloudabi_mflags_t"; + break; + case 4: + p = "cloudabi_fd_t"; + break; + case 5: + p = "cloudabi_filesize_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_mem_protect */ + case 35: + switch(ndx) { + case 0: + p = "void *"; + break; + case 1: + p = "size_t"; + break; + case 2: + p = "cloudabi_mprot_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_mem_sync */ + case 36: + switch(ndx) { + case 0: + p = "void *"; + break; + case 1: + p = "size_t"; + break; + case 2: + p = "cloudabi_msflags_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_mem_unlock */ + case 37: + switch(ndx) { + case 0: + p = "const void *"; + break; + case 1: + p = "size_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_mem_unmap */ + case 38: + switch(ndx) { + case 0: + p = "void *"; + break; + case 1: + p = "size_t"; + break; + default: + break; + }; + break; + /* cloudabi32_sys_poll */ + case 39: + switch(ndx) { + case 0: + p = "const cloudabi32_subscription_t *"; + break; + case 1: + p = "cloudabi32_event_t *"; + break; + case 2: + p = "size_t"; + break; + default: + break; + }; + break; + /* cloudabi32_sys_poll_fd */ + case 40: + switch(ndx) { + case 0: + p = "cloudabi_fd_t"; + break; + case 1: + p = "const cloudabi32_subscription_t *"; + break; + case 2: + p = "size_t"; + break; + case 3: + p = "cloudabi32_event_t *"; + break; + case 4: + p = "size_t"; + break; + case 5: + p = "const cloudabi32_subscription_t *"; + break; + default: + break; + }; + break; + /* cloudabi_sys_proc_exec */ + case 41: + switch(ndx) { + case 0: + p = "cloudabi_fd_t"; + break; + case 1: + p = "const void *"; + break; + case 2: + p = "size_t"; + break; + case 3: + p = "const cloudabi_fd_t *"; + break; + case 4: + p = "size_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_proc_exit */ + case 42: + switch(ndx) { + case 0: + p = "cloudabi_exitcode_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_proc_fork */ + case 43: + break; + /* cloudabi_sys_proc_raise */ + case 44: + switch(ndx) { + case 0: + p = "cloudabi_signal_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_random_get */ + case 45: + switch(ndx) { + case 0: + p = "void *"; + break; + case 1: + p = "size_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_sock_accept */ + case 46: + switch(ndx) { + case 0: + p = "cloudabi_fd_t"; + break; + case 1: + p = "cloudabi_sockstat_t *"; + break; + default: + break; + }; + break; + /* cloudabi_sys_sock_bind */ + case 47: + switch(ndx) { + case 0: + p = "cloudabi_fd_t"; + break; + case 1: + p = "cloudabi_fd_t"; + break; + case 2: + p = "const char *"; + break; + case 3: + p = "size_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_sock_connect */ + case 48: + switch(ndx) { + case 0: + p = "cloudabi_fd_t"; + break; + case 1: + p = "cloudabi_fd_t"; + break; + case 2: + p = "const char *"; + break; + case 3: + p = "size_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_sock_listen */ + case 49: + switch(ndx) { + case 0: + p = "cloudabi_fd_t"; + break; + case 1: + p = "cloudabi_backlog_t"; + break; + default: + break; + }; + break; + /* cloudabi32_sys_sock_recv */ + case 50: + switch(ndx) { + case 0: + p = "cloudabi_fd_t"; + break; + case 1: + p = "const cloudabi32_recv_in_t *"; + break; + case 2: + p = "cloudabi32_recv_out_t *"; + break; + default: + break; + }; + break; + /* cloudabi32_sys_sock_send */ + case 51: + switch(ndx) { + case 0: + p = "cloudabi_fd_t"; + break; + case 1: + p = "const cloudabi32_send_in_t *"; + break; + case 2: + p = "cloudabi32_send_out_t *"; + break; + default: + break; + }; + break; + /* cloudabi_sys_sock_shutdown */ + case 52: + switch(ndx) { + case 0: + p = "cloudabi_fd_t"; + break; + case 1: + p = "cloudabi_sdflags_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_sock_stat_get */ + case 53: + switch(ndx) { + case 0: + p = "cloudabi_fd_t"; + break; + case 1: + p = "cloudabi_sockstat_t *"; + break; + case 2: + p = "cloudabi_ssflags_t"; + break; + default: + break; + }; + break; + /* cloudabi32_sys_thread_create */ + case 54: + switch(ndx) { + case 0: + p = "cloudabi32_threadattr_t *"; + break; + default: + break; + }; + break; + /* cloudabi_sys_thread_exit */ + case 55: + switch(ndx) { + case 0: + p = "cloudabi_lock_t *"; + break; + case 1: + p = "cloudabi_scope_t"; + break; + default: + break; + }; + break; + /* cloudabi_sys_thread_yield */ + case 56: + break; + default: + break; + }; + if (p != NULL) + strlcpy(desc, p, descsz); +} +static void +systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) +{ + const char *p = NULL; + switch (sysnum) { + /* cloudabi_sys_clock_res_get */ + case 0: + if (ndx == 0 || ndx == 1) + p = "cloudabi_timestamp_t"; + break; + /* cloudabi_sys_clock_time_get */ + case 1: + if (ndx == 0 || ndx == 1) + p = "cloudabi_timestamp_t"; + break; + /* cloudabi_sys_condvar_signal */ + case 2: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_fd_close */ + case 3: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_fd_create1 */ + case 4: + if (ndx == 0 || ndx == 1) + p = "cloudabi_fd_t"; + break; + /* cloudabi_sys_fd_create2 */ + case 5: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_fd_datasync */ + case 6: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_fd_dup */ + case 7: + if (ndx == 0 || ndx == 1) + p = "cloudabi_fd_t"; + break; + /* cloudabi32_sys_fd_pread */ + case 8: + if (ndx == 0 || ndx == 1) + p = "size_t"; + break; + /* cloudabi32_sys_fd_pwrite */ + case 9: + if (ndx == 0 || ndx == 1) + p = "size_t"; + break; + /* cloudabi32_sys_fd_read */ + case 10: + if (ndx == 0 || ndx == 1) + p = "size_t"; + break; + /* cloudabi_sys_fd_replace */ + case 11: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_fd_seek */ + case 12: + if (ndx == 0 || ndx == 1) + p = "cloudabi_filesize_t"; + break; + /* cloudabi_sys_fd_stat_get */ + case 13: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_fd_stat_put */ + case 14: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_fd_sync */ + case 15: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi32_sys_fd_write */ + case 16: + if (ndx == 0 || ndx == 1) + p = "size_t"; + break; + /* cloudabi_sys_file_advise */ + case 17: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_file_allocate */ + case 18: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_file_create */ + case 19: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_file_link */ + case 20: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_file_open */ + case 21: + if (ndx == 0 || ndx == 1) + p = "cloudabi_fd_t"; + break; + /* cloudabi_sys_file_readdir */ + case 22: + if (ndx == 0 || ndx == 1) + p = "size_t"; + break; + /* cloudabi_sys_file_readlink */ + case 23: + if (ndx == 0 || ndx == 1) + p = "size_t"; + break; + /* cloudabi_sys_file_rename */ + case 24: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_file_stat_fget */ + case 25: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_file_stat_fput */ + case 26: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_file_stat_get */ + case 27: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_file_stat_put */ + case 28: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_file_symlink */ + case 29: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_file_unlink */ + case 30: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_lock_unlock */ + case 31: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_mem_advise */ + case 32: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_mem_lock */ + case 33: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_mem_map */ + case 34: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_mem_protect */ + case 35: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_mem_sync */ + case 36: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_mem_unlock */ + case 37: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_mem_unmap */ + case 38: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi32_sys_poll */ + case 39: + if (ndx == 0 || ndx == 1) + p = "size_t"; + break; + /* cloudabi32_sys_poll_fd */ + case 40: + if (ndx == 0 || ndx == 1) + p = "size_t"; + break; + /* cloudabi_sys_proc_exec */ + case 41: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_proc_exit */ + case 42: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_proc_fork */ + case 43: + /* cloudabi_sys_proc_raise */ + case 44: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_random_get */ + case 45: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_sock_accept */ + case 46: + if (ndx == 0 || ndx == 1) + p = "cloudabi_fd_t"; + break; + /* cloudabi_sys_sock_bind */ + case 47: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_sock_connect */ + case 48: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_sock_listen */ + case 49: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi32_sys_sock_recv */ + case 50: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi32_sys_sock_send */ + case 51: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_sock_shutdown */ + case 52: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_sock_stat_get */ + case 53: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi32_sys_thread_create */ + case 54: + if (ndx == 0 || ndx == 1) + p = "cloudabi_tid_t"; + break; + /* cloudabi_sys_thread_exit */ + case 55: + if (ndx == 0 || ndx == 1) + p = "void"; + break; + /* cloudabi_sys_thread_yield */ + case 56: + default: + break; + }; + if (p != NULL) + strlcpy(desc, p, descsz); +} diff --git a/sys/compat/cloudabi32/cloudabi32_thread.c b/sys/compat/cloudabi32/cloudabi32_thread.c new file mode 100644 index 0000000..50538d9 --- /dev/null +++ b/sys/compat/cloudabi32/cloudabi32_thread.c @@ -0,0 +1,77 @@ +/*- + * Copyright (c) 2015 Nuxi, https://nuxi.nl/ + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/param.h> +#include <sys/proc.h> +#include <sys/systm.h> + +#include <contrib/cloudabi/cloudabi32_types.h> + +#include <compat/cloudabi32/cloudabi32_proto.h> +#include <compat/cloudabi32/cloudabi32_util.h> + +struct thread_create_args { + cloudabi32_threadattr_t attr; + uint32_t tcb; + lwpid_t tid; +}; + +static int +initialize_thread(struct thread *td, void *thunk) +{ + struct thread_create_args *args = thunk; + + /* Save the thread ID, so it can be returned. */ + args->tid = td->td_tid; + + /* Set up initial register contents. */ + return (cloudabi32_thread_setregs(td, &args->attr, args->tcb)); +} + +int +cloudabi32_sys_thread_create(struct thread *td, + struct cloudabi32_sys_thread_create_args *uap) +{ + struct thread_create_args args; + int error; + + error = copyin(uap->attr, &args.attr, sizeof(args.attr)); + if (error != 0) + return (error); + + /* Remove some space on the top of the stack for the TCB. */ + args.tcb = rounddown(args.attr.stack + args.attr.stack_size - + sizeof(cloudabi32_tcb_t), _Alignof(cloudabi32_tcb_t)); + args.attr.stack_size = args.tcb - args.attr.stack; + + error = thread_create(td, NULL, initialize_thread, &args); + if (error != 0) + return (error); + td->td_retval[0] = args.tid; + return (0); +} diff --git a/sys/compat/cloudabi32/cloudabi32_util.h b/sys/compat/cloudabi32/cloudabi32_util.h new file mode 100644 index 0000000..c08c91e --- /dev/null +++ b/sys/compat/cloudabi32/cloudabi32_util.h @@ -0,0 +1,51 @@ +/*- + * Copyright (c) 2015 Nuxi, https://nuxi.nl/ + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _CLOUDABI32_UTIL_H_ +#define _CLOUDABI32_UTIL_H_ + +#include <sys/types.h> +#define __ELF_WORD_SIZE 32 +#include <sys/imgact_elf.h> + +#include <contrib/cloudabi/cloudabi32_types.h> + +struct image_params; +struct thread; + +extern Elf32_Brandinfo cloudabi32_brand; + +#define TO_PTR(x) ((void *)(uintptr_t)(x)) + +/* Stack initialization during process execution. */ +register_t *cloudabi32_copyout_strings(struct image_params *); +int cloudabi32_fixup(register_t **, struct image_params *); + +int cloudabi32_thread_setregs(struct thread *, + const cloudabi32_threadattr_t *, uint32_t); + +#endif diff --git a/sys/compat/cloudabi32/syscalls.conf b/sys/compat/cloudabi32/syscalls.conf new file mode 100644 index 0000000..8e6522a --- /dev/null +++ b/sys/compat/cloudabi32/syscalls.conf @@ -0,0 +1,15 @@ +# $FreeBSD$ +sysnames="cloudabi32_syscalls.c" +sysproto="cloudabi32_proto.h" +sysproto_h=_CLOUDABI32_SYSPROTO_H_ +syshdr="cloudabi32_syscall.h" +syssw="cloudabi32_sysent.c" +sysmk="/dev/null" +syscallprefix="CLOUDABI32_SYS_" +switchname="cloudabi32_sysent" +namesname="cloudabi32_syscallnames" +systrace="cloudabi32_systrace_args.c" + +# Allow all system calls in capabilities mode. Extract the names of the +# system calls from syscalls.master. +capenabled=`sed -n -e 's/.*\<\(cloudabi[0-9]*_sys_[a-z0-9_]*\)\>.*/\1/p' $1 | tr '\n' ','` diff --git a/sys/compat/cloudabi64/Makefile b/sys/compat/cloudabi64/Makefile index 83d27a3..60ae571 100644 --- a/sys/compat/cloudabi64/Makefile +++ b/sys/compat/cloudabi64/Makefile @@ -8,7 +8,7 @@ sysent: cloudabi64_sysent.c cloudabi64_syscall.h cloudabi64_proto.h \ cloudabi64_sysent.c cloudabi64_syscall.h cloudabi64_proto.h \ cloudabi64_syscalls.c cloudabi64_systrace_args.c: \ - ../../kern/makesyscalls.sh ../../contrib/cloudabi/syscalls.master \ + ../../kern/makesyscalls.sh ../../contrib/cloudabi/syscalls64.master \ syscalls.conf - sh ../../kern/makesyscalls.sh ../../contrib/cloudabi/syscalls.master \ + sh ../../kern/makesyscalls.sh ../../contrib/cloudabi/syscalls64.master \ syscalls.conf diff --git a/sys/compat/cloudabi64/cloudabi64_fd.c b/sys/compat/cloudabi64/cloudabi64_fd.c index 7d0c69a..fcfcc42 100644 --- a/sys/compat/cloudabi64/cloudabi64_fd.c +++ b/sys/compat/cloudabi64/cloudabi64_fd.c @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include <contrib/cloudabi/cloudabi64_types.h> #include <compat/cloudabi64/cloudabi64_proto.h> +#include <compat/cloudabi64/cloudabi64_util.h> /* Copies in 64-bit iovec structures from userspace. */ static int @@ -70,9 +71,9 @@ cloudabi64_copyinuio(const cloudabi64_iovec_t *iovp, size_t iovcnt, free(uio, M_IOV); return (error); } - iov[i].iov_base = (void *)iovobj.iov_base; + iov[i].iov_base = TO_PTR(iovobj.iov_base); iov[i].iov_len = iovobj.iov_len; - if (iov[i].iov_len > SSIZE_MAX - uio->uio_resid) { + if (iov[i].iov_len > INT64_MAX - uio->uio_resid) { free(uio, M_IOV); return (EINVAL); } @@ -105,8 +106,7 @@ cloudabi64_sys_fd_pwrite(struct thread *td, struct uio *uio; int error; - error = cloudabi64_copyinuio((const cloudabi64_iovec_t *)uap->iov, - uap->iovcnt, &uio); + error = cloudabi64_copyinuio(TO_PTR(uap->iov), uap->iovcnt, &uio); if (error != 0) return (error); error = kern_pwritev(td, uap->fd, uio, uap->offset); @@ -136,8 +136,7 @@ cloudabi64_sys_fd_write(struct thread *td, struct uio *uio; int error; - error = cloudabi64_copyinuio((const cloudabi64_iovec_t *)uap->iov, - uap->iovcnt, &uio); + error = cloudabi64_copyinuio(TO_PTR(uap->iov), uap->iovcnt, &uio); if (error != 0) return (error); error = kern_writev(td, uap->fd, uio); diff --git a/sys/compat/cloudabi64/cloudabi64_module.c b/sys/compat/cloudabi64/cloudabi64_module.c index 246a887..da1ea11 100644 --- a/sys/compat/cloudabi64/cloudabi64_module.c +++ b/sys/compat/cloudabi64/cloudabi64_module.c @@ -38,8 +38,13 @@ __FBSDID("$FreeBSD$"); #include <contrib/cloudabi/cloudabi64_types.h> +#include <compat/cloudabi/cloudabi_util.h> + #include <compat/cloudabi64/cloudabi64_util.h> +extern char _binary_cloudabi64_vdso_o_start[]; +extern char _binary_cloudabi64_vdso_o_end[]; + register_t * cloudabi64_copyout_strings(struct image_params *imgp) { @@ -107,6 +112,8 @@ cloudabi64_fixup(register_t **stack_base, struct image_params *imgp) PTR(CLOUDABI_AT_PHDR, args->phdr), VAL(CLOUDABI_AT_PHNUM, args->phnum), VAL(CLOUDABI_AT_TID, td->td_tid), + PTR(CLOUDABI_AT_SYSINFO_EHDR, + imgp->proc->p_sysent->sv_shared_page_base), #undef VAL #undef PTR { .a_type = CLOUDABI_AT_NULL }, @@ -127,6 +134,9 @@ cloudabi64_modevent(module_t mod, int type, void *data) switch (type) { case MOD_LOAD: + cloudabi_vdso_init(cloudabi64_brand.sysvec, + _binary_cloudabi64_vdso_o_start, + _binary_cloudabi64_vdso_o_end); if (elf64_insert_brand_entry(&cloudabi64_brand) < 0) { printf("Failed to add CloudABI ELF brand handler\n"); return (EINVAL); @@ -139,6 +149,7 @@ cloudabi64_modevent(module_t mod, int type, void *data) printf("Failed to remove CloudABI ELF brand handler\n"); return (EINVAL); } + cloudabi_vdso_destroy(cloudabi64_brand.sysvec); return (0); default: return (EOPNOTSUPP); diff --git a/sys/compat/cloudabi64/cloudabi64_poll.c b/sys/compat/cloudabi64/cloudabi64_poll.c index e44d69f..63d8120 100644 --- a/sys/compat/cloudabi64/cloudabi64_poll.c +++ b/sys/compat/cloudabi64/cloudabi64_poll.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include <compat/cloudabi/cloudabi_util.h> #include <compat/cloudabi64/cloudabi64_proto.h> +#include <compat/cloudabi64/cloudabi64_util.h> /* Converts a FreeBSD signal number to a CloudABI signal number. */ static cloudabi_signal_t @@ -98,7 +99,7 @@ cloudabi64_kevent_copyin(void *arg, struct kevent *kevp, int count) return (error); memset(kevp, 0, sizeof(*kevp)); - kevp->udata = (void *)sub.userdata; + kevp->udata = TO_PTR(sub.userdata); switch (sub.type) { case CLOUDABI_EVENTTYPE_CLOCK: kevp->filter = EVFILT_TIMER; @@ -264,9 +265,9 @@ cloudabi64_sys_poll(struct thread *td, struct cloudabi64_sys_poll_args *uap) ev.condvar.condvar = sub.condvar.condvar; ev.error = cloudabi_convert_errno( cloudabi_futex_condvar_wait( - td, (cloudabi_condvar_t *)sub.condvar.condvar, + td, TO_PTR(sub.condvar.condvar), sub.condvar.condvar_scope, - (cloudabi_lock_t *)sub.condvar.lock, + TO_PTR(sub.condvar.lock), sub.condvar.lock_scope, CLOUDABI_CLOCK_MONOTONIC, UINT64_MAX, 0)); td->td_retval[0] = 1; @@ -276,7 +277,7 @@ cloudabi64_sys_poll(struct thread *td, struct cloudabi64_sys_poll_args *uap) ev.lock.lock = sub.lock.lock; ev.error = cloudabi_convert_errno( cloudabi_futex_lock_rdlock( - td, (cloudabi_lock_t *)sub.lock.lock, + td, TO_PTR(sub.lock.lock), sub.lock.lock_scope, CLOUDABI_CLOCK_MONOTONIC, UINT64_MAX, 0)); td->td_retval[0] = 1; @@ -286,7 +287,7 @@ cloudabi64_sys_poll(struct thread *td, struct cloudabi64_sys_poll_args *uap) ev.lock.lock = sub.lock.lock; ev.error = cloudabi_convert_errno( cloudabi_futex_lock_wrlock( - td, (cloudabi_lock_t *)sub.lock.lock, + td, TO_PTR(sub.lock.lock), sub.lock.lock_scope, CLOUDABI_CLOCK_MONOTONIC, UINT64_MAX, 0)); td->td_retval[0] = 1; @@ -311,9 +312,9 @@ cloudabi64_sys_poll(struct thread *td, struct cloudabi64_sys_poll_args *uap) ev[0].condvar.condvar = sub[0].condvar.condvar; ev[1].clock.identifier = sub[1].clock.identifier; error = cloudabi_futex_condvar_wait( - td, (cloudabi_condvar_t *)sub[0].condvar.condvar, + td, TO_PTR(sub[0].condvar.condvar), sub[0].condvar.condvar_scope, - (cloudabi_lock_t *)sub[0].condvar.lock, + TO_PTR(sub[0].condvar.lock), sub[0].condvar.lock_scope, sub[1].clock.clock_id, sub[1].clock.timeout, sub[1].clock.precision); if (error == ETIMEDOUT) { @@ -332,7 +333,7 @@ cloudabi64_sys_poll(struct thread *td, struct cloudabi64_sys_poll_args *uap) ev[0].lock.lock = sub[0].lock.lock; ev[1].clock.identifier = sub[1].clock.identifier; error = cloudabi_futex_lock_rdlock( - td, (cloudabi_lock_t *)sub[0].lock.lock, + td, TO_PTR(sub[0].lock.lock), sub[0].lock.lock_scope, sub[1].clock.clock_id, sub[1].clock.timeout, sub[1].clock.precision); if (error == ETIMEDOUT) { @@ -351,7 +352,7 @@ cloudabi64_sys_poll(struct thread *td, struct cloudabi64_sys_poll_args *uap) ev[0].lock.lock = sub[0].lock.lock; ev[1].clock.identifier = sub[1].clock.identifier; error = cloudabi_futex_lock_wrlock( - td, (cloudabi_lock_t *)sub[0].lock.lock, + td, TO_PTR(sub[0].lock.lock), sub[0].lock.lock_scope, sub[1].clock.clock_id, sub[1].clock.timeout, sub[1].clock.precision); if (error == ETIMEDOUT) { diff --git a/sys/compat/cloudabi64/cloudabi64_proto.h b/sys/compat/cloudabi64/cloudabi64_proto.h index 79a0f60..aed44ad 100644 --- a/sys/compat/cloudabi64/cloudabi64_proto.h +++ b/sys/compat/cloudabi64/cloudabi64_proto.h @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/contrib/cloudabi/syscalls.master 297468 2016-03-31 18:50:06Z ed + * created from FreeBSD: head/sys/contrib/cloudabi/syscalls64.master 304483 2016-08-19 17:53:37Z ed */ #ifndef _CLOUDABI64_SYSPROTO_H_ @@ -236,6 +236,14 @@ struct cloudabi64_sys_poll_args { char out_l_[PADL_(cloudabi64_event_t *)]; cloudabi64_event_t * out; char out_r_[PADR_(cloudabi64_event_t *)]; char nsubscriptions_l_[PADL_(size_t)]; size_t nsubscriptions; char nsubscriptions_r_[PADR_(size_t)]; }; +struct cloudabi64_sys_poll_fd_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char in_l_[PADL_(const cloudabi64_subscription_t *)]; const cloudabi64_subscription_t * in; char in_r_[PADR_(const cloudabi64_subscription_t *)]; + char nin_l_[PADL_(size_t)]; size_t nin; char nin_r_[PADR_(size_t)]; + char out_l_[PADL_(cloudabi64_event_t *)]; cloudabi64_event_t * out; char out_r_[PADR_(cloudabi64_event_t *)]; + char nout_l_[PADL_(size_t)]; size_t nout; char nout_r_[PADR_(size_t)]; + char timeout_l_[PADL_(const cloudabi64_subscription_t *)]; const cloudabi64_subscription_t * timeout; char timeout_r_[PADR_(const cloudabi64_subscription_t *)]; +}; struct cloudabi_sys_proc_exec_args { char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; char data_l_[PADL_(const void *)]; const void * data; char data_r_[PADR_(const void *)]; @@ -302,20 +310,9 @@ struct cloudabi_sys_thread_exit_args { char lock_l_[PADL_(cloudabi_lock_t *)]; cloudabi_lock_t * lock; char lock_r_[PADR_(cloudabi_lock_t *)]; char scope_l_[PADL_(cloudabi_scope_t)]; cloudabi_scope_t scope; char scope_r_[PADR_(cloudabi_scope_t)]; }; -struct cloudabi_sys_thread_tcb_set_args { - char tcb_l_[PADL_(void *)]; void * tcb; char tcb_r_[PADR_(void *)]; -}; struct cloudabi_sys_thread_yield_args { register_t dummy; }; -struct cloudabi64_sys_poll_fd_args { - char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; - char in_l_[PADL_(const cloudabi64_subscription_t *)]; const cloudabi64_subscription_t * in; char in_r_[PADR_(const cloudabi64_subscription_t *)]; - char nin_l_[PADL_(size_t)]; size_t nin; char nin_r_[PADR_(size_t)]; - char out_l_[PADL_(cloudabi64_event_t *)]; cloudabi64_event_t * out; char out_r_[PADR_(cloudabi64_event_t *)]; - char nout_l_[PADL_(size_t)]; size_t nout; char nout_r_[PADR_(size_t)]; - char timeout_l_[PADL_(const cloudabi64_subscription_t *)]; const cloudabi64_subscription_t * timeout; char timeout_r_[PADR_(const cloudabi64_subscription_t *)]; -}; int cloudabi_sys_clock_res_get(struct thread *, struct cloudabi_sys_clock_res_get_args *); int cloudabi_sys_clock_time_get(struct thread *, struct cloudabi_sys_clock_time_get_args *); int cloudabi_sys_condvar_signal(struct thread *, struct cloudabi_sys_condvar_signal_args *); @@ -356,6 +353,7 @@ int cloudabi_sys_mem_sync(struct thread *, struct cloudabi_sys_mem_sync_args *); int cloudabi_sys_mem_unlock(struct thread *, struct cloudabi_sys_mem_unlock_args *); int cloudabi_sys_mem_unmap(struct thread *, struct cloudabi_sys_mem_unmap_args *); int cloudabi64_sys_poll(struct thread *, struct cloudabi64_sys_poll_args *); +int cloudabi64_sys_poll_fd(struct thread *, struct cloudabi64_sys_poll_fd_args *); int cloudabi_sys_proc_exec(struct thread *, struct cloudabi_sys_proc_exec_args *); int cloudabi_sys_proc_exit(struct thread *, struct cloudabi_sys_proc_exit_args *); int cloudabi_sys_proc_fork(struct thread *, struct cloudabi_sys_proc_fork_args *); @@ -371,9 +369,7 @@ int cloudabi_sys_sock_shutdown(struct thread *, struct cloudabi_sys_sock_shutdow int cloudabi_sys_sock_stat_get(struct thread *, struct cloudabi_sys_sock_stat_get_args *); int cloudabi64_sys_thread_create(struct thread *, struct cloudabi64_sys_thread_create_args *); int cloudabi_sys_thread_exit(struct thread *, struct cloudabi_sys_thread_exit_args *); -int cloudabi_sys_thread_tcb_set(struct thread *, struct cloudabi_sys_thread_tcb_set_args *); int cloudabi_sys_thread_yield(struct thread *, struct cloudabi_sys_thread_yield_args *); -int cloudabi64_sys_poll_fd(struct thread *, struct cloudabi64_sys_poll_fd_args *); #ifdef COMPAT_43 @@ -398,6 +394,12 @@ int cloudabi64_sys_poll_fd(struct thread *, struct cloudabi64_sys_poll_fd_args * #endif /* COMPAT_FREEBSD7 */ + +#ifdef COMPAT_FREEBSD10 + + +#endif /* COMPAT_FREEBSD10 */ + #define CLOUDABI64_SYS_AUE_cloudabi_sys_clock_res_get AUE_NULL #define CLOUDABI64_SYS_AUE_cloudabi_sys_clock_time_get AUE_NULL #define CLOUDABI64_SYS_AUE_cloudabi_sys_condvar_signal AUE_NULL @@ -438,6 +440,7 @@ int cloudabi64_sys_poll_fd(struct thread *, struct cloudabi64_sys_poll_fd_args * #define CLOUDABI64_SYS_AUE_cloudabi_sys_mem_unlock AUE_NULL #define CLOUDABI64_SYS_AUE_cloudabi_sys_mem_unmap AUE_NULL #define CLOUDABI64_SYS_AUE_cloudabi64_sys_poll AUE_NULL +#define CLOUDABI64_SYS_AUE_cloudabi64_sys_poll_fd AUE_NULL #define CLOUDABI64_SYS_AUE_cloudabi_sys_proc_exec AUE_NULL #define CLOUDABI64_SYS_AUE_cloudabi_sys_proc_exit AUE_NULL #define CLOUDABI64_SYS_AUE_cloudabi_sys_proc_fork AUE_NULL @@ -453,9 +456,7 @@ int cloudabi64_sys_poll_fd(struct thread *, struct cloudabi64_sys_poll_fd_args * #define CLOUDABI64_SYS_AUE_cloudabi_sys_sock_stat_get AUE_NULL #define CLOUDABI64_SYS_AUE_cloudabi64_sys_thread_create AUE_NULL #define CLOUDABI64_SYS_AUE_cloudabi_sys_thread_exit AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi_sys_thread_tcb_set AUE_NULL #define CLOUDABI64_SYS_AUE_cloudabi_sys_thread_yield AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi64_sys_poll_fd AUE_NULL #undef PAD_ #undef PADL_ diff --git a/sys/compat/cloudabi64/cloudabi64_sock.c b/sys/compat/cloudabi64/cloudabi64_sock.c index e6b9c94..3915ddf 100644 --- a/sys/compat/cloudabi64/cloudabi64_sock.c +++ b/sys/compat/cloudabi64/cloudabi64_sock.c @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include <compat/cloudabi/cloudabi_util.h> #include <compat/cloudabi64/cloudabi64_proto.h> +#include <compat/cloudabi64/cloudabi64_util.h> static MALLOC_DEFINE(M_SOCKET, "socket", "CloudABI socket"); @@ -52,6 +53,7 @@ cloudabi64_sys_sock_recv(struct thread *td, cloudabi64_recv_out_t ro = {}; cloudabi64_iovec_t iovobj; struct msghdr msghdr = {}; + const cloudabi64_iovec_t *user_iov; size_t i; int error; @@ -65,14 +67,14 @@ cloudabi64_sys_sock_recv(struct thread *td, msghdr.msg_iovlen = ri.ri_datalen; msghdr.msg_iov = malloc(msghdr.msg_iovlen * sizeof(struct iovec), M_SOCKET, M_WAITOK); + user_iov = TO_PTR(ri.ri_data); for (i = 0; i < msghdr.msg_iovlen; i++) { - error = copyin(&((cloudabi64_iovec_t *)ri.ri_data)[i], &iovobj, - sizeof(iovobj)); + error = copyin(&user_iov[i], &iovobj, sizeof(iovobj)); if (error != 0) { free(msghdr.msg_iov, M_SOCKET); return (error); } - msghdr.msg_iov[i].iov_base = (void *)iovobj.iov_base; + msghdr.msg_iov[i].iov_base = TO_PTR(iovobj.iov_base); msghdr.msg_iov[i].iov_len = iovobj.iov_len; } msghdr.msg_name = &ss; @@ -104,6 +106,7 @@ cloudabi64_sys_sock_send(struct thread *td, cloudabi64_send_out_t so = {}; cloudabi64_ciovec_t iovobj; struct msghdr msghdr = {}; + const cloudabi64_ciovec_t *user_iov; size_t i; int error, flags; @@ -117,14 +120,14 @@ cloudabi64_sys_sock_send(struct thread *td, msghdr.msg_iovlen = si.si_datalen; msghdr.msg_iov = malloc(msghdr.msg_iovlen * sizeof(struct iovec), M_SOCKET, M_WAITOK); + user_iov = TO_PTR(si.si_data); for (i = 0; i < msghdr.msg_iovlen; i++) { - error = copyin(&((cloudabi64_ciovec_t *)si.si_data)[i], &iovobj, - sizeof(iovobj)); + error = copyin(&user_iov[i], &iovobj, sizeof(iovobj)); if (error != 0) { free(msghdr.msg_iov, M_SOCKET); return (error); } - msghdr.msg_iov[i].iov_base = (void *)iovobj.iov_base; + msghdr.msg_iov[i].iov_base = TO_PTR(iovobj.iov_base); msghdr.msg_iov[i].iov_len = iovobj.iov_len; } diff --git a/sys/compat/cloudabi64/cloudabi64_syscall.h b/sys/compat/cloudabi64/cloudabi64_syscall.h index b5694bf..7d99d5e 100644 --- a/sys/compat/cloudabi64/cloudabi64_syscall.h +++ b/sys/compat/cloudabi64/cloudabi64_syscall.h @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/contrib/cloudabi/syscalls.master 297468 2016-03-31 18:50:06Z ed + * created from FreeBSD: head/sys/contrib/cloudabi/syscalls64.master 304483 2016-08-19 17:53:37Z ed */ #define CLOUDABI64_SYS_cloudabi_sys_clock_res_get 0 @@ -46,22 +46,21 @@ #define CLOUDABI64_SYS_cloudabi_sys_mem_unlock 37 #define CLOUDABI64_SYS_cloudabi_sys_mem_unmap 38 #define CLOUDABI64_SYS_cloudabi64_sys_poll 39 -#define CLOUDABI64_SYS_cloudabi_sys_proc_exec 40 -#define CLOUDABI64_SYS_cloudabi_sys_proc_exit 41 -#define CLOUDABI64_SYS_cloudabi_sys_proc_fork 42 -#define CLOUDABI64_SYS_cloudabi_sys_proc_raise 43 -#define CLOUDABI64_SYS_cloudabi_sys_random_get 44 -#define CLOUDABI64_SYS_cloudabi_sys_sock_accept 45 -#define CLOUDABI64_SYS_cloudabi_sys_sock_bind 46 -#define CLOUDABI64_SYS_cloudabi_sys_sock_connect 47 -#define CLOUDABI64_SYS_cloudabi_sys_sock_listen 48 -#define CLOUDABI64_SYS_cloudabi64_sys_sock_recv 49 -#define CLOUDABI64_SYS_cloudabi64_sys_sock_send 50 -#define CLOUDABI64_SYS_cloudabi_sys_sock_shutdown 51 -#define CLOUDABI64_SYS_cloudabi_sys_sock_stat_get 52 -#define CLOUDABI64_SYS_cloudabi64_sys_thread_create 53 -#define CLOUDABI64_SYS_cloudabi_sys_thread_exit 54 -#define CLOUDABI64_SYS_cloudabi_sys_thread_tcb_set 55 +#define CLOUDABI64_SYS_cloudabi64_sys_poll_fd 40 +#define CLOUDABI64_SYS_cloudabi_sys_proc_exec 41 +#define CLOUDABI64_SYS_cloudabi_sys_proc_exit 42 +#define CLOUDABI64_SYS_cloudabi_sys_proc_fork 43 +#define CLOUDABI64_SYS_cloudabi_sys_proc_raise 44 +#define CLOUDABI64_SYS_cloudabi_sys_random_get 45 +#define CLOUDABI64_SYS_cloudabi_sys_sock_accept 46 +#define CLOUDABI64_SYS_cloudabi_sys_sock_bind 47 +#define CLOUDABI64_SYS_cloudabi_sys_sock_connect 48 +#define CLOUDABI64_SYS_cloudabi_sys_sock_listen 49 +#define CLOUDABI64_SYS_cloudabi64_sys_sock_recv 50 +#define CLOUDABI64_SYS_cloudabi64_sys_sock_send 51 +#define CLOUDABI64_SYS_cloudabi_sys_sock_shutdown 52 +#define CLOUDABI64_SYS_cloudabi_sys_sock_stat_get 53 +#define CLOUDABI64_SYS_cloudabi64_sys_thread_create 54 +#define CLOUDABI64_SYS_cloudabi_sys_thread_exit 55 #define CLOUDABI64_SYS_cloudabi_sys_thread_yield 56 -#define CLOUDABI64_SYS_cloudabi64_sys_poll_fd 57 -#define CLOUDABI64_SYS_MAXSYSCALL 58 +#define CLOUDABI64_SYS_MAXSYSCALL 57 diff --git a/sys/compat/cloudabi64/cloudabi64_syscalls.c b/sys/compat/cloudabi64/cloudabi64_syscalls.c index 03407ff..d430056 100644 --- a/sys/compat/cloudabi64/cloudabi64_syscalls.c +++ b/sys/compat/cloudabi64/cloudabi64_syscalls.c @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/contrib/cloudabi/syscalls.master 297468 2016-03-31 18:50:06Z ed + * created from FreeBSD: head/sys/contrib/cloudabi/syscalls64.master 304483 2016-08-19 17:53:37Z ed */ const char *cloudabi64_syscallnames[] = { @@ -47,22 +47,21 @@ const char *cloudabi64_syscallnames[] = { "cloudabi_sys_mem_unlock", /* 37 = cloudabi_sys_mem_unlock */ "cloudabi_sys_mem_unmap", /* 38 = cloudabi_sys_mem_unmap */ "cloudabi64_sys_poll", /* 39 = cloudabi64_sys_poll */ - "cloudabi_sys_proc_exec", /* 40 = cloudabi_sys_proc_exec */ - "cloudabi_sys_proc_exit", /* 41 = cloudabi_sys_proc_exit */ - "cloudabi_sys_proc_fork", /* 42 = cloudabi_sys_proc_fork */ - "cloudabi_sys_proc_raise", /* 43 = cloudabi_sys_proc_raise */ - "cloudabi_sys_random_get", /* 44 = cloudabi_sys_random_get */ - "cloudabi_sys_sock_accept", /* 45 = cloudabi_sys_sock_accept */ - "cloudabi_sys_sock_bind", /* 46 = cloudabi_sys_sock_bind */ - "cloudabi_sys_sock_connect", /* 47 = cloudabi_sys_sock_connect */ - "cloudabi_sys_sock_listen", /* 48 = cloudabi_sys_sock_listen */ - "cloudabi64_sys_sock_recv", /* 49 = cloudabi64_sys_sock_recv */ - "cloudabi64_sys_sock_send", /* 50 = cloudabi64_sys_sock_send */ - "cloudabi_sys_sock_shutdown", /* 51 = cloudabi_sys_sock_shutdown */ - "cloudabi_sys_sock_stat_get", /* 52 = cloudabi_sys_sock_stat_get */ - "cloudabi64_sys_thread_create", /* 53 = cloudabi64_sys_thread_create */ - "cloudabi_sys_thread_exit", /* 54 = cloudabi_sys_thread_exit */ - "cloudabi_sys_thread_tcb_set", /* 55 = cloudabi_sys_thread_tcb_set */ + "cloudabi64_sys_poll_fd", /* 40 = cloudabi64_sys_poll_fd */ + "cloudabi_sys_proc_exec", /* 41 = cloudabi_sys_proc_exec */ + "cloudabi_sys_proc_exit", /* 42 = cloudabi_sys_proc_exit */ + "cloudabi_sys_proc_fork", /* 43 = cloudabi_sys_proc_fork */ + "cloudabi_sys_proc_raise", /* 44 = cloudabi_sys_proc_raise */ + "cloudabi_sys_random_get", /* 45 = cloudabi_sys_random_get */ + "cloudabi_sys_sock_accept", /* 46 = cloudabi_sys_sock_accept */ + "cloudabi_sys_sock_bind", /* 47 = cloudabi_sys_sock_bind */ + "cloudabi_sys_sock_connect", /* 48 = cloudabi_sys_sock_connect */ + "cloudabi_sys_sock_listen", /* 49 = cloudabi_sys_sock_listen */ + "cloudabi64_sys_sock_recv", /* 50 = cloudabi64_sys_sock_recv */ + "cloudabi64_sys_sock_send", /* 51 = cloudabi64_sys_sock_send */ + "cloudabi_sys_sock_shutdown", /* 52 = cloudabi_sys_sock_shutdown */ + "cloudabi_sys_sock_stat_get", /* 53 = cloudabi_sys_sock_stat_get */ + "cloudabi64_sys_thread_create", /* 54 = cloudabi64_sys_thread_create */ + "cloudabi_sys_thread_exit", /* 55 = cloudabi_sys_thread_exit */ "cloudabi_sys_thread_yield", /* 56 = cloudabi_sys_thread_yield */ - "cloudabi64_sys_poll_fd", /* 57 = cloudabi64_sys_poll_fd */ }; diff --git a/sys/compat/cloudabi64/cloudabi64_sysent.c b/sys/compat/cloudabi64/cloudabi64_sysent.c index 50f4a65..3b11850 100644 --- a/sys/compat/cloudabi64/cloudabi64_sysent.c +++ b/sys/compat/cloudabi64/cloudabi64_sysent.c @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/contrib/cloudabi/syscalls.master 297468 2016-03-31 18:50:06Z ed + * created from FreeBSD: head/sys/contrib/cloudabi/syscalls64.master 304483 2016-08-19 17:53:37Z ed */ #include <sys/sysent.h> @@ -55,22 +55,21 @@ struct sysent cloudabi64_sysent[] = { { AS(cloudabi_sys_mem_unlock_args), (sy_call_t *)cloudabi_sys_mem_unlock, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 37 = cloudabi_sys_mem_unlock */ { AS(cloudabi_sys_mem_unmap_args), (sy_call_t *)cloudabi_sys_mem_unmap, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 38 = cloudabi_sys_mem_unmap */ { AS(cloudabi64_sys_poll_args), (sy_call_t *)cloudabi64_sys_poll, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 39 = cloudabi64_sys_poll */ - { AS(cloudabi_sys_proc_exec_args), (sy_call_t *)cloudabi_sys_proc_exec, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 40 = cloudabi_sys_proc_exec */ - { AS(cloudabi_sys_proc_exit_args), (sy_call_t *)cloudabi_sys_proc_exit, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 41 = cloudabi_sys_proc_exit */ - { 0, (sy_call_t *)cloudabi_sys_proc_fork, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 42 = cloudabi_sys_proc_fork */ - { AS(cloudabi_sys_proc_raise_args), (sy_call_t *)cloudabi_sys_proc_raise, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 43 = cloudabi_sys_proc_raise */ - { AS(cloudabi_sys_random_get_args), (sy_call_t *)cloudabi_sys_random_get, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 44 = cloudabi_sys_random_get */ - { AS(cloudabi_sys_sock_accept_args), (sy_call_t *)cloudabi_sys_sock_accept, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 45 = cloudabi_sys_sock_accept */ - { AS(cloudabi_sys_sock_bind_args), (sy_call_t *)cloudabi_sys_sock_bind, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 46 = cloudabi_sys_sock_bind */ - { AS(cloudabi_sys_sock_connect_args), (sy_call_t *)cloudabi_sys_sock_connect, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 47 = cloudabi_sys_sock_connect */ - { AS(cloudabi_sys_sock_listen_args), (sy_call_t *)cloudabi_sys_sock_listen, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 48 = cloudabi_sys_sock_listen */ - { AS(cloudabi64_sys_sock_recv_args), (sy_call_t *)cloudabi64_sys_sock_recv, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 49 = cloudabi64_sys_sock_recv */ - { AS(cloudabi64_sys_sock_send_args), (sy_call_t *)cloudabi64_sys_sock_send, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 50 = cloudabi64_sys_sock_send */ - { AS(cloudabi_sys_sock_shutdown_args), (sy_call_t *)cloudabi_sys_sock_shutdown, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 51 = cloudabi_sys_sock_shutdown */ - { AS(cloudabi_sys_sock_stat_get_args), (sy_call_t *)cloudabi_sys_sock_stat_get, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 52 = cloudabi_sys_sock_stat_get */ - { AS(cloudabi64_sys_thread_create_args), (sy_call_t *)cloudabi64_sys_thread_create, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 53 = cloudabi64_sys_thread_create */ - { AS(cloudabi_sys_thread_exit_args), (sy_call_t *)cloudabi_sys_thread_exit, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 54 = cloudabi_sys_thread_exit */ - { AS(cloudabi_sys_thread_tcb_set_args), (sy_call_t *)cloudabi_sys_thread_tcb_set, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 55 = cloudabi_sys_thread_tcb_set */ + { AS(cloudabi64_sys_poll_fd_args), (sy_call_t *)cloudabi64_sys_poll_fd, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 40 = cloudabi64_sys_poll_fd */ + { AS(cloudabi_sys_proc_exec_args), (sy_call_t *)cloudabi_sys_proc_exec, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 41 = cloudabi_sys_proc_exec */ + { AS(cloudabi_sys_proc_exit_args), (sy_call_t *)cloudabi_sys_proc_exit, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 42 = cloudabi_sys_proc_exit */ + { 0, (sy_call_t *)cloudabi_sys_proc_fork, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 43 = cloudabi_sys_proc_fork */ + { AS(cloudabi_sys_proc_raise_args), (sy_call_t *)cloudabi_sys_proc_raise, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 44 = cloudabi_sys_proc_raise */ + { AS(cloudabi_sys_random_get_args), (sy_call_t *)cloudabi_sys_random_get, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 45 = cloudabi_sys_random_get */ + { AS(cloudabi_sys_sock_accept_args), (sy_call_t *)cloudabi_sys_sock_accept, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 46 = cloudabi_sys_sock_accept */ + { AS(cloudabi_sys_sock_bind_args), (sy_call_t *)cloudabi_sys_sock_bind, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 47 = cloudabi_sys_sock_bind */ + { AS(cloudabi_sys_sock_connect_args), (sy_call_t *)cloudabi_sys_sock_connect, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 48 = cloudabi_sys_sock_connect */ + { AS(cloudabi_sys_sock_listen_args), (sy_call_t *)cloudabi_sys_sock_listen, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 49 = cloudabi_sys_sock_listen */ + { AS(cloudabi64_sys_sock_recv_args), (sy_call_t *)cloudabi64_sys_sock_recv, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 50 = cloudabi64_sys_sock_recv */ + { AS(cloudabi64_sys_sock_send_args), (sy_call_t *)cloudabi64_sys_sock_send, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 51 = cloudabi64_sys_sock_send */ + { AS(cloudabi_sys_sock_shutdown_args), (sy_call_t *)cloudabi_sys_sock_shutdown, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 52 = cloudabi_sys_sock_shutdown */ + { AS(cloudabi_sys_sock_stat_get_args), (sy_call_t *)cloudabi_sys_sock_stat_get, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 53 = cloudabi_sys_sock_stat_get */ + { AS(cloudabi64_sys_thread_create_args), (sy_call_t *)cloudabi64_sys_thread_create, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 54 = cloudabi64_sys_thread_create */ + { AS(cloudabi_sys_thread_exit_args), (sy_call_t *)cloudabi_sys_thread_exit, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 55 = cloudabi_sys_thread_exit */ { 0, (sy_call_t *)cloudabi_sys_thread_yield, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 56 = cloudabi_sys_thread_yield */ - { AS(cloudabi64_sys_poll_fd_args), (sy_call_t *)cloudabi64_sys_poll_fd, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 57 = cloudabi64_sys_poll_fd */ }; diff --git a/sys/compat/cloudabi64/cloudabi64_systrace_args.c b/sys/compat/cloudabi64/cloudabi64_systrace_args.c index 9429e8e..3e97b25 100644 --- a/sys/compat/cloudabi64/cloudabi64_systrace_args.c +++ b/sys/compat/cloudabi64/cloudabi64_systrace_args.c @@ -373,8 +373,20 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) *n_args = 3; break; } - /* cloudabi_sys_proc_exec */ + /* cloudabi64_sys_poll_fd */ case 40: { + struct cloudabi64_sys_poll_fd_args *p = params; + iarg[0] = p->fd; /* cloudabi_fd_t */ + uarg[1] = (intptr_t) p->in; /* const cloudabi64_subscription_t * */ + uarg[2] = p->nin; /* size_t */ + uarg[3] = (intptr_t) p->out; /* cloudabi64_event_t * */ + uarg[4] = p->nout; /* size_t */ + uarg[5] = (intptr_t) p->timeout; /* const cloudabi64_subscription_t * */ + *n_args = 6; + break; + } + /* cloudabi_sys_proc_exec */ + case 41: { struct cloudabi_sys_proc_exec_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->data; /* const void * */ @@ -385,26 +397,26 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) break; } /* cloudabi_sys_proc_exit */ - case 41: { + case 42: { struct cloudabi_sys_proc_exit_args *p = params; iarg[0] = p->rval; /* cloudabi_exitcode_t */ *n_args = 1; break; } /* cloudabi_sys_proc_fork */ - case 42: { + case 43: { *n_args = 0; break; } /* cloudabi_sys_proc_raise */ - case 43: { + case 44: { struct cloudabi_sys_proc_raise_args *p = params; iarg[0] = p->sig; /* cloudabi_signal_t */ *n_args = 1; break; } /* cloudabi_sys_random_get */ - case 44: { + case 45: { struct cloudabi_sys_random_get_args *p = params; uarg[0] = (intptr_t) p->buf; /* void * */ uarg[1] = p->nbyte; /* size_t */ @@ -412,7 +424,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) break; } /* cloudabi_sys_sock_accept */ - case 45: { + case 46: { struct cloudabi_sys_sock_accept_args *p = params; iarg[0] = p->sock; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->buf; /* cloudabi_sockstat_t * */ @@ -420,7 +432,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) break; } /* cloudabi_sys_sock_bind */ - case 46: { + case 47: { struct cloudabi_sys_sock_bind_args *p = params; iarg[0] = p->sock; /* cloudabi_fd_t */ iarg[1] = p->fd; /* cloudabi_fd_t */ @@ -430,7 +442,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) break; } /* cloudabi_sys_sock_connect */ - case 47: { + case 48: { struct cloudabi_sys_sock_connect_args *p = params; iarg[0] = p->sock; /* cloudabi_fd_t */ iarg[1] = p->fd; /* cloudabi_fd_t */ @@ -440,7 +452,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) break; } /* cloudabi_sys_sock_listen */ - case 48: { + case 49: { struct cloudabi_sys_sock_listen_args *p = params; iarg[0] = p->sock; /* cloudabi_fd_t */ iarg[1] = p->backlog; /* cloudabi_backlog_t */ @@ -448,7 +460,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) break; } /* cloudabi64_sys_sock_recv */ - case 49: { + case 50: { struct cloudabi64_sys_sock_recv_args *p = params; iarg[0] = p->sock; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->in; /* const cloudabi64_recv_in_t * */ @@ -457,7 +469,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) break; } /* cloudabi64_sys_sock_send */ - case 50: { + case 51: { struct cloudabi64_sys_sock_send_args *p = params; iarg[0] = p->sock; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->in; /* const cloudabi64_send_in_t * */ @@ -466,7 +478,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) break; } /* cloudabi_sys_sock_shutdown */ - case 51: { + case 52: { struct cloudabi_sys_sock_shutdown_args *p = params; iarg[0] = p->sock; /* cloudabi_fd_t */ iarg[1] = p->how; /* cloudabi_sdflags_t */ @@ -474,7 +486,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) break; } /* cloudabi_sys_sock_stat_get */ - case 52: { + case 53: { struct cloudabi_sys_sock_stat_get_args *p = params; iarg[0] = p->sock; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->buf; /* cloudabi_sockstat_t * */ @@ -483,44 +495,25 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) break; } /* cloudabi64_sys_thread_create */ - case 53: { + case 54: { struct cloudabi64_sys_thread_create_args *p = params; uarg[0] = (intptr_t) p->attr; /* cloudabi64_threadattr_t * */ *n_args = 1; break; } /* cloudabi_sys_thread_exit */ - case 54: { + case 55: { struct cloudabi_sys_thread_exit_args *p = params; uarg[0] = (intptr_t) p->lock; /* cloudabi_lock_t * */ iarg[1] = p->scope; /* cloudabi_scope_t */ *n_args = 2; break; } - /* cloudabi_sys_thread_tcb_set */ - case 55: { - struct cloudabi_sys_thread_tcb_set_args *p = params; - uarg[0] = (intptr_t) p->tcb; /* void * */ - *n_args = 1; - break; - } /* cloudabi_sys_thread_yield */ case 56: { *n_args = 0; break; } - /* cloudabi64_sys_poll_fd */ - case 57: { - struct cloudabi64_sys_poll_fd_args *p = params; - iarg[0] = p->fd; /* cloudabi_fd_t */ - uarg[1] = (intptr_t) p->in; /* const cloudabi64_subscription_t * */ - uarg[2] = p->nin; /* size_t */ - uarg[3] = (intptr_t) p->out; /* cloudabi64_event_t * */ - uarg[4] = p->nout; /* size_t */ - uarg[5] = (intptr_t) p->timeout; /* const cloudabi64_subscription_t * */ - *n_args = 6; - break; - } default: *n_args = 0; break; @@ -1177,13 +1170,38 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) break; }; break; - /* cloudabi_sys_proc_exec */ + /* cloudabi64_sys_poll_fd */ case 40: switch(ndx) { case 0: p = "cloudabi_fd_t"; break; case 1: + p = "const cloudabi64_subscription_t *"; + break; + case 2: + p = "size_t"; + break; + case 3: + p = "cloudabi64_event_t *"; + break; + case 4: + p = "size_t"; + break; + case 5: + p = "const cloudabi64_subscription_t *"; + break; + default: + break; + }; + break; + /* cloudabi_sys_proc_exec */ + case 41: + switch(ndx) { + case 0: + p = "cloudabi_fd_t"; + break; + case 1: p = "const void *"; break; case 2: @@ -1200,7 +1218,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) }; break; /* cloudabi_sys_proc_exit */ - case 41: + case 42: switch(ndx) { case 0: p = "cloudabi_exitcode_t"; @@ -1210,10 +1228,10 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) }; break; /* cloudabi_sys_proc_fork */ - case 42: + case 43: break; /* cloudabi_sys_proc_raise */ - case 43: + case 44: switch(ndx) { case 0: p = "cloudabi_signal_t"; @@ -1223,7 +1241,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) }; break; /* cloudabi_sys_random_get */ - case 44: + case 45: switch(ndx) { case 0: p = "void *"; @@ -1236,7 +1254,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) }; break; /* cloudabi_sys_sock_accept */ - case 45: + case 46: switch(ndx) { case 0: p = "cloudabi_fd_t"; @@ -1249,7 +1267,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) }; break; /* cloudabi_sys_sock_bind */ - case 46: + case 47: switch(ndx) { case 0: p = "cloudabi_fd_t"; @@ -1268,7 +1286,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) }; break; /* cloudabi_sys_sock_connect */ - case 47: + case 48: switch(ndx) { case 0: p = "cloudabi_fd_t"; @@ -1287,7 +1305,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) }; break; /* cloudabi_sys_sock_listen */ - case 48: + case 49: switch(ndx) { case 0: p = "cloudabi_fd_t"; @@ -1300,7 +1318,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) }; break; /* cloudabi64_sys_sock_recv */ - case 49: + case 50: switch(ndx) { case 0: p = "cloudabi_fd_t"; @@ -1316,7 +1334,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) }; break; /* cloudabi64_sys_sock_send */ - case 50: + case 51: switch(ndx) { case 0: p = "cloudabi_fd_t"; @@ -1332,7 +1350,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) }; break; /* cloudabi_sys_sock_shutdown */ - case 51: + case 52: switch(ndx) { case 0: p = "cloudabi_fd_t"; @@ -1345,7 +1363,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) }; break; /* cloudabi_sys_sock_stat_get */ - case 52: + case 53: switch(ndx) { case 0: p = "cloudabi_fd_t"; @@ -1361,7 +1379,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) }; break; /* cloudabi64_sys_thread_create */ - case 53: + case 54: switch(ndx) { case 0: p = "cloudabi64_threadattr_t *"; @@ -1371,7 +1389,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) }; break; /* cloudabi_sys_thread_exit */ - case 54: + case 55: switch(ndx) { case 0: p = "cloudabi_lock_t *"; @@ -1383,44 +1401,9 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) break; }; break; - /* cloudabi_sys_thread_tcb_set */ - case 55: - switch(ndx) { - case 0: - p = "void *"; - break; - default: - break; - }; - break; /* cloudabi_sys_thread_yield */ case 56: break; - /* cloudabi64_sys_poll_fd */ - case 57: - switch(ndx) { - case 0: - p = "cloudabi_fd_t"; - break; - case 1: - p = "const cloudabi64_subscription_t *"; - break; - case 2: - p = "size_t"; - break; - case 3: - p = "cloudabi64_event_t *"; - break; - case 4: - p = "size_t"; - break; - case 5: - p = "const cloudabi64_subscription_t *"; - break; - default: - break; - }; - break; default: break; }; @@ -1632,90 +1615,85 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) if (ndx == 0 || ndx == 1) p = "size_t"; break; - /* cloudabi_sys_proc_exec */ + /* cloudabi64_sys_poll_fd */ case 40: if (ndx == 0 || ndx == 1) + p = "size_t"; + break; + /* cloudabi_sys_proc_exec */ + case 41: + if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_proc_exit */ - case 41: + case 42: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_proc_fork */ - case 42: - /* cloudabi_sys_proc_raise */ case 43: + /* cloudabi_sys_proc_raise */ + case 44: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_random_get */ - case 44: + case 45: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_sock_accept */ - case 45: + case 46: if (ndx == 0 || ndx == 1) p = "cloudabi_fd_t"; break; /* cloudabi_sys_sock_bind */ - case 46: + case 47: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_sock_connect */ - case 47: + case 48: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_sock_listen */ - case 48: + case 49: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi64_sys_sock_recv */ - case 49: + case 50: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi64_sys_sock_send */ - case 50: + case 51: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_sock_shutdown */ - case 51: + case 52: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_sock_stat_get */ - case 52: + case 53: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi64_sys_thread_create */ - case 53: + case 54: if (ndx == 0 || ndx == 1) p = "cloudabi_tid_t"; break; /* cloudabi_sys_thread_exit */ - case 54: - if (ndx == 0 || ndx == 1) - p = "void"; - break; - /* cloudabi_sys_thread_tcb_set */ case 55: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_thread_yield */ case 56: - /* cloudabi64_sys_poll_fd */ - case 57: - if (ndx == 0 || ndx == 1) - p = "size_t"; - break; default: break; }; diff --git a/sys/compat/cloudabi64/cloudabi64_util.h b/sys/compat/cloudabi64/cloudabi64_util.h index 29a90d7..5d50639 100644 --- a/sys/compat/cloudabi64/cloudabi64_util.h +++ b/sys/compat/cloudabi64/cloudabi64_util.h @@ -29,6 +29,7 @@ #define _CLOUDABI64_UTIL_H_ #include <sys/types.h> +#define __ELF_WORD_SIZE 64 #include <sys/imgact_elf.h> #include <contrib/cloudabi/cloudabi64_types.h> @@ -38,6 +39,8 @@ struct thread; extern Elf64_Brandinfo cloudabi64_brand; +#define TO_PTR(x) ((void *)(uintptr_t)(x)) + /* Stack initialization during process execution. */ register_t *cloudabi64_copyout_strings(struct image_params *); int cloudabi64_fixup(register_t **, struct image_params *); diff --git a/sys/conf/files b/sys/conf/files index 005822f..4de8306 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -275,16 +275,24 @@ cddl/dev/fbt/fbt.c optional dtrace_fbt | dtraceall compile-with "${FBT_C} cddl/dev/systrace/systrace.c optional dtrace_systrace | dtraceall compile-with "${CDDL_C}" cddl/dev/prototype.c optional dtrace_prototype | dtraceall compile-with "${CDDL_C}" fs/nfsclient/nfs_clkdtrace.c optional dtnfscl nfscl | dtraceall nfscl compile-with "${CDDL_C}" -compat/cloudabi/cloudabi_clock.c optional compat_cloudabi64 -compat/cloudabi/cloudabi_errno.c optional compat_cloudabi64 -compat/cloudabi/cloudabi_fd.c optional compat_cloudabi64 -compat/cloudabi/cloudabi_file.c optional compat_cloudabi64 -compat/cloudabi/cloudabi_futex.c optional compat_cloudabi64 -compat/cloudabi/cloudabi_mem.c optional compat_cloudabi64 -compat/cloudabi/cloudabi_proc.c optional compat_cloudabi64 -compat/cloudabi/cloudabi_random.c optional compat_cloudabi64 -compat/cloudabi/cloudabi_sock.c optional compat_cloudabi64 -compat/cloudabi/cloudabi_thread.c optional compat_cloudabi64 +compat/cloudabi/cloudabi_clock.c optional compat_cloudabi32 | compat_cloudabi64 +compat/cloudabi/cloudabi_errno.c optional compat_cloudabi32 | compat_cloudabi64 +compat/cloudabi/cloudabi_fd.c optional compat_cloudabi32 | compat_cloudabi64 +compat/cloudabi/cloudabi_file.c optional compat_cloudabi32 | compat_cloudabi64 +compat/cloudabi/cloudabi_futex.c optional compat_cloudabi32 | compat_cloudabi64 +compat/cloudabi/cloudabi_mem.c optional compat_cloudabi32 | compat_cloudabi64 +compat/cloudabi/cloudabi_proc.c optional compat_cloudabi32 | compat_cloudabi64 +compat/cloudabi/cloudabi_random.c optional compat_cloudabi32 | compat_cloudabi64 +compat/cloudabi/cloudabi_sock.c optional compat_cloudabi32 | compat_cloudabi64 +compat/cloudabi/cloudabi_thread.c optional compat_cloudabi32 | compat_cloudabi64 +compat/cloudabi/cloudabi_vdso.c optional compat_cloudabi32 | compat_cloudabi64 +compat/cloudabi32/cloudabi32_fd.c optional compat_cloudabi32 +compat/cloudabi32/cloudabi32_module.c optional compat_cloudabi32 +compat/cloudabi32/cloudabi32_poll.c optional compat_cloudabi32 +compat/cloudabi32/cloudabi32_sock.c optional compat_cloudabi32 +compat/cloudabi32/cloudabi32_syscalls.c optional compat_cloudabi32 +compat/cloudabi32/cloudabi32_sysent.c optional compat_cloudabi32 +compat/cloudabi32/cloudabi32_thread.c optional compat_cloudabi32 compat/cloudabi64/cloudabi64_fd.c optional compat_cloudabi64 compat/cloudabi64/cloudabi64_module.c optional compat_cloudabi64 compat/cloudabi64/cloudabi64_poll.c optional compat_cloudabi64 diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64 index 72b8666..3d17289 100644 --- a/sys/conf/files.amd64 +++ b/sys/conf/files.amd64 @@ -8,6 +8,30 @@ # dependency lines other than the first are silently ignored. # # +cloudabi32_vdso.o optional compat_cloudabi32 \ + dependency "$S/contrib/cloudabi/cloudabi_vdso_i686_on_64bit.S" \ + compile-with "${CC} -x assembler-with-cpp -m32 -shared -nostdinc -nostdlib -Wl,-T$S/compat/cloudabi/cloudabi_vdso.lds $S/contrib/cloudabi/cloudabi_vdso_i686_on_64bit.S -o ${.TARGET}" \ + no-obj no-implicit-rule \ + clean "cloudabi32_vdso.o" +# +cloudabi32_vdso_blob.o optional compat_cloudabi32 \ + dependency "cloudabi32_vdso.o" \ + compile-with "${OBJCOPY} --input-target binary --output-target elf64-x86-64-freebsd --binary-architecture i386 cloudabi32_vdso.o ${.TARGET}" \ + no-implicit-rule \ + clean "cloudabi32_vdso_blob.o" +# +cloudabi64_vdso.o optional compat_cloudabi64 \ + dependency "$S/contrib/cloudabi/cloudabi_vdso_x86_64.S" \ + compile-with "${CC} -x assembler-with-cpp -shared -nostdinc -nostdlib -Wl,-T$S/compat/cloudabi/cloudabi_vdso.lds $S/contrib/cloudabi/cloudabi_vdso_x86_64.S -o ${.TARGET}" \ + no-obj no-implicit-rule \ + clean "cloudabi64_vdso.o" +# +cloudabi64_vdso_blob.o optional compat_cloudabi64 \ + dependency "cloudabi64_vdso.o" \ + compile-with "${OBJCOPY} --input-target binary --output-target elf64-x86-64-freebsd --binary-architecture i386 cloudabi64_vdso.o ${.TARGET}" \ + no-implicit-rule \ + clean "cloudabi64_vdso_blob.o" +# linux32_genassym.o optional compat_linux32 \ dependency "$S/amd64/linux32/linux32_genassym.c" \ compile-with "${CC} ${CFLAGS:N-fno-common} -c ${.IMPSRC}" \ @@ -135,6 +159,7 @@ amd64/amd64/trap.c standard amd64/amd64/uio_machdep.c standard amd64/amd64/uma_machdep.c standard amd64/amd64/vm_machdep.c standard +amd64/cloudabi32/cloudabi32_sysvec.c optional compat_cloudabi32 amd64/cloudabi64/cloudabi64_sysvec.c optional compat_cloudabi64 amd64/pci/pci_cfgreg.c optional pci cddl/contrib/opensolaris/common/atomic/amd64/opensolaris_atomic.S optional zfs | dtrace compile-with "${ZFS_S}" diff --git a/sys/conf/files.arm b/sys/conf/files.arm index 06800ae..d6bd843 100644 --- a/sys/conf/files.arm +++ b/sys/conf/files.arm @@ -1,4 +1,16 @@ # $FreeBSD$ +cloudabi32_vdso.o optional compat_cloudabi32 \ + dependency "$S/contrib/cloudabi/cloudabi_vdso_armv6.S" \ + compile-with "${CC} -x assembler-with-cpp -shared -nostdinc -nostdlib -Wl,-T$S/compat/cloudabi/cloudabi_vdso.lds $S/contrib/cloudabi/cloudabi_vdso_armv6.S -o ${.TARGET}" \ + no-obj no-implicit-rule \ + clean "cloudabi32_vdso.o" +# +cloudabi32_vdso_blob.o optional compat_cloudabi32 \ + dependency "cloudabi32_vdso.o" \ + compile-with "${OBJCOPY} --input-target binary --output-target elf32-littlearm --binary-architecture arm cloudabi32_vdso.o ${.TARGET}" \ + no-implicit-rule \ + clean "cloudabi32_vdso_blob.o" +# arm/arm/autoconf.c standard arm/arm/bcopy_page.S standard arm/arm/bcopyinout.S standard @@ -82,6 +94,7 @@ arm/arm/undefined.c standard arm/arm/unwind.c optional ddb | kdtrace_hooks arm/arm/vm_machdep.c standard arm/arm/vfp.c standard +arm/cloudabi32/cloudabi32_sysvec.c optional compat_cloudabi32 board_id.h standard \ dependency "$S/arm/conf/genboardid.awk $S/arm/conf/mach-types" \ compile-with "${AWK} -f $S/arm/conf/genboardid.awk $S/arm/conf/mach-types > board_id.h" \ diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 index 12ffa77..053eb5d 100644 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -1,4 +1,16 @@ # $FreeBSD$ +cloudabi64_vdso.o optional compat_cloudabi64 \ + dependency "$S/contrib/cloudabi/cloudabi_vdso_aarch64.S" \ + compile-with "${CC} -x assembler-with-cpp -shared -nostdinc -nostdlib -Wl,-T$S/compat/cloudabi/cloudabi_vdso.lds $S/contrib/cloudabi/cloudabi_vdso_aarch64.S -o ${.TARGET}" \ + no-obj no-implicit-rule \ + clean "cloudabi64_vdso.o" +# +cloudabi64_vdso_blob.o optional compat_cloudabi64 \ + dependency "cloudabi64_vdso.o" \ + compile-with "${OBJCOPY} --input-target binary --output-target elf64-littleaarch64 --binary-architecture aarch64 cloudabi64_vdso.o ${.TARGET}" \ + no-implicit-rule \ + clean "cloudabi64_vdso_blob.o" +# arm/arm/generic_timer.c standard arm/arm/gic.c optional intrng arm/arm/pmu.c standard diff --git a/sys/conf/files.i386 b/sys/conf/files.i386 index 85df7d0..aef02a0 100644 --- a/sys/conf/files.i386 +++ b/sys/conf/files.i386 @@ -7,6 +7,18 @@ # limitations in config: backslash-newline doesn't work in strings, and # dependency lines other than the first are silently ignored. # +cloudabi32_vdso.o optional compat_cloudabi32 \ + dependency "$S/contrib/cloudabi/cloudabi_vdso_i686.S" \ + compile-with "${CC} -x assembler-with-cpp -shared -nostdinc -nostdlib -Wl,-T$S/compat/cloudabi/cloudabi_vdso.lds $S/contrib/cloudabi/cloudabi_vdso_i686.S -o ${.TARGET}" \ + no-obj no-implicit-rule \ + clean "cloudabi32_vdso.o" +# +cloudabi32_vdso_blob.o optional compat_cloudabi32 \ + dependency "cloudabi32_vdso.o" \ + compile-with "${OBJCOPY} --input-target binary --output-target elf32-i386-freebsd --binary-architecture i386 cloudabi32_vdso.o ${.TARGET}" \ + no-implicit-rule \ + clean "cloudabi32_vdso_blob.o" +# linux_genassym.o optional compat_linux \ dependency "$S/i386/linux/linux_genassym.c" \ compile-with "${CC} ${CFLAGS:N-fno-common} -c ${.IMPSRC}" \ @@ -456,6 +468,7 @@ i386/bios/apm.c optional apm i386/bios/mca_machdep.c optional mca i386/bios/smapi.c optional smapi i386/bios/smapi_bios.S optional smapi +i386/cloudabi32/cloudabi32_sysvec.c optional compat_cloudabi32 #i386/i386/apic_vector.s optional apic i386/i386/atomic.c standard \ compile-with "${CC} -c ${CFLAGS} ${DEFINED_PROF:S/^$/-fomit-frame-pointer/} ${.IMPSRC}" diff --git a/sys/conf/options b/sys/conf/options index ba410ee..75244fb 100644 --- a/sys/conf/options +++ b/sys/conf/options @@ -85,6 +85,7 @@ COMPAT_FREEBSD6 opt_compat.h COMPAT_FREEBSD7 opt_compat.h COMPAT_FREEBSD9 opt_compat.h COMPAT_FREEBSD10 opt_compat.h +COMPAT_CLOUDABI32 opt_dontuse.h COMPAT_CLOUDABI64 opt_dontuse.h COMPAT_LINUXKPI opt_compat.h COMPILING_LINT opt_global.h diff --git a/sys/contrib/cloudabi/cloudabi32_types.h b/sys/contrib/cloudabi/cloudabi32_types.h new file mode 100644 index 0000000..71d6429 --- /dev/null +++ b/sys/contrib/cloudabi/cloudabi32_types.h @@ -0,0 +1,232 @@ +// Copyright (c) 2016 Nuxi (https://nuxi.nl/) and contributors. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +// SUCH DAMAGE. +// +// This file is automatically generated. Do not edit. +// +// Source: https://github.com/NuxiNL/cloudabi + +#ifndef CLOUDABI32_TYPES_H +#define CLOUDABI32_TYPES_H + +#include "cloudabi_types_common.h" + +typedef struct { + _Alignas(4) cloudabi_auxtype_t a_type; + union { + _Alignas(4) uint32_t a_val; + _Alignas(4) uint32_t a_ptr; + }; +} cloudabi32_auxv_t; +_Static_assert(offsetof(cloudabi32_auxv_t, a_type) == 0, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_auxv_t, a_val) == 4, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_auxv_t, a_ptr) == 4, "Incorrect layout"); +_Static_assert(sizeof(cloudabi32_auxv_t) == 8, "Incorrect layout"); +_Static_assert(_Alignof(cloudabi32_auxv_t) == 4, "Incorrect layout"); + +typedef struct { + _Alignas(4) uint32_t iov_base; + _Alignas(4) uint32_t iov_len; +} cloudabi32_ciovec_t; +_Static_assert(offsetof(cloudabi32_ciovec_t, iov_base) == 0, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_ciovec_t, iov_len) == 4, "Incorrect layout"); +_Static_assert(sizeof(cloudabi32_ciovec_t) == 8, "Incorrect layout"); +_Static_assert(_Alignof(cloudabi32_ciovec_t) == 4, "Incorrect layout"); + +typedef struct { + _Alignas(8) cloudabi_userdata_t userdata; + _Alignas(2) cloudabi_errno_t error; + _Alignas(1) cloudabi_eventtype_t type; + union { + struct { + _Alignas(8) cloudabi_userdata_t identifier; + } clock; + struct { + _Alignas(4) uint32_t condvar; + } condvar; + struct { + _Alignas(8) cloudabi_filesize_t nbytes; + _Alignas(4) cloudabi_fd_t fd; + _Alignas(2) cloudabi_eventrwflags_t flags; + } fd_readwrite; + struct { + _Alignas(4) uint32_t lock; + } lock; + struct { + _Alignas(4) cloudabi_fd_t fd; + _Alignas(1) cloudabi_signal_t signal; + _Alignas(4) cloudabi_exitcode_t exitcode; + } proc_terminate; + }; +} cloudabi32_event_t; +_Static_assert(offsetof(cloudabi32_event_t, userdata) == 0, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_event_t, error) == 8, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_event_t, type) == 10, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_event_t, clock.identifier) == 16, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_event_t, condvar.condvar) == 16, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_event_t, fd_readwrite.nbytes) == 16, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_event_t, fd_readwrite.fd) == 24, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_event_t, fd_readwrite.flags) == 28, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_event_t, lock.lock) == 16, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_event_t, proc_terminate.fd) == 16, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_event_t, proc_terminate.signal) == 20, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_event_t, proc_terminate.exitcode) == 24, "Incorrect layout"); +_Static_assert(sizeof(cloudabi32_event_t) == 32, "Incorrect layout"); +_Static_assert(_Alignof(cloudabi32_event_t) == 8, "Incorrect layout"); + +typedef struct { + _Alignas(4) uint32_t iov_base; + _Alignas(4) uint32_t iov_len; +} cloudabi32_iovec_t; +_Static_assert(offsetof(cloudabi32_iovec_t, iov_base) == 0, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_iovec_t, iov_len) == 4, "Incorrect layout"); +_Static_assert(sizeof(cloudabi32_iovec_t) == 8, "Incorrect layout"); +_Static_assert(_Alignof(cloudabi32_iovec_t) == 4, "Incorrect layout"); + +typedef void cloudabi32_processentry_t(uint32_t auxv); + +typedef struct { + _Alignas(4) uint32_t ri_data; + _Alignas(4) uint32_t ri_datalen; + _Alignas(4) uint32_t ri_fds; + _Alignas(4) uint32_t ri_fdslen; + _Alignas(2) cloudabi_msgflags_t ri_flags; +} cloudabi32_recv_in_t; +_Static_assert(offsetof(cloudabi32_recv_in_t, ri_data) == 0, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_recv_in_t, ri_datalen) == 4, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_recv_in_t, ri_fds) == 8, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_recv_in_t, ri_fdslen) == 12, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_recv_in_t, ri_flags) == 16, "Incorrect layout"); +_Static_assert(sizeof(cloudabi32_recv_in_t) == 20, "Incorrect layout"); +_Static_assert(_Alignof(cloudabi32_recv_in_t) == 4, "Incorrect layout"); + +typedef struct { + _Alignas(4) uint32_t si_data; + _Alignas(4) uint32_t si_datalen; + _Alignas(4) uint32_t si_fds; + _Alignas(4) uint32_t si_fdslen; + _Alignas(2) cloudabi_msgflags_t si_flags; +} cloudabi32_send_in_t; +_Static_assert(offsetof(cloudabi32_send_in_t, si_data) == 0, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_send_in_t, si_datalen) == 4, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_send_in_t, si_fds) == 8, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_send_in_t, si_fdslen) == 12, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_send_in_t, si_flags) == 16, "Incorrect layout"); +_Static_assert(sizeof(cloudabi32_send_in_t) == 20, "Incorrect layout"); +_Static_assert(_Alignof(cloudabi32_send_in_t) == 4, "Incorrect layout"); + +typedef struct { + _Alignas(4) uint32_t so_datalen; +} cloudabi32_send_out_t; +_Static_assert(offsetof(cloudabi32_send_out_t, so_datalen) == 0, "Incorrect layout"); +_Static_assert(sizeof(cloudabi32_send_out_t) == 4, "Incorrect layout"); +_Static_assert(_Alignof(cloudabi32_send_out_t) == 4, "Incorrect layout"); + +typedef struct { + _Alignas(8) cloudabi_userdata_t userdata; + _Alignas(2) cloudabi_subflags_t flags; + _Alignas(1) cloudabi_eventtype_t type; + union { + struct { + _Alignas(8) cloudabi_userdata_t identifier; + _Alignas(4) cloudabi_clockid_t clock_id; + _Alignas(8) cloudabi_timestamp_t timeout; + _Alignas(8) cloudabi_timestamp_t precision; + _Alignas(2) cloudabi_subclockflags_t flags; + } clock; + struct { + _Alignas(4) uint32_t condvar; + _Alignas(4) uint32_t lock; + _Alignas(1) cloudabi_scope_t condvar_scope; + _Alignas(1) cloudabi_scope_t lock_scope; + } condvar; + struct { + _Alignas(4) cloudabi_fd_t fd; + _Alignas(2) cloudabi_subrwflags_t flags; + } fd_readwrite; + struct { + _Alignas(4) uint32_t lock; + _Alignas(1) cloudabi_scope_t lock_scope; + } lock; + struct { + _Alignas(4) cloudabi_fd_t fd; + } proc_terminate; + }; +} cloudabi32_subscription_t; +_Static_assert(offsetof(cloudabi32_subscription_t, userdata) == 0, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_subscription_t, flags) == 8, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_subscription_t, type) == 10, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_subscription_t, clock.identifier) == 16, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_subscription_t, clock.clock_id) == 24, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_subscription_t, clock.timeout) == 32, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_subscription_t, clock.precision) == 40, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_subscription_t, clock.flags) == 48, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_subscription_t, condvar.condvar) == 16, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_subscription_t, condvar.lock) == 20, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_subscription_t, condvar.condvar_scope) == 24, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_subscription_t, condvar.lock_scope) == 25, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_subscription_t, fd_readwrite.fd) == 16, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_subscription_t, fd_readwrite.flags) == 20, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_subscription_t, lock.lock) == 16, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_subscription_t, lock.lock_scope) == 20, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_subscription_t, proc_terminate.fd) == 16, "Incorrect layout"); +_Static_assert(sizeof(cloudabi32_subscription_t) == 56, "Incorrect layout"); +_Static_assert(_Alignof(cloudabi32_subscription_t) == 8, "Incorrect layout"); + +typedef struct { + _Alignas(4) uint32_t parent; +} cloudabi32_tcb_t; +_Static_assert(offsetof(cloudabi32_tcb_t, parent) == 0, "Incorrect layout"); +_Static_assert(sizeof(cloudabi32_tcb_t) == 4, "Incorrect layout"); +_Static_assert(_Alignof(cloudabi32_tcb_t) == 4, "Incorrect layout"); + +typedef void cloudabi32_threadentry_t(cloudabi_tid_t tid, uint32_t aux); + +typedef struct { + _Alignas(4) uint32_t ro_datalen; + _Alignas(4) uint32_t ro_fdslen; + _Alignas(2) cloudabi_sockaddr_t ro_sockname; + _Alignas(2) cloudabi_sockaddr_t ro_peername; + _Alignas(2) cloudabi_msgflags_t ro_flags; +} cloudabi32_recv_out_t; +_Static_assert(offsetof(cloudabi32_recv_out_t, ro_datalen) == 0, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_recv_out_t, ro_fdslen) == 4, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_recv_out_t, ro_sockname) == 8, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_recv_out_t, ro_peername) == 28, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_recv_out_t, ro_flags) == 48, "Incorrect layout"); +_Static_assert(sizeof(cloudabi32_recv_out_t) == 52, "Incorrect layout"); +_Static_assert(_Alignof(cloudabi32_recv_out_t) == 4, "Incorrect layout"); + +typedef struct { + _Alignas(4) uint32_t entry_point; + _Alignas(4) uint32_t stack; + _Alignas(4) uint32_t stack_size; + _Alignas(4) uint32_t argument; +} cloudabi32_threadattr_t; +_Static_assert(offsetof(cloudabi32_threadattr_t, entry_point) == 0, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_threadattr_t, stack) == 4, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_threadattr_t, stack_size) == 8, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_threadattr_t, argument) == 12, "Incorrect layout"); +_Static_assert(sizeof(cloudabi32_threadattr_t) == 16, "Incorrect layout"); +_Static_assert(_Alignof(cloudabi32_threadattr_t) == 4, "Incorrect layout"); + +#endif diff --git a/sys/contrib/cloudabi/cloudabi64_types.h b/sys/contrib/cloudabi/cloudabi64_types.h index cb354d4..5d54e7e 100644 --- a/sys/contrib/cloudabi/cloudabi64_types.h +++ b/sys/contrib/cloudabi/cloudabi64_types.h @@ -31,11 +31,11 @@ #include "cloudabi_types_common.h" typedef struct { - _Alignas(4) cloudabi_auxtype_t a_type; - union { - _Alignas(8) uint64_t a_val; - _Alignas(8) uint64_t a_ptr; - }; + _Alignas(4) cloudabi_auxtype_t a_type; + union { + _Alignas(8) uint64_t a_val; + _Alignas(8) uint64_t a_ptr; + }; } cloudabi64_auxv_t; _Static_assert(offsetof(cloudabi64_auxv_t, a_type) == 0, "Incorrect layout"); _Static_assert(offsetof(cloudabi64_auxv_t, a_val) == 8, "Incorrect layout"); @@ -44,58 +44,68 @@ _Static_assert(sizeof(cloudabi64_auxv_t) == 16, "Incorrect layout"); _Static_assert(_Alignof(cloudabi64_auxv_t) == 8, "Incorrect layout"); typedef struct { - _Alignas(8) uint64_t iov_base; - _Alignas(8) uint64_t iov_len; + _Alignas(8) uint64_t iov_base; + _Alignas(8) uint64_t iov_len; } cloudabi64_ciovec_t; -_Static_assert(offsetof(cloudabi64_ciovec_t, iov_base) == 0, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_ciovec_t, iov_base) == 0, + "Incorrect layout"); _Static_assert(offsetof(cloudabi64_ciovec_t, iov_len) == 8, "Incorrect layout"); _Static_assert(sizeof(cloudabi64_ciovec_t) == 16, "Incorrect layout"); _Static_assert(_Alignof(cloudabi64_ciovec_t) == 8, "Incorrect layout"); typedef struct { - _Alignas(8) cloudabi_userdata_t userdata; - _Alignas(2) cloudabi_errno_t error; - _Alignas(1) cloudabi_eventtype_t type; - union { - struct { - _Alignas(8) cloudabi_userdata_t identifier; - } clock; - struct { - _Alignas(8) uint64_t condvar; - } condvar; - struct { - _Alignas(8) cloudabi_filesize_t nbytes; - _Alignas(4) cloudabi_fd_t fd; - _Alignas(2) cloudabi_eventrwflags_t flags; - } fd_readwrite; - struct { - _Alignas(8) uint64_t lock; - } lock; - struct { - _Alignas(4) cloudabi_fd_t fd; - _Alignas(1) cloudabi_signal_t signal; - _Alignas(4) cloudabi_exitcode_t exitcode; - } proc_terminate; - }; + _Alignas(8) cloudabi_userdata_t userdata; + _Alignas(2) cloudabi_errno_t error; + _Alignas(1) cloudabi_eventtype_t type; + union { + struct { + _Alignas(8) cloudabi_userdata_t identifier; + } clock; + struct { + _Alignas(8) uint64_t condvar; + } condvar; + struct { + _Alignas(8) cloudabi_filesize_t nbytes; + _Alignas(4) cloudabi_fd_t fd; + _Alignas(2) cloudabi_eventrwflags_t flags; + } fd_readwrite; + struct { + _Alignas(8) uint64_t lock; + } lock; + struct { + _Alignas(4) cloudabi_fd_t fd; + _Alignas(1) cloudabi_signal_t signal; + _Alignas(4) cloudabi_exitcode_t exitcode; + } proc_terminate; + }; } cloudabi64_event_t; _Static_assert(offsetof(cloudabi64_event_t, userdata) == 0, "Incorrect layout"); _Static_assert(offsetof(cloudabi64_event_t, error) == 8, "Incorrect layout"); _Static_assert(offsetof(cloudabi64_event_t, type) == 10, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_event_t, clock.identifier) == 16, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_event_t, condvar.condvar) == 16, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_event_t, fd_readwrite.nbytes) == 16, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_event_t, fd_readwrite.fd) == 24, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_event_t, fd_readwrite.flags) == 28, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_event_t, lock.lock) == 16, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_event_t, proc_terminate.fd) == 16, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_event_t, proc_terminate.signal) == 20, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_event_t, proc_terminate.exitcode) == 24, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_event_t, clock.identifier) == 16, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_event_t, condvar.condvar) == 16, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_event_t, fd_readwrite.nbytes) == 16, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_event_t, fd_readwrite.fd) == 24, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_event_t, fd_readwrite.flags) == 28, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_event_t, lock.lock) == 16, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_event_t, proc_terminate.fd) == 16, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_event_t, proc_terminate.signal) == 20, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_event_t, proc_terminate.exitcode) == 24, + "Incorrect layout"); _Static_assert(sizeof(cloudabi64_event_t) == 32, "Incorrect layout"); _Static_assert(_Alignof(cloudabi64_event_t) == 8, "Incorrect layout"); typedef struct { - _Alignas(8) uint64_t iov_base; - _Alignas(8) uint64_t iov_len; + _Alignas(8) uint64_t iov_base; + _Alignas(8) uint64_t iov_len; } cloudabi64_iovec_t; _Static_assert(offsetof(cloudabi64_iovec_t, iov_base) == 0, "Incorrect layout"); _Static_assert(offsetof(cloudabi64_iovec_t, iov_len) == 8, "Incorrect layout"); @@ -105,96 +115,120 @@ _Static_assert(_Alignof(cloudabi64_iovec_t) == 8, "Incorrect layout"); typedef void cloudabi64_processentry_t(uint64_t auxv); typedef struct { - _Alignas(8) uint64_t ri_data; - _Alignas(8) uint64_t ri_datalen; - _Alignas(8) uint64_t ri_fds; - _Alignas(8) uint64_t ri_fdslen; - _Alignas(2) cloudabi_msgflags_t ri_flags; + _Alignas(8) uint64_t ri_data; + _Alignas(8) uint64_t ri_datalen; + _Alignas(8) uint64_t ri_fds; + _Alignas(8) uint64_t ri_fdslen; + _Alignas(2) cloudabi_msgflags_t ri_flags; } cloudabi64_recv_in_t; -_Static_assert(offsetof(cloudabi64_recv_in_t, ri_data) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_recv_in_t, ri_datalen) == 8, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_recv_in_t, ri_fds) == 16, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_recv_in_t, ri_fdslen) == 24, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_recv_in_t, ri_flags) == 32, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_recv_in_t, ri_data) == 0, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_recv_in_t, ri_datalen) == 8, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_recv_in_t, ri_fds) == 16, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_recv_in_t, ri_fdslen) == 24, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_recv_in_t, ri_flags) == 32, + "Incorrect layout"); _Static_assert(sizeof(cloudabi64_recv_in_t) == 40, "Incorrect layout"); _Static_assert(_Alignof(cloudabi64_recv_in_t) == 8, "Incorrect layout"); typedef struct { - _Alignas(8) uint64_t si_data; - _Alignas(8) uint64_t si_datalen; - _Alignas(8) uint64_t si_fds; - _Alignas(8) uint64_t si_fdslen; - _Alignas(2) cloudabi_msgflags_t si_flags; + _Alignas(8) uint64_t si_data; + _Alignas(8) uint64_t si_datalen; + _Alignas(8) uint64_t si_fds; + _Alignas(8) uint64_t si_fdslen; + _Alignas(2) cloudabi_msgflags_t si_flags; } cloudabi64_send_in_t; -_Static_assert(offsetof(cloudabi64_send_in_t, si_data) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_send_in_t, si_datalen) == 8, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_send_in_t, si_fds) == 16, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_send_in_t, si_fdslen) == 24, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_send_in_t, si_flags) == 32, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_send_in_t, si_data) == 0, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_send_in_t, si_datalen) == 8, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_send_in_t, si_fds) == 16, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_send_in_t, si_fdslen) == 24, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_send_in_t, si_flags) == 32, + "Incorrect layout"); _Static_assert(sizeof(cloudabi64_send_in_t) == 40, "Incorrect layout"); _Static_assert(_Alignof(cloudabi64_send_in_t) == 8, "Incorrect layout"); -typedef struct { - _Alignas(8) uint64_t so_datalen; -} cloudabi64_send_out_t; -_Static_assert(offsetof(cloudabi64_send_out_t, so_datalen) == 0, "Incorrect layout"); +typedef struct { _Alignas(8) uint64_t so_datalen; } cloudabi64_send_out_t; +_Static_assert(offsetof(cloudabi64_send_out_t, so_datalen) == 0, + "Incorrect layout"); _Static_assert(sizeof(cloudabi64_send_out_t) == 8, "Incorrect layout"); _Static_assert(_Alignof(cloudabi64_send_out_t) == 8, "Incorrect layout"); typedef struct { - _Alignas(8) cloudabi_userdata_t userdata; - _Alignas(2) cloudabi_subflags_t flags; - _Alignas(1) cloudabi_eventtype_t type; - union { - struct { - _Alignas(8) cloudabi_userdata_t identifier; - _Alignas(4) cloudabi_clockid_t clock_id; - _Alignas(8) cloudabi_timestamp_t timeout; - _Alignas(8) cloudabi_timestamp_t precision; - _Alignas(2) cloudabi_subclockflags_t flags; - } clock; - struct { - _Alignas(8) uint64_t condvar; - _Alignas(8) uint64_t lock; - _Alignas(1) cloudabi_scope_t condvar_scope; - _Alignas(1) cloudabi_scope_t lock_scope; - } condvar; - struct { - _Alignas(4) cloudabi_fd_t fd; - _Alignas(2) cloudabi_subrwflags_t flags; - } fd_readwrite; - struct { - _Alignas(8) uint64_t lock; - _Alignas(1) cloudabi_scope_t lock_scope; - } lock; - struct { - _Alignas(4) cloudabi_fd_t fd; - } proc_terminate; - }; + _Alignas(8) cloudabi_userdata_t userdata; + _Alignas(2) cloudabi_subflags_t flags; + _Alignas(1) cloudabi_eventtype_t type; + union { + struct { + _Alignas(8) cloudabi_userdata_t identifier; + _Alignas(4) cloudabi_clockid_t clock_id; + _Alignas(8) cloudabi_timestamp_t timeout; + _Alignas(8) cloudabi_timestamp_t precision; + _Alignas(2) cloudabi_subclockflags_t flags; + } clock; + struct { + _Alignas(8) uint64_t condvar; + _Alignas(8) uint64_t lock; + _Alignas(1) cloudabi_scope_t condvar_scope; + _Alignas(1) cloudabi_scope_t lock_scope; + } condvar; + struct { + _Alignas(4) cloudabi_fd_t fd; + _Alignas(2) cloudabi_subrwflags_t flags; + } fd_readwrite; + struct { + _Alignas(8) uint64_t lock; + _Alignas(1) cloudabi_scope_t lock_scope; + } lock; + struct { + _Alignas(4) cloudabi_fd_t fd; + } proc_terminate; + }; } cloudabi64_subscription_t; -_Static_assert(offsetof(cloudabi64_subscription_t, userdata) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, flags) == 8, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, type) == 10, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, clock.identifier) == 16, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, clock.clock_id) == 24, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, clock.timeout) == 32, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, clock.precision) == 40, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, clock.flags) == 48, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, condvar.condvar) == 16, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, condvar.lock) == 24, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, condvar.condvar_scope) == 32, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, condvar.lock_scope) == 33, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, fd_readwrite.fd) == 16, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, fd_readwrite.flags) == 20, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, lock.lock) == 16, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, lock.lock_scope) == 24, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, proc_terminate.fd) == 16, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, userdata) == 0, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, flags) == 8, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, type) == 10, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, clock.identifier) == 16, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, clock.clock_id) == 24, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, clock.timeout) == 32, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, clock.precision) == 40, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, clock.flags) == 48, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, condvar.condvar) == 16, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, condvar.lock) == 24, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, condvar.condvar_scope) == 32, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, condvar.lock_scope) == 33, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, fd_readwrite.fd) == 16, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, fd_readwrite.flags) == 20, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, lock.lock) == 16, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, lock.lock_scope) == 24, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, proc_terminate.fd) == 16, + "Incorrect layout"); _Static_assert(sizeof(cloudabi64_subscription_t) == 56, "Incorrect layout"); _Static_assert(_Alignof(cloudabi64_subscription_t) == 8, "Incorrect layout"); -typedef struct { - _Alignas(8) uint64_t parent; -} cloudabi64_tcb_t; +typedef struct { _Alignas(8) uint64_t parent; } cloudabi64_tcb_t; _Static_assert(offsetof(cloudabi64_tcb_t, parent) == 0, "Incorrect layout"); _Static_assert(sizeof(cloudabi64_tcb_t) == 8, "Incorrect layout"); _Static_assert(_Alignof(cloudabi64_tcb_t) == 8, "Incorrect layout"); @@ -202,30 +236,39 @@ _Static_assert(_Alignof(cloudabi64_tcb_t) == 8, "Incorrect layout"); typedef void cloudabi64_threadentry_t(cloudabi_tid_t tid, uint64_t aux); typedef struct { - _Alignas(8) uint64_t ro_datalen; - _Alignas(8) uint64_t ro_fdslen; - _Alignas(2) cloudabi_sockaddr_t ro_sockname; - _Alignas(2) cloudabi_sockaddr_t ro_peername; - _Alignas(2) cloudabi_msgflags_t ro_flags; + _Alignas(8) uint64_t ro_datalen; + _Alignas(8) uint64_t ro_fdslen; + _Alignas(2) cloudabi_sockaddr_t ro_sockname; + _Alignas(2) cloudabi_sockaddr_t ro_peername; + _Alignas(2) cloudabi_msgflags_t ro_flags; } cloudabi64_recv_out_t; -_Static_assert(offsetof(cloudabi64_recv_out_t, ro_datalen) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_recv_out_t, ro_fdslen) == 8, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_recv_out_t, ro_sockname) == 16, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_recv_out_t, ro_peername) == 36, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_recv_out_t, ro_flags) == 56, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_recv_out_t, ro_datalen) == 0, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_recv_out_t, ro_fdslen) == 8, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_recv_out_t, ro_sockname) == 16, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_recv_out_t, ro_peername) == 36, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_recv_out_t, ro_flags) == 56, + "Incorrect layout"); _Static_assert(sizeof(cloudabi64_recv_out_t) == 64, "Incorrect layout"); _Static_assert(_Alignof(cloudabi64_recv_out_t) == 8, "Incorrect layout"); typedef struct { - _Alignas(8) uint64_t entry_point; - _Alignas(8) uint64_t stack; - _Alignas(8) uint64_t stack_size; - _Alignas(8) uint64_t argument; + _Alignas(8) uint64_t entry_point; + _Alignas(8) uint64_t stack; + _Alignas(8) uint64_t stack_size; + _Alignas(8) uint64_t argument; } cloudabi64_threadattr_t; -_Static_assert(offsetof(cloudabi64_threadattr_t, entry_point) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_threadattr_t, stack) == 8, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_threadattr_t, stack_size) == 16, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_threadattr_t, argument) == 24, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_threadattr_t, entry_point) == 0, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_threadattr_t, stack) == 8, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_threadattr_t, stack_size) == 16, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_threadattr_t, argument) == 24, + "Incorrect layout"); _Static_assert(sizeof(cloudabi64_threadattr_t) == 32, "Incorrect layout"); _Static_assert(_Alignof(cloudabi64_threadattr_t) == 8, "Incorrect layout"); diff --git a/sys/contrib/cloudabi/cloudabi_types_common.h b/sys/contrib/cloudabi/cloudabi_types_common.h index 83c61b9..0297e2a9 100644 --- a/sys/contrib/cloudabi/cloudabi_types_common.h +++ b/sys/contrib/cloudabi/cloudabi_types_common.h @@ -29,7 +29,7 @@ #define CLOUDABI_TYPES_COMMON_H #if defined(__FreeBSD__) && defined(_KERNEL) -#include <sys/stdint.h> +#include <sys/types.h> #elif defined(__linux__) && defined(__KERNEL__) #include <linux/types.h> #else @@ -38,33 +38,34 @@ #endif typedef uint8_t cloudabi_advice_t; -#define CLOUDABI_ADVICE_DONTNEED 1 -#define CLOUDABI_ADVICE_NOREUSE 2 -#define CLOUDABI_ADVICE_NORMAL 3 -#define CLOUDABI_ADVICE_RANDOM 4 +#define CLOUDABI_ADVICE_DONTNEED 1 +#define CLOUDABI_ADVICE_NOREUSE 2 +#define CLOUDABI_ADVICE_NORMAL 3 +#define CLOUDABI_ADVICE_RANDOM 4 #define CLOUDABI_ADVICE_SEQUENTIAL 5 -#define CLOUDABI_ADVICE_WILLNEED 6 +#define CLOUDABI_ADVICE_WILLNEED 6 typedef uint32_t cloudabi_auxtype_t; -#define CLOUDABI_AT_ARGDATA 256 +#define CLOUDABI_AT_ARGDATA 256 #define CLOUDABI_AT_ARGDATALEN 257 -#define CLOUDABI_AT_BASE 7 -#define CLOUDABI_AT_CANARY 258 -#define CLOUDABI_AT_CANARYLEN 259 -#define CLOUDABI_AT_NCPUS 260 -#define CLOUDABI_AT_NULL 0 -#define CLOUDABI_AT_PAGESZ 6 -#define CLOUDABI_AT_PHDR 3 -#define CLOUDABI_AT_PHNUM 4 -#define CLOUDABI_AT_TID 261 +#define CLOUDABI_AT_BASE 7 +#define CLOUDABI_AT_CANARY 258 +#define CLOUDABI_AT_CANARYLEN 259 +#define CLOUDABI_AT_NCPUS 260 +#define CLOUDABI_AT_NULL 0 +#define CLOUDABI_AT_PAGESZ 6 +#define CLOUDABI_AT_PHDR 3 +#define CLOUDABI_AT_PHNUM 4 +#define CLOUDABI_AT_SYSINFO_EHDR 262 +#define CLOUDABI_AT_TID 261 typedef uint32_t cloudabi_backlog_t; typedef uint32_t cloudabi_clockid_t; -#define CLOUDABI_CLOCK_MONOTONIC 1 +#define CLOUDABI_CLOCK_MONOTONIC 1 #define CLOUDABI_CLOCK_PROCESS_CPUTIME_ID 2 -#define CLOUDABI_CLOCK_REALTIME 3 -#define CLOUDABI_CLOCK_THREAD_CPUTIME_ID 4 +#define CLOUDABI_CLOCK_REALTIME 3 +#define CLOUDABI_CLOCK_THREAD_CPUTIME_ID 4 typedef uint32_t cloudabi_condvar_t; #define CLOUDABI_CONDVAR_HAS_NO_WAITERS 0 @@ -75,110 +76,110 @@ typedef uint64_t cloudabi_dircookie_t; #define CLOUDABI_DIRCOOKIE_START 0 typedef uint16_t cloudabi_errno_t; -#define CLOUDABI_E2BIG 1 -#define CLOUDABI_EACCES 2 -#define CLOUDABI_EADDRINUSE 3 -#define CLOUDABI_EADDRNOTAVAIL 4 -#define CLOUDABI_EAFNOSUPPORT 5 -#define CLOUDABI_EAGAIN 6 -#define CLOUDABI_EALREADY 7 -#define CLOUDABI_EBADF 8 -#define CLOUDABI_EBADMSG 9 -#define CLOUDABI_EBUSY 10 -#define CLOUDABI_ECANCELED 11 -#define CLOUDABI_ECHILD 12 -#define CLOUDABI_ECONNABORTED 13 -#define CLOUDABI_ECONNREFUSED 14 -#define CLOUDABI_ECONNRESET 15 -#define CLOUDABI_EDEADLK 16 -#define CLOUDABI_EDESTADDRREQ 17 -#define CLOUDABI_EDOM 18 -#define CLOUDABI_EDQUOT 19 -#define CLOUDABI_EEXIST 20 -#define CLOUDABI_EFAULT 21 -#define CLOUDABI_EFBIG 22 -#define CLOUDABI_EHOSTUNREACH 23 -#define CLOUDABI_EIDRM 24 -#define CLOUDABI_EILSEQ 25 -#define CLOUDABI_EINPROGRESS 26 -#define CLOUDABI_EINTR 27 -#define CLOUDABI_EINVAL 28 -#define CLOUDABI_EIO 29 -#define CLOUDABI_EISCONN 30 -#define CLOUDABI_EISDIR 31 -#define CLOUDABI_ELOOP 32 -#define CLOUDABI_EMFILE 33 -#define CLOUDABI_EMLINK 34 -#define CLOUDABI_EMSGSIZE 35 -#define CLOUDABI_EMULTIHOP 36 -#define CLOUDABI_ENAMETOOLONG 37 -#define CLOUDABI_ENETDOWN 38 -#define CLOUDABI_ENETRESET 39 -#define CLOUDABI_ENETUNREACH 40 -#define CLOUDABI_ENFILE 41 -#define CLOUDABI_ENOBUFS 42 -#define CLOUDABI_ENODEV 43 -#define CLOUDABI_ENOENT 44 -#define CLOUDABI_ENOEXEC 45 -#define CLOUDABI_ENOLCK 46 -#define CLOUDABI_ENOLINK 47 -#define CLOUDABI_ENOMEM 48 -#define CLOUDABI_ENOMSG 49 -#define CLOUDABI_ENOPROTOOPT 50 -#define CLOUDABI_ENOSPC 51 -#define CLOUDABI_ENOSYS 52 -#define CLOUDABI_ENOTCONN 53 -#define CLOUDABI_ENOTDIR 54 -#define CLOUDABI_ENOTEMPTY 55 +#define CLOUDABI_E2BIG 1 +#define CLOUDABI_EACCES 2 +#define CLOUDABI_EADDRINUSE 3 +#define CLOUDABI_EADDRNOTAVAIL 4 +#define CLOUDABI_EAFNOSUPPORT 5 +#define CLOUDABI_EAGAIN 6 +#define CLOUDABI_EALREADY 7 +#define CLOUDABI_EBADF 8 +#define CLOUDABI_EBADMSG 9 +#define CLOUDABI_EBUSY 10 +#define CLOUDABI_ECANCELED 11 +#define CLOUDABI_ECHILD 12 +#define CLOUDABI_ECONNABORTED 13 +#define CLOUDABI_ECONNREFUSED 14 +#define CLOUDABI_ECONNRESET 15 +#define CLOUDABI_EDEADLK 16 +#define CLOUDABI_EDESTADDRREQ 17 +#define CLOUDABI_EDOM 18 +#define CLOUDABI_EDQUOT 19 +#define CLOUDABI_EEXIST 20 +#define CLOUDABI_EFAULT 21 +#define CLOUDABI_EFBIG 22 +#define CLOUDABI_EHOSTUNREACH 23 +#define CLOUDABI_EIDRM 24 +#define CLOUDABI_EILSEQ 25 +#define CLOUDABI_EINPROGRESS 26 +#define CLOUDABI_EINTR 27 +#define CLOUDABI_EINVAL 28 +#define CLOUDABI_EIO 29 +#define CLOUDABI_EISCONN 30 +#define CLOUDABI_EISDIR 31 +#define CLOUDABI_ELOOP 32 +#define CLOUDABI_EMFILE 33 +#define CLOUDABI_EMLINK 34 +#define CLOUDABI_EMSGSIZE 35 +#define CLOUDABI_EMULTIHOP 36 +#define CLOUDABI_ENAMETOOLONG 37 +#define CLOUDABI_ENETDOWN 38 +#define CLOUDABI_ENETRESET 39 +#define CLOUDABI_ENETUNREACH 40 +#define CLOUDABI_ENFILE 41 +#define CLOUDABI_ENOBUFS 42 +#define CLOUDABI_ENODEV 43 +#define CLOUDABI_ENOENT 44 +#define CLOUDABI_ENOEXEC 45 +#define CLOUDABI_ENOLCK 46 +#define CLOUDABI_ENOLINK 47 +#define CLOUDABI_ENOMEM 48 +#define CLOUDABI_ENOMSG 49 +#define CLOUDABI_ENOPROTOOPT 50 +#define CLOUDABI_ENOSPC 51 +#define CLOUDABI_ENOSYS 52 +#define CLOUDABI_ENOTCONN 53 +#define CLOUDABI_ENOTDIR 54 +#define CLOUDABI_ENOTEMPTY 55 #define CLOUDABI_ENOTRECOVERABLE 56 -#define CLOUDABI_ENOTSOCK 57 -#define CLOUDABI_ENOTSUP 58 -#define CLOUDABI_ENOTTY 59 -#define CLOUDABI_ENXIO 60 -#define CLOUDABI_EOVERFLOW 61 -#define CLOUDABI_EOWNERDEAD 62 -#define CLOUDABI_EPERM 63 -#define CLOUDABI_EPIPE 64 -#define CLOUDABI_EPROTO 65 +#define CLOUDABI_ENOTSOCK 57 +#define CLOUDABI_ENOTSUP 58 +#define CLOUDABI_ENOTTY 59 +#define CLOUDABI_ENXIO 60 +#define CLOUDABI_EOVERFLOW 61 +#define CLOUDABI_EOWNERDEAD 62 +#define CLOUDABI_EPERM 63 +#define CLOUDABI_EPIPE 64 +#define CLOUDABI_EPROTO 65 #define CLOUDABI_EPROTONOSUPPORT 66 -#define CLOUDABI_EPROTOTYPE 67 -#define CLOUDABI_ERANGE 68 -#define CLOUDABI_EROFS 69 -#define CLOUDABI_ESPIPE 70 -#define CLOUDABI_ESRCH 71 -#define CLOUDABI_ESTALE 72 -#define CLOUDABI_ETIMEDOUT 73 -#define CLOUDABI_ETXTBSY 74 -#define CLOUDABI_EXDEV 75 -#define CLOUDABI_ENOTCAPABLE 76 +#define CLOUDABI_EPROTOTYPE 67 +#define CLOUDABI_ERANGE 68 +#define CLOUDABI_EROFS 69 +#define CLOUDABI_ESPIPE 70 +#define CLOUDABI_ESRCH 71 +#define CLOUDABI_ESTALE 72 +#define CLOUDABI_ETIMEDOUT 73 +#define CLOUDABI_ETXTBSY 74 +#define CLOUDABI_EXDEV 75 +#define CLOUDABI_ENOTCAPABLE 76 typedef uint16_t cloudabi_eventrwflags_t; #define CLOUDABI_EVENT_FD_READWRITE_HANGUP 0x0001 typedef uint8_t cloudabi_eventtype_t; -#define CLOUDABI_EVENTTYPE_CLOCK 1 -#define CLOUDABI_EVENTTYPE_CONDVAR 2 -#define CLOUDABI_EVENTTYPE_FD_READ 3 -#define CLOUDABI_EVENTTYPE_FD_WRITE 4 -#define CLOUDABI_EVENTTYPE_LOCK_RDLOCK 5 -#define CLOUDABI_EVENTTYPE_LOCK_WRLOCK 6 +#define CLOUDABI_EVENTTYPE_CLOCK 1 +#define CLOUDABI_EVENTTYPE_CONDVAR 2 +#define CLOUDABI_EVENTTYPE_FD_READ 3 +#define CLOUDABI_EVENTTYPE_FD_WRITE 4 +#define CLOUDABI_EVENTTYPE_LOCK_RDLOCK 5 +#define CLOUDABI_EVENTTYPE_LOCK_WRLOCK 6 #define CLOUDABI_EVENTTYPE_PROC_TERMINATE 7 typedef uint32_t cloudabi_exitcode_t; typedef uint32_t cloudabi_fd_t; #define CLOUDABI_PROCESS_CHILD 0xffffffff -#define CLOUDABI_MAP_ANON_FD 0xffffffff +#define CLOUDABI_MAP_ANON_FD 0xffffffff typedef uint16_t cloudabi_fdflags_t; -#define CLOUDABI_FDFLAG_APPEND 0x0001 -#define CLOUDABI_FDFLAG_DSYNC 0x0002 +#define CLOUDABI_FDFLAG_APPEND 0x0001 +#define CLOUDABI_FDFLAG_DSYNC 0x0002 #define CLOUDABI_FDFLAG_NONBLOCK 0x0004 -#define CLOUDABI_FDFLAG_RSYNC 0x0008 -#define CLOUDABI_FDFLAG_SYNC 0x0010 +#define CLOUDABI_FDFLAG_RSYNC 0x0008 +#define CLOUDABI_FDFLAG_SYNC 0x0010 typedef uint16_t cloudabi_fdsflags_t; -#define CLOUDABI_FDSTAT_FLAGS 0x0001 +#define CLOUDABI_FDSTAT_FLAGS 0x0001 #define CLOUDABI_FDSTAT_RIGHTS 0x0002 typedef int64_t cloudabi_filedelta_t; @@ -186,155 +187,155 @@ typedef int64_t cloudabi_filedelta_t; typedef uint64_t cloudabi_filesize_t; typedef uint8_t cloudabi_filetype_t; -#define CLOUDABI_FILETYPE_UNKNOWN 0 -#define CLOUDABI_FILETYPE_BLOCK_DEVICE 16 -#define CLOUDABI_FILETYPE_CHARACTER_DEVICE 17 -#define CLOUDABI_FILETYPE_DIRECTORY 32 -#define CLOUDABI_FILETYPE_FIFO 48 -#define CLOUDABI_FILETYPE_POLL 64 -#define CLOUDABI_FILETYPE_PROCESS 80 -#define CLOUDABI_FILETYPE_REGULAR_FILE 96 -#define CLOUDABI_FILETYPE_SHARED_MEMORY 112 -#define CLOUDABI_FILETYPE_SOCKET_DGRAM 128 +#define CLOUDABI_FILETYPE_UNKNOWN 0 +#define CLOUDABI_FILETYPE_BLOCK_DEVICE 16 +#define CLOUDABI_FILETYPE_CHARACTER_DEVICE 17 +#define CLOUDABI_FILETYPE_DIRECTORY 32 +#define CLOUDABI_FILETYPE_FIFO 48 +#define CLOUDABI_FILETYPE_POLL 64 +#define CLOUDABI_FILETYPE_PROCESS 80 +#define CLOUDABI_FILETYPE_REGULAR_FILE 96 +#define CLOUDABI_FILETYPE_SHARED_MEMORY 112 +#define CLOUDABI_FILETYPE_SOCKET_DGRAM 128 #define CLOUDABI_FILETYPE_SOCKET_SEQPACKET 129 -#define CLOUDABI_FILETYPE_SOCKET_STREAM 130 -#define CLOUDABI_FILETYPE_SYMBOLIC_LINK 144 +#define CLOUDABI_FILETYPE_SOCKET_STREAM 130 +#define CLOUDABI_FILETYPE_SYMBOLIC_LINK 144 typedef uint16_t cloudabi_fsflags_t; -#define CLOUDABI_FILESTAT_ATIM 0x0001 +#define CLOUDABI_FILESTAT_ATIM 0x0001 #define CLOUDABI_FILESTAT_ATIM_NOW 0x0002 -#define CLOUDABI_FILESTAT_MTIM 0x0004 +#define CLOUDABI_FILESTAT_MTIM 0x0004 #define CLOUDABI_FILESTAT_MTIM_NOW 0x0008 -#define CLOUDABI_FILESTAT_SIZE 0x0010 +#define CLOUDABI_FILESTAT_SIZE 0x0010 typedef uint64_t cloudabi_inode_t; typedef uint32_t cloudabi_linkcount_t; typedef uint32_t cloudabi_lock_t; -#define CLOUDABI_LOCK_UNLOCKED 0x00000000 -#define CLOUDABI_LOCK_WRLOCKED 0x40000000 +#define CLOUDABI_LOCK_UNLOCKED 0x00000000 +#define CLOUDABI_LOCK_WRLOCKED 0x40000000 #define CLOUDABI_LOCK_KERNEL_MANAGED 0x80000000 -#define CLOUDABI_LOCK_BOGUS 0x80000000 +#define CLOUDABI_LOCK_BOGUS 0x80000000 typedef uint32_t cloudabi_lookupflags_t; #define CLOUDABI_LOOKUP_SYMLINK_FOLLOW 0x00000001 typedef uint8_t cloudabi_mflags_t; -#define CLOUDABI_MAP_ANON 0x01 -#define CLOUDABI_MAP_FIXED 0x02 +#define CLOUDABI_MAP_ANON 0x01 +#define CLOUDABI_MAP_FIXED 0x02 #define CLOUDABI_MAP_PRIVATE 0x04 -#define CLOUDABI_MAP_SHARED 0x08 +#define CLOUDABI_MAP_SHARED 0x08 typedef uint8_t cloudabi_mprot_t; -#define CLOUDABI_PROT_EXEC 0x01 +#define CLOUDABI_PROT_EXEC 0x01 #define CLOUDABI_PROT_WRITE 0x02 -#define CLOUDABI_PROT_READ 0x04 +#define CLOUDABI_PROT_READ 0x04 typedef uint8_t cloudabi_msflags_t; -#define CLOUDABI_MS_ASYNC 0x01 +#define CLOUDABI_MS_ASYNC 0x01 #define CLOUDABI_MS_INVALIDATE 0x02 -#define CLOUDABI_MS_SYNC 0x04 +#define CLOUDABI_MS_SYNC 0x04 typedef uint16_t cloudabi_msgflags_t; -#define CLOUDABI_MSG_CTRUNC 0x0001 -#define CLOUDABI_MSG_EOR 0x0002 -#define CLOUDABI_MSG_PEEK 0x0004 -#define CLOUDABI_MSG_TRUNC 0x0008 +#define CLOUDABI_MSG_CTRUNC 0x0001 +#define CLOUDABI_MSG_EOR 0x0002 +#define CLOUDABI_MSG_PEEK 0x0004 +#define CLOUDABI_MSG_TRUNC 0x0008 #define CLOUDABI_MSG_WAITALL 0x0010 typedef uint32_t cloudabi_nthreads_t; typedef uint16_t cloudabi_oflags_t; -#define CLOUDABI_O_CREAT 0x0001 +#define CLOUDABI_O_CREAT 0x0001 #define CLOUDABI_O_DIRECTORY 0x0002 -#define CLOUDABI_O_EXCL 0x0004 -#define CLOUDABI_O_TRUNC 0x0008 +#define CLOUDABI_O_EXCL 0x0004 +#define CLOUDABI_O_TRUNC 0x0008 typedef uint64_t cloudabi_rights_t; -#define CLOUDABI_RIGHT_FD_DATASYNC 0x0000000000000001 -#define CLOUDABI_RIGHT_FD_READ 0x0000000000000002 -#define CLOUDABI_RIGHT_FD_SEEK 0x0000000000000004 -#define CLOUDABI_RIGHT_FD_STAT_PUT_FLAGS 0x0000000000000008 -#define CLOUDABI_RIGHT_FD_SYNC 0x0000000000000010 -#define CLOUDABI_RIGHT_FD_TELL 0x0000000000000020 -#define CLOUDABI_RIGHT_FD_WRITE 0x0000000000000040 -#define CLOUDABI_RIGHT_FILE_ADVISE 0x0000000000000080 -#define CLOUDABI_RIGHT_FILE_ALLOCATE 0x0000000000000100 -#define CLOUDABI_RIGHT_FILE_CREATE_DIRECTORY 0x0000000000000200 -#define CLOUDABI_RIGHT_FILE_CREATE_FILE 0x0000000000000400 -#define CLOUDABI_RIGHT_FILE_CREATE_FIFO 0x0000000000000800 -#define CLOUDABI_RIGHT_FILE_LINK_SOURCE 0x0000000000001000 -#define CLOUDABI_RIGHT_FILE_LINK_TARGET 0x0000000000002000 -#define CLOUDABI_RIGHT_FILE_OPEN 0x0000000000004000 -#define CLOUDABI_RIGHT_FILE_READDIR 0x0000000000008000 -#define CLOUDABI_RIGHT_FILE_READLINK 0x0000000000010000 -#define CLOUDABI_RIGHT_FILE_RENAME_SOURCE 0x0000000000020000 -#define CLOUDABI_RIGHT_FILE_RENAME_TARGET 0x0000000000040000 -#define CLOUDABI_RIGHT_FILE_STAT_FGET 0x0000000000080000 -#define CLOUDABI_RIGHT_FILE_STAT_FPUT_SIZE 0x0000000000100000 -#define CLOUDABI_RIGHT_FILE_STAT_FPUT_TIMES 0x0000000000200000 -#define CLOUDABI_RIGHT_FILE_STAT_GET 0x0000000000400000 -#define CLOUDABI_RIGHT_FILE_STAT_PUT_TIMES 0x0000000000800000 -#define CLOUDABI_RIGHT_FILE_SYMLINK 0x0000000001000000 -#define CLOUDABI_RIGHT_FILE_UNLINK 0x0000000002000000 -#define CLOUDABI_RIGHT_MEM_MAP 0x0000000004000000 -#define CLOUDABI_RIGHT_MEM_MAP_EXEC 0x0000000008000000 -#define CLOUDABI_RIGHT_POLL_FD_READWRITE 0x0000000010000000 -#define CLOUDABI_RIGHT_POLL_MODIFY 0x0000000020000000 -#define CLOUDABI_RIGHT_POLL_PROC_TERMINATE 0x0000000040000000 -#define CLOUDABI_RIGHT_POLL_WAIT 0x0000000080000000 -#define CLOUDABI_RIGHT_PROC_EXEC 0x0000000100000000 -#define CLOUDABI_RIGHT_SOCK_ACCEPT 0x0000000200000000 -#define CLOUDABI_RIGHT_SOCK_BIND_DIRECTORY 0x0000000400000000 -#define CLOUDABI_RIGHT_SOCK_BIND_SOCKET 0x0000000800000000 +#define CLOUDABI_RIGHT_FD_DATASYNC 0x0000000000000001 +#define CLOUDABI_RIGHT_FD_READ 0x0000000000000002 +#define CLOUDABI_RIGHT_FD_SEEK 0x0000000000000004 +#define CLOUDABI_RIGHT_FD_STAT_PUT_FLAGS 0x0000000000000008 +#define CLOUDABI_RIGHT_FD_SYNC 0x0000000000000010 +#define CLOUDABI_RIGHT_FD_TELL 0x0000000000000020 +#define CLOUDABI_RIGHT_FD_WRITE 0x0000000000000040 +#define CLOUDABI_RIGHT_FILE_ADVISE 0x0000000000000080 +#define CLOUDABI_RIGHT_FILE_ALLOCATE 0x0000000000000100 +#define CLOUDABI_RIGHT_FILE_CREATE_DIRECTORY 0x0000000000000200 +#define CLOUDABI_RIGHT_FILE_CREATE_FILE 0x0000000000000400 +#define CLOUDABI_RIGHT_FILE_CREATE_FIFO 0x0000000000000800 +#define CLOUDABI_RIGHT_FILE_LINK_SOURCE 0x0000000000001000 +#define CLOUDABI_RIGHT_FILE_LINK_TARGET 0x0000000000002000 +#define CLOUDABI_RIGHT_FILE_OPEN 0x0000000000004000 +#define CLOUDABI_RIGHT_FILE_READDIR 0x0000000000008000 +#define CLOUDABI_RIGHT_FILE_READLINK 0x0000000000010000 +#define CLOUDABI_RIGHT_FILE_RENAME_SOURCE 0x0000000000020000 +#define CLOUDABI_RIGHT_FILE_RENAME_TARGET 0x0000000000040000 +#define CLOUDABI_RIGHT_FILE_STAT_FGET 0x0000000000080000 +#define CLOUDABI_RIGHT_FILE_STAT_FPUT_SIZE 0x0000000000100000 +#define CLOUDABI_RIGHT_FILE_STAT_FPUT_TIMES 0x0000000000200000 +#define CLOUDABI_RIGHT_FILE_STAT_GET 0x0000000000400000 +#define CLOUDABI_RIGHT_FILE_STAT_PUT_TIMES 0x0000000000800000 +#define CLOUDABI_RIGHT_FILE_SYMLINK 0x0000000001000000 +#define CLOUDABI_RIGHT_FILE_UNLINK 0x0000000002000000 +#define CLOUDABI_RIGHT_MEM_MAP 0x0000000004000000 +#define CLOUDABI_RIGHT_MEM_MAP_EXEC 0x0000000008000000 +#define CLOUDABI_RIGHT_POLL_FD_READWRITE 0x0000000010000000 +#define CLOUDABI_RIGHT_POLL_MODIFY 0x0000000020000000 +#define CLOUDABI_RIGHT_POLL_PROC_TERMINATE 0x0000000040000000 +#define CLOUDABI_RIGHT_POLL_WAIT 0x0000000080000000 +#define CLOUDABI_RIGHT_PROC_EXEC 0x0000000100000000 +#define CLOUDABI_RIGHT_SOCK_ACCEPT 0x0000000200000000 +#define CLOUDABI_RIGHT_SOCK_BIND_DIRECTORY 0x0000000400000000 +#define CLOUDABI_RIGHT_SOCK_BIND_SOCKET 0x0000000800000000 #define CLOUDABI_RIGHT_SOCK_CONNECT_DIRECTORY 0x0000001000000000 -#define CLOUDABI_RIGHT_SOCK_CONNECT_SOCKET 0x0000002000000000 -#define CLOUDABI_RIGHT_SOCK_LISTEN 0x0000004000000000 -#define CLOUDABI_RIGHT_SOCK_SHUTDOWN 0x0000008000000000 -#define CLOUDABI_RIGHT_SOCK_STAT_GET 0x0000010000000000 +#define CLOUDABI_RIGHT_SOCK_CONNECT_SOCKET 0x0000002000000000 +#define CLOUDABI_RIGHT_SOCK_LISTEN 0x0000004000000000 +#define CLOUDABI_RIGHT_SOCK_SHUTDOWN 0x0000008000000000 +#define CLOUDABI_RIGHT_SOCK_STAT_GET 0x0000010000000000 typedef uint8_t cloudabi_sa_family_t; #define CLOUDABI_AF_UNSPEC 0 -#define CLOUDABI_AF_INET 1 -#define CLOUDABI_AF_INET6 2 -#define CLOUDABI_AF_UNIX 3 +#define CLOUDABI_AF_INET 1 +#define CLOUDABI_AF_INET6 2 +#define CLOUDABI_AF_UNIX 3 typedef uint8_t cloudabi_scope_t; #define CLOUDABI_SCOPE_PRIVATE 4 -#define CLOUDABI_SCOPE_SHARED 8 +#define CLOUDABI_SCOPE_SHARED 8 typedef uint8_t cloudabi_sdflags_t; #define CLOUDABI_SHUT_RD 0x01 #define CLOUDABI_SHUT_WR 0x02 typedef uint8_t cloudabi_signal_t; -#define CLOUDABI_SIGABRT 1 -#define CLOUDABI_SIGALRM 2 -#define CLOUDABI_SIGBUS 3 -#define CLOUDABI_SIGCHLD 4 -#define CLOUDABI_SIGCONT 5 -#define CLOUDABI_SIGFPE 6 -#define CLOUDABI_SIGHUP 7 -#define CLOUDABI_SIGILL 8 -#define CLOUDABI_SIGINT 9 -#define CLOUDABI_SIGKILL 10 -#define CLOUDABI_SIGPIPE 11 -#define CLOUDABI_SIGQUIT 12 -#define CLOUDABI_SIGSEGV 13 -#define CLOUDABI_SIGSTOP 14 -#define CLOUDABI_SIGSYS 15 -#define CLOUDABI_SIGTERM 16 -#define CLOUDABI_SIGTRAP 17 -#define CLOUDABI_SIGTSTP 18 -#define CLOUDABI_SIGTTIN 19 -#define CLOUDABI_SIGTTOU 20 -#define CLOUDABI_SIGURG 21 -#define CLOUDABI_SIGUSR1 22 -#define CLOUDABI_SIGUSR2 23 +#define CLOUDABI_SIGABRT 1 +#define CLOUDABI_SIGALRM 2 +#define CLOUDABI_SIGBUS 3 +#define CLOUDABI_SIGCHLD 4 +#define CLOUDABI_SIGCONT 5 +#define CLOUDABI_SIGFPE 6 +#define CLOUDABI_SIGHUP 7 +#define CLOUDABI_SIGILL 8 +#define CLOUDABI_SIGINT 9 +#define CLOUDABI_SIGKILL 10 +#define CLOUDABI_SIGPIPE 11 +#define CLOUDABI_SIGQUIT 12 +#define CLOUDABI_SIGSEGV 13 +#define CLOUDABI_SIGSTOP 14 +#define CLOUDABI_SIGSYS 15 +#define CLOUDABI_SIGTERM 16 +#define CLOUDABI_SIGTRAP 17 +#define CLOUDABI_SIGTSTP 18 +#define CLOUDABI_SIGTTIN 19 +#define CLOUDABI_SIGTTOU 20 +#define CLOUDABI_SIGURG 21 +#define CLOUDABI_SIGUSR1 22 +#define CLOUDABI_SIGUSR2 23 #define CLOUDABI_SIGVTALRM 24 -#define CLOUDABI_SIGXCPU 25 -#define CLOUDABI_SIGXFSZ 26 +#define CLOUDABI_SIGXCPU 25 +#define CLOUDABI_SIGXFSZ 26 typedef uint8_t cloudabi_ssflags_t; #define CLOUDABI_SOCKSTAT_CLEAR_ERROR 0x01 @@ -346,11 +347,11 @@ typedef uint16_t cloudabi_subclockflags_t; #define CLOUDABI_SUBSCRIPTION_CLOCK_ABSTIME 0x0001 typedef uint16_t cloudabi_subflags_t; -#define CLOUDABI_SUBSCRIPTION_ADD 0x0001 -#define CLOUDABI_SUBSCRIPTION_CLEAR 0x0002 -#define CLOUDABI_SUBSCRIPTION_DELETE 0x0004 +#define CLOUDABI_SUBSCRIPTION_ADD 0x0001 +#define CLOUDABI_SUBSCRIPTION_CLEAR 0x0002 +#define CLOUDABI_SUBSCRIPTION_DELETE 0x0004 #define CLOUDABI_SUBSCRIPTION_DISABLE 0x0008 -#define CLOUDABI_SUBSCRIPTION_ENABLE 0x0010 +#define CLOUDABI_SUBSCRIPTION_ENABLE 0x0010 #define CLOUDABI_SUBSCRIPTION_ONESHOT 0x0020 typedef uint16_t cloudabi_subrwflags_t; @@ -371,10 +372,10 @@ typedef uint8_t cloudabi_whence_t; #define CLOUDABI_WHENCE_SET 3 typedef struct { - _Alignas(8) cloudabi_dircookie_t d_next; - _Alignas(8) cloudabi_inode_t d_ino; - _Alignas(4) uint32_t d_namlen; - _Alignas(1) cloudabi_filetype_t d_type; + _Alignas(8) cloudabi_dircookie_t d_next; + _Alignas(8) cloudabi_inode_t d_ino; + _Alignas(4) uint32_t d_namlen; + _Alignas(1) cloudabi_filetype_t d_type; } cloudabi_dirent_t; _Static_assert(offsetof(cloudabi_dirent_t, d_next) == 0, "Incorrect layout"); _Static_assert(offsetof(cloudabi_dirent_t, d_ino) == 8, "Incorrect layout"); @@ -384,42 +385,51 @@ _Static_assert(sizeof(cloudabi_dirent_t) == 24, "Incorrect layout"); _Static_assert(_Alignof(cloudabi_dirent_t) == 8, "Incorrect layout"); typedef struct { - _Alignas(1) cloudabi_filetype_t fs_filetype; - _Alignas(2) cloudabi_fdflags_t fs_flags; - _Alignas(8) cloudabi_rights_t fs_rights_base; - _Alignas(8) cloudabi_rights_t fs_rights_inheriting; + _Alignas(1) cloudabi_filetype_t fs_filetype; + _Alignas(2) cloudabi_fdflags_t fs_flags; + _Alignas(8) cloudabi_rights_t fs_rights_base; + _Alignas(8) cloudabi_rights_t fs_rights_inheriting; } cloudabi_fdstat_t; -_Static_assert(offsetof(cloudabi_fdstat_t, fs_filetype) == 0, "Incorrect layout"); +_Static_assert(offsetof(cloudabi_fdstat_t, fs_filetype) == 0, + "Incorrect layout"); _Static_assert(offsetof(cloudabi_fdstat_t, fs_flags) == 2, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_fdstat_t, fs_rights_base) == 8, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_fdstat_t, fs_rights_inheriting) == 16, "Incorrect layout"); +_Static_assert(offsetof(cloudabi_fdstat_t, fs_rights_base) == 8, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi_fdstat_t, fs_rights_inheriting) == 16, + "Incorrect layout"); _Static_assert(sizeof(cloudabi_fdstat_t) == 24, "Incorrect layout"); _Static_assert(_Alignof(cloudabi_fdstat_t) == 8, "Incorrect layout"); typedef struct { - _Alignas(8) cloudabi_device_t st_dev; - _Alignas(8) cloudabi_inode_t st_ino; - _Alignas(1) cloudabi_filetype_t st_filetype; - _Alignas(4) cloudabi_linkcount_t st_nlink; - _Alignas(8) cloudabi_filesize_t st_size; - _Alignas(8) cloudabi_timestamp_t st_atim; - _Alignas(8) cloudabi_timestamp_t st_mtim; - _Alignas(8) cloudabi_timestamp_t st_ctim; + _Alignas(8) cloudabi_device_t st_dev; + _Alignas(8) cloudabi_inode_t st_ino; + _Alignas(1) cloudabi_filetype_t st_filetype; + _Alignas(4) cloudabi_linkcount_t st_nlink; + _Alignas(8) cloudabi_filesize_t st_size; + _Alignas(8) cloudabi_timestamp_t st_atim; + _Alignas(8) cloudabi_timestamp_t st_mtim; + _Alignas(8) cloudabi_timestamp_t st_ctim; } cloudabi_filestat_t; _Static_assert(offsetof(cloudabi_filestat_t, st_dev) == 0, "Incorrect layout"); _Static_assert(offsetof(cloudabi_filestat_t, st_ino) == 8, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_filestat_t, st_filetype) == 16, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_filestat_t, st_nlink) == 20, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_filestat_t, st_size) == 24, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_filestat_t, st_atim) == 32, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_filestat_t, st_mtim) == 40, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_filestat_t, st_ctim) == 48, "Incorrect layout"); +_Static_assert(offsetof(cloudabi_filestat_t, st_filetype) == 16, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi_filestat_t, st_nlink) == 20, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi_filestat_t, st_size) == 24, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi_filestat_t, st_atim) == 32, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi_filestat_t, st_mtim) == 40, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi_filestat_t, st_ctim) == 48, + "Incorrect layout"); _Static_assert(sizeof(cloudabi_filestat_t) == 56, "Incorrect layout"); _Static_assert(_Alignof(cloudabi_filestat_t) == 8, "Incorrect layout"); typedef struct { - _Alignas(4) cloudabi_fd_t fd; - _Alignas(4) cloudabi_lookupflags_t flags; + _Alignas(4) cloudabi_fd_t fd; + _Alignas(4) cloudabi_lookupflags_t flags; } cloudabi_lookup_t; _Static_assert(offsetof(cloudabi_lookup_t, fd) == 0, "Incorrect layout"); _Static_assert(offsetof(cloudabi_lookup_t, flags) == 4, "Incorrect layout"); @@ -427,36 +437,45 @@ _Static_assert(sizeof(cloudabi_lookup_t) == 8, "Incorrect layout"); _Static_assert(_Alignof(cloudabi_lookup_t) == 4, "Incorrect layout"); typedef struct { - _Alignas(1) cloudabi_sa_family_t sa_family; - union { - struct { - _Alignas(1) uint8_t addr[4]; - _Alignas(2) uint16_t port; - } sa_inet; - struct { - _Alignas(1) uint8_t addr[16]; - _Alignas(2) uint16_t port; - } sa_inet6; - }; + _Alignas(1) cloudabi_sa_family_t sa_family; + union { + struct { + _Alignas(1) uint8_t addr[4]; + _Alignas(2) uint16_t port; + } sa_inet; + struct { + _Alignas(1) uint8_t addr[16]; + _Alignas(2) uint16_t port; + } sa_inet6; + }; } cloudabi_sockaddr_t; -_Static_assert(offsetof(cloudabi_sockaddr_t, sa_family) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_sockaddr_t, sa_inet.addr) == 2, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_sockaddr_t, sa_inet.port) == 6, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_sockaddr_t, sa_inet6.addr) == 2, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_sockaddr_t, sa_inet6.port) == 18, "Incorrect layout"); +_Static_assert(offsetof(cloudabi_sockaddr_t, sa_family) == 0, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi_sockaddr_t, sa_inet.addr) == 2, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi_sockaddr_t, sa_inet.port) == 6, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi_sockaddr_t, sa_inet6.addr) == 2, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi_sockaddr_t, sa_inet6.port) == 18, + "Incorrect layout"); _Static_assert(sizeof(cloudabi_sockaddr_t) == 20, "Incorrect layout"); _Static_assert(_Alignof(cloudabi_sockaddr_t) == 2, "Incorrect layout"); typedef struct { - _Alignas(2) cloudabi_sockaddr_t ss_sockname; - _Alignas(2) cloudabi_sockaddr_t ss_peername; - _Alignas(2) cloudabi_errno_t ss_error; - _Alignas(4) cloudabi_sstate_t ss_state; + _Alignas(2) cloudabi_sockaddr_t ss_sockname; + _Alignas(2) cloudabi_sockaddr_t ss_peername; + _Alignas(2) cloudabi_errno_t ss_error; + _Alignas(4) cloudabi_sstate_t ss_state; } cloudabi_sockstat_t; -_Static_assert(offsetof(cloudabi_sockstat_t, ss_sockname) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_sockstat_t, ss_peername) == 20, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_sockstat_t, ss_error) == 40, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_sockstat_t, ss_state) == 44, "Incorrect layout"); +_Static_assert(offsetof(cloudabi_sockstat_t, ss_sockname) == 0, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi_sockstat_t, ss_peername) == 20, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi_sockstat_t, ss_error) == 40, + "Incorrect layout"); +_Static_assert(offsetof(cloudabi_sockstat_t, ss_state) == 44, + "Incorrect layout"); _Static_assert(sizeof(cloudabi_sockstat_t) == 48, "Incorrect layout"); _Static_assert(_Alignof(cloudabi_sockstat_t) == 4, "Incorrect layout"); diff --git a/sys/contrib/cloudabi/cloudabi_vdso_aarch64.S b/sys/contrib/cloudabi/cloudabi_vdso_aarch64.S new file mode 100644 index 0000000..3acebc1 --- /dev/null +++ b/sys/contrib/cloudabi/cloudabi_vdso_aarch64.S @@ -0,0 +1,491 @@ +// Copyright (c) 2016 Nuxi (https://nuxi.nl/) and contributors. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +// SUCH DAMAGE. +// +// This file is automatically generated. Do not edit. +// +// Source: https://github.com/NuxiNL/cloudabi + +#define ENTRY(name) \ + .text; \ + .p2align 2; \ + .global name; \ + .type name, @function; \ +name: + +#define END(name) .size name, . - name + +ENTRY(cloudabi_sys_clock_res_get) + str x1, [sp, #-8] + mov w8, #0 + svc #0 + ldr x2, [sp, #-8] + b.cs 1f + str x0, [x2] + mov w0, wzr +1: + ret +END(cloudabi_sys_clock_res_get) + +ENTRY(cloudabi_sys_clock_time_get) + str x2, [sp, #-8] + mov w8, #1 + svc #0 + ldr x2, [sp, #-8] + b.cs 1f + str x0, [x2] + mov w0, wzr +1: + ret +END(cloudabi_sys_clock_time_get) + +ENTRY(cloudabi_sys_condvar_signal) + mov w8, #2 + svc #0 + ret +END(cloudabi_sys_condvar_signal) + +ENTRY(cloudabi_sys_fd_close) + mov w8, #3 + svc #0 + ret +END(cloudabi_sys_fd_close) + +ENTRY(cloudabi_sys_fd_create1) + str x1, [sp, #-8] + mov w8, #4 + svc #0 + ldr x2, [sp, #-8] + b.cs 1f + str w0, [x2] + mov w0, wzr +1: + ret +END(cloudabi_sys_fd_create1) + +ENTRY(cloudabi_sys_fd_create2) + stp x1, x2, [sp, #-16] + mov w8, #5 + svc #0 + ldp x2, x3, [sp, #-16] + b.cs 1f + str w0, [x2] + str w1, [x3] + mov w0, wzr +1: + ret +END(cloudabi_sys_fd_create2) + +ENTRY(cloudabi_sys_fd_datasync) + mov w8, #6 + svc #0 + ret +END(cloudabi_sys_fd_datasync) + +ENTRY(cloudabi_sys_fd_dup) + str x1, [sp, #-8] + mov w8, #7 + svc #0 + ldr x2, [sp, #-8] + b.cs 1f + str w0, [x2] + mov w0, wzr +1: + ret +END(cloudabi_sys_fd_dup) + +ENTRY(cloudabi_sys_fd_pread) + str x4, [sp, #-8] + mov w8, #8 + svc #0 + ldr x2, [sp, #-8] + b.cs 1f + str x0, [x2] + mov w0, wzr +1: + ret +END(cloudabi_sys_fd_pread) + +ENTRY(cloudabi_sys_fd_pwrite) + str x4, [sp, #-8] + mov w8, #9 + svc #0 + ldr x2, [sp, #-8] + b.cs 1f + str x0, [x2] + mov w0, wzr +1: + ret +END(cloudabi_sys_fd_pwrite) + +ENTRY(cloudabi_sys_fd_read) + str x3, [sp, #-8] + mov w8, #10 + svc #0 + ldr x2, [sp, #-8] + b.cs 1f + str x0, [x2] + mov w0, wzr +1: + ret +END(cloudabi_sys_fd_read) + +ENTRY(cloudabi_sys_fd_replace) + mov w8, #11 + svc #0 + ret +END(cloudabi_sys_fd_replace) + +ENTRY(cloudabi_sys_fd_seek) + str x3, [sp, #-8] + mov w8, #12 + svc #0 + ldr x2, [sp, #-8] + b.cs 1f + str x0, [x2] + mov w0, wzr +1: + ret +END(cloudabi_sys_fd_seek) + +ENTRY(cloudabi_sys_fd_stat_get) + mov w8, #13 + svc #0 + ret +END(cloudabi_sys_fd_stat_get) + +ENTRY(cloudabi_sys_fd_stat_put) + mov w8, #14 + svc #0 + ret +END(cloudabi_sys_fd_stat_put) + +ENTRY(cloudabi_sys_fd_sync) + mov w8, #15 + svc #0 + ret +END(cloudabi_sys_fd_sync) + +ENTRY(cloudabi_sys_fd_write) + str x3, [sp, #-8] + mov w8, #16 + svc #0 + ldr x2, [sp, #-8] + b.cs 1f + str x0, [x2] + mov w0, wzr +1: + ret +END(cloudabi_sys_fd_write) + +ENTRY(cloudabi_sys_file_advise) + mov w8, #17 + svc #0 + ret +END(cloudabi_sys_file_advise) + +ENTRY(cloudabi_sys_file_allocate) + mov w8, #18 + svc #0 + ret +END(cloudabi_sys_file_allocate) + +ENTRY(cloudabi_sys_file_create) + mov w8, #19 + svc #0 + ret +END(cloudabi_sys_file_create) + +ENTRY(cloudabi_sys_file_link) + mov w8, #20 + svc #0 + ret +END(cloudabi_sys_file_link) + +ENTRY(cloudabi_sys_file_open) + str x5, [sp, #-8] + mov w8, #21 + svc #0 + ldr x2, [sp, #-8] + b.cs 1f + str w0, [x2] + mov w0, wzr +1: + ret +END(cloudabi_sys_file_open) + +ENTRY(cloudabi_sys_file_readdir) + str x4, [sp, #-8] + mov w8, #22 + svc #0 + ldr x2, [sp, #-8] + b.cs 1f + str x0, [x2] + mov w0, wzr +1: + ret +END(cloudabi_sys_file_readdir) + +ENTRY(cloudabi_sys_file_readlink) + str x5, [sp, #-8] + mov w8, #23 + svc #0 + ldr x2, [sp, #-8] + b.cs 1f + str x0, [x2] + mov w0, wzr +1: + ret +END(cloudabi_sys_file_readlink) + +ENTRY(cloudabi_sys_file_rename) + mov w8, #24 + svc #0 + ret +END(cloudabi_sys_file_rename) + +ENTRY(cloudabi_sys_file_stat_fget) + mov w8, #25 + svc #0 + ret +END(cloudabi_sys_file_stat_fget) + +ENTRY(cloudabi_sys_file_stat_fput) + mov w8, #26 + svc #0 + ret +END(cloudabi_sys_file_stat_fput) + +ENTRY(cloudabi_sys_file_stat_get) + mov w8, #27 + svc #0 + ret +END(cloudabi_sys_file_stat_get) + +ENTRY(cloudabi_sys_file_stat_put) + mov w8, #28 + svc #0 + ret +END(cloudabi_sys_file_stat_put) + +ENTRY(cloudabi_sys_file_symlink) + mov w8, #29 + svc #0 + ret +END(cloudabi_sys_file_symlink) + +ENTRY(cloudabi_sys_file_unlink) + mov w8, #30 + svc #0 + ret +END(cloudabi_sys_file_unlink) + +ENTRY(cloudabi_sys_lock_unlock) + mov w8, #31 + svc #0 + ret +END(cloudabi_sys_lock_unlock) + +ENTRY(cloudabi_sys_mem_advise) + mov w8, #32 + svc #0 + ret +END(cloudabi_sys_mem_advise) + +ENTRY(cloudabi_sys_mem_lock) + mov w8, #33 + svc #0 + ret +END(cloudabi_sys_mem_lock) + +ENTRY(cloudabi_sys_mem_map) + str x6, [sp, #-8] + mov w8, #34 + svc #0 + ldr x2, [sp, #-8] + b.cs 1f + str x0, [x2] + mov w0, wzr +1: + ret +END(cloudabi_sys_mem_map) + +ENTRY(cloudabi_sys_mem_protect) + mov w8, #35 + svc #0 + ret +END(cloudabi_sys_mem_protect) + +ENTRY(cloudabi_sys_mem_sync) + mov w8, #36 + svc #0 + ret +END(cloudabi_sys_mem_sync) + +ENTRY(cloudabi_sys_mem_unlock) + mov w8, #37 + svc #0 + ret +END(cloudabi_sys_mem_unlock) + +ENTRY(cloudabi_sys_mem_unmap) + mov w8, #38 + svc #0 + ret +END(cloudabi_sys_mem_unmap) + +ENTRY(cloudabi_sys_poll) + str x3, [sp, #-8] + mov w8, #39 + svc #0 + ldr x2, [sp, #-8] + b.cs 1f + str x0, [x2] + mov w0, wzr +1: + ret +END(cloudabi_sys_poll) + +ENTRY(cloudabi_sys_poll_fd) + str x6, [sp, #-8] + mov w8, #40 + svc #0 + ldr x2, [sp, #-8] + b.cs 1f + str x0, [x2] + mov w0, wzr +1: + ret +END(cloudabi_sys_poll_fd) + +ENTRY(cloudabi_sys_proc_exec) + mov w8, #41 + svc #0 + ret +END(cloudabi_sys_proc_exec) + +ENTRY(cloudabi_sys_proc_exit) + mov w8, #42 + svc #0 +END(cloudabi_sys_proc_exit) + +ENTRY(cloudabi_sys_proc_fork) + stp x0, x1, [sp, #-16] + mov w8, #43 + svc #0 + ldp x2, x3, [sp, #-16] + b.cs 1f + str w0, [x2] + str w1, [x3] + mov w0, wzr +1: + ret +END(cloudabi_sys_proc_fork) + +ENTRY(cloudabi_sys_proc_raise) + mov w8, #44 + svc #0 + ret +END(cloudabi_sys_proc_raise) + +ENTRY(cloudabi_sys_random_get) + mov w8, #45 + svc #0 + ret +END(cloudabi_sys_random_get) + +ENTRY(cloudabi_sys_sock_accept) + str x2, [sp, #-8] + mov w8, #46 + svc #0 + ldr x2, [sp, #-8] + b.cs 1f + str w0, [x2] + mov w0, wzr +1: + ret +END(cloudabi_sys_sock_accept) + +ENTRY(cloudabi_sys_sock_bind) + mov w8, #47 + svc #0 + ret +END(cloudabi_sys_sock_bind) + +ENTRY(cloudabi_sys_sock_connect) + mov w8, #48 + svc #0 + ret +END(cloudabi_sys_sock_connect) + +ENTRY(cloudabi_sys_sock_listen) + mov w8, #49 + svc #0 + ret +END(cloudabi_sys_sock_listen) + +ENTRY(cloudabi_sys_sock_recv) + mov w8, #50 + svc #0 + ret +END(cloudabi_sys_sock_recv) + +ENTRY(cloudabi_sys_sock_send) + mov w8, #51 + svc #0 + ret +END(cloudabi_sys_sock_send) + +ENTRY(cloudabi_sys_sock_shutdown) + mov w8, #52 + svc #0 + ret +END(cloudabi_sys_sock_shutdown) + +ENTRY(cloudabi_sys_sock_stat_get) + mov w8, #53 + svc #0 + ret +END(cloudabi_sys_sock_stat_get) + +ENTRY(cloudabi_sys_thread_create) + str x1, [sp, #-8] + mov w8, #54 + svc #0 + ldr x2, [sp, #-8] + b.cs 1f + str w0, [x2] + mov w0, wzr +1: + ret +END(cloudabi_sys_thread_create) + +ENTRY(cloudabi_sys_thread_exit) + mov w8, #55 + svc #0 +END(cloudabi_sys_thread_exit) + +ENTRY(cloudabi_sys_thread_yield) + mov w8, #56 + svc #0 + ret +END(cloudabi_sys_thread_yield) diff --git a/sys/contrib/cloudabi/cloudabi_vdso_armv6.S b/sys/contrib/cloudabi/cloudabi_vdso_armv6.S new file mode 100644 index 0000000..b4d68cc --- /dev/null +++ b/sys/contrib/cloudabi/cloudabi_vdso_armv6.S @@ -0,0 +1,451 @@ +// Copyright (c) 2016 Nuxi (https://nuxi.nl/) and contributors. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +// SUCH DAMAGE. +// +// This file is automatically generated. Do not edit. +// +// Source: https://github.com/NuxiNL/cloudabi + +#define ENTRY(name) \ + .text; \ + .p2align 2; \ + .global name; \ + .type name, %function; \ +name: + +#define END(name) .size name, . - name + +ENTRY(cloudabi_sys_clock_res_get) + str r1, [sp, #-4] + mov ip, #0 + swi 0 + ldrcc r2, [sp, #-4] + strcc r0, [r2, 0] + strcc r1, [r2, 4] + movcc r0, $0 + bx lr +END(cloudabi_sys_clock_res_get) + +ENTRY(cloudabi_sys_clock_time_get) + mov ip, #1 + swi 0 + ldrcc r2, [sp, #0] + strcc r0, [r2, 0] + strcc r1, [r2, 4] + movcc r0, $0 + bx lr +END(cloudabi_sys_clock_time_get) + +ENTRY(cloudabi_sys_condvar_signal) + mov ip, #2 + swi 0 + bx lr +END(cloudabi_sys_condvar_signal) + +ENTRY(cloudabi_sys_fd_close) + mov ip, #3 + swi 0 + bx lr +END(cloudabi_sys_fd_close) + +ENTRY(cloudabi_sys_fd_create1) + str r1, [sp, #-4] + mov ip, #4 + swi 0 + ldrcc r2, [sp, #-4] + strcc r0, [r2] + movcc r0, $0 + bx lr +END(cloudabi_sys_fd_create1) + +ENTRY(cloudabi_sys_fd_create2) + str r1, [sp, #-4] + str r2, [sp, #-8] + mov ip, #5 + swi 0 + ldrcc r2, [sp, #-4] + ldrcc r3, [sp, #-8] + strcc r0, [r2] + strcc r1, [r3] + movcc r0, $0 + bx lr +END(cloudabi_sys_fd_create2) + +ENTRY(cloudabi_sys_fd_datasync) + mov ip, #6 + swi 0 + bx lr +END(cloudabi_sys_fd_datasync) + +ENTRY(cloudabi_sys_fd_dup) + str r1, [sp, #-4] + mov ip, #7 + swi 0 + ldrcc r2, [sp, #-4] + strcc r0, [r2] + movcc r0, $0 + bx lr +END(cloudabi_sys_fd_dup) + +ENTRY(cloudabi_sys_fd_pread) + mov ip, #8 + swi 0 + ldrcc r2, [sp, #8] + strcc r0, [r2] + movcc r0, $0 + bx lr +END(cloudabi_sys_fd_pread) + +ENTRY(cloudabi_sys_fd_pwrite) + mov ip, #9 + swi 0 + ldrcc r2, [sp, #8] + strcc r0, [r2] + movcc r0, $0 + bx lr +END(cloudabi_sys_fd_pwrite) + +ENTRY(cloudabi_sys_fd_read) + str r3, [sp, #-4] + mov ip, #10 + swi 0 + ldrcc r2, [sp, #-4] + strcc r0, [r2] + movcc r0, $0 + bx lr +END(cloudabi_sys_fd_read) + +ENTRY(cloudabi_sys_fd_replace) + mov ip, #11 + swi 0 + bx lr +END(cloudabi_sys_fd_replace) + +ENTRY(cloudabi_sys_fd_seek) + mov ip, #12 + swi 0 + ldrcc r2, [sp, #4] + strcc r0, [r2, 0] + strcc r1, [r2, 4] + movcc r0, $0 + bx lr +END(cloudabi_sys_fd_seek) + +ENTRY(cloudabi_sys_fd_stat_get) + mov ip, #13 + swi 0 + bx lr +END(cloudabi_sys_fd_stat_get) + +ENTRY(cloudabi_sys_fd_stat_put) + mov ip, #14 + swi 0 + bx lr +END(cloudabi_sys_fd_stat_put) + +ENTRY(cloudabi_sys_fd_sync) + mov ip, #15 + swi 0 + bx lr +END(cloudabi_sys_fd_sync) + +ENTRY(cloudabi_sys_fd_write) + str r3, [sp, #-4] + mov ip, #16 + swi 0 + ldrcc r2, [sp, #-4] + strcc r0, [r2] + movcc r0, $0 + bx lr +END(cloudabi_sys_fd_write) + +ENTRY(cloudabi_sys_file_advise) + mov ip, #17 + swi 0 + bx lr +END(cloudabi_sys_file_advise) + +ENTRY(cloudabi_sys_file_allocate) + mov ip, #18 + swi 0 + bx lr +END(cloudabi_sys_file_allocate) + +ENTRY(cloudabi_sys_file_create) + mov ip, #19 + swi 0 + bx lr +END(cloudabi_sys_file_create) + +ENTRY(cloudabi_sys_file_link) + mov ip, #20 + swi 0 + bx lr +END(cloudabi_sys_file_link) + +ENTRY(cloudabi_sys_file_open) + mov ip, #21 + swi 0 + ldrcc r2, [sp, #8] + strcc r0, [r2] + movcc r0, $0 + bx lr +END(cloudabi_sys_file_open) + +ENTRY(cloudabi_sys_file_readdir) + mov ip, #22 + swi 0 + ldrcc r2, [sp, #8] + strcc r0, [r2] + movcc r0, $0 + bx lr +END(cloudabi_sys_file_readdir) + +ENTRY(cloudabi_sys_file_readlink) + mov ip, #23 + swi 0 + ldrcc r2, [sp, #4] + strcc r0, [r2] + movcc r0, $0 + bx lr +END(cloudabi_sys_file_readlink) + +ENTRY(cloudabi_sys_file_rename) + mov ip, #24 + swi 0 + bx lr +END(cloudabi_sys_file_rename) + +ENTRY(cloudabi_sys_file_stat_fget) + mov ip, #25 + swi 0 + bx lr +END(cloudabi_sys_file_stat_fget) + +ENTRY(cloudabi_sys_file_stat_fput) + mov ip, #26 + swi 0 + bx lr +END(cloudabi_sys_file_stat_fput) + +ENTRY(cloudabi_sys_file_stat_get) + mov ip, #27 + swi 0 + bx lr +END(cloudabi_sys_file_stat_get) + +ENTRY(cloudabi_sys_file_stat_put) + mov ip, #28 + swi 0 + bx lr +END(cloudabi_sys_file_stat_put) + +ENTRY(cloudabi_sys_file_symlink) + mov ip, #29 + swi 0 + bx lr +END(cloudabi_sys_file_symlink) + +ENTRY(cloudabi_sys_file_unlink) + mov ip, #30 + swi 0 + bx lr +END(cloudabi_sys_file_unlink) + +ENTRY(cloudabi_sys_lock_unlock) + mov ip, #31 + swi 0 + bx lr +END(cloudabi_sys_lock_unlock) + +ENTRY(cloudabi_sys_mem_advise) + mov ip, #32 + swi 0 + bx lr +END(cloudabi_sys_mem_advise) + +ENTRY(cloudabi_sys_mem_lock) + mov ip, #33 + swi 0 + bx lr +END(cloudabi_sys_mem_lock) + +ENTRY(cloudabi_sys_mem_map) + mov ip, #34 + swi 0 + ldrcc r2, [sp, #16] + strcc r0, [r2] + movcc r0, $0 + bx lr +END(cloudabi_sys_mem_map) + +ENTRY(cloudabi_sys_mem_protect) + mov ip, #35 + swi 0 + bx lr +END(cloudabi_sys_mem_protect) + +ENTRY(cloudabi_sys_mem_sync) + mov ip, #36 + swi 0 + bx lr +END(cloudabi_sys_mem_sync) + +ENTRY(cloudabi_sys_mem_unlock) + mov ip, #37 + swi 0 + bx lr +END(cloudabi_sys_mem_unlock) + +ENTRY(cloudabi_sys_mem_unmap) + mov ip, #38 + swi 0 + bx lr +END(cloudabi_sys_mem_unmap) + +ENTRY(cloudabi_sys_poll) + str r3, [sp, #-4] + mov ip, #39 + swi 0 + ldrcc r2, [sp, #-4] + strcc r0, [r2] + movcc r0, $0 + bx lr +END(cloudabi_sys_poll) + +ENTRY(cloudabi_sys_poll_fd) + mov ip, #40 + swi 0 + ldrcc r2, [sp, #8] + strcc r0, [r2] + movcc r0, $0 + bx lr +END(cloudabi_sys_poll_fd) + +ENTRY(cloudabi_sys_proc_exec) + mov ip, #41 + swi 0 + bx lr +END(cloudabi_sys_proc_exec) + +ENTRY(cloudabi_sys_proc_exit) + mov ip, #42 + swi 0 +END(cloudabi_sys_proc_exit) + +ENTRY(cloudabi_sys_proc_fork) + str r0, [sp, #-4] + str r1, [sp, #-8] + mov ip, #43 + swi 0 + ldrcc r2, [sp, #-4] + ldrcc r3, [sp, #-8] + strcc r0, [r2] + strcc r1, [r3] + movcc r0, $0 + bx lr +END(cloudabi_sys_proc_fork) + +ENTRY(cloudabi_sys_proc_raise) + mov ip, #44 + swi 0 + bx lr +END(cloudabi_sys_proc_raise) + +ENTRY(cloudabi_sys_random_get) + mov ip, #45 + swi 0 + bx lr +END(cloudabi_sys_random_get) + +ENTRY(cloudabi_sys_sock_accept) + str r2, [sp, #-4] + mov ip, #46 + swi 0 + ldrcc r2, [sp, #-4] + strcc r0, [r2] + movcc r0, $0 + bx lr +END(cloudabi_sys_sock_accept) + +ENTRY(cloudabi_sys_sock_bind) + mov ip, #47 + swi 0 + bx lr +END(cloudabi_sys_sock_bind) + +ENTRY(cloudabi_sys_sock_connect) + mov ip, #48 + swi 0 + bx lr +END(cloudabi_sys_sock_connect) + +ENTRY(cloudabi_sys_sock_listen) + mov ip, #49 + swi 0 + bx lr +END(cloudabi_sys_sock_listen) + +ENTRY(cloudabi_sys_sock_recv) + mov ip, #50 + swi 0 + bx lr +END(cloudabi_sys_sock_recv) + +ENTRY(cloudabi_sys_sock_send) + mov ip, #51 + swi 0 + bx lr +END(cloudabi_sys_sock_send) + +ENTRY(cloudabi_sys_sock_shutdown) + mov ip, #52 + swi 0 + bx lr +END(cloudabi_sys_sock_shutdown) + +ENTRY(cloudabi_sys_sock_stat_get) + mov ip, #53 + swi 0 + bx lr +END(cloudabi_sys_sock_stat_get) + +ENTRY(cloudabi_sys_thread_create) + str r1, [sp, #-4] + mov ip, #54 + swi 0 + ldrcc r2, [sp, #-4] + strcc r0, [r2] + movcc r0, $0 + bx lr +END(cloudabi_sys_thread_create) + +ENTRY(cloudabi_sys_thread_exit) + mov ip, #55 + swi 0 +END(cloudabi_sys_thread_exit) + +ENTRY(cloudabi_sys_thread_yield) + mov ip, #56 + swi 0 + bx lr +END(cloudabi_sys_thread_yield) diff --git a/sys/contrib/cloudabi/cloudabi_vdso_i686.S b/sys/contrib/cloudabi/cloudabi_vdso_i686.S new file mode 100644 index 0000000..d02c6e1 --- /dev/null +++ b/sys/contrib/cloudabi/cloudabi_vdso_i686.S @@ -0,0 +1,477 @@ +// Copyright (c) 2016 Nuxi (https://nuxi.nl/) and contributors. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +// SUCH DAMAGE. +// +// This file is automatically generated. Do not edit. +// +// Source: https://github.com/NuxiNL/cloudabi + +#define ENTRY(name) \ + .text; \ + .p2align 2, 0x90; \ + .global name; \ + .type name, @function; \ +name: + +#define END(name) .size name, . - name + +ENTRY(cloudabi_sys_clock_res_get) + mov $0, %eax + int $0x80 + jc 1f + mov 8(%esp), %ecx + mov %eax, 0(%ecx) + mov %edx, 4(%ecx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_clock_res_get) + +ENTRY(cloudabi_sys_clock_time_get) + mov $1, %eax + int $0x80 + jc 1f + mov 16(%esp), %ecx + mov %eax, 0(%ecx) + mov %edx, 4(%ecx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_clock_time_get) + +ENTRY(cloudabi_sys_condvar_signal) + mov $2, %eax + int $0x80 + ret +END(cloudabi_sys_condvar_signal) + +ENTRY(cloudabi_sys_fd_close) + mov $3, %eax + int $0x80 + ret +END(cloudabi_sys_fd_close) + +ENTRY(cloudabi_sys_fd_create1) + mov $4, %eax + int $0x80 + jc 1f + mov 8(%esp), %ecx + mov %eax, (%ecx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_fd_create1) + +ENTRY(cloudabi_sys_fd_create2) + mov $5, %eax + int $0x80 + jc 1f + mov 8(%esp), %ecx + mov %eax, (%ecx) + mov 12(%esp), %ecx + mov %edx, (%ecx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_fd_create2) + +ENTRY(cloudabi_sys_fd_datasync) + mov $6, %eax + int $0x80 + ret +END(cloudabi_sys_fd_datasync) + +ENTRY(cloudabi_sys_fd_dup) + mov $7, %eax + int $0x80 + jc 1f + mov 8(%esp), %ecx + mov %eax, (%ecx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_fd_dup) + +ENTRY(cloudabi_sys_fd_pread) + mov $8, %eax + int $0x80 + jc 1f + mov 24(%esp), %ecx + mov %eax, (%ecx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_fd_pread) + +ENTRY(cloudabi_sys_fd_pwrite) + mov $9, %eax + int $0x80 + jc 1f + mov 24(%esp), %ecx + mov %eax, (%ecx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_fd_pwrite) + +ENTRY(cloudabi_sys_fd_read) + mov $10, %eax + int $0x80 + jc 1f + mov 16(%esp), %ecx + mov %eax, (%ecx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_fd_read) + +ENTRY(cloudabi_sys_fd_replace) + mov $11, %eax + int $0x80 + ret +END(cloudabi_sys_fd_replace) + +ENTRY(cloudabi_sys_fd_seek) + mov $12, %eax + int $0x80 + jc 1f + mov 20(%esp), %ecx + mov %eax, 0(%ecx) + mov %edx, 4(%ecx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_fd_seek) + +ENTRY(cloudabi_sys_fd_stat_get) + mov $13, %eax + int $0x80 + ret +END(cloudabi_sys_fd_stat_get) + +ENTRY(cloudabi_sys_fd_stat_put) + mov $14, %eax + int $0x80 + ret +END(cloudabi_sys_fd_stat_put) + +ENTRY(cloudabi_sys_fd_sync) + mov $15, %eax + int $0x80 + ret +END(cloudabi_sys_fd_sync) + +ENTRY(cloudabi_sys_fd_write) + mov $16, %eax + int $0x80 + jc 1f + mov 16(%esp), %ecx + mov %eax, (%ecx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_fd_write) + +ENTRY(cloudabi_sys_file_advise) + mov $17, %eax + int $0x80 + ret +END(cloudabi_sys_file_advise) + +ENTRY(cloudabi_sys_file_allocate) + mov $18, %eax + int $0x80 + ret +END(cloudabi_sys_file_allocate) + +ENTRY(cloudabi_sys_file_create) + mov $19, %eax + int $0x80 + ret +END(cloudabi_sys_file_create) + +ENTRY(cloudabi_sys_file_link) + mov $20, %eax + int $0x80 + ret +END(cloudabi_sys_file_link) + +ENTRY(cloudabi_sys_file_open) + mov $21, %eax + int $0x80 + jc 1f + mov 28(%esp), %ecx + mov %eax, (%ecx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_file_open) + +ENTRY(cloudabi_sys_file_readdir) + mov $22, %eax + int $0x80 + jc 1f + mov 24(%esp), %ecx + mov %eax, (%ecx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_file_readdir) + +ENTRY(cloudabi_sys_file_readlink) + mov $23, %eax + int $0x80 + jc 1f + mov 24(%esp), %ecx + mov %eax, (%ecx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_file_readlink) + +ENTRY(cloudabi_sys_file_rename) + mov $24, %eax + int $0x80 + ret +END(cloudabi_sys_file_rename) + +ENTRY(cloudabi_sys_file_stat_fget) + mov $25, %eax + int $0x80 + ret +END(cloudabi_sys_file_stat_fget) + +ENTRY(cloudabi_sys_file_stat_fput) + mov $26, %eax + int $0x80 + ret +END(cloudabi_sys_file_stat_fput) + +ENTRY(cloudabi_sys_file_stat_get) + mov $27, %eax + int $0x80 + ret +END(cloudabi_sys_file_stat_get) + +ENTRY(cloudabi_sys_file_stat_put) + mov $28, %eax + int $0x80 + ret +END(cloudabi_sys_file_stat_put) + +ENTRY(cloudabi_sys_file_symlink) + mov $29, %eax + int $0x80 + ret +END(cloudabi_sys_file_symlink) + +ENTRY(cloudabi_sys_file_unlink) + mov $30, %eax + int $0x80 + ret +END(cloudabi_sys_file_unlink) + +ENTRY(cloudabi_sys_lock_unlock) + mov $31, %eax + int $0x80 + ret +END(cloudabi_sys_lock_unlock) + +ENTRY(cloudabi_sys_mem_advise) + mov $32, %eax + int $0x80 + ret +END(cloudabi_sys_mem_advise) + +ENTRY(cloudabi_sys_mem_lock) + mov $33, %eax + int $0x80 + ret +END(cloudabi_sys_mem_lock) + +ENTRY(cloudabi_sys_mem_map) + mov $34, %eax + int $0x80 + jc 1f + mov 32(%esp), %ecx + mov %eax, (%ecx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_mem_map) + +ENTRY(cloudabi_sys_mem_protect) + mov $35, %eax + int $0x80 + ret +END(cloudabi_sys_mem_protect) + +ENTRY(cloudabi_sys_mem_sync) + mov $36, %eax + int $0x80 + ret +END(cloudabi_sys_mem_sync) + +ENTRY(cloudabi_sys_mem_unlock) + mov $37, %eax + int $0x80 + ret +END(cloudabi_sys_mem_unlock) + +ENTRY(cloudabi_sys_mem_unmap) + mov $38, %eax + int $0x80 + ret +END(cloudabi_sys_mem_unmap) + +ENTRY(cloudabi_sys_poll) + mov $39, %eax + int $0x80 + jc 1f + mov 16(%esp), %ecx + mov %eax, (%ecx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_poll) + +ENTRY(cloudabi_sys_poll_fd) + mov $40, %eax + int $0x80 + jc 1f + mov 28(%esp), %ecx + mov %eax, (%ecx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_poll_fd) + +ENTRY(cloudabi_sys_proc_exec) + mov $41, %eax + int $0x80 + ret +END(cloudabi_sys_proc_exec) + +ENTRY(cloudabi_sys_proc_exit) + mov $42, %eax + int $0x80 +END(cloudabi_sys_proc_exit) + +ENTRY(cloudabi_sys_proc_fork) + mov $43, %eax + int $0x80 + jc 1f + mov 4(%esp), %ecx + mov %eax, (%ecx) + mov 8(%esp), %ecx + mov %edx, (%ecx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_proc_fork) + +ENTRY(cloudabi_sys_proc_raise) + mov $44, %eax + int $0x80 + ret +END(cloudabi_sys_proc_raise) + +ENTRY(cloudabi_sys_random_get) + mov $45, %eax + int $0x80 + ret +END(cloudabi_sys_random_get) + +ENTRY(cloudabi_sys_sock_accept) + mov $46, %eax + int $0x80 + jc 1f + mov 12(%esp), %ecx + mov %eax, (%ecx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_sock_accept) + +ENTRY(cloudabi_sys_sock_bind) + mov $47, %eax + int $0x80 + ret +END(cloudabi_sys_sock_bind) + +ENTRY(cloudabi_sys_sock_connect) + mov $48, %eax + int $0x80 + ret +END(cloudabi_sys_sock_connect) + +ENTRY(cloudabi_sys_sock_listen) + mov $49, %eax + int $0x80 + ret +END(cloudabi_sys_sock_listen) + +ENTRY(cloudabi_sys_sock_recv) + mov $50, %eax + int $0x80 + ret +END(cloudabi_sys_sock_recv) + +ENTRY(cloudabi_sys_sock_send) + mov $51, %eax + int $0x80 + ret +END(cloudabi_sys_sock_send) + +ENTRY(cloudabi_sys_sock_shutdown) + mov $52, %eax + int $0x80 + ret +END(cloudabi_sys_sock_shutdown) + +ENTRY(cloudabi_sys_sock_stat_get) + mov $53, %eax + int $0x80 + ret +END(cloudabi_sys_sock_stat_get) + +ENTRY(cloudabi_sys_thread_create) + mov $54, %eax + int $0x80 + jc 1f + mov 8(%esp), %ecx + mov %eax, (%ecx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_thread_create) + +ENTRY(cloudabi_sys_thread_exit) + mov $55, %eax + int $0x80 +END(cloudabi_sys_thread_exit) + +ENTRY(cloudabi_sys_thread_yield) + mov $56, %eax + int $0x80 + ret +END(cloudabi_sys_thread_yield) diff --git a/sys/contrib/cloudabi/cloudabi_vdso_i686_on_64bit.S b/sys/contrib/cloudabi/cloudabi_vdso_i686_on_64bit.S new file mode 100644 index 0000000..74f59db --- /dev/null +++ b/sys/contrib/cloudabi/cloudabi_vdso_i686_on_64bit.S @@ -0,0 +1,1223 @@ +// Copyright (c) 2016 Nuxi (https://nuxi.nl/) and contributors. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +// SUCH DAMAGE. +// +// This file is automatically generated. Do not edit. +// +// Source: https://github.com/NuxiNL/cloudabi + +#define ENTRY(name) \ + .text; \ + .p2align 2, 0x90; \ + .global name; \ + .type name, @function; \ +name: + +#define END(name) .size name, . - name + +ENTRY(cloudabi_sys_clock_res_get) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -16(%ebp) + mov $0, %eax + mov %ebp, %ecx + sub $16, %ecx + int $0x80 + test %eax, %eax + jnz 1f + mov 12(%ebp), %ecx + mov -16(%ebp), %edx + mov %edx, 0(%ecx) + mov -12(%ebp), %edx + mov %edx, 4(%ecx) +1: + pop %ebp + ret +END(cloudabi_sys_clock_res_get) + +ENTRY(cloudabi_sys_clock_time_get) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -16(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -8(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -4(%ebp) + mov $1, %eax + mov %ebp, %ecx + sub $16, %ecx + int $0x80 + test %eax, %eax + jnz 1f + mov 20(%ebp), %ecx + mov -16(%ebp), %edx + mov %edx, 0(%ecx) + mov -12(%ebp), %edx + mov %edx, 4(%ecx) +1: + pop %ebp + ret +END(cloudabi_sys_clock_time_get) + +ENTRY(cloudabi_sys_condvar_signal) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -24(%ebp) + movl $0, -20(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -16(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -8(%ebp) + mov $2, %eax + mov %ebp, %ecx + sub $24, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_condvar_signal) + +ENTRY(cloudabi_sys_fd_close) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -16(%ebp) + mov $3, %eax + mov %ebp, %ecx + sub $16, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_fd_close) + +ENTRY(cloudabi_sys_fd_create1) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -16(%ebp) + mov $4, %eax + mov %ebp, %ecx + sub $16, %ecx + int $0x80 + test %eax, %eax + jnz 1f + mov 12(%ebp), %ecx + mov -16(%ebp), %edx + mov %edx, 0(%ecx) +1: + pop %ebp + ret +END(cloudabi_sys_fd_create1) + +ENTRY(cloudabi_sys_fd_create2) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -16(%ebp) + mov $5, %eax + mov %ebp, %ecx + sub $16, %ecx + int $0x80 + test %eax, %eax + jnz 1f + mov 12(%ebp), %ecx + mov -16(%ebp), %edx + mov %edx, 0(%ecx) + mov 16(%ebp), %ecx + mov -8(%ebp), %edx + mov %edx, 0(%ecx) +1: + pop %ebp + ret +END(cloudabi_sys_fd_create2) + +ENTRY(cloudabi_sys_fd_datasync) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -16(%ebp) + mov $6, %eax + mov %ebp, %ecx + sub $16, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_fd_datasync) + +ENTRY(cloudabi_sys_fd_dup) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -16(%ebp) + mov $7, %eax + mov %ebp, %ecx + sub $16, %ecx + int $0x80 + test %eax, %eax + jnz 1f + mov 12(%ebp), %ecx + mov -16(%ebp), %edx + mov %edx, 0(%ecx) +1: + pop %ebp + ret +END(cloudabi_sys_fd_dup) + +ENTRY(cloudabi_sys_fd_pread) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -32(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -24(%ebp) + movl $0, -20(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov 20(%ebp), %ecx + mov %ecx, -8(%ebp) + mov 24(%ebp), %ecx + mov %ecx, -4(%ebp) + mov $8, %eax + mov %ebp, %ecx + sub $32, %ecx + int $0x80 + test %eax, %eax + jnz 1f + mov 28(%ebp), %ecx + mov -32(%ebp), %edx + mov %edx, 0(%ecx) +1: + pop %ebp + ret +END(cloudabi_sys_fd_pread) + +ENTRY(cloudabi_sys_fd_pwrite) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -32(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -24(%ebp) + movl $0, -20(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov 20(%ebp), %ecx + mov %ecx, -8(%ebp) + mov 24(%ebp), %ecx + mov %ecx, -4(%ebp) + mov $9, %eax + mov %ebp, %ecx + sub $32, %ecx + int $0x80 + test %eax, %eax + jnz 1f + mov 28(%ebp), %ecx + mov -32(%ebp), %edx + mov %edx, 0(%ecx) +1: + pop %ebp + ret +END(cloudabi_sys_fd_pwrite) + +ENTRY(cloudabi_sys_fd_read) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -24(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -8(%ebp) + movl $0, -4(%ebp) + mov $10, %eax + mov %ebp, %ecx + sub $24, %ecx + int $0x80 + test %eax, %eax + jnz 1f + mov 20(%ebp), %ecx + mov -24(%ebp), %edx + mov %edx, 0(%ecx) +1: + pop %ebp + ret +END(cloudabi_sys_fd_read) + +ENTRY(cloudabi_sys_fd_replace) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -16(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -8(%ebp) + mov $11, %eax + mov %ebp, %ecx + sub $16, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_fd_replace) + +ENTRY(cloudabi_sys_fd_seek) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -24(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -16(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -12(%ebp) + mov 20(%ebp), %ecx + mov %ecx, -8(%ebp) + mov $12, %eax + mov %ebp, %ecx + sub $24, %ecx + int $0x80 + test %eax, %eax + jnz 1f + mov 24(%ebp), %ecx + mov -24(%ebp), %edx + mov %edx, 0(%ecx) + mov -20(%ebp), %edx + mov %edx, 4(%ecx) +1: + pop %ebp + ret +END(cloudabi_sys_fd_seek) + +ENTRY(cloudabi_sys_fd_stat_get) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -16(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -8(%ebp) + movl $0, -4(%ebp) + mov $13, %eax + mov %ebp, %ecx + sub $16, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_fd_stat_get) + +ENTRY(cloudabi_sys_fd_stat_put) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -24(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -8(%ebp) + mov $14, %eax + mov %ebp, %ecx + sub $24, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_fd_stat_put) + +ENTRY(cloudabi_sys_fd_sync) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -16(%ebp) + mov $15, %eax + mov %ebp, %ecx + sub $16, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_fd_sync) + +ENTRY(cloudabi_sys_fd_write) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -24(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -8(%ebp) + movl $0, -4(%ebp) + mov $16, %eax + mov %ebp, %ecx + sub $24, %ecx + int $0x80 + test %eax, %eax + jnz 1f + mov 20(%ebp), %ecx + mov -24(%ebp), %edx + mov %edx, 0(%ecx) +1: + pop %ebp + ret +END(cloudabi_sys_fd_write) + +ENTRY(cloudabi_sys_file_advise) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -32(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -24(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -20(%ebp) + mov 20(%ebp), %ecx + mov %ecx, -16(%ebp) + mov 24(%ebp), %ecx + mov %ecx, -12(%ebp) + mov 28(%ebp), %ecx + mov %ecx, -8(%ebp) + mov $17, %eax + mov %ebp, %ecx + sub $32, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_file_advise) + +ENTRY(cloudabi_sys_file_allocate) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -24(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -16(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -12(%ebp) + mov 20(%ebp), %ecx + mov %ecx, -8(%ebp) + mov 24(%ebp), %ecx + mov %ecx, -4(%ebp) + mov $18, %eax + mov %ebp, %ecx + sub $24, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_file_allocate) + +ENTRY(cloudabi_sys_file_create) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -32(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -24(%ebp) + movl $0, -20(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov 20(%ebp), %ecx + mov %ecx, -8(%ebp) + mov $19, %eax + mov %ebp, %ecx + sub $32, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_file_create) + +ENTRY(cloudabi_sys_file_link) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -48(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -44(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -40(%ebp) + movl $0, -36(%ebp) + mov 20(%ebp), %ecx + mov %ecx, -32(%ebp) + movl $0, -28(%ebp) + mov 24(%ebp), %ecx + mov %ecx, -24(%ebp) + mov 28(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov 32(%ebp), %ecx + mov %ecx, -8(%ebp) + movl $0, -4(%ebp) + mov $20, %eax + mov %ebp, %ecx + sub $48, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_file_link) + +ENTRY(cloudabi_sys_file_open) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -40(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -36(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -32(%ebp) + movl $0, -28(%ebp) + mov 20(%ebp), %ecx + mov %ecx, -24(%ebp) + movl $0, -20(%ebp) + mov 24(%ebp), %ecx + mov %ecx, -16(%ebp) + mov 28(%ebp), %ecx + mov %ecx, -8(%ebp) + movl $0, -4(%ebp) + mov $21, %eax + mov %ebp, %ecx + sub $40, %ecx + int $0x80 + test %eax, %eax + jnz 1f + mov 32(%ebp), %ecx + mov -40(%ebp), %edx + mov %edx, 0(%ecx) +1: + pop %ebp + ret +END(cloudabi_sys_file_open) + +ENTRY(cloudabi_sys_file_readdir) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -32(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -24(%ebp) + movl $0, -20(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov 20(%ebp), %ecx + mov %ecx, -8(%ebp) + mov 24(%ebp), %ecx + mov %ecx, -4(%ebp) + mov $22, %eax + mov %ebp, %ecx + sub $32, %ecx + int $0x80 + test %eax, %eax + jnz 1f + mov 28(%ebp), %ecx + mov -32(%ebp), %edx + mov %edx, 0(%ecx) +1: + pop %ebp + ret +END(cloudabi_sys_file_readdir) + +ENTRY(cloudabi_sys_file_readlink) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -40(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -32(%ebp) + movl $0, -28(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -24(%ebp) + movl $0, -20(%ebp) + mov 20(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov 24(%ebp), %ecx + mov %ecx, -8(%ebp) + movl $0, -4(%ebp) + mov $23, %eax + mov %ebp, %ecx + sub $40, %ecx + int $0x80 + test %eax, %eax + jnz 1f + mov 28(%ebp), %ecx + mov -40(%ebp), %edx + mov %edx, 0(%ecx) +1: + pop %ebp + ret +END(cloudabi_sys_file_readlink) + +ENTRY(cloudabi_sys_file_rename) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -48(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -40(%ebp) + movl $0, -36(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -32(%ebp) + movl $0, -28(%ebp) + mov 20(%ebp), %ecx + mov %ecx, -24(%ebp) + mov 24(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov 28(%ebp), %ecx + mov %ecx, -8(%ebp) + movl $0, -4(%ebp) + mov $24, %eax + mov %ebp, %ecx + sub $48, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_file_rename) + +ENTRY(cloudabi_sys_file_stat_fget) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -16(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -8(%ebp) + movl $0, -4(%ebp) + mov $25, %eax + mov %ebp, %ecx + sub $16, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_file_stat_fget) + +ENTRY(cloudabi_sys_file_stat_fput) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -24(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -8(%ebp) + mov $26, %eax + mov %ebp, %ecx + sub $24, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_file_stat_fput) + +ENTRY(cloudabi_sys_file_stat_get) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -32(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -28(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -24(%ebp) + movl $0, -20(%ebp) + mov 20(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov 24(%ebp), %ecx + mov %ecx, -8(%ebp) + movl $0, -4(%ebp) + mov $27, %eax + mov %ebp, %ecx + sub $32, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_file_stat_get) + +ENTRY(cloudabi_sys_file_stat_put) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -40(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -36(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -32(%ebp) + movl $0, -28(%ebp) + mov 20(%ebp), %ecx + mov %ecx, -24(%ebp) + movl $0, -20(%ebp) + mov 24(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov 28(%ebp), %ecx + mov %ecx, -8(%ebp) + mov $28, %eax + mov %ebp, %ecx + sub $40, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_file_stat_put) + +ENTRY(cloudabi_sys_file_symlink) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -40(%ebp) + movl $0, -36(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -32(%ebp) + movl $0, -28(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -24(%ebp) + mov 20(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov 24(%ebp), %ecx + mov %ecx, -8(%ebp) + movl $0, -4(%ebp) + mov $29, %eax + mov %ebp, %ecx + sub $40, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_file_symlink) + +ENTRY(cloudabi_sys_file_unlink) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -32(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -24(%ebp) + movl $0, -20(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov 20(%ebp), %ecx + mov %ecx, -8(%ebp) + mov $30, %eax + mov %ebp, %ecx + sub $32, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_file_unlink) + +ENTRY(cloudabi_sys_lock_unlock) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -8(%ebp) + mov $31, %eax + mov %ebp, %ecx + sub $16, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_lock_unlock) + +ENTRY(cloudabi_sys_mem_advise) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -24(%ebp) + movl $0, -20(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -8(%ebp) + mov $32, %eax + mov %ebp, %ecx + sub $24, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_mem_advise) + +ENTRY(cloudabi_sys_mem_lock) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -8(%ebp) + movl $0, -4(%ebp) + mov $33, %eax + mov %ebp, %ecx + sub $16, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_mem_lock) + +ENTRY(cloudabi_sys_mem_map) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -48(%ebp) + movl $0, -44(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -40(%ebp) + movl $0, -36(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -32(%ebp) + mov 20(%ebp), %ecx + mov %ecx, -24(%ebp) + mov 24(%ebp), %ecx + mov %ecx, -16(%ebp) + mov 28(%ebp), %ecx + mov %ecx, -8(%ebp) + mov 32(%ebp), %ecx + mov %ecx, -4(%ebp) + mov $34, %eax + mov %ebp, %ecx + sub $48, %ecx + int $0x80 + test %eax, %eax + jnz 1f + mov 36(%ebp), %ecx + mov -48(%ebp), %edx + mov %edx, 0(%ecx) +1: + pop %ebp + ret +END(cloudabi_sys_mem_map) + +ENTRY(cloudabi_sys_mem_protect) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -24(%ebp) + movl $0, -20(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -8(%ebp) + mov $35, %eax + mov %ebp, %ecx + sub $24, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_mem_protect) + +ENTRY(cloudabi_sys_mem_sync) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -24(%ebp) + movl $0, -20(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -8(%ebp) + mov $36, %eax + mov %ebp, %ecx + sub $24, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_mem_sync) + +ENTRY(cloudabi_sys_mem_unlock) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -8(%ebp) + movl $0, -4(%ebp) + mov $37, %eax + mov %ebp, %ecx + sub $16, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_mem_unlock) + +ENTRY(cloudabi_sys_mem_unmap) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -8(%ebp) + movl $0, -4(%ebp) + mov $38, %eax + mov %ebp, %ecx + sub $16, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_mem_unmap) + +ENTRY(cloudabi_sys_poll) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -24(%ebp) + movl $0, -20(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -8(%ebp) + movl $0, -4(%ebp) + mov $39, %eax + mov %ebp, %ecx + sub $24, %ecx + int $0x80 + test %eax, %eax + jnz 1f + mov 20(%ebp), %ecx + mov -24(%ebp), %edx + mov %edx, 0(%ecx) +1: + pop %ebp + ret +END(cloudabi_sys_poll) + +ENTRY(cloudabi_sys_poll_fd) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -48(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -40(%ebp) + movl $0, -36(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -32(%ebp) + movl $0, -28(%ebp) + mov 20(%ebp), %ecx + mov %ecx, -24(%ebp) + movl $0, -20(%ebp) + mov 24(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov 28(%ebp), %ecx + mov %ecx, -8(%ebp) + movl $0, -4(%ebp) + mov $40, %eax + mov %ebp, %ecx + sub $48, %ecx + int $0x80 + test %eax, %eax + jnz 1f + mov 32(%ebp), %ecx + mov -48(%ebp), %edx + mov %edx, 0(%ecx) +1: + pop %ebp + ret +END(cloudabi_sys_poll_fd) + +ENTRY(cloudabi_sys_proc_exec) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -40(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -32(%ebp) + movl $0, -28(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -24(%ebp) + movl $0, -20(%ebp) + mov 20(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov 24(%ebp), %ecx + mov %ecx, -8(%ebp) + movl $0, -4(%ebp) + mov $41, %eax + mov %ebp, %ecx + sub $40, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_proc_exec) + +ENTRY(cloudabi_sys_proc_exit) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -16(%ebp) + mov $42, %eax + mov %ebp, %ecx + sub $16, %ecx + int $0x80 +END(cloudabi_sys_proc_exit) + +ENTRY(cloudabi_sys_proc_fork) + push %ebp + mov %esp, %ebp + mov $43, %eax + mov %ebp, %ecx + sub $16, %ecx + int $0x80 + test %eax, %eax + jnz 1f + mov 8(%ebp), %ecx + mov -16(%ebp), %edx + mov %edx, 0(%ecx) + mov 12(%ebp), %ecx + mov -8(%ebp), %edx + mov %edx, 0(%ecx) +1: + pop %ebp + ret +END(cloudabi_sys_proc_fork) + +ENTRY(cloudabi_sys_proc_raise) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -16(%ebp) + mov $44, %eax + mov %ebp, %ecx + sub $16, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_proc_raise) + +ENTRY(cloudabi_sys_random_get) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -8(%ebp) + movl $0, -4(%ebp) + mov $45, %eax + mov %ebp, %ecx + sub $16, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_random_get) + +ENTRY(cloudabi_sys_sock_accept) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -16(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -8(%ebp) + movl $0, -4(%ebp) + mov $46, %eax + mov %ebp, %ecx + sub $16, %ecx + int $0x80 + test %eax, %eax + jnz 1f + mov 16(%ebp), %ecx + mov -16(%ebp), %edx + mov %edx, 0(%ecx) +1: + pop %ebp + ret +END(cloudabi_sys_sock_accept) + +ENTRY(cloudabi_sys_sock_bind) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -32(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -24(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov 20(%ebp), %ecx + mov %ecx, -8(%ebp) + movl $0, -4(%ebp) + mov $47, %eax + mov %ebp, %ecx + sub $32, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_sock_bind) + +ENTRY(cloudabi_sys_sock_connect) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -32(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -24(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov 20(%ebp), %ecx + mov %ecx, -8(%ebp) + movl $0, -4(%ebp) + mov $48, %eax + mov %ebp, %ecx + sub $32, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_sock_connect) + +ENTRY(cloudabi_sys_sock_listen) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -16(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -8(%ebp) + mov $49, %eax + mov %ebp, %ecx + sub $16, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_sock_listen) + +ENTRY(cloudabi_sys_sock_recv) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -24(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -8(%ebp) + movl $0, -4(%ebp) + mov $50, %eax + mov %ebp, %ecx + sub $24, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_sock_recv) + +ENTRY(cloudabi_sys_sock_send) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -24(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -8(%ebp) + movl $0, -4(%ebp) + mov $51, %eax + mov %ebp, %ecx + sub $24, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_sock_send) + +ENTRY(cloudabi_sys_sock_shutdown) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -16(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -8(%ebp) + mov $52, %eax + mov %ebp, %ecx + sub $16, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_sock_shutdown) + +ENTRY(cloudabi_sys_sock_stat_get) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -24(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov 16(%ebp), %ecx + mov %ecx, -8(%ebp) + mov $53, %eax + mov %ebp, %ecx + sub $24, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_sock_stat_get) + +ENTRY(cloudabi_sys_thread_create) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov $54, %eax + mov %ebp, %ecx + sub $16, %ecx + int $0x80 + test %eax, %eax + jnz 1f + mov 12(%ebp), %ecx + mov -16(%ebp), %edx + mov %edx, 0(%ecx) +1: + pop %ebp + ret +END(cloudabi_sys_thread_create) + +ENTRY(cloudabi_sys_thread_exit) + push %ebp + mov %esp, %ebp + mov 8(%ebp), %ecx + mov %ecx, -16(%ebp) + movl $0, -12(%ebp) + mov 12(%ebp), %ecx + mov %ecx, -8(%ebp) + mov $55, %eax + mov %ebp, %ecx + sub $16, %ecx + int $0x80 +END(cloudabi_sys_thread_exit) + +ENTRY(cloudabi_sys_thread_yield) + push %ebp + mov %esp, %ebp + mov $56, %eax + mov %ebp, %ecx + sub $16, %ecx + int $0x80 + pop %ebp + ret +END(cloudabi_sys_thread_yield) diff --git a/sys/contrib/cloudabi/cloudabi_vdso_x86_64.S b/sys/contrib/cloudabi/cloudabi_vdso_x86_64.S new file mode 100644 index 0000000..049cb0d --- /dev/null +++ b/sys/contrib/cloudabi/cloudabi_vdso_x86_64.S @@ -0,0 +1,511 @@ +// Copyright (c) 2016 Nuxi (https://nuxi.nl/) and contributors. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +// SUCH DAMAGE. +// +// This file is automatically generated. Do not edit. +// +// Source: https://github.com/NuxiNL/cloudabi + +#define ENTRY(name) \ + .text; \ + .p2align 4, 0x90; \ + .global name; \ + .type name, @function; \ +name: + +#define END(name) .size name, . - name + +ENTRY(cloudabi_sys_clock_res_get) + push %rsi + mov $0, %eax + syscall + pop %rcx + jc 1f + mov %rax, (%rcx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_clock_res_get) + +ENTRY(cloudabi_sys_clock_time_get) + push %rdx + mov $1, %eax + syscall + pop %rcx + jc 1f + mov %rax, (%rcx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_clock_time_get) + +ENTRY(cloudabi_sys_condvar_signal) + mov $2, %eax + syscall + ret +END(cloudabi_sys_condvar_signal) + +ENTRY(cloudabi_sys_fd_close) + mov $3, %eax + syscall + ret +END(cloudabi_sys_fd_close) + +ENTRY(cloudabi_sys_fd_create1) + push %rsi + mov $4, %eax + syscall + pop %rcx + jc 1f + mov %eax, (%rcx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_fd_create1) + +ENTRY(cloudabi_sys_fd_create2) + push %rsi + push %rdx + mov $5, %eax + syscall + pop %rsi + pop %rcx + jc 1f + mov %eax, (%rcx) + mov %edx, (%rsi) + xor %eax, %eax +1: + ret +END(cloudabi_sys_fd_create2) + +ENTRY(cloudabi_sys_fd_datasync) + mov $6, %eax + syscall + ret +END(cloudabi_sys_fd_datasync) + +ENTRY(cloudabi_sys_fd_dup) + push %rsi + mov $7, %eax + syscall + pop %rcx + jc 1f + mov %eax, (%rcx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_fd_dup) + +ENTRY(cloudabi_sys_fd_pread) + mov %rcx, %r10 + push %r8 + mov $8, %eax + syscall + pop %rcx + jc 1f + mov %rax, (%rcx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_fd_pread) + +ENTRY(cloudabi_sys_fd_pwrite) + mov %rcx, %r10 + push %r8 + mov $9, %eax + syscall + pop %rcx + jc 1f + mov %rax, (%rcx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_fd_pwrite) + +ENTRY(cloudabi_sys_fd_read) + push %rcx + mov $10, %eax + syscall + pop %rcx + jc 1f + mov %rax, (%rcx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_fd_read) + +ENTRY(cloudabi_sys_fd_replace) + mov $11, %eax + syscall + ret +END(cloudabi_sys_fd_replace) + +ENTRY(cloudabi_sys_fd_seek) + push %rcx + mov $12, %eax + syscall + pop %rcx + jc 1f + mov %rax, (%rcx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_fd_seek) + +ENTRY(cloudabi_sys_fd_stat_get) + mov $13, %eax + syscall + ret +END(cloudabi_sys_fd_stat_get) + +ENTRY(cloudabi_sys_fd_stat_put) + mov $14, %eax + syscall + ret +END(cloudabi_sys_fd_stat_put) + +ENTRY(cloudabi_sys_fd_sync) + mov $15, %eax + syscall + ret +END(cloudabi_sys_fd_sync) + +ENTRY(cloudabi_sys_fd_write) + push %rcx + mov $16, %eax + syscall + pop %rcx + jc 1f + mov %rax, (%rcx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_fd_write) + +ENTRY(cloudabi_sys_file_advise) + mov %rcx, %r10 + mov $17, %eax + syscall + ret +END(cloudabi_sys_file_advise) + +ENTRY(cloudabi_sys_file_allocate) + mov $18, %eax + syscall + ret +END(cloudabi_sys_file_allocate) + +ENTRY(cloudabi_sys_file_create) + mov %rcx, %r10 + mov $19, %eax + syscall + ret +END(cloudabi_sys_file_create) + +ENTRY(cloudabi_sys_file_link) + mov %rcx, %r10 + mov $20, %eax + syscall + ret +END(cloudabi_sys_file_link) + +ENTRY(cloudabi_sys_file_open) + mov %rcx, %r10 + push %r9 + mov $21, %eax + syscall + pop %rcx + jc 1f + mov %eax, (%rcx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_file_open) + +ENTRY(cloudabi_sys_file_readdir) + mov %rcx, %r10 + push %r8 + mov $22, %eax + syscall + pop %rcx + jc 1f + mov %rax, (%rcx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_file_readdir) + +ENTRY(cloudabi_sys_file_readlink) + mov %rcx, %r10 + push %r9 + mov $23, %eax + syscall + pop %rcx + jc 1f + mov %rax, (%rcx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_file_readlink) + +ENTRY(cloudabi_sys_file_rename) + mov %rcx, %r10 + mov $24, %eax + syscall + ret +END(cloudabi_sys_file_rename) + +ENTRY(cloudabi_sys_file_stat_fget) + mov $25, %eax + syscall + ret +END(cloudabi_sys_file_stat_fget) + +ENTRY(cloudabi_sys_file_stat_fput) + mov $26, %eax + syscall + ret +END(cloudabi_sys_file_stat_fput) + +ENTRY(cloudabi_sys_file_stat_get) + mov %rcx, %r10 + mov $27, %eax + syscall + ret +END(cloudabi_sys_file_stat_get) + +ENTRY(cloudabi_sys_file_stat_put) + mov %rcx, %r10 + mov $28, %eax + syscall + ret +END(cloudabi_sys_file_stat_put) + +ENTRY(cloudabi_sys_file_symlink) + mov %rcx, %r10 + mov $29, %eax + syscall + ret +END(cloudabi_sys_file_symlink) + +ENTRY(cloudabi_sys_file_unlink) + mov %rcx, %r10 + mov $30, %eax + syscall + ret +END(cloudabi_sys_file_unlink) + +ENTRY(cloudabi_sys_lock_unlock) + mov $31, %eax + syscall + ret +END(cloudabi_sys_lock_unlock) + +ENTRY(cloudabi_sys_mem_advise) + mov $32, %eax + syscall + ret +END(cloudabi_sys_mem_advise) + +ENTRY(cloudabi_sys_mem_lock) + mov $33, %eax + syscall + ret +END(cloudabi_sys_mem_lock) + +ENTRY(cloudabi_sys_mem_map) + mov %rcx, %r10 + mov $34, %eax + syscall + jc 1f + mov 8(%rsp), %rcx + mov %rax, (%rcx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_mem_map) + +ENTRY(cloudabi_sys_mem_protect) + mov $35, %eax + syscall + ret +END(cloudabi_sys_mem_protect) + +ENTRY(cloudabi_sys_mem_sync) + mov $36, %eax + syscall + ret +END(cloudabi_sys_mem_sync) + +ENTRY(cloudabi_sys_mem_unlock) + mov $37, %eax + syscall + ret +END(cloudabi_sys_mem_unlock) + +ENTRY(cloudabi_sys_mem_unmap) + mov $38, %eax + syscall + ret +END(cloudabi_sys_mem_unmap) + +ENTRY(cloudabi_sys_poll) + push %rcx + mov $39, %eax + syscall + pop %rcx + jc 1f + mov %rax, (%rcx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_poll) + +ENTRY(cloudabi_sys_poll_fd) + mov %rcx, %r10 + mov $40, %eax + syscall + jc 1f + mov 8(%rsp), %rcx + mov %rax, (%rcx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_poll_fd) + +ENTRY(cloudabi_sys_proc_exec) + mov %rcx, %r10 + mov $41, %eax + syscall + ret +END(cloudabi_sys_proc_exec) + +ENTRY(cloudabi_sys_proc_exit) + mov $42, %eax + syscall +END(cloudabi_sys_proc_exit) + +ENTRY(cloudabi_sys_proc_fork) + push %rdi + push %rsi + mov $43, %eax + syscall + pop %rsi + pop %rcx + jc 1f + mov %eax, (%rcx) + mov %edx, (%rsi) + xor %eax, %eax +1: + ret +END(cloudabi_sys_proc_fork) + +ENTRY(cloudabi_sys_proc_raise) + mov $44, %eax + syscall + ret +END(cloudabi_sys_proc_raise) + +ENTRY(cloudabi_sys_random_get) + mov $45, %eax + syscall + ret +END(cloudabi_sys_random_get) + +ENTRY(cloudabi_sys_sock_accept) + push %rdx + mov $46, %eax + syscall + pop %rcx + jc 1f + mov %eax, (%rcx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_sock_accept) + +ENTRY(cloudabi_sys_sock_bind) + mov %rcx, %r10 + mov $47, %eax + syscall + ret +END(cloudabi_sys_sock_bind) + +ENTRY(cloudabi_sys_sock_connect) + mov %rcx, %r10 + mov $48, %eax + syscall + ret +END(cloudabi_sys_sock_connect) + +ENTRY(cloudabi_sys_sock_listen) + mov $49, %eax + syscall + ret +END(cloudabi_sys_sock_listen) + +ENTRY(cloudabi_sys_sock_recv) + mov $50, %eax + syscall + ret +END(cloudabi_sys_sock_recv) + +ENTRY(cloudabi_sys_sock_send) + mov $51, %eax + syscall + ret +END(cloudabi_sys_sock_send) + +ENTRY(cloudabi_sys_sock_shutdown) + mov $52, %eax + syscall + ret +END(cloudabi_sys_sock_shutdown) + +ENTRY(cloudabi_sys_sock_stat_get) + mov $53, %eax + syscall + ret +END(cloudabi_sys_sock_stat_get) + +ENTRY(cloudabi_sys_thread_create) + push %rsi + mov $54, %eax + syscall + pop %rcx + jc 1f + mov %eax, (%rcx) + xor %eax, %eax +1: + ret +END(cloudabi_sys_thread_create) + +ENTRY(cloudabi_sys_thread_exit) + mov $55, %eax + syscall +END(cloudabi_sys_thread_exit) + +ENTRY(cloudabi_sys_thread_yield) + mov $56, %eax + syscall + ret +END(cloudabi_sys_thread_yield) diff --git a/sys/contrib/cloudabi/syscalls32.master b/sys/contrib/cloudabi/syscalls32.master new file mode 100644 index 0000000..aa3314b --- /dev/null +++ b/sys/contrib/cloudabi/syscalls32.master @@ -0,0 +1,315 @@ + $FreeBSD$ + +; Copyright (c) 2016 Nuxi (https://nuxi.nl/) and contributors. +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions +; are met: +; 1. Redistributions of source code must retain the above copyright +; notice, this list of conditions and the following disclaimer. +; 2. Redistributions in binary form must reproduce the above copyright +; notice, this list of conditions and the following disclaimer in the +; documentation and/or other materials provided with the distribution. +; +; THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +; LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +; SUCH DAMAGE. +; +; This file is automatically generated. Do not edit. +; +; Source: https://github.com/NuxiNL/cloudabi + +#include <sys/sysent.h> +#include <sys/sysproto.h> + +#include <contrib/cloudabi/cloudabi32_types.h> + +#include <compat/cloudabi32/cloudabi32_proto.h> + +0 AUE_NULL STD { cloudabi_timestamp_t \ + cloudabi_sys_clock_res_get( \ + cloudabi_clockid_t clock_id); } + +1 AUE_NULL STD { cloudabi_timestamp_t \ + cloudabi_sys_clock_time_get( \ + cloudabi_clockid_t clock_id, \ + cloudabi_timestamp_t precision); } + +2 AUE_NULL STD { void cloudabi_sys_condvar_signal( \ + cloudabi_condvar_t *condvar, \ + cloudabi_scope_t scope, \ + cloudabi_nthreads_t nwaiters); } + +3 AUE_NULL STD { void cloudabi_sys_fd_close( \ + cloudabi_fd_t fd); } + +4 AUE_NULL STD { cloudabi_fd_t cloudabi_sys_fd_create1( \ + cloudabi_filetype_t type); } + +5 AUE_NULL STD { void cloudabi_sys_fd_create2( \ + cloudabi_filetype_t type); } + +6 AUE_NULL STD { void cloudabi_sys_fd_datasync( \ + cloudabi_fd_t fd); } + +7 AUE_NULL STD { cloudabi_fd_t cloudabi_sys_fd_dup( \ + cloudabi_fd_t from); } + +8 AUE_NULL STD { size_t cloudabi32_sys_fd_pread( \ + cloudabi_fd_t fd, \ + const cloudabi32_iovec_t *iov, \ + size_t iovcnt, \ + cloudabi_filesize_t offset); } + +9 AUE_NULL STD { size_t cloudabi32_sys_fd_pwrite( \ + cloudabi_fd_t fd, \ + const cloudabi32_ciovec_t *iov, \ + size_t iovcnt, \ + cloudabi_filesize_t offset); } + +10 AUE_NULL STD { size_t cloudabi32_sys_fd_read( \ + cloudabi_fd_t fd, \ + const cloudabi32_iovec_t *iov, \ + size_t iovcnt); } + +11 AUE_NULL STD { void cloudabi_sys_fd_replace( \ + cloudabi_fd_t from, \ + cloudabi_fd_t to); } + +12 AUE_NULL STD { cloudabi_filesize_t \ + cloudabi_sys_fd_seek( \ + cloudabi_fd_t fd, \ + cloudabi_filedelta_t offset, \ + cloudabi_whence_t whence); } + +13 AUE_NULL STD { void cloudabi_sys_fd_stat_get( \ + cloudabi_fd_t fd, \ + cloudabi_fdstat_t *buf); } + +14 AUE_NULL STD { void cloudabi_sys_fd_stat_put( \ + cloudabi_fd_t fd, \ + const cloudabi_fdstat_t *buf, \ + cloudabi_fdsflags_t flags); } + +15 AUE_NULL STD { void cloudabi_sys_fd_sync( \ + cloudabi_fd_t fd); } + +16 AUE_NULL STD { size_t cloudabi32_sys_fd_write( \ + cloudabi_fd_t fd, \ + const cloudabi32_ciovec_t *iov, \ + size_t iovcnt); } + +17 AUE_NULL STD { void cloudabi_sys_file_advise( \ + cloudabi_fd_t fd, \ + cloudabi_filesize_t offset, \ + cloudabi_filesize_t len, \ + cloudabi_advice_t advice); } + +18 AUE_NULL STD { void cloudabi_sys_file_allocate( \ + cloudabi_fd_t fd, \ + cloudabi_filesize_t offset, \ + cloudabi_filesize_t len); } + +19 AUE_NULL STD { void cloudabi_sys_file_create( \ + cloudabi_fd_t fd, \ + const char *path, \ + size_t pathlen, \ + cloudabi_filetype_t type); } + +20 AUE_NULL STD { void cloudabi_sys_file_link( \ + cloudabi_lookup_t fd1, \ + const char *path1, \ + size_t path1len, \ + cloudabi_fd_t fd2, \ + const char *path2, \ + size_t path2len); } + +21 AUE_NULL STD { cloudabi_fd_t cloudabi_sys_file_open( \ + cloudabi_lookup_t dirfd, \ + const char *path, \ + size_t pathlen, \ + cloudabi_oflags_t oflags, \ + const cloudabi_fdstat_t *fds); } + +22 AUE_NULL STD { size_t cloudabi_sys_file_readdir( \ + cloudabi_fd_t fd, \ + void *buf, \ + size_t nbyte, \ + cloudabi_dircookie_t cookie); } + +23 AUE_NULL STD { size_t cloudabi_sys_file_readlink( \ + cloudabi_fd_t fd, \ + const char *path, \ + size_t pathlen, \ + char *buf, \ + size_t bufsize); } + +24 AUE_NULL STD { void cloudabi_sys_file_rename( \ + cloudabi_fd_t oldfd, \ + const char *old, \ + size_t oldlen, \ + cloudabi_fd_t newfd, \ + const char *new, \ + size_t newlen); } + +25 AUE_NULL STD { void cloudabi_sys_file_stat_fget( \ + cloudabi_fd_t fd, \ + cloudabi_filestat_t *buf); } + +26 AUE_NULL STD { void cloudabi_sys_file_stat_fput( \ + cloudabi_fd_t fd, \ + const cloudabi_filestat_t *buf, \ + cloudabi_fsflags_t flags); } + +27 AUE_NULL STD { void cloudabi_sys_file_stat_get( \ + cloudabi_lookup_t fd, \ + const char *path, \ + size_t pathlen, \ + cloudabi_filestat_t *buf); } + +28 AUE_NULL STD { void cloudabi_sys_file_stat_put( \ + cloudabi_lookup_t fd, \ + const char *path, \ + size_t pathlen, \ + const cloudabi_filestat_t *buf, \ + cloudabi_fsflags_t flags); } + +29 AUE_NULL STD { void cloudabi_sys_file_symlink( \ + const char *path1, \ + size_t path1len, \ + cloudabi_fd_t fd, \ + const char *path2, \ + size_t path2len); } + +30 AUE_NULL STD { void cloudabi_sys_file_unlink( \ + cloudabi_fd_t fd, \ + const char *path, \ + size_t pathlen, \ + cloudabi_ulflags_t flags); } + +31 AUE_NULL STD { void cloudabi_sys_lock_unlock( \ + cloudabi_lock_t *lock, \ + cloudabi_scope_t scope); } + +32 AUE_NULL STD { void cloudabi_sys_mem_advise( \ + void *addr, \ + size_t len, \ + cloudabi_advice_t advice); } + +33 AUE_NULL STD { void cloudabi_sys_mem_lock( \ + const void *addr, \ + size_t len); } + +34 AUE_NULL STD { void cloudabi_sys_mem_map( \ + void *addr, \ + size_t len, \ + cloudabi_mprot_t prot, \ + cloudabi_mflags_t flags, \ + cloudabi_fd_t fd, \ + cloudabi_filesize_t off); } + +35 AUE_NULL STD { void cloudabi_sys_mem_protect( \ + void *addr, \ + size_t len, \ + cloudabi_mprot_t prot); } + +36 AUE_NULL STD { void cloudabi_sys_mem_sync( \ + void *addr, \ + size_t len, \ + cloudabi_msflags_t flags); } + +37 AUE_NULL STD { void cloudabi_sys_mem_unlock( \ + const void *addr, \ + size_t len); } + +38 AUE_NULL STD { void cloudabi_sys_mem_unmap( \ + void *addr, \ + size_t len); } + +39 AUE_NULL STD { size_t cloudabi32_sys_poll( \ + const cloudabi32_subscription_t *in, \ + cloudabi32_event_t *out, \ + size_t nsubscriptions); } + +40 AUE_NULL STD { size_t cloudabi32_sys_poll_fd( \ + cloudabi_fd_t fd, \ + const cloudabi32_subscription_t *in, \ + size_t nin, \ + cloudabi32_event_t *out, \ + size_t nout, \ + const cloudabi32_subscription_t *timeout); } + +41 AUE_NULL STD { void cloudabi_sys_proc_exec( \ + cloudabi_fd_t fd, \ + const void *data, \ + size_t datalen, \ + const cloudabi_fd_t *fds, \ + size_t fdslen); } + +42 AUE_NULL STD { void cloudabi_sys_proc_exit( \ + cloudabi_exitcode_t rval); } + +43 AUE_NULL STD { void cloudabi_sys_proc_fork(); } + +44 AUE_NULL STD { void cloudabi_sys_proc_raise( \ + cloudabi_signal_t sig); } + +45 AUE_NULL STD { void cloudabi_sys_random_get( \ + void *buf, \ + size_t nbyte); } + +46 AUE_NULL STD { cloudabi_fd_t cloudabi_sys_sock_accept( \ + cloudabi_fd_t sock, \ + cloudabi_sockstat_t *buf); } + +47 AUE_NULL STD { void cloudabi_sys_sock_bind( \ + cloudabi_fd_t sock, \ + cloudabi_fd_t fd, \ + const char *path, \ + size_t pathlen); } + +48 AUE_NULL STD { void cloudabi_sys_sock_connect( \ + cloudabi_fd_t sock, \ + cloudabi_fd_t fd, \ + const char *path, \ + size_t pathlen); } + +49 AUE_NULL STD { void cloudabi_sys_sock_listen( \ + cloudabi_fd_t sock, \ + cloudabi_backlog_t backlog); } + +50 AUE_NULL STD { void cloudabi32_sys_sock_recv( \ + cloudabi_fd_t sock, \ + const cloudabi32_recv_in_t *in, \ + cloudabi32_recv_out_t *out); } + +51 AUE_NULL STD { void cloudabi32_sys_sock_send( \ + cloudabi_fd_t sock, \ + const cloudabi32_send_in_t *in, \ + cloudabi32_send_out_t *out); } + +52 AUE_NULL STD { void cloudabi_sys_sock_shutdown( \ + cloudabi_fd_t sock, \ + cloudabi_sdflags_t how); } + +53 AUE_NULL STD { void cloudabi_sys_sock_stat_get( \ + cloudabi_fd_t sock, \ + cloudabi_sockstat_t *buf, \ + cloudabi_ssflags_t flags); } + +54 AUE_NULL STD { cloudabi_tid_t cloudabi32_sys_thread_create( \ + cloudabi32_threadattr_t *attr); } + +55 AUE_NULL STD { void cloudabi_sys_thread_exit( \ + cloudabi_lock_t *lock, \ + cloudabi_scope_t scope); } + +56 AUE_NULL STD { void cloudabi_sys_thread_yield(); } diff --git a/sys/contrib/cloudabi/syscalls.master b/sys/contrib/cloudabi/syscalls64.master index 7da55c5..b2378bd 100644 --- a/sys/contrib/cloudabi/syscalls.master +++ b/sys/contrib/cloudabi/syscalls64.master @@ -239,80 +239,77 @@ cloudabi64_event_t *out, \ size_t nsubscriptions); } -40 AUE_NULL STD { void cloudabi_sys_proc_exec( \ +40 AUE_NULL STD { size_t cloudabi64_sys_poll_fd( \ + cloudabi_fd_t fd, \ + const cloudabi64_subscription_t *in, \ + size_t nin, \ + cloudabi64_event_t *out, \ + size_t nout, \ + const cloudabi64_subscription_t *timeout); } + +41 AUE_NULL STD { void cloudabi_sys_proc_exec( \ cloudabi_fd_t fd, \ const void *data, \ size_t datalen, \ const cloudabi_fd_t *fds, \ size_t fdslen); } -41 AUE_NULL STD { void cloudabi_sys_proc_exit( \ +42 AUE_NULL STD { void cloudabi_sys_proc_exit( \ cloudabi_exitcode_t rval); } -42 AUE_NULL STD { void cloudabi_sys_proc_fork(); } +43 AUE_NULL STD { void cloudabi_sys_proc_fork(); } -43 AUE_NULL STD { void cloudabi_sys_proc_raise( \ +44 AUE_NULL STD { void cloudabi_sys_proc_raise( \ cloudabi_signal_t sig); } -44 AUE_NULL STD { void cloudabi_sys_random_get( \ +45 AUE_NULL STD { void cloudabi_sys_random_get( \ void *buf, \ size_t nbyte); } -45 AUE_NULL STD { cloudabi_fd_t cloudabi_sys_sock_accept( \ +46 AUE_NULL STD { cloudabi_fd_t cloudabi_sys_sock_accept( \ cloudabi_fd_t sock, \ cloudabi_sockstat_t *buf); } -46 AUE_NULL STD { void cloudabi_sys_sock_bind( \ +47 AUE_NULL STD { void cloudabi_sys_sock_bind( \ cloudabi_fd_t sock, \ cloudabi_fd_t fd, \ const char *path, \ size_t pathlen); } -47 AUE_NULL STD { void cloudabi_sys_sock_connect( \ +48 AUE_NULL STD { void cloudabi_sys_sock_connect( \ cloudabi_fd_t sock, \ cloudabi_fd_t fd, \ const char *path, \ size_t pathlen); } -48 AUE_NULL STD { void cloudabi_sys_sock_listen( \ +49 AUE_NULL STD { void cloudabi_sys_sock_listen( \ cloudabi_fd_t sock, \ cloudabi_backlog_t backlog); } -49 AUE_NULL STD { void cloudabi64_sys_sock_recv( \ +50 AUE_NULL STD { void cloudabi64_sys_sock_recv( \ cloudabi_fd_t sock, \ const cloudabi64_recv_in_t *in, \ cloudabi64_recv_out_t *out); } -50 AUE_NULL STD { void cloudabi64_sys_sock_send( \ +51 AUE_NULL STD { void cloudabi64_sys_sock_send( \ cloudabi_fd_t sock, \ const cloudabi64_send_in_t *in, \ cloudabi64_send_out_t *out); } -51 AUE_NULL STD { void cloudabi_sys_sock_shutdown( \ +52 AUE_NULL STD { void cloudabi_sys_sock_shutdown( \ cloudabi_fd_t sock, \ cloudabi_sdflags_t how); } -52 AUE_NULL STD { void cloudabi_sys_sock_stat_get( \ +53 AUE_NULL STD { void cloudabi_sys_sock_stat_get( \ cloudabi_fd_t sock, \ cloudabi_sockstat_t *buf, \ cloudabi_ssflags_t flags); } -53 AUE_NULL STD { cloudabi_tid_t cloudabi64_sys_thread_create( \ +54 AUE_NULL STD { cloudabi_tid_t cloudabi64_sys_thread_create( \ cloudabi64_threadattr_t *attr); } -54 AUE_NULL STD { void cloudabi_sys_thread_exit( \ +55 AUE_NULL STD { void cloudabi_sys_thread_exit( \ cloudabi_lock_t *lock, \ cloudabi_scope_t scope); } -55 AUE_NULL STD { void cloudabi_sys_thread_tcb_set( \ - void *tcb); } - 56 AUE_NULL STD { void cloudabi_sys_thread_yield(); } - -57 AUE_NULL STD { size_t cloudabi64_sys_poll_fd( \ - cloudabi_fd_t fd, \ - const cloudabi64_subscription_t *in, \ - size_t nin, \ - cloudabi64_event_t *out, \ - size_t nout, \ - const cloudabi64_subscription_t *timeout); } diff --git a/sys/i386/cloudabi32/cloudabi32_sysvec.c b/sys/i386/cloudabi32/cloudabi32_sysvec.c new file mode 100644 index 0000000..1ecd8d5 --- /dev/null +++ b/sys/i386/cloudabi32/cloudabi32_sysvec.c @@ -0,0 +1,204 @@ +/*- + * Copyright (c) 2015-2016 Nuxi, https://nuxi.nl/ + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/param.h> +#include <sys/imgact.h> +#include <sys/kernel.h> +#include <sys/proc.h> +#include <sys/sysent.h> + +#include <vm/vm.h> +#include <vm/pmap.h> + +#include <machine/frame.h> +#include <machine/pcb.h> +#include <machine/vmparam.h> + +#include <compat/cloudabi/cloudabi_util.h> + +#include <compat/cloudabi32/cloudabi32_syscall.h> +#include <compat/cloudabi32/cloudabi32_util.h> + +extern const char *cloudabi32_syscallnames[]; +extern struct sysent cloudabi32_sysent[]; + +static int +cloudabi32_fixup_tcb(register_t **stack_base, struct image_params *imgp) +{ + int error; + uint32_t args[2]; + + /* Place auxiliary vector and TCB on the stack. */ + error = cloudabi32_fixup(stack_base, imgp); + if (error != 0) + return (error); + + /* + * On i386, the TCB is referred to by %gs:0. Reuse the empty + * space normally used by the return address (args[0]) to store + * a single element array, containing a pointer to the TCB. %gs + * base will point to this. + * + * Also let the first argument of the entry point (args[1]) + * refer to the auxiliary vector, which is stored right after + * the TCB. + */ + args[0] = (uintptr_t)*stack_base; + args[1] = (uintptr_t)*stack_base + + roundup(sizeof(cloudabi32_tcb_t), sizeof(register_t)); + *stack_base -= howmany(sizeof(args), sizeof(register_t)); + return (copyout(args, *stack_base, sizeof(args))); +} + +static void +cloudabi32_proc_setregs(struct thread *td, struct image_params *imgp, + unsigned long stack) +{ + + exec_setregs(td, imgp, stack); + (void)cpu_set_user_tls(td, (void *)stack); +} + +static int +cloudabi32_fetch_syscall_args(struct thread *td, struct syscall_args *sa) +{ + struct trapframe *frame = td->td_frame; + int error; + + /* Obtain system call number. */ + sa->code = frame->tf_eax; + if (sa->code >= CLOUDABI32_SYS_MAXSYSCALL) + return (ENOSYS); + sa->callp = &cloudabi32_sysent[sa->code]; + sa->narg = sa->callp->sy_narg; + + /* Fetch system call arguments from the stack. */ + error = copyin((void *)(frame->tf_esp + 4), sa->args, + sa->narg * sizeof(sa->args[0])); + if (error != 0) + return (error); + + /* Default system call return values. */ + td->td_retval[0] = 0; + td->td_retval[1] = frame->tf_edx; + return (0); +} + +static void +cloudabi32_set_syscall_retval(struct thread *td, int error) +{ + struct trapframe *frame = td->td_frame; + + switch (error) { + case 0: + /* System call succeeded. */ + frame->tf_eax = td->td_retval[0]; + frame->tf_edx = td->td_retval[1]; + frame->tf_eflags &= ~PSL_C; + break; + case ERESTART: + /* Restart system call. */ + frame->tf_eip -= frame->tf_err; + break; + case EJUSTRETURN: + break; + default: + /* System call returned an error. */ + frame->tf_eax = cloudabi_convert_errno(error); + frame->tf_eflags |= PSL_C; + break; + } +} + +static void +cloudabi32_schedtail(struct thread *td) +{ + struct trapframe *frame = td->td_frame; + + /* Initial register values for processes returning from fork. */ + frame->tf_eax = CLOUDABI_PROCESS_CHILD; + frame->tf_edx = td->td_tid; +} + +int +cloudabi32_thread_setregs(struct thread *td, + const cloudabi32_threadattr_t *attr, uint32_t tcb) +{ + stack_t stack; + uint32_t args[3]; + void *frameptr; + int error; + + /* Perform standard register initialization. */ + stack.ss_sp = TO_PTR(attr->stack); + stack.ss_size = attr->stack_size - sizeof(args); + cpu_set_upcall(td, TO_PTR(attr->entry_point), NULL, &stack); + + /* + * Copy the arguments for the thread entry point onto the stack + * (args[1] and args[2]). Similar to process startup, use the + * otherwise unused return address (args[0]) for TLS. + */ + args[0] = tcb; + args[1] = td->td_tid; + args[2] = attr->argument; + frameptr = (void *)td->td_frame->tf_esp; + error = copyout(args, frameptr, sizeof(args)); + if (error != 0) + return (error); + + return (cpu_set_user_tls(td, frameptr)); +} + +static struct sysentvec cloudabi32_elf_sysvec = { + .sv_size = CLOUDABI32_SYS_MAXSYSCALL, + .sv_table = cloudabi32_sysent, + .sv_fixup = cloudabi32_fixup_tcb, + .sv_name = "CloudABI ELF32", + .sv_coredump = elf32_coredump, + .sv_pagesize = PAGE_SIZE, + .sv_minuser = VM_MIN_ADDRESS, + .sv_maxuser = VM_MAXUSER_ADDRESS, + .sv_stackprot = VM_PROT_READ | VM_PROT_WRITE, + .sv_copyout_strings = cloudabi32_copyout_strings, + .sv_setregs = cloudabi32_proc_setregs, + .sv_flags = SV_ABI_CLOUDABI | SV_CAPSICUM | SV_IA32 | SV_ILP32, + .sv_set_syscall_retval = cloudabi32_set_syscall_retval, + .sv_fetch_syscall_args = cloudabi32_fetch_syscall_args, + .sv_syscallnames = cloudabi32_syscallnames, + .sv_schedtail = cloudabi32_schedtail, +}; + +INIT_SYSENTVEC(elf_sysvec, &cloudabi32_elf_sysvec); + +Elf32_Brandinfo cloudabi32_brand = { + .brand = ELFOSABI_CLOUDABI, + .machine = EM_386, + .sysvec = &cloudabi32_elf_sysvec, + .compat_3_brand = "CloudABI", +}; diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES index 52bd6bf..e0065f8 100644 --- a/sys/i386/conf/NOTES +++ b/sys/i386/conf/NOTES @@ -989,6 +989,9 @@ options NKPT=31 # Emulate spx device for client side of SVR3 local X interface options SPX_HACK +# Enable 32-bit runtime support for CloudABI binaries. +options COMPAT_CLOUDABI32 + # Enable Linux ABI emulation options COMPAT_LINUX diff --git a/sys/modules/Makefile b/sys/modules/Makefile index f3d2435..18af4ba 100644 --- a/sys/modules/Makefile +++ b/sys/modules/Makefile @@ -75,6 +75,7 @@ SUBDIR= \ ${_cfi} \ ${_ciss} \ cloudabi \ + ${_cloudabi32} \ ${_cloudabi64} \ ${_cm} \ ${_cmx} \ @@ -768,6 +769,10 @@ _epic= epic _igb= igb .endif +.if (${MACHINE_CPUARCH} == "amd64" || ${MACHINE_ARCH} == "armv6" || \ + ${MACHINE_CPUARCH} == "i386") +_cloudabi32= cloudabi32 +.endif .if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" _cloudabi64= cloudabi64 .endif diff --git a/sys/modules/cloudabi/Makefile b/sys/modules/cloudabi/Makefile index bba5036..c608580 100644 --- a/sys/modules/cloudabi/Makefile +++ b/sys/modules/cloudabi/Makefile @@ -5,6 +5,6 @@ KMOD= cloudabi SRCS= cloudabi_clock.c cloudabi_errno.c cloudabi_fd.c cloudabi_file.c \ cloudabi_futex.c cloudabi_mem.c cloudabi_proc.c cloudabi_random.c \ - cloudabi_sock.c cloudabi_thread.c vnode_if.h + cloudabi_sock.c cloudabi_thread.c cloudabi_vdso.c vnode_if.h .include <bsd.kmod.mk> diff --git a/sys/modules/cloudabi32/Makefile b/sys/modules/cloudabi32/Makefile new file mode 100644 index 0000000..61e5142 --- /dev/null +++ b/sys/modules/cloudabi32/Makefile @@ -0,0 +1,42 @@ +# $FreeBSD$ + +SYSDIR?=${.CURDIR}/../.. + +.PATH: ${SYSDIR}/compat/cloudabi32 +.PATH: ${SYSDIR}/${MACHINE_CPUARCH}/cloudabi32 +.PATH: ${SYSDIR}/${MACHINE}/cloudabi32 + +KMOD= cloudabi32 +SRCS= cloudabi32_fd.c cloudabi32_module.c cloudabi32_poll.c \ + cloudabi32_sock.c cloudabi32_syscalls.c cloudabi32_sysent.c \ + cloudabi32_sysvec.c cloudabi32_thread.c + +OBJS= cloudabi32_vdso_blob.o +CLEANFILES=cloudabi32_vdso.o + +.if ${MACHINE_CPUARCH} == "amd64" +VDSO_SRCS=${SYSDIR}/contrib/cloudabi/cloudabi_vdso_i686_on_64bit.S +OUTPUT_TARGET=elf64-x86-64-freebsd +BINARY_ARCHITECTURE=i386 +.elif ${MACHINE_ARCH} == "armv6" +VDSO_SRCS=${SYSDIR}/contrib/cloudabi/cloudabi_vdso_armv6.S +OUTPUT_TARGET=elf32-littlearm +BINARY_ARCHITECTURE=arm +.elif ${MACHINE_CPUARCH} == "i386" +VDSO_SRCS=${SYSDIR}/contrib/cloudabi/cloudabi_vdso_i686.S +OUTPUT_TARGET=elf32-i386-freebsd +BINARY_ARCHITECTURE=i386 +.endif + +cloudabi32_vdso.o: ${VDSO_SRCS} + ${CC} -x assembler-with-cpp -m32 -shared -nostdinc -nostdlib \ + -Wl,-T${SYSDIR}/compat/cloudabi/cloudabi_vdso.lds \ + ${VDSO_SRCS} -o ${.TARGET} + +cloudabi32_vdso_blob.o: cloudabi32_vdso.o + ${OBJCOPY} --input-target binary \ + --output-target ${OUTPUT_TARGET} \ + --binary-architecture ${BINARY_ARCHITECTURE} \ + cloudabi32_vdso.o ${.TARGET} + +.include <bsd.kmod.mk> diff --git a/sys/modules/cloudabi64/Makefile b/sys/modules/cloudabi64/Makefile index 3aee96d..1769854 100644 --- a/sys/modules/cloudabi64/Makefile +++ b/sys/modules/cloudabi64/Makefile @@ -1,11 +1,38 @@ # $FreeBSD$ -.PATH: ${.CURDIR}/../../compat/cloudabi64 -.PATH: ${.CURDIR}/../../${MACHINE}/cloudabi64 +SYSDIR?=${.CURDIR}/../.. + +.PATH: ${SYSDIR}/compat/cloudabi64 +.PATH: ${SYSDIR}/${MACHINE_CPUARCH}/cloudabi64 +.PATH: ${SYSDIR}/${MACHINE}/cloudabi64 KMOD= cloudabi64 SRCS= cloudabi64_fd.c cloudabi64_module.c cloudabi64_poll.c \ cloudabi64_sock.c cloudabi64_syscalls.c cloudabi64_sysent.c \ cloudabi64_sysvec.c cloudabi64_thread.c +OBJS= cloudabi64_vdso_blob.o +CLEANFILES=cloudabi64_vdso.o + +.if ${MACHINE_CPUARCH} == "aarch64" +VDSO_SRCS=${SYSDIR}/contrib/cloudabi/cloudabi_vdso_aarch64.S +OUTPUT_TARGET=elf64-littleaarch64 +BINARY_ARCHITECTURE=aarch64 +.elif ${MACHINE_CPUARCH} == "amd64" +VDSO_SRCS=${SYSDIR}/contrib/cloudabi/cloudabi_vdso_x86_64.S +OUTPUT_TARGET=elf64-x86-64-freebsd +BINARY_ARCHITECTURE=i386 +.endif + +cloudabi64_vdso.o: ${VDSO_SRCS} + ${CC} -x assembler-with-cpp -shared -nostdinc -nostdlib \ + -Wl,-T${SYSDIR}/compat/cloudabi/cloudabi_vdso.lds \ + ${VDSO_SRCS} -o ${.TARGET} + +cloudabi64_vdso_blob.o: cloudabi64_vdso.o + ${OBJCOPY} --input-target binary \ + --output-target ${OUTPUT_TARGET} \ + --binary-architecture ${BINARY_ARCHITECTURE} \ + cloudabi64_vdso.o ${.TARGET} + .include <bsd.kmod.mk> |