1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015 Intel Corporation.
3 * Copyright(c) Cavium, Inc. 2017.
5 * Copyright (C) 2012, Hasan Alayli <halayli@gmail.com>
6 * Portions derived from: https://github.com/halayli/lthread
7 * With permissions from Hasan Alayli to use them as BSD-3-Clause
17 #include "lthread_int.h"
20 * Sets up the initial stack for the lthread.
23 arch_set_stack(struct lthread *lt, void *func)
25 char *stack_top = (char *)(lt->stack) + lt->stack_size;
26 void **s = (void **)stack_top;
28 /* set initial context */
31 lt->ctx.rsp = (void *)(stack_top - (4 * sizeof(void *)));
32 lt->ctx.rbp = (void *)(stack_top - (3 * sizeof(void *)));