1/**
2 * \file
3 * \brief Threads architecture-specific code
4 */
5
6/*
7 * Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich.
8 * All rights reserved.
9 *
10 * This file is distributed under the terms in the attached LICENSE file.
11 * If you do not find this file, copies can be found by writing to:
12 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
13 */
14
15#ifndef LIBBARRELFISH_ARCH_THREADS_H
16#define LIBBARRELFISH_ARCH_THREADS_H
17
18#include <barrelfish/syscall_arch.h>
19
20/* this is a label defined in the assembler code that implements cap_invoke() */
21extern void barrelfish_cap_invoke_post_syscall_instr(void);
22extern void barrelfish_lrpc_post_syscall_instr(void);
23
24/// 16-byte alignment required for x86-64
25#define STACK_ALIGNMENT (sizeof(uint64_t) * 2)
26
27#define THREAD_ALIGNMENT (16)
28
29#if 0 // Using the old format of dispatcher_frame and not called by anyone -akhi
30/**
31 * Returns true iff the thread with the given save area has successfully
32 * performed a syscall. Used for the thread_invoke_cap_and_exit() hack.
33 */
34static inline bool thread_check_syscall_succeeded(uintptr_t *save_area)
35{
36    return ((save_area[RIP_REG] == (lvaddr_t)barrelfish_cap_invoke_post_syscall_instr
37             || save_area[RIP_REG] == (lvaddr_t)barrelfish_lrpc_post_syscall_instr)
38            && save_area[RAX_REG] == 0);
39}
40#endif
41
42#endif // LIBBARRELFISH_ARCH_THREADS_H
43