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
36typedef struct l4_kernel_info_t
37{
38 /* offset 0x00 */
46 l4_uint8_t node;
48
49 /* offset 0x10 */
52
53 /* offset 0x20 */
54 volatile l4_cpu_time_t _clock_val;
56
57 /* offset 0x30 */
60
61 /* offset 0x40 */
63 l4_uint64_t _res0[1];
64
65 /* offset 0x50 */
69 l4_uint32_t _res1[1];
70
71 /* offset 0x60 */
73
74 /* offset 0x70 */
75 struct l4_kip_platform_info platform_info;
77
89enum l4_kernel_info_consts_t
90{
91 L4_KIP_VERSION_FIASCO = 0x87004444,
92 L4_KIP_VERSION_FIASCO_MASK = 0xff00ffff,
93};
94
95enum
96{
106
117};
118
122extern l4_kernel_info_t const *l4_global_kip;
123
127#define L4_KERNEL_INFO_MAGIC (0x4BE6344CL) /* "L4µK" */
128
129
136
137
146
155
164L4_INLINE int
166
186
201 L4_DEPRECATED("Use l4_kip_clock() instead");
202
218
221/*************************************************************************
222 * Implementations
223 *************************************************************************/
224
227{ return l4_global_kip; }
228
231{ return kip->version & L4_KIP_VERSION_FIASCO_MASK; }
232
233L4_INLINE const char*
236
237L4_INLINE int
239{ return kip->offset_version_strings << 4; }
240
243{
244 // Use kernel-provided code to determine the current clock.
245 typedef l4_uint64_t (*kip_time_fn_read_us)(void);
246 kip_time_fn_read_us read_us =
247 (kip_time_fn_read_us)((l4_uint8_t const*)kip + L4_KIP_OFFS_READ_US);
248 return read_us();
249}
250
253{
254 typedef l4_uint64_t (*kip_time_fn_read_ns)(void);
255 kip_time_fn_read_ns read_ns =
256 (kip_time_fn_read_ns)((l4_uint8_t const*)kip + L4_KIP_OFFS_READ_NS);
257 return read_ns();
258}
259
262{
263 return l4_kip_clock(kip);
264}
265
272#define l4_kip_for_each_feature(s) \
273 for (s += __builtin_strlen(s) + 1; *s; s += __builtin_strlen(s) + 1)
274
285L4_INLINE int
286l4_kip_kernel_has_feature(l4_kernel_info_t const *kip, char const *str)
287{
288 const char *s = l4_kip_version_string(kip);
289 if (!s)
290 return 0;
291
293 {
294 if (__builtin_strcmp(s, str) == 0)
295 return 1;
296 }
297
298 return 0;
299}
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:238
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:261
l4_kernel_info_t const * l4_kip(void) L4_NOTHROW
Get Kernel Info Page.
Definition kip.h:226
const char * l4_kip_version_string(l4_kernel_info_t const *kip) L4_NOTHROW
Get the kernel version string.
Definition kip.h:234
l4_umword_t l4_kip_version(l4_kernel_info_t const *kip) L4_NOTHROW
Get the kernel version.
Definition kip.h:230
l4_cpu_time_t l4_kip_clock(l4_kernel_info_t const *kip) L4_NOTHROW
Return clock value from the KIP.
Definition kip.h:242
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:252
@ 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:116
@ L4_KIP_OFFS_READ_US
Offset of KIP code (provided by the kernel) for reading the KIP clock in microseconds.
Definition kip.h:105
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition compiler.h:161
#define L4_INLINE
L4 Inline function attribute.
Definition compiler.h:51
#define L4_DEPRECATED(s)
Mark symbol deprecated.
Definition compiler.h:289
L4 Kernel Interface Page.
Definition kip.h:37
l4_uint64_t acpi_rsdp_addr
ACPI RSDP/XSDP.
Definition kip.h:58
l4_uint8_t _fill0[3]
reserved
Definition kip.h:44
l4_uint32_t version
Kernel version.
Definition kip.h:42
l4_uint64_t dt_addr
Device Tree.
Definition kip.h:59
l4_uint64_t _res2[2]
internal - spare space
Definition kip.h:72
l4_uint8_t offset_version_strings
offset to version string
Definition kip.h:43
l4_uint8_t _fill1[2]
reserved
Definition kip.h:47
l4_uint8_t kip_sys_calls
pointer to system calls
Definition kip.h:45
l4_uint32_t scheduler_granularity
for rounding time slices
Definition kip.h:66
l4_uint64_t user_ptr
user_ptr
Definition kip.h:62
l4_uint32_t magic
Kernel Info Page identifier ("L4µK").
Definition kip.h:39
l4_uint64_t sigma0_ip
Sigma0 instruction pointer.
Definition kip.h:50
l4_uint64_t frequency_cpu
CPU frequency in kHz.
Definition kip.h:55
l4_uint64_t root_ip
Root task instruction pointer.
Definition kip.h:51
l4_uint32_t mem_descs_num
number of memory descriptors
Definition kip.h:68
l4_uint32_t mem_descs
memory descriptors relative to Kip
Definition kip.h:67
int l4_kip_kernel_has_feature(l4_kernel_info_t const *kip, char const *str)
Check if kernel supports a feature.
Definition kip.h:286
#define l4_kip_for_each_feature(s)
Cycle through kernel features given in the KIP.
Definition kip.h:272