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
56 Info = 0xd,
57 Bootloader = 0xe,
58 Arch = 0xf
59 };
60
72
81
82 private:
83 unsigned long _l, _h;
84
85 public:
93 static Mem_desc *first(l4_kernel_info_t *kip) noexcept
94 {
95 return reinterpret_cast<Mem_desc *>(reinterpret_cast<char *>(kip) + kip->mem_descs);
96 }
97
98 static Mem_desc const *first(l4_kernel_info_t const *kip) noexcept
99 {
100 char const *addr = reinterpret_cast<char const *>(kip) + kip->mem_descs;
101 return reinterpret_cast<Mem_desc const *>(addr);
102 }
103
111 static unsigned long count(l4_kernel_info_t const *kip) noexcept
112 {
113 return kip->mem_descs_num;
114 }
115
122 static void count(l4_kernel_info_t *kip, unsigned count) noexcept
123 {
124 kip->mem_descs_num = count;
125 }
126
137
148
162 Mem_desc(unsigned long start, unsigned long end,
163 Mem_type t, unsigned char st = 0, bool virt = false,
164 bool eager = false) noexcept
165 : _l((start & ~0x3ffUL) | (t & 0x0f) | ((st << 4) & 0x0f0)
166 | (virt ? 0x0200 : 0x0) | (eager ? 0x100 : 0x0)), _h(end | 0x3ffUL)
167 {}
168
174 unsigned long start() const noexcept { return _l & ~0x3ffUL; }
175
181 unsigned long end() const noexcept { return _h | 0x3ffUL; }
182
188 unsigned long size() const noexcept { return end() + 1 - start(); }
189
195 Mem_type type() const noexcept
196 {
197 return static_cast<Mem_type>(_l & 0x0f);
198 }
199
205 unsigned char sub_type() const noexcept { return (_l >> 4) & 0x0f; }
206
213 unsigned is_virtual() const noexcept { return _l & 0x200; }
214
219 unsigned eager_map() const noexcept { return _l & 0x100; }
220
233 void set(unsigned long start, unsigned long end,
234 Mem_type t, unsigned char st = 0, bool virt = false,
235 bool eager = false) noexcept
236 {
237 _l = (start & ~0x3ffUL) | (t & 0x0f) | ((st << 4) & 0x0f0)
238 | (virt?0x0200:0x0) | (eager ? 0x0100 : 0x0);
239
240 _h = end | 0x3ffUL;
241 }
242
243 };
244 };
245};
Memory descriptors stored in the kernel interface page.
Definition kip:43
Mem_type type() const noexcept
Return type of the memory descriptor.
Definition kip:195
unsigned long end() const noexcept
Return end address of memory descriptor.
Definition kip:181
static cxx::static_vector< Mem_desc const > all(l4_kernel_info_t const *kip)
Return enumerable list of memory descriptors.
Definition kip:132
unsigned long start() const noexcept
Return start address of memory descriptor.
Definition kip:174
Arch_sub_type_common
Common sub types across all architectures for the Mem_type::Arch type.
Definition kip:77
@ Arch_acpi_tables
Firmware ACPI tables.
Definition kip:78
@ Arch_acpi_nvs
Firmware reserved address space.
Definition kip:79
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:233
unsigned is_virtual() const noexcept
Return whether the memory descriptor describes a virtual or physical region.
Definition kip:213
Info_sub_type
Memory sub types for the Mem_type::Info type.
Definition kip:65
@ Reserved_mmio
MMIO range reserved by kernel.
Definition kip:70
@ Info_acpi_rsdp
Physical address of the ACPI root pointer.
Definition kip:66
@ Reserved_heap
Kernel heap.
Definition kip:69
@ Reserved_kernel
Kernel image.
Definition kip:68
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:162
unsigned eager_map() const noexcept
Return whether the region shall be eligible for eager mapping in sigma0 or the root task.
Definition kip:219
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:56
@ Undefined
Undefined memory.
Definition kip:50
@ Arch
Architecture specific memory.
Definition kip:58
@ Bootloader
Memory belongs to the boot loader.
Definition kip:57
static void count(l4_kernel_info_t *kip, unsigned count) noexcept
Set number of memory descriptors.
Definition kip:122
static unsigned long count(l4_kernel_info_t const *kip) noexcept
Return number of memory descriptors stored in the kernel info page.
Definition kip:111
static cxx::static_vector< Mem_desc > all(l4_kernel_info_t *kip)
Return enumerable list of memory descriptors.
Definition kip:143
unsigned long size() const noexcept
Return size of region described by the memory descriptor.
Definition kip:188
static Mem_desc * first(l4_kernel_info_t *kip) noexcept
Get first memory descriptor.
Definition kip:93
unsigned char sub_type() const noexcept
Return sub-type of the memory descriptor.
Definition kip:205
Simple encapsulation for a dynamically allocated array.
Definition static_vector:17
L4 low-level kernel interface.
L4 Kernel Interface Page.
Definition kip.h:37
Kernel Info Page access functions.