L4Re - L4 Runtime Environment
segment.h
Go to the documentation of this file.
1 
6 /*
7  * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>
8  * economic rights: Technische Universit├Ąt Dresden (Germany)
9  *
10  * This file is part of TUD:OS and distributed under the terms of the
11  * GNU General Public License 2.
12  * Please see the COPYING-GPL-2 file for details.
13  *
14  * As a special exception, you may use this file as part of a free software
15  * library without restriction. Specifically, if other files instantiate
16  * templates or use macros or inline functions from this file, or you compile
17  * this file and link it with other files to produce an executable, this
18  * file does not by itself cause the resulting executable to be covered by
19  * the GNU General Public License. This exception does not however
20  * invalidate any other reasons why the executable file might be covered by
21  * the GNU General Public License.
22  */
23 /*****************************************************************************/
24 #ifndef __L4_SYS__ARCH_X86__SEGMENT_H__
25 #define __L4_SYS__ARCH_X86__SEGMENT_H__
26 
27 #ifndef L4API_l4f
28 #error This header file can only be used with a L4API version!
29 #endif
30 
31 #include <l4/sys/ipc.h>
32 
43 L4_INLINE long
44 fiasco_ldt_set(l4_cap_idx_t task, void *ldt, unsigned int size,
45  unsigned int entry_number_start, l4_utcb_t *utcb);
46 
60 L4_INLINE long
61 fiasco_gdt_set(l4_cap_idx_t thread, void *desc, unsigned int size,
62  unsigned int entry_number_start, l4_utcb_t *utcb);
63 
70 L4_INLINE unsigned
72 
77 {
84 };
85 
86 /*****************************************************************************
87  *** Implementation
88  *****************************************************************************/
89 
90 #include <l4/sys/task.h>
91 #include <l4/sys/thread.h>
92 
93 L4_INLINE long
94 fiasco_ldt_set(l4_cap_idx_t task, void *ldt, unsigned int num_desc,
95  unsigned int entry_number_start, l4_utcb_t *utcb)
96 {
97  if (num_desc > L4_TASK_LDT_X86_MAX_ENTRIES)
98  return -L4_EINVAL;
99  l4_utcb_mr_u(utcb)->mr[0] = L4_TASK_LDT_SET_X86_OP;
100  l4_utcb_mr_u(utcb)->mr[1] = entry_number_start;
101  __builtin_memcpy(&l4_utcb_mr_u(utcb)->mr[2], ldt,
102  num_desc * L4_TASK_LDT_X86_ENTRY_SIZE);
103  return l4_error_u(l4_ipc_call(task, utcb, l4_msgtag(L4_PROTO_TASK, 2 + num_desc * 2, 0, 0), L4_IPC_NEVER), utcb);
104 }
105 
106 L4_INLINE unsigned
108 {
109  l4_utcb_mr_u(utcb)->mr[0] = L4_THREAD_X86_GDT_OP;
110  if (l4_error_u(l4_ipc_call(thread, utcb, l4_msgtag(L4_PROTO_THREAD, 1, 0, 0), L4_IPC_NEVER), utcb))
111  return -1;
112  return l4_utcb_mr_u(utcb)->mr[0];
113 }
114 
115 #endif /* ! __L4_SYS__ARCH_X86__SEGMENT_H__ */
Total number of message register (MRs) available.
Definition: utcb.h:47
x86: LDT set
Definition: task.h:279
Invalid argument.
Definition: err.h:56
Size of an LDT entry.
Definition: segment.h:79
Maximum number of LDT entries that can be written with one call.
Definition: segment.h:81
l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE]
Message registers.
Definition: utcb.h:80
l4_msgtag_t l4_ipc_call(l4_cap_idx_t object, l4_utcb_t *utcb, l4_msgtag_t tag, l4_timeout_t timeout) L4_NOTHROW
Object call (usual invocation).
Definition: ipc.h:445
unsigned long l4_cap_idx_t
L4 Capability selector Type.
Definition: types.h:341
long fiasco_gdt_set(l4_cap_idx_t thread, void *desc, unsigned int size, unsigned int entry_number_start, l4_utcb_t *utcb)
Set GDT segment descriptors.
Definition: segment.h:52
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition: utcb.h:67
#define L4_IPC_NEVER
never timeout
Definition: __timeout.h:80
Protocol for messages to a thread object.
Definition: types.h:64
long fiasco_ldt_set(l4_cap_idx_t task, void *ldt, unsigned int num_desc, unsigned int entry_number_start, l4_utcb_t *utcb)
Set LDT segments descriptors.
Definition: segment.h:136
Protocol for messages to a task object.
Definition: types.h:63
Common task related definitions.
l4_msgtag_t l4_msgtag(long label, unsigned words, unsigned items, unsigned flags) L4_NOTHROW
Create a message tag from the specified values.
Definition: types.h:407
unsigned fiasco_gdt_get_entry_offset(l4_cap_idx_t thread, l4_utcb_t *utcb)
Return the offset of the entry in the GDT.
Definition: segment.h:149
L4_task_ldt_x86_consts
Contants for LDT handling.
Definition: segment.h:76
#define L4_MWORD_BITS
Size of machine words in bits.
Definition: l4int.h:33