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 
110 L4_INLINE l4_cpu_time_t
112 
120 L4_INLINE l4_umword_t
122 
125 /*************************************************************************
126  * Implementations
127  *************************************************************************/
128 
129 L4_INLINE l4_umword_t
131 { return kip->version & L4_KIP_VERSION_FIASCO_MASK; }
132 
133 L4_INLINE const char*
135 { return (const char *)k + l4_kernel_info_version_offset(k); }
136 
137 L4_INLINE int
139 { return kip->offset_version_strings << 4; }
140 
141 L4_INLINE l4_cpu_time_t
143 {
144  unsigned long h1, l;
145  unsigned long *c;
146 
147  if (sizeof(unsigned long) == 8)
148  return kip->_clock_val;
149 
150  c = (unsigned long *)&kip->_clock_val;
151  do
152  {
153  h1 = c[1];
154  l4_mb();
155  l = c[0];
156  l4_mb();
157  }
158  while (h1 != c[1]);
159 
160  return ((unsigned long long)h1 << 32) | l;
161 }
162 
163 L4_INLINE l4_umword_t
165 {
166  /* We do the casting because the clock field is volatile */
167  unsigned long *c = (unsigned long *)&kip->_clock_val;
168  l4_mb();
169  return c[0];
170 }
L4 compiler related defines.
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition: compiler.h:186
void l4_mb(void)
Memory barrier.
Definition: compiler.h:278
unsigned long l4_umword_t
Unsigned machine word.
Definition: l4int.h:51
l4_uint64_t l4_cpu_time_t
CPU clock type.
Definition: l4int.h:58
unsigned int l4_uint32_t
Unsigned 32bit value.
Definition: l4int.h:40
L4 Kernel Interface Page.
Definition: __kip-32bit.h:39
l4_umword_t l4_kip_version(l4_kernel_info_t *kip) L4_NOTHROW
Get the kernel version.
Definition: kip.h:130
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:138
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:164
l4_cpu_time_t l4_kip_clock(l4_kernel_info_t *kip) L4_NOTHROW
Return clock value from the KIP.
Definition: kip.h:142
const char * l4_kip_version_string(l4_kernel_info_t *kip) L4_NOTHROW
Get the kernel version string.
Definition: kip.h:134