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
65 {
67 };
68
77
78 private:
79 unsigned long _l, _h;
80
81 public:
89 static Mem_desc *first(l4_kernel_info_t *kip) noexcept
90 {
91 return reinterpret_cast<Mem_desc *>(reinterpret_cast<char *>(kip) + kip->mem_descs);
92 }
93
94 static Mem_desc const *first(l4_kernel_info_t const *kip) noexcept
95 {
96 char const *addr = reinterpret_cast<char const *>(kip) + kip->mem_descs;
97 return reinterpret_cast<Mem_desc const *>(addr);
98 }
99
107 static unsigned long count(l4_kernel_info_t const *kip) noexcept
108 {
109 return kip->mem_descs_num;
110 }
111
118 static void count(l4_kernel_info_t *kip, unsigned count) noexcept
119 {
120 kip->mem_descs_num = count;
121 }
122
133
144
158 Mem_desc(unsigned long start, unsigned long end,
159 Mem_type t, unsigned char st = 0, bool virt = false,
160 bool eager = false) noexcept
161 : _l((start & ~0x3ffUL) | (t & 0x0f) | ((st << 4) & 0x0f0)
162 | (virt ? 0x0200 : 0x0) | (eager ? 0x100 : 0x0)), _h(end | 0x3ffUL)
163 {}
164
170 unsigned long start() const noexcept { return _l & ~0x3ffUL; }
171
177 unsigned long end() const noexcept { return _h | 0x3ffUL; }
178
184 unsigned long size() const noexcept { return end() + 1 - start(); }
185
191 Mem_type type() const noexcept
192 {
193 return static_cast<Mem_type>(_l & 0x0f);
194 }
195
201 unsigned char sub_type() const noexcept { return (_l >> 4) & 0x0f; }
202
209 unsigned is_virtual() const noexcept { return _l & 0x200; }
210
215 unsigned eager_map() const noexcept { return _l & 0x100; }
216
229 void set(unsigned long start, unsigned long end,
230 Mem_type t, unsigned char st = 0, bool virt = false,
231 bool eager = false) noexcept
232 {
233 _l = (start & ~0x3ffUL) | (t & 0x0f) | ((st << 4) & 0x0f0)
234 | (virt?0x0200:0x0) | (eager ? 0x0100 : 0x0);
235
236 _h = end | 0x3ffUL;
237 }
238
239 };
240 };
241};
Memory descriptors stored in the kernel interface page.
Definition kip:43
Mem_type type() const noexcept
Return type of the memory descriptor.
Definition kip:191
unsigned long end() const noexcept
Return end address of memory descriptor.
Definition kip:177
static cxx::static_vector< Mem_desc const > all(l4_kernel_info_t const *kip)
Return enumerable list of memory descriptors.
Definition kip:128
unsigned long start() const noexcept
Return start address of memory descriptor.
Definition kip:170
Arch_sub_type_common
Common sub types across all architectures for the Mem_type::Arch type.
Definition kip:73
@ Arch_acpi_tables
Firmware ACPI tables.
Definition kip:74
@ Arch_acpi_nvs
Firmware reserved address space.
Definition kip:75
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:229
unsigned is_virtual() const noexcept
Return whether the memory descriptor describes a virtual or physical region.
Definition kip:209
Info_sub_type
Memory sub types for the Mem_type::Info type.
Definition kip:65
@ Info_acpi_rsdp
Physical address of the ACPI root pointer.
Definition kip:66
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:158
unsigned eager_map() const noexcept
Return whether the region shall be eligible for eager mapping in sigma0 or the root task.
Definition kip:215
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:118
static unsigned long count(l4_kernel_info_t const *kip) noexcept
Return number of memory descriptors stored in the kernel info page.
Definition kip:107
static cxx::static_vector< Mem_desc > all(l4_kernel_info_t *kip)
Return enumerable list of memory descriptors.
Definition kip:139
unsigned long size() const noexcept
Return size of region described by the memory descriptor.
Definition kip:184
static Mem_desc * first(l4_kernel_info_t *kip) noexcept
Get first memory descriptor.
Definition kip:89
unsigned char sub_type() const noexcept
Return sub-type of the memory descriptor.
Definition kip:201
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.