L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
kip
Go to the documentation of this file.
1// vim:set ft=cpp: -*- Mode: C++ -*-
10/*
11 * (c) 2008-2009 Author(s)
12 * economic rights: Technische Universität Dresden (Germany)
13 *
14 * License: see LICENSE.spdx (in this directory or the directories above)
15 */
16#pragma once
17
18#include <l4/cxx/static_vector>
19#include <l4/sys/kip.h>
20
21/* C++ version of memory descriptors */
22
31
32namespace L4
33{
34 namespace Kip
35 {
43 {
44 public:
49 {
50 Undefined = 0x0,
52 Reserved = 0x2,
53 Dedicated = 0x3,
54 Shared = 0x4,
55 Kmem = 0x5,
56
57 // 0x7 is internally used by the kernel
58
59 Info = 0xd,
60 Bootloader = 0xe,
61 Arch = 0xf
62 };
63
75
85
86 private:
87 unsigned long _l, _h;
88
89 public:
97 static Mem_desc *first(l4_kernel_info_t *kip) noexcept
98 {
99 return reinterpret_cast<Mem_desc *>(reinterpret_cast<char *>(kip) + kip->mem_descs);
100 }
101
102 static Mem_desc const *first(l4_kernel_info_t const *kip) noexcept
103 {
104 char const *addr = reinterpret_cast<char const *>(kip) + kip->mem_descs;
105 return reinterpret_cast<Mem_desc const *>(addr);
106 }
107
115 static unsigned long count(l4_kernel_info_t const *kip) noexcept
116 {
117 return kip->mem_descs_num;
118 }
119
126 static void count(l4_kernel_info_t *kip, unsigned count) noexcept
127 {
128 kip->mem_descs_num = count;
129 }
130
141
152
166 Mem_desc(unsigned long start, unsigned long end,
167 Mem_type t, unsigned char st = 0, bool virt = false,
168 bool eager = false) noexcept
169 : _l((start & ~0x3ffUL) | (t & 0x0f) | ((st << 4) & 0x0f0)
170 | (virt ? 0x0200 : 0x0) | (eager ? 0x100 : 0x0)), _h(end | 0x3ffUL)
171 {}
172
178 unsigned long start() const noexcept { return _l & ~0x3ffUL; }
179
185 unsigned long end() const noexcept { return _h | 0x3ffUL; }
186
192 unsigned long size() const noexcept { return end() + 1 - start(); }
193
199 Mem_type type() const noexcept
200 {
201 return static_cast<Mem_type>(_l & 0x0f);
202 }
203
209 unsigned char sub_type() const noexcept { return (_l >> 4) & 0x0f; }
210
217 unsigned is_virtual() const noexcept { return _l & 0x200; }
218
223 unsigned eager_map() const noexcept { return _l & 0x100; }
224
237 void set(unsigned long start, unsigned long end,
238 Mem_type t, unsigned char st = 0, bool virt = false,
239 bool eager = false) noexcept
240 {
241 _l = (start & ~0x3ffUL) | (t & 0x0f) | ((st << 4) & 0x0f0)
242 | (virt?0x0200:0x0) | (eager ? 0x0100 : 0x0);
243
244 _h = end | 0x3ffUL;
245 }
246
247 };
248 };
249};
Memory descriptors stored in the kernel interface page.
Definition kip:43
Mem_type type() const noexcept
Return type of the memory descriptor.
Definition kip:199
unsigned long end() const noexcept
Return end address of memory descriptor.
Definition kip:185
static cxx::static_vector< Mem_desc const > all(l4_kernel_info_t const *kip)
Return enumerable list of memory descriptors.
Definition kip:136
unsigned long start() const noexcept
Return start address of memory descriptor.
Definition kip:178
Arch_sub_type_common
Common sub types across all architectures for the Mem_type::Arch type.
Definition kip:80
@ Arch_cpu_fw
CPU firmware.
Definition kip:83
@ Arch_acpi_tables
Firmware ACPI tables.
Definition kip:81
@ Arch_acpi_nvs
Firmware reserved address space.
Definition kip:82
void set(unsigned long start, unsigned long end, Mem_type t, unsigned char st=0, bool virt=false, bool eager=false) noexcept
Set values of a memory descriptor.
Definition kip:237
unsigned is_virtual() const noexcept
Return whether the memory descriptor describes a virtual or physical region.
Definition kip:217
Info_sub_type
Memory sub types for the Mem_type::Info type.
Definition kip:68
@ Reserved_mmio
MMIO range reserved by kernel.
Definition kip:73
@ Info_acpi_rsdp
Physical address of the ACPI root pointer.
Definition kip:69
@ Reserved_heap
Kernel heap.
Definition kip:72
@ Reserved_kernel
Kernel image.
Definition kip:71
Mem_desc(unsigned long start, unsigned long end, Mem_type t, unsigned char st=0, bool virt=false, bool eager=false) noexcept
Initialize memory descriptor.
Definition kip:166
unsigned eager_map() const noexcept
Return whether the region shall be eligible for eager mapping in sigma0 or the root task.
Definition kip:223
Mem_type
Memory types.
Definition kip:49
@ Reserved
Reserved region, do not use this memory.
Definition kip:52
@ Shared
Shared.
Definition kip:54
@ Dedicated
Dedicated.
Definition kip:53
@ Conventional
Conventional memory.
Definition kip:51
@ Info
Info by boot loader.
Definition kip:59
@ Undefined
Undefined memory.
Definition kip:50
@ Arch
Architecture specific memory.
Definition kip:61
@ Bootloader
Memory belongs to the boot loader.
Definition kip:60
@ Kmem
Kernel memory.
Definition kip:55
static void count(l4_kernel_info_t *kip, unsigned count) noexcept
Set number of memory descriptors.
Definition kip:126
static unsigned long count(l4_kernel_info_t const *kip) noexcept
Return number of memory descriptors stored in the kernel info page.
Definition kip:115
static cxx::static_vector< Mem_desc > all(l4_kernel_info_t *kip)
Return enumerable list of memory descriptors.
Definition kip:147
unsigned long size() const noexcept
Return size of region described by the memory descriptor.
Definition kip:192
static Mem_desc * first(l4_kernel_info_t *kip) noexcept
Get first memory descriptor.
Definition kip:97
unsigned char sub_type() const noexcept
Return sub-type of the memory descriptor.
Definition kip:209
Simple encapsulation for a dynamically allocated array.
Definition static_vector:17
Kernel Info Page access functions.
L4 low-level kernel interface.
L4 Kernel Interface Page.
Definition kip.h:37