1/*
2 * Copyright 2017, Data61
3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO)
4 * ABN 41 687 119 230.
5 *
6 * This software may be distributed and modified according to the terms of
7 * the BSD 2-Clause license. Note that NO WARRANTY is provided.
8 * See "LICENSE_BSD2.txt" for details.
9 *
10 * @TAG(DATA61_BSD)
11 */
12
13#pragma once
14
15#include <utils/arch/stack.h>
16#include <utils/arith.h>
17
18#define STACK_CALL_ALIGNMENT_BITS LOG_BASE_2(STACK_CALL_ALIGNMENT)
19
20/**
21 * Switch to a new stack and start running func on it.
22 * If func returns, you will be back on the old stack.
23 *
24 * @param stack_top top of previously allocated stack.
25 * @param func to jump to with the new stack.
26 * @param arg to pass to new function.
27 * @ret   the return value of func.
28 */
29void *utils_run_on_stack(void *stack_top, void * (*func)(void *arg), void *arg);
30