L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
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
34struct 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
58enum l4_kernel_info_consts_t
59{
60 L4_KIP_VERSION_FIASCO = 0x87004444,
61 L4_KIP_VERSION_FIASCO_MASK = 0xff00ffff,
62};
63
64enum
65{
75
86};
87
91extern l4_kernel_info_t const *l4_global_kip;
92
96#define L4_KERNEL_INFO_MAGIC (0x4BE6344CL) /* "L4µK" */
97
98
105
106
115
124
133L4_INLINE int
135
155
170 L4_DEPRECATED("Use l4_kip_clock() instead");
171
187
190/*************************************************************************
191 * Implementations
192 *************************************************************************/
193
196{ return l4_global_kip; }
197
200{ return kip->version & L4_KIP_VERSION_FIASCO_MASK; }
201
202L4_INLINE const char*
205
206L4_INLINE int
208{ return kip->offset_version_strings << 4; }
209
212{
213 // Use kernel-provided code to determine the current clock.
214 typedef l4_uint64_t (*kip_time_fn_read_us)(void);
215 kip_time_fn_read_us read_us =
216 (kip_time_fn_read_us)((l4_uint8_t const*)kip + L4_KIP_OFFS_READ_US);
217 return read_us();
218}
219
222{
223 typedef l4_uint64_t (*kip_time_fn_read_ns)(void);
224 kip_time_fn_read_ns read_ns =
225 (kip_time_fn_read_ns)((l4_uint8_t const*)kip + L4_KIP_OFFS_READ_NS);
226 return read_ns();
227}
228
231{
232 return l4_kip_clock(kip);
233}
234
241#define l4_kip_for_each_feature(s) \
242 for (s += __builtin_strlen(s) + 1; *s; s += __builtin_strlen(s) + 1)
243
254L4_INLINE int
255l4_kip_kernel_has_feature(l4_kernel_info_t const *kip, char const *str)
256{
257 const char *s = l4_kip_version_string(kip);
258 if (!s)
259 return 0;
260
262 {
263 if (__builtin_strcmp(s, str) == 0)
264 return 1;
265 }
266
267 return 0;
268}
L4 compiler related defines.
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 char l4_uint8_t
Unsigned 8bit value.
Definition l4int.h:36
unsigned int l4_uint32_t
Unsigned 32bit value.
Definition l4int.h:40
unsigned long long l4_uint64_t
Unsigned 64bit value.
Definition l4int.h:42
int l4_kernel_info_version_offset(l4_kernel_info_t const *kip) L4_NOTHROW
Return offset in bytes of version_strings relative to the KIP base.
Definition kip.h:207
l4_umword_t l4_kip_clock_lw(l4_kernel_info_t const *kip) L4_NOTHROW
Return least significant machine word of clock value from the KIP.
Definition kip.h:230
l4_kernel_info_t const * l4_kip(void) L4_NOTHROW
Get Kernel Info Page.
Definition kip.h:195
const char * l4_kip_version_string(l4_kernel_info_t const *kip) L4_NOTHROW
Get the kernel version string.
Definition kip.h:203
l4_umword_t l4_kip_version(l4_kernel_info_t const *kip) L4_NOTHROW
Get the kernel version.
Definition kip.h:199
l4_cpu_time_t l4_kip_clock(l4_kernel_info_t const *kip) L4_NOTHROW
Return clock value from the KIP.
Definition kip.h:211
l4_uint64_t l4_kip_clock_ns(l4_kernel_info_t const *kip) L4_NOTHROW
Return current clock using the KIP in nanoseconds.
Definition kip.h:221
@ L4_KIP_OFFS_READ_NS
Offset of KIP code (provided by the kernel) for reading the time stamp counter and transforming this ...
Definition kip.h:85
@ L4_KIP_OFFS_READ_US
Offset of KIP code (provided by the kernel) for reading the KIP clock in microseconds.
Definition kip.h:74
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition compiler.h:188
#define L4_INLINE
L4 Inline function attribute.
Definition compiler.h:62
#define L4_DEPRECATED(s)
Mark symbol deprecated.
Definition compiler.h:301
L4 Kernel Interface Page.
Definition __kip-32bit.h:39
l4_uint32_t version
Kernel version.
Definition __kip-32bit.h:44
int l4_kip_kernel_has_feature(l4_kernel_info_t const *kip, char const *str)
Check if kernel supports a feature.
Definition kip.h:255
#define l4_kip_for_each_feature(s)
Cycle through kernel features given in the KIP.
Definition kip.h:241