]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4sys/include/kip.h
3bf4423aa0e34837c941ef507e5bd3ccfdf9f01e
[l4.git] / l4 / pkg / l4sys / include / kip.h
1 /**
2  * \file
3  * \brief Kernel Info Page access functions.
4  * \ingroup l4_api
5  */
6 /*
7  * (c) 2008-2009 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 enum l4_kip_kernel_uart_info_types
30 {
31   L4_KIP_KERNEL_UART_INFO_INVALID = 0,
32   L4_KIP_KERNEL_UART_INFO_IOPORT,
33   L4_KIP_KERNEL_UART_INFO_MMIO,
34 };
35
36 struct l4_kip_kernel_uart_info
37 {
38   l4_uint32_t type;
39   l4_uint32_t irqno;
40   l4_uint64_t base;
41 };
42
43 struct l4_kip_platform_info
44 {
45   char name[16];
46 };
47
48 #if L4_MWORD_BITS == 32
49 #  include <l4/sys/__kip-32bit.h>
50 #else
51 #  include <l4/sys/__kip-64bit.h>
52 #endif
53
54
55
56
57 /**
58  * \addtogroup l4_kip_api
59  *
60  * C interface for the Kernel Interface Page:<br>
61  * <c>\#include <l4/sys/kip.h></c>
62  */
63 /*@{*/
64
65 /**
66  * \internal
67  */
68 enum l4_kernel_info_consts_t
69 {
70   L4_KIP_VERSION_FIASCO      = 0x87004444,
71   L4_KIP_VERSION_FIASCO_MASK = 0xff00ffff,
72 };
73
74 /**
75  * \brief Kernel Info Page identifier ("L4µK").
76  */
77 #define L4_KERNEL_INFO_MAGIC (0x4BE6344CL) /* "L4µK" */
78
79
80 /**
81  * \brief  Get the kernel version.
82  * \param kip Kernel Interface Page.
83  * \return Kernel version string. 0 if KIP could not be mapped.
84  */
85 L4_INLINE l4_umword_t l4_kip_version(l4_kernel_info_t *kip) L4_NOTHROW;
86
87 /**
88  * \brief  Get the kernel version string.
89  * \param kip Kernel Interface Page.
90  * \return Kernel version string.
91  */
92 L4_INLINE const char *l4_kip_version_string(l4_kernel_info_t *kip) L4_NOTHROW;
93
94 /**
95  * \brief Return offset in bytes of version_strings relative to the KIP base.
96  *
97  * \param kip   Pointer to the kernel into page (KIP).
98  *
99  * \return offset of version_strings relative to the KIP base address, in
100  *         bytes.
101  */
102 L4_INLINE int
103 l4_kernel_info_version_offset(l4_kernel_info_t *kip) L4_NOTHROW;
104
105 /*@}*/
106
107 /*************************************************************************
108  * Implementations
109  *************************************************************************/
110
111 L4_INLINE l4_umword_t
112 l4_kip_version(l4_kernel_info_t *kip) L4_NOTHROW
113 { return kip->version & L4_KIP_VERSION_FIASCO_MASK; }
114
115 L4_INLINE const char*
116 l4_kip_version_string(l4_kernel_info_t *k) L4_NOTHROW
117 { return (const char *)k + l4_kernel_info_version_offset(k); }
118
119 L4_INLINE int
120 l4_kernel_info_version_offset(l4_kernel_info_t *kip) L4_NOTHROW
121 { return kip->offset_version_strings << 4; }