L4Re Operating System Framework
Interface and Usage Documentation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 * License: see LICENSE.spdx (in this directory or the directories above)
12 */
13#pragma once
14
15#include <l4/sys/compiler.h>
16#include <l4/sys/l4int.h>
17
18#include <l4/sys/__kip-arch.h>
19
23struct l4_kip_platform_info
24{
25 char name[16];
26 l4_uint32_t is_mp;
27 struct l4_kip_platform_info_arch arch;
28};
29
30#if L4_MWORD_BITS == 32
31# include <l4/sys/__kip-32bit.h>
32#else
33# include <l4/sys/__kip-64bit.h>
34#endif
35
47enum l4_kernel_info_consts_t
48{
49 L4_KIP_VERSION_FIASCO = 0x87004444,
50 L4_KIP_VERSION_FIASCO_MASK = 0xff00ffff,
51};
52
53enum
54{
64
75};
76
80extern l4_kernel_info_t const *l4_global_kip;
81
85#define L4_KERNEL_INFO_MAGIC (0x4BE6344CL) /* "L4µK" */
86
87
94
95
104
113
122L4_INLINE int
124
144
159 L4_DEPRECATED("Use l4_kip_clock() instead");
160
176
179/*************************************************************************
180 * Implementations
181 *************************************************************************/
182
185{ return l4_global_kip; }
186
189{ return kip->version & L4_KIP_VERSION_FIASCO_MASK; }
190
191L4_INLINE const char*
194
195L4_INLINE int
197{ return kip->offset_version_strings << 4; }
198
201{
202 // Use kernel-provided code to determine the current clock.
203 typedef l4_uint64_t (*kip_time_fn_read_us)(void);
204 kip_time_fn_read_us read_us =
205 (kip_time_fn_read_us)((l4_uint8_t const*)kip + L4_KIP_OFFS_READ_US);
206 return read_us();
207}
208
211{
212 typedef l4_uint64_t (*kip_time_fn_read_ns)(void);
213 kip_time_fn_read_ns read_ns =
214 (kip_time_fn_read_ns)((l4_uint8_t const*)kip + L4_KIP_OFFS_READ_NS);
215 return read_ns();
216}
217
220{
221 return l4_kip_clock(kip);
222}
223
230#define l4_kip_for_each_feature(s) \
231 for (s += __builtin_strlen(s) + 1; *s; s += __builtin_strlen(s) + 1)
232
243L4_INLINE int
244l4_kip_kernel_has_feature(l4_kernel_info_t const *kip, char const *str)
245{
246 const char *s = l4_kip_version_string(kip);
247 if (!s)
248 return 0;
249
251 {
252 if (__builtin_strcmp(s, str) == 0)
253 return 1;
254 }
255
256 return 0;
257}
L4 compiler related defines.
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:40
l4_uint64_t l4_cpu_time_t
CPU clock type.
Definition l4int.h:47
unsigned char l4_uint8_t
Unsigned 8bit value.
Definition l4int.h:25
unsigned int l4_uint32_t
Unsigned 32bit value.
Definition l4int.h:29
unsigned long long l4_uint64_t
Unsigned 64bit value.
Definition l4int.h:31
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:196
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:219
l4_kernel_info_t const * l4_kip(void) L4_NOTHROW
Get Kernel Info Page.
Definition kip.h:184
const char * l4_kip_version_string(l4_kernel_info_t const *kip) L4_NOTHROW
Get the kernel version string.
Definition kip.h:192
l4_umword_t l4_kip_version(l4_kernel_info_t const *kip) L4_NOTHROW
Get the kernel version.
Definition kip.h:188
l4_cpu_time_t l4_kip_clock(l4_kernel_info_t const *kip) L4_NOTHROW
Return clock value from the KIP.
Definition kip.h:200
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:210
@ 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:74
@ L4_KIP_OFFS_READ_US
Offset of KIP code (provided by the kernel) for reading the KIP clock in microseconds.
Definition kip.h:63
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition compiler.h:159
#define L4_INLINE
L4 Inline function attribute.
Definition compiler.h:51
#define L4_DEPRECATED(s)
Mark symbol deprecated.
Definition compiler.h:280
L4 Kernel Interface Page.
Definition __kip-32bit.h:28
l4_uint32_t version
Kernel version.
Definition __kip-32bit.h:33
int l4_kip_kernel_has_feature(l4_kernel_info_t const *kip, char const *str)
Check if kernel supports a feature.
Definition kip.h:244
#define l4_kip_for_each_feature(s)
Cycle through kernel features given in the KIP.
Definition kip.h:230