Loading...
Searching...
No Matches
kip
Go to the documentation of this file.
// vim:set ft=cpp: -*- Mode: C++ -*-
/*
* (c) 2008-2009 Author(s)
* economic rights: Technische Universität Dresden (Germany)
*
* License: see LICENSE.spdx (in this directory or the directories above)
*/
#pragma once
#include <l4/cxx/static_vector>
#include <l4/sys/kip.h>
/* C++ version of memory descriptors */
namespace L4
{
namespace Kip
{
class Mem_desc
{
public:
enum Mem_type
{
Undefined = 0x0,
Conventional = 0x1,
Reserved = 0x2,
Dedicated = 0x3,
Shared = 0x4,
Info = 0xd,
Bootloader = 0xe,
Arch = 0xf
};
enum Info_sub_type
{
Info_acpi_rsdp = 0
};
enum Arch_sub_type_common
{
Arch_acpi_tables = 3,
Arch_acpi_nvs = 4,
};
private:
unsigned long _l, _h;
public:
static Mem_desc *first(l4_kernel_info_t *kip) noexcept
{
return reinterpret_cast< Mem_desc *>(reinterpret_cast<char *>(kip) + kip->mem_descs);
}
static Mem_desc const *first(l4_kernel_info_t const *kip) noexcept
{
char const *addr = reinterpret_cast<char const *>(kip) + kip->mem_descs;
return reinterpret_cast< Mem_desc const *>(addr);
}
static unsigned long count(l4_kernel_info_t const *kip) noexcept
{
return kip->mem_descs_num;
}
static void count(l4_kernel_info_t *kip, unsigned count) noexcept
{
kip->mem_descs_num = count;
}
static inline cxx::static_vector<Mem_desc const> all(l4_kernel_info_t const *kip)
{
return cxx::static_vector<Mem_desc const>(Mem_desc::first(kip),
Mem_desc::count(kip));
}
static inline cxx::static_vector<Mem_desc> all(l4_kernel_info_t *kip)
{
return cxx::static_vector<Mem_desc>(Mem_desc::first(kip),
Mem_desc::count(kip));
}
Mem_desc(unsigned long start, unsigned long end,
Mem_type t, unsigned char st = 0, bool virt = false,
bool eager = false) noexcept
: _l((start & ~0x3ffUL) | (t & 0x0f) | ((st << 4) & 0x0f0)
| (virt ? 0x0200 : 0x0) | (eager ? 0x100 : 0x0)), _h(end | 0x3ffUL)
{}
unsigned long start() const noexcept { return _l & ~0x3ffUL; }
unsigned long end() const noexcept { return _h | 0x3ffUL; }
unsigned long size() const noexcept { return end() + 1 - start(); }
Mem_type type() const noexcept
{
return static_cast< Mem_type >(_l & 0x0f);
}
unsigned char sub_type() const noexcept { return (_l >> 4) & 0x0f; }
unsigned is_virtual() const noexcept { return _l & 0x200; }
unsigned eager_map() const noexcept { return _l & 0x100; }
void set(unsigned long start, unsigned long end,
Mem_type t, unsigned char st = 0, bool virt = false,
bool eager = false) noexcept
{
_l = (start & ~0x3ffUL) | (t & 0x0f) | ((st << 4) & 0x0f0)
| (virt?0x0200:0x0) | (eager ? 0x0100 : 0x0);
_h = end | 0x3ffUL;
}
};
};
};
L4::Kip::Mem_desc
Memory descriptors stored in the kernel interface page.
Definition kip:43
L4::Kip::Mem_desc::type
Mem_type type() const noexcept
Return type of the memory descriptor.
Definition kip:191
L4::Kip::Mem_desc::end
unsigned long end() const noexcept
Return end address of memory descriptor.
Definition kip:177
L4::Kip::Mem_desc::all
static cxx::static_vector< Mem_desc const > all(l4_kernel_info_t const *kip)
Return enumerable list of memory descriptors.
Definition kip:128
L4::Kip::Mem_desc::start
unsigned long start() const noexcept
Return start address of memory descriptor.
Definition kip:170
L4::Kip::Mem_desc::Arch_sub_type_common
Arch_sub_type_common
Common sub types across all architectures for the Mem_type::Arch type.
Definition kip:73
L4::Kip::Mem_desc::Arch_acpi_tables
@ Arch_acpi_tables
Firmware ACPI tables.
Definition kip:74
L4::Kip::Mem_desc::Arch_acpi_nvs
@ Arch_acpi_nvs
Firmware reserved address space.
Definition kip:75
L4::Kip::Mem_desc::set
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
L4::Kip::Mem_desc::is_virtual
unsigned is_virtual() const noexcept
Return whether the memory descriptor describes a virtual or physical region.
Definition kip:209
L4::Kip::Mem_desc::Info_sub_type
Info_sub_type
Memory sub types for the Mem_type::Info type.
Definition kip:65
L4::Kip::Mem_desc::Info_acpi_rsdp
@ Info_acpi_rsdp
Physical address of the ACPI root pointer.
Definition kip:66
L4::Kip::Mem_desc::Mem_desc
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
L4::Kip::Mem_desc::eager_map
unsigned eager_map() const noexcept
Return whether the region shall be eligible for eager mapping in sigma0 or the root task.
Definition kip:215
L4::Kip::Mem_desc::Mem_type
Mem_type
Memory types.
Definition kip:49
L4::Kip::Mem_desc::Reserved
@ Reserved
Reserved region, do not use this memory.
Definition kip:52
L4::Kip::Mem_desc::Shared
@ Shared
Shared.
Definition kip:54
L4::Kip::Mem_desc::Dedicated
@ Dedicated
Dedicated.
Definition kip:53
L4::Kip::Mem_desc::Conventional
@ Conventional
Conventional memory.
Definition kip:51
L4::Kip::Mem_desc::Info
@ Info
Info by boot loader.
Definition kip:56
L4::Kip::Mem_desc::Undefined
@ Undefined
Undefined memory.
Definition kip:50
L4::Kip::Mem_desc::Arch
@ Arch
Architecture specific memory.
Definition kip:58
L4::Kip::Mem_desc::Bootloader
@ Bootloader
Memory belongs to the boot loader.
Definition kip:57
L4::Kip::Mem_desc::count
static void count(l4_kernel_info_t *kip, unsigned count) noexcept
Set number of memory descriptors.
Definition kip:118
L4::Kip::Mem_desc::count
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
L4::Kip::Mem_desc::all
static cxx::static_vector< Mem_desc > all(l4_kernel_info_t *kip)
Return enumerable list of memory descriptors.
Definition kip:139
L4::Kip::Mem_desc::size
unsigned long size() const noexcept
Return size of region described by the memory descriptor.
Definition kip:184
L4::Kip::Mem_desc::first
static Mem_desc * first(l4_kernel_info_t *kip) noexcept
Get first memory descriptor.
Definition kip:89
L4::Kip::Mem_desc::sub_type
unsigned char sub_type() const noexcept
Return sub-type of the memory descriptor.
Definition kip:201
cxx::static_vector
Simple encapsulation for a dynamically allocated array.
Definition static_vector:17
L4
L4 low-level kernel interface.
Definition l4sys-l4f-groups.dox:50
l4_kernel_info_t
L4 Kernel Interface Page.
Definition kip.h:37
kip.h
Kernel Info Page access functions.