Loading...
Searching...
No Matches
kip.h
Go to the documentation of this file.
/*
* (c) 2008-2013 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
* Alexander Warg <warg@os.inf.tu-dresden.de>
* economic rights: Technische Universität Dresden (Germany)
*
* License: see LICENSE.spdx (in this directory or the directories above)
*/
#pragma once
#include <l4/sys/compiler.h>
#include <l4/sys/l4int.h>
#include <l4/sys/__kip-arch.h>
struct l4_kip_platform_info
{
char name[16];
l4_uint32_t is_mp;
struct l4_kip_platform_info_arch arch;
};
typedef struct l4_kernel_info_t
{
/* offset 0x00 */
l4_uint32_t magic;
l4_uint32_t version;
l4_uint8_t offset_version_strings;
l4_uint8_t _fill0[3];
l4_uint8_t kip_sys_calls;
l4_uint8_t node;
l4_uint8_t _fill1[2];
/* offset 0x10 */
l4_uint64_t sigma0_ip;
l4_uint64_t root_ip;
/* offset 0x20 */
volatile l4_cpu_time_t _clock_val;
l4_uint64_t frequency_cpu;
/* offset 0x30 */
l4_uint64_t acpi_rsdp_addr;
l4_uint64_t dt_addr;
/* offset 0x40 */
l4_uint64_t user_ptr;
l4_uint64_t _res0[1];
/* offset 0x50 */
l4_uint32_t scheduler_granularity;
l4_uint32_t mem_descs;
l4_uint32_t mem_descs_num;
l4_uint32_t _res1[1];
/* offset 0x60 */
l4_uint64_t _res2[2];
/* offset 0x70 */
struct l4_kip_platform_info platform_info;
} l4_kernel_info_t;
enum l4_kernel_info_consts_t
{
L4_KIP_VERSION_FIASCO = 0x87004444,
L4_KIP_VERSION_FIASCO_MASK = 0xff00ffff,
};
enum
{
L4_KIP_OFFS_READ_US = 0x900,
L4_KIP_OFFS_READ_NS = 0x980,
};
extern l4_kernel_info_t const *l4_global_kip;
#define L4_KERNEL_INFO_MAGIC (0x4BE6344CL) /* "L4µK" */
L4_INLINE l4_kernel_info_t const *l4_kip(void) L4_NOTHROW;
L4_INLINE l4_umword_t l4_kip_version(l4_kernel_info_t const *kip) L4_NOTHROW;
L4_INLINE const char *l4_kip_version_string(l4_kernel_info_t const *kip) L4_NOTHROW;
L4_INLINE int
l4_kernel_info_version_offset(l4_kernel_info_t const *kip) L4_NOTHROW;
L4_INLINE l4_cpu_time_t
l4_kip_clock(l4_kernel_info_t const *kip) L4_NOTHROW;
L4_INLINE l4_umword_t
l4_kip_clock_lw(l4_kernel_info_t const *kip) L4_NOTHROW
L4_DEPRECATED("Use l4_kip_clock() instead");
L4_INLINE l4_uint64_t
l4_kip_clock_ns(l4_kernel_info_t const *kip) L4_NOTHROW;
/*************************************************************************
* Implementations
*************************************************************************/
L4_INLINE l4_kernel_info_t const*
l4_kip(void) L4_NOTHROW
{ return l4_global_kip; }
L4_INLINE l4_umword_t
l4_kip_version(l4_kernel_info_t const *kip) L4_NOTHROW
{ return kip->version & L4_KIP_VERSION_FIASCO_MASK; }
L4_INLINE const char*
l4_kip_version_string(l4_kernel_info_t const *k) L4_NOTHROW
{ return (const char *)k + l4_kernel_info_version_offset(k); }
L4_INLINE int
l4_kernel_info_version_offset(l4_kernel_info_t const *kip) L4_NOTHROW
{ return kip->offset_version_strings << 4; }
L4_INLINE l4_cpu_time_t
l4_kip_clock(l4_kernel_info_t const *kip) L4_NOTHROW
{
// Use kernel-provided code to determine the current clock.
typedef l4_uint64_t (*kip_time_fn_read_us)(void);
kip_time_fn_read_us read_us =
(kip_time_fn_read_us)((l4_uint8_t const*)kip + L4_KIP_OFFS_READ_US);
return read_us();
}
L4_INLINE l4_cpu_time_t
l4_kip_clock_ns(l4_kernel_info_t const *kip) L4_NOTHROW
{
typedef l4_uint64_t (*kip_time_fn_read_ns)(void);
kip_time_fn_read_ns read_ns =
(kip_time_fn_read_ns)((l4_uint8_t const*)kip + L4_KIP_OFFS_READ_NS);
return read_ns();
}
L4_INLINE l4_umword_t
l4_kip_clock_lw(l4_kernel_info_t const *kip) L4_NOTHROW
{
return l4_kip_clock(kip);
}
#define l4_kip_for_each_feature(s) \
for (s += __builtin_strlen(s) + 1; *s; s += __builtin_strlen(s) + 1)
L4_INLINE int
l4_kip_kernel_has_feature(l4_kernel_info_t const *kip, char const *str)
{
const char *s = l4_kip_version_string(kip);
if (!s)
return 0;
l4_kip_for_each_feature(s)
{
if (__builtin_strcmp(s, str) == 0)
return 1;
}
return 0;
}
compiler.h
L4 compiler related defines.
l4_umword_t
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:40
l4_cpu_time_t
l4_uint64_t l4_cpu_time_t
CPU clock type.
Definition l4int.h:47
l4_uint8_t
unsigned char l4_uint8_t
Unsigned 8bit value.
Definition l4int.h:25
l4_uint32_t
unsigned int l4_uint32_t
Unsigned 32bit value.
Definition l4int.h:29
l4_uint64_t
unsigned long long l4_uint64_t
Unsigned 64bit value.
Definition l4int.h:31
l4_kernel_info_version_offset
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_kip_clock_lw
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_kip
l4_kernel_info_t const * l4_kip(void) L4_NOTHROW
Get Kernel Info Page.
Definition kip.h:226
l4_kip_version_string
const char * l4_kip_version_string(l4_kernel_info_t const *kip) L4_NOTHROW
Get the kernel version string.
Definition kip.h:234
l4_kip_version
l4_umword_t l4_kip_version(l4_kernel_info_t const *kip) L4_NOTHROW
Get the kernel version.
Definition kip.h:230
l4_kip_clock
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_kip_clock_ns
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
@ 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
@ L4_KIP_OFFS_READ_US
Offset of KIP code (provided by the kernel) for reading the KIP clock in microseconds.
Definition kip.h:105
L4_NOTHROW
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition compiler.h:161
L4_INLINE
#define L4_INLINE
L4 Inline function attribute.
Definition compiler.h:51
L4_DEPRECATED
#define L4_DEPRECATED(s)
Mark symbol deprecated.
Definition compiler.h:289
l4int.h
Fixed sized integer types, generic version.
l4_kernel_info_t
L4 Kernel Interface Page.
Definition kip.h:37
l4_kernel_info_t::acpi_rsdp_addr
l4_uint64_t acpi_rsdp_addr
ACPI RSDP/XSDP.
Definition kip.h:58
l4_kernel_info_t::_fill0
l4_uint8_t _fill0[3]
reserved
Definition kip.h:44
l4_kernel_info_t::version
l4_uint32_t version
Kernel version.
Definition kip.h:42
l4_kernel_info_t::dt_addr
l4_uint64_t dt_addr
Device Tree.
Definition kip.h:59
l4_kernel_info_t::_res2
l4_uint64_t _res2[2]
internal - spare space
Definition kip.h:72
l4_kernel_info_t::offset_version_strings
l4_uint8_t offset_version_strings
offset to version string
Definition kip.h:43
l4_kernel_info_t::_fill1
l4_uint8_t _fill1[2]
reserved
Definition kip.h:47
l4_kernel_info_t::kip_sys_calls
l4_uint8_t kip_sys_calls
pointer to system calls
Definition kip.h:45
l4_kernel_info_t::scheduler_granularity
l4_uint32_t scheduler_granularity
for rounding time slices
Definition kip.h:66
l4_kernel_info_t::user_ptr
l4_uint64_t user_ptr
user_ptr
Definition kip.h:62
l4_kernel_info_t::magic
l4_uint32_t magic
Kernel Info Page identifier ("L4µK").
Definition kip.h:39
l4_kernel_info_t::sigma0_ip
l4_uint64_t sigma0_ip
Sigma0 instruction pointer.
Definition kip.h:50
l4_kernel_info_t::frequency_cpu
l4_uint64_t frequency_cpu
CPU frequency in kHz.
Definition kip.h:55
l4_kernel_info_t::root_ip
l4_uint64_t root_ip
Root task instruction pointer.
Definition kip.h:51
l4_kernel_info_t::mem_descs_num
l4_uint32_t mem_descs_num
number of memory descriptors
Definition kip.h:68
l4_kernel_info_t::mem_descs
l4_uint32_t mem_descs
memory descriptors relative to Kip
Definition kip.h:67
l4_kip_kernel_has_feature
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
l4_kip_for_each_feature
#define l4_kip_for_each_feature(s)
Cycle through kernel features given in the KIP.
Definition kip.h:272