1 #include_next <l4/sys/segment.h>
2
3 /**
4 * \file
5 * \brief l4f specific fs/gs manipulation
6 * \ingroup api_calls_fiasco
7 */
8 /*
9 * (c) 2011 Adam Lackorzynski <adam@os.inf.tu-dresden.de>
10 * economic rights: Technische Universität Dresden (Germany)
11 *
12 * This file is part of TUD:OS and distributed under the terms of the
13 * GNU General Public License 2.
14 * Please see the COPYING-GPL-2 file for details.
15 *
16 * As a special exception, you may use this file as part of a free software
17 * library without restriction. Specifically, if other files instantiate
18 * templates or use macros or inline functions from this file, or you compile
19 * this file and link it with other files to produce an executable, this
20 * file does not by itself cause the resulting executable to be covered by
21 * the GNU General Public License. This exception does not however
22 * invalidate any other reasons why the executable file might be covered by
23 * the GNU General Public License.
24 */
25 #ifndef __L4_SYS__ARCH_AMD64__L4API_L4F__SEGMENT_H__
26 #define __L4_SYS__ARCH_AMD64__L4API_L4F__SEGMENT_H__
27
28 #include <l4/sys/compiler.h>
29
30 /*****************************************************************************
31 *** Implementation
32 *****************************************************************************/
33
34 L4_INLINE long
fiasco_amd64_set_fs(l4_cap_idx_t thread,l4_umword_t base,l4_utcb_t * utcb)35 fiasco_amd64_set_fs(l4_cap_idx_t thread, l4_umword_t base, l4_utcb_t *utcb)
36 {
37 l4_utcb_mr_u(utcb)->mr[0] = L4_THREAD_AMD64_SET_SEGMENT_BASE_OP | ((l4_umword_t)L4_AMD64_SEGMENT_FS << 16);
38 l4_utcb_mr_u(utcb)->mr[1] = base;
39 return l4_error_u(l4_ipc_call(thread, utcb, l4_msgtag(L4_PROTO_THREAD, 2, 0, 0), L4_IPC_NEVER), utcb);
40 }
41
42 L4_INLINE long
fiasco_amd64_set_segment_base(l4_cap_idx_t thread,enum L4_sys_segment segr,l4_umword_t base,l4_utcb_t * utcb)43 fiasco_amd64_set_segment_base(l4_cap_idx_t thread, enum L4_sys_segment segr,
44 l4_umword_t base, l4_utcb_t *utcb)
45 {
46 l4_utcb_mr_u(utcb)->mr[0] = L4_THREAD_AMD64_SET_SEGMENT_BASE_OP | ((l4_umword_t)segr << 16);
47 l4_utcb_mr_u(utcb)->mr[1] = base;
48 return l4_error_u(l4_ipc_call(thread, utcb, l4_msgtag(L4_PROTO_THREAD, 2, 0, 0), L4_IPC_NEVER), utcb);
49 }
50
51 L4_INLINE long
fiasco_gdt_set(l4_cap_idx_t thread,void * desc,unsigned int size,unsigned int entry_number_start,l4_utcb_t * utcb)52 fiasco_gdt_set(l4_cap_idx_t thread, void *desc, unsigned int size,
53 unsigned int entry_number_start, l4_utcb_t *utcb)
54 {
55 l4_utcb_mr_u(utcb)->mr[0] = L4_THREAD_X86_GDT_OP;
56 l4_utcb_mr_u(utcb)->mr[1] = entry_number_start;
57 __builtin_memcpy(&l4_utcb_mr_u(utcb)->mr[2], desc, size);
58 return l4_error_u(l4_ipc_call(thread, utcb, l4_msgtag(L4_PROTO_THREAD, 2 + (size / 8), 0, 0), L4_IPC_NEVER), utcb);
59 }
60
61 #endif /* ! __L4_SYS__ARCH_X86__L4API_L4F__SEGMENT_H__ */
62