L4Re - L4 Runtime Environment
kip.h
Go to the documentation of this file.
1 
6 /*
7  * (c) 2008-2013 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
8  * Alexander Warg <warg@os.inf.tu-dresden.de>
9  * economic rights: Technische Universität Dresden (Germany)
10  *
11  * This file is part of TUD:OS and distributed under the terms of the
12  * GNU General Public License 2.
13  * Please see the COPYING-GPL-2 file for details.
14  *
15  * As a special exception, you may use this file as part of a free software
16  * library without restriction. Specifically, if other files instantiate
17  * templates or use macros or inline functions from this file, or you compile
18  * this file and link it with other files to produce an executable, this
19  * file does not by itself cause the resulting executable to be covered by
20  * the GNU General Public License. This exception does not however
21  * invalidate any other reasons why the executable file might be covered by
22  * the GNU General Public License.
23  */
24 #pragma once
25 
26 #include <l4/sys/compiler.h>
27 #include <l4/sys/l4int.h>
28 
29 #include <l4/sys/__kip-arch.h>
30 
34 struct l4_kip_platform_info
35 {
36  char name[16];
37  l4_uint32_t is_mp;
38  struct l4_kip_platform_info_arch arch;
39 };
40 
41 #if L4_MWORD_BITS == 32
42 # include <l4/sys/__kip-32bit.h>
43 #else
44 # include <l4/sys/__kip-64bit.h>
45 #endif
46 
54 
58 enum l4_kernel_info_consts_t
59 {
60  L4_KIP_VERSION_FIASCO = 0x87004444,
61  L4_KIP_VERSION_FIASCO_MASK = 0xff00ffff,
62 };
63 
67 #define L4_KERNEL_INFO_MAGIC (0x4BE6344CL) /* "L4µK" */
68 
69 
78 
86 L4_INLINE const char *l4_kip_version_string(l4_kernel_info_t *kip) L4_NOTHROW;
87 
96 L4_INLINE int
98 
106 L4_INLINE l4_cpu_time_t
108 
116 L4_INLINE l4_umword_t
118 
121 /*************************************************************************
122  * Implementations
123  *************************************************************************/
124 
125 L4_INLINE l4_umword_t
127 { return kip->version & L4_KIP_VERSION_FIASCO_MASK; }
128 
129 L4_INLINE const char*
131 { return (const char *)k + l4_kernel_info_version_offset(k); }
132 
133 L4_INLINE int
135 { return kip->offset_version_strings << 4; }
136 
137 L4_INLINE l4_cpu_time_t
139 {
140  unsigned long h1, l;
141  unsigned long *c;
142 
143  if (sizeof(unsigned long) == 8)
144  return kip->_clock_val;
145 
146  c = (unsigned long *)&kip->_clock_val;
147  do
148  {
149  h1 = c[1];
150  l4_mb();
151  l = c[0];
152  l4_mb();
153  }
154  while (h1 != c[1]);
155 
156  return ((unsigned long long)h1 << 32) | l;
157 }
158 
159 L4_INLINE l4_umword_t
161 {
162  /* We do the casting because the clock field is volatile */
163  unsigned long *c = (unsigned long *)&kip->_clock_val;
164  l4_mb();
165  return c[0];
166 }
void l4_mb(void)
Memory barrier.
Definition: compiler.h:274
l4_umword_t l4_kip_clock_lw(l4_kernel_info_t *kip) L4_NOTHROW
Return least significant machine word of clock value from the KIP.
Definition: kip.h:160
l4_umword_t l4_kip_version(l4_kernel_info_t *kip) L4_NOTHROW
Get the kernel version.
Definition: kip.h:126
L4 compiler related defines.
int l4_kernel_info_version_offset(l4_kernel_info_t *kip) L4_NOTHROW
Return offset in bytes of version_strings relative to the KIP base.
Definition: kip.h:134
L4 Kernel Interface Page.
Definition: __kip-32bit.h:38
l4_uint64_t l4_cpu_time_t
CPU clock type.
Definition: l4int.h:59
unsigned long l4_umword_t
Unsigned machine word.
Definition: l4int.h:52
const char * l4_kip_version_string(l4_kernel_info_t *kip) L4_NOTHROW
Get the kernel version string.
Definition: kip.h:130
l4_cpu_time_t l4_kip_clock(l4_kernel_info_t *kip) L4_NOTHROW
Return clock value from the KIP.
Definition: kip.h:138
unsigned int l4_uint32_t
Unsigned 32bit value.
Definition: l4int.h:40
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition: compiler.h:185