示例#1
0
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));
}
示例#2
0
void *
ts_lua_atomiclist_popall(ts_lua_atomiclist * l)
{
    int64_t     item, next;
    void        *ret;
    int         result = 0;

    do {
        INK_QUEUE_LD64(item, l->head);
        if (TO_PTR(FREELIST_POINTER(item)) == NULL)
            return NULL;

        SET_FREELIST_POINTER_VERSION(next, FROM_PTR(NULL), FREELIST_VERSION(item) + 1);
        result = ts_lua_atomic_cas64((int64_t *) & l->head, item, next);
    } while (result == 0);

    ret = TO_PTR(FREELIST_POINTER(item)); 

    return ret;
}
示例#3
0
int
cloudabi64_thread_setregs(struct thread *td,
                          const cloudabi64_threadattr_t *attr, uint64_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_x[0] = td->td_tid;
    frame->tf_x[1] = attr->argument;

    /* Set up TLS. */
    return (cpu_set_user_tls(td, (void *)tcb));
}
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 =
	    stack + roundup(sizeof(cloudabi32_tcb_t), sizeof(register_t));
	(void)cpu_set_user_tls(td, TO_PTR(stack));
}
示例#5
0
void print_form(uptr_t form) {

  if (IS_NIL(form)) {
    printf_P(PSTR("()"));
  } else if (IS_REG(form)) {
    printf_P(PSTR("R:%p"), TO_PTR(form));
  } else if (IS_INT(form)) {
    printf_P(PSTR("%d"), TO_INT(form));
  } else if (IS_SYM(form)) {
    char buf[7];
    memset(buf, 0, 7);
    unhash_sym(buf, form);
    printf_P(PSTR("%s"), buf);
  } else {
    printf_P(PSTR("("));
    print_list(form);
    printf_P(PSTR(")"));
  }

}
示例#6
0
void *
ts_lua_atomiclist_push(ts_lua_atomiclist * l, void *item)
{
    int64_t         head;
    int64_t         item_pair;
    int             result = 0;
    volatile void   *h = NULL;

    volatile void **adr_of_next = (volatile void **) ADDRESS_OF_NEXT(item, l->offset);

    do {
        INK_QUEUE_LD64(head, l->head);
        h = FREELIST_POINTER(head);
        *adr_of_next = h;
        SET_FREELIST_POINTER_VERSION(item_pair, FROM_PTR(item), FREELIST_VERSION(head));
        INK_MEMORY_BARRIER;

        result = ts_lua_atomic_cas64((int64_t *) & l->head, head, item_pair);
    } while (result == 0);

    return TO_PTR(h);
}