mirror of
https://github.com/mmueller41/genode.git
synced 2026-01-21 12:32:56 +01:00
base: avoid implicit conversions
This patch is a prerequisite for compiling the code with the warnings -Wconversion enabled. Issue #23
This commit is contained in:
@@ -34,14 +34,14 @@ class Genode::Cnode_base
|
||||
private:
|
||||
|
||||
Cap_sel const _sel;
|
||||
size_t const _size_log2;
|
||||
uint8_t const _size_log2;
|
||||
|
||||
public:
|
||||
|
||||
typedef Cnode_index Index;
|
||||
|
||||
Cap_sel sel() const { return _sel; }
|
||||
size_t size_log2() const { return _size_log2; }
|
||||
uint8_t size_log2() const { return _size_log2; }
|
||||
|
||||
/**
|
||||
* Copy selector from another CNode
|
||||
@@ -60,7 +60,7 @@ class Genode::Cnode_base
|
||||
src_root, src_index, src_depth, rights);
|
||||
if (ret != 0) {
|
||||
warning(__FUNCTION__, ": seL4_CNode_Copy (",
|
||||
(void*)from_idx.value(), ") returned ", ret);
|
||||
Hex(from_idx.value()), ") returned ", ret);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ class Genode::Cnode_base
|
||||
src_root, src_index, src_depth);
|
||||
if (ret != 0) {
|
||||
warning(__FUNCTION__, ": seL4_CNode_Move (",
|
||||
(void*)from_idx.value(), ") returned ", ret);
|
||||
Hex(from_idx.value()), ") returned ", ret);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ class Genode::Cnode_base
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Cnode_base(Cap_sel sel, size_t size_log2)
|
||||
Cnode_base(Cap_sel sel, uint8_t size_log2)
|
||||
: _sel(sel), _size_log2(size_log2) { }
|
||||
};
|
||||
|
||||
@@ -154,7 +154,7 @@ class Genode::Cnode : public Cnode_base, Noncopyable
|
||||
*
|
||||
* \deprecated
|
||||
*/
|
||||
Cnode(Cap_sel parent_sel, Index dst_idx, size_t size_log2,
|
||||
Cnode(Cap_sel parent_sel, Index dst_idx, uint8_t size_log2,
|
||||
Range_allocator &phys_alloc)
|
||||
:
|
||||
Cnode_base(dst_idx, size_log2)
|
||||
@@ -178,7 +178,7 @@ class Genode::Cnode : public Cnode_base, Noncopyable
|
||||
* \throw Retype_untyped_failed
|
||||
* \throw Initial_untyped_pool::Initial_untyped_pool_exhausted
|
||||
*/
|
||||
Cnode(Cap_sel parent_sel, Index dst_idx, size_t size_log2,
|
||||
Cnode(Cap_sel parent_sel, Index dst_idx, uint8_t size_log2,
|
||||
Initial_untyped_pool &untyped_pool)
|
||||
:
|
||||
Cnode_base(dst_idx, size_log2)
|
||||
|
||||
@@ -34,13 +34,13 @@ class Genode::Core_cspace
|
||||
};
|
||||
|
||||
/* selectors for initially created CNodes during core bootup */
|
||||
static inline unsigned long top_cnode_sel() { return sel4_boot_info().empty.start; }
|
||||
static inline unsigned long core_pad_cnode_sel() { return top_cnode_sel() + 1; }
|
||||
static inline unsigned long core_cnode_sel() { return core_pad_cnode_sel() + 1; }
|
||||
static inline unsigned long phys_cnode_sel() { return core_cnode_sel() + 1; }
|
||||
static inline unsigned long untyped_cnode_4k() { return phys_cnode_sel() + 1; }
|
||||
static inline unsigned long untyped_cnode_16k() { return untyped_cnode_4k() + 1; }
|
||||
static unsigned long core_static_sel_end() { return untyped_cnode_16k() + 1; }
|
||||
static unsigned top_cnode_sel() { return (unsigned)sel4_boot_info().empty.start; }
|
||||
static unsigned core_pad_cnode_sel() { return top_cnode_sel() + 1; }
|
||||
static unsigned core_cnode_sel() { return core_pad_cnode_sel() + 1; }
|
||||
static unsigned phys_cnode_sel() { return core_cnode_sel() + 1; }
|
||||
static unsigned untyped_cnode_4k() { return phys_cnode_sel() + 1; }
|
||||
static unsigned untyped_cnode_16k() { return untyped_cnode_4k() + 1; }
|
||||
static unsigned core_static_sel_end() { return untyped_cnode_16k() + 1; }
|
||||
|
||||
/* indices within top-level CNode */
|
||||
enum Top_cnode_idx {
|
||||
|
||||
@@ -48,7 +48,7 @@ class Genode::Initial_untyped_pool
|
||||
unsigned const sel;
|
||||
|
||||
/* index into 'untypedSizeBitsList' */
|
||||
unsigned const index = sel - sel4_boot_info().untyped.start;
|
||||
unsigned const index = (unsigned)(sel - sel4_boot_info().untyped.start);
|
||||
|
||||
/* original size of untyped memory range */
|
||||
size_t const size = 1UL << sel4_boot_info().untypedList[index].sizeBits;
|
||||
@@ -72,7 +72,7 @@ class Genode::Initial_untyped_pool
|
||||
/**
|
||||
* Calculate free index after allocation
|
||||
*/
|
||||
addr_t _align_offset(Range &range, size_t size_log2)
|
||||
addr_t _align_offset(Range &range, unsigned size_log2)
|
||||
{
|
||||
/*
|
||||
* The seL4 kernel naturally aligns allocations within untuped
|
||||
@@ -94,8 +94,8 @@ class Genode::Initial_untyped_pool
|
||||
void for_each_range(FUNC const &func)
|
||||
{
|
||||
seL4_BootInfo const &bi = sel4_boot_info();
|
||||
for (unsigned sel = bi.untyped.start; sel < bi.untyped.end; sel++) {
|
||||
Range range(*this, sel);
|
||||
for (addr_t sel = bi.untyped.start; sel < bi.untyped.end; sel++) {
|
||||
Range range(*this, (unsigned)sel);
|
||||
func(range);
|
||||
}
|
||||
}
|
||||
@@ -115,7 +115,7 @@ class Genode::Initial_untyped_pool
|
||||
*
|
||||
* \throw Initial_untyped_pool_exhausted
|
||||
*/
|
||||
unsigned alloc(size_t size_log2)
|
||||
unsigned alloc(unsigned size_log2)
|
||||
{
|
||||
enum { UNKNOWN = 0 };
|
||||
unsigned sel = UNKNOWN;
|
||||
@@ -177,10 +177,10 @@ class Genode::Initial_untyped_pool
|
||||
* objects of size_log2 and up to a maximum as specified by max_memory
|
||||
*/
|
||||
template <typename FUNC>
|
||||
void turn_into_untyped_object(addr_t const node_index,
|
||||
FUNC const & func,
|
||||
addr_t const size_log2 = get_page_size_log2(),
|
||||
addr_t max_memory = 0UL - 0x1000UL)
|
||||
void turn_into_untyped_object(addr_t const node_index,
|
||||
FUNC const & func,
|
||||
uint8_t const size_log2 = get_page_size_log2(),
|
||||
addr_t max_memory = 0UL - 0x1000UL)
|
||||
{
|
||||
for_each_range([&] (Range &range) {
|
||||
|
||||
@@ -222,7 +222,9 @@ class Genode::Initial_untyped_pool
|
||||
|
||||
/* XXX skip memory because of limited untyped cnode range */
|
||||
if (node_offset >= (1UL << (32 - get_page_size_log2()))) {
|
||||
Genode::warning(range.device ? "device" : " ", " memory in range ", Hex_range<addr_t>(range.phys, range.size), " is unavailable (due to limited untyped cnode range)");
|
||||
warning(range.device ? "device" : " ", " memory in range ",
|
||||
Hex_range<addr_t>(range.phys, range.size),
|
||||
" is unavailable (due to limited untyped cnode range)");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Genode {
|
||||
*/
|
||||
struct Cnode_index : Cap_sel
|
||||
{
|
||||
explicit Cnode_index(addr_t value) : Cap_sel(value) { }
|
||||
explicit Cnode_index(uint32_t value) : Cap_sel(value) { }
|
||||
|
||||
Cnode_index(Cap_sel sel) : Cap_sel(sel.value()) { }
|
||||
};
|
||||
@@ -84,16 +84,16 @@ namespace Genode {
|
||||
template <typename KOBJ>
|
||||
static void create(seL4_Untyped const service,
|
||||
Cap_sel const dst_cnode_sel,
|
||||
Cnode_index dst_idx,
|
||||
size_t size_log2 = 0)
|
||||
Cnode_index const dst_idx,
|
||||
uint8_t const size_log2 = 0)
|
||||
{
|
||||
int const type = KOBJ::SEL4_TYPE;
|
||||
int const size_bits = size_log2;
|
||||
seL4_CNode const root = dst_cnode_sel.value();
|
||||
int const node_index = 0;
|
||||
int const node_depth = 0;
|
||||
int const node_offset = dst_idx.value();
|
||||
int const num_objects = 1;
|
||||
unsigned const type = KOBJ::SEL4_TYPE;
|
||||
uint8_t const size_bits = size_log2;
|
||||
seL4_CNode const root = dst_cnode_sel.value();
|
||||
unsigned const node_index = 0;
|
||||
unsigned const node_depth = 0;
|
||||
unsigned const node_offset = dst_idx.value();
|
||||
unsigned const num_objects = 1;
|
||||
|
||||
int const ret = seL4_Untyped_Retype(service,
|
||||
type,
|
||||
|
||||
@@ -220,23 +220,23 @@ class Genode::Page_table_registry
|
||||
|
||||
bool page_frame_at(addr_t const vaddr) {
|
||||
return Frame::lookup(_frames, vaddr, LEVEL_0); }
|
||||
bool page_table_at(addr_t const vaddr, addr_t const level_log2) {
|
||||
bool page_table_at(addr_t const vaddr, unsigned const level_log2) {
|
||||
return Table::lookup(_level1, vaddr, level_log2); }
|
||||
bool page_directory_at(addr_t const vaddr, addr_t const level_log2) {
|
||||
bool page_directory_at(addr_t const vaddr, unsigned const level_log2) {
|
||||
return Table::lookup(_level2, vaddr, level_log2); }
|
||||
bool page_level3_at(addr_t const vaddr, addr_t const level_log2) {
|
||||
bool page_level3_at(addr_t const vaddr, unsigned const level_log2) {
|
||||
return Table::lookup(_level3, vaddr, level_log2); }
|
||||
|
||||
void insert_page_frame(addr_t const vaddr, Cap_sel const sel) {
|
||||
_insert(vaddr, sel, Level::FRAME, 0, LEVEL_0); }
|
||||
void insert_page_table(addr_t const vaddr, Cap_sel const sel,
|
||||
addr_t const paddr, addr_t const level_log2) {
|
||||
addr_t const paddr, unsigned const level_log2) {
|
||||
_insert(vaddr, sel, Level::PAGE_TABLE, paddr, level_log2); }
|
||||
void insert_page_directory(addr_t const vaddr, Cap_sel const sel,
|
||||
addr_t const paddr, addr_t const level_log2) {
|
||||
addr_t const paddr, unsigned const level_log2) {
|
||||
_insert(vaddr, sel, Level::LEVEL2, paddr, level_log2); }
|
||||
void insert_page_level3(addr_t const vaddr, Cap_sel const sel,
|
||||
addr_t const paddr, addr_t const level_log2) {
|
||||
addr_t const paddr, unsigned const level_log2) {
|
||||
_insert(vaddr, sel, Level::LEVEL3, paddr, level_log2); }
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
namespace Genode {
|
||||
class Platform;
|
||||
template <Genode::size_t> class Static_allocator;
|
||||
template <auto> class Static_allocator;
|
||||
class Address_space;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Genode {
|
||||
*
|
||||
* The size of a single ELEM must be a multiple of sizeof(long).
|
||||
*/
|
||||
template <Genode::size_t MAX>
|
||||
template <auto MAX>
|
||||
class Genode::Static_allocator : public Allocator
|
||||
{
|
||||
private:
|
||||
@@ -69,7 +69,7 @@ class Genode::Static_allocator : public Allocator
|
||||
void free(void *ptr, size_t) override
|
||||
{
|
||||
Elem_space *elem = reinterpret_cast<Elem_space *>(ptr);
|
||||
unsigned const index = elem - &_elements[0];
|
||||
unsigned const index = (unsigned)(elem - &_elements[0]);
|
||||
_used.free(index);
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ class Genode::Platform : public Platform_generic
|
||||
Mutex::Guard guard(_mutex);
|
||||
|
||||
try {
|
||||
return Cap_sel(Core_sel_bit_alloc::alloc()); }
|
||||
return Cap_sel((uint32_t)Core_sel_bit_alloc::alloc()); }
|
||||
catch (Bit_allocator::Out_of_indices) {
|
||||
throw Alloc_failed(); }
|
||||
}
|
||||
@@ -246,7 +246,7 @@ class Genode::Platform : public Platform_generic
|
||||
Rom_fs &rom_fs() override { return _rom_fs; }
|
||||
|
||||
Affinity::Space affinity_space() const override {
|
||||
return sel4_boot_info().numNodes; }
|
||||
return (unsigned)sel4_boot_info().numNodes; }
|
||||
|
||||
bool supports_direct_unmap() const override { return true; }
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ struct Genode::Untyped_memory
|
||||
addr_t size_log2 = get_page_size_log2())
|
||||
{
|
||||
unsigned const upper_bits = top_idx << Core_cspace::NUM_PHYS_SEL_LOG2;
|
||||
unsigned const lower_bits = phys_addr >> size_log2;
|
||||
unsigned const lower_bits = (unsigned)(phys_addr >> size_log2);
|
||||
|
||||
return Cap_sel(upper_bits | lower_bits);
|
||||
}
|
||||
@@ -141,7 +141,8 @@ struct Genode::Untyped_memory
|
||||
for (addr_t phys = phys_addr; phys < phys_addr + phys_size;
|
||||
phys += get_page_size()) {
|
||||
|
||||
int const index = phys >> get_page_size_log2();
|
||||
unsigned const index = (unsigned)(phys >> get_page_size_log2());
|
||||
|
||||
/**
|
||||
* Without the revoke, one gets sporadically
|
||||
* Untyped Retype: Insufficient memory ( xx bytes needed, x bytes
|
||||
|
||||
@@ -166,8 +166,10 @@ class Genode::Vm_space
|
||||
/**
|
||||
* Return selector for a capability slot within '_vm_cnodes'
|
||||
*/
|
||||
addr_t _idx_to_sel(addr_t idx) const { return (_id << 20) | idx; }
|
||||
|
||||
Cap_sel _idx_to_sel(addr_t idx) const
|
||||
{
|
||||
return Cap_sel((uint32_t)((_id << 20) | idx));
|
||||
}
|
||||
|
||||
template <typename FN>
|
||||
void _flush(bool const flush_support, FN const &fn)
|
||||
@@ -181,10 +183,8 @@ class Genode::Vm_space
|
||||
_pd_label.string());
|
||||
|
||||
_page_table_registry.flush_pages(fn);
|
||||
|
||||
}
|
||||
|
||||
|
||||
template <typename FN>
|
||||
bool _map_frame(addr_t const from_phys, addr_t const to_dest,
|
||||
Map_attr const attr, bool guest, FN const &fn)
|
||||
@@ -201,13 +201,13 @@ class Genode::Vm_space
|
||||
return true;
|
||||
}
|
||||
/* allocate page-table-entry selector */
|
||||
addr_t pte_idx;
|
||||
try { pte_idx = _sel_alloc.alloc(); }
|
||||
uint32_t pte_idx = 0;
|
||||
try { pte_idx = (uint32_t)_sel_alloc.alloc(); }
|
||||
catch (Selector_allocator::Out_of_indices) {
|
||||
|
||||
/* free all page-table-entry selectors and retry once */
|
||||
_flush(attr.flush_support, fn);
|
||||
pte_idx = _sel_alloc.alloc();
|
||||
pte_idx = (uint32_t)_sel_alloc.alloc();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -217,7 +217,7 @@ class Genode::Vm_space
|
||||
* inserted into only a single page table.
|
||||
*/
|
||||
_leaf_cnode(pte_idx).copy(_phys_cnode,
|
||||
Cnode_index(from_phys >> get_page_size_log2()),
|
||||
Cnode_index((uint32_t)(from_phys >> get_page_size_log2())),
|
||||
Cnode_index(_leaf_cnode_entry(pte_idx)));
|
||||
|
||||
/* remember relationship between pte_sel and the virtual address */
|
||||
@@ -256,11 +256,11 @@ class Genode::Vm_space
|
||||
*/
|
||||
template <typename KOBJ>
|
||||
Cap_sel _alloc_and_map(addr_t const virt,
|
||||
long (&map_fn)(Cap_sel, Cap_sel, addr_t),
|
||||
addr_t &phys)
|
||||
long (&map_fn)(Cap_sel, Cap_sel, addr_t),
|
||||
addr_t &phys)
|
||||
{
|
||||
/* allocate page-* selector */
|
||||
addr_t const idx = _sel_alloc.alloc();
|
||||
uint32_t const idx = (uint32_t)_sel_alloc.alloc();
|
||||
|
||||
try {
|
||||
phys = Untyped_memory::alloc_page(_phys_alloc);
|
||||
@@ -272,7 +272,7 @@ class Genode::Vm_space
|
||||
throw Alloc_page_table_failed();
|
||||
}
|
||||
|
||||
Cap_sel const pt_sel(_idx_to_sel(idx));
|
||||
Cap_sel const pt_sel = _idx_to_sel(idx);
|
||||
|
||||
long const result = map_fn(pt_sel, _pd_sel, virt);
|
||||
if (result != seL4_NoError)
|
||||
|
||||
@@ -101,7 +101,7 @@ Irq_object::Irq_object(unsigned irq)
|
||||
Irq_session_component::Irq_session_component(Range_allocator &irq_alloc,
|
||||
const char *args)
|
||||
:
|
||||
_irq_number(Arg_string::find_arg(args, "irq_number").long_value(-1)),
|
||||
_irq_number((unsigned)Arg_string::find_arg(args, "irq_number").long_value(-1)),
|
||||
_irq_alloc(irq_alloc),
|
||||
_irq_object(_irq_number)
|
||||
{
|
||||
|
||||
@@ -58,8 +58,7 @@ extern unsigned _prog_img_beg, _prog_img_end;
|
||||
** Support for core memory management **
|
||||
****************************************/
|
||||
|
||||
bool Mapped_mem_allocator::_map_local(addr_t virt_addr, addr_t phys_addr,
|
||||
unsigned size)
|
||||
bool Mapped_mem_allocator::_map_local(addr_t virt_addr, addr_t phys_addr, size_t size)
|
||||
{
|
||||
if (platform_in_construction)
|
||||
Genode::warning("need physical memory, but Platform object not constructed yet");
|
||||
@@ -72,8 +71,7 @@ bool Mapped_mem_allocator::_map_local(addr_t virt_addr, addr_t phys_addr,
|
||||
}
|
||||
|
||||
|
||||
bool Mapped_mem_allocator::_unmap_local(addr_t virt_addr, addr_t phys_addr,
|
||||
unsigned size)
|
||||
bool Mapped_mem_allocator::_unmap_local(addr_t virt_addr, addr_t phys_addr, size_t size)
|
||||
{
|
||||
if (!unmap_local(virt_addr, size / get_page_size()))
|
||||
return false;
|
||||
@@ -197,16 +195,16 @@ void Platform::_switch_to_core_cspace()
|
||||
*
|
||||
* <<seL4: Error deriving cap for CNode Copy operation.>>
|
||||
*/
|
||||
for (unsigned sel = bi.untyped.start; sel < bi.untyped.end; sel++)
|
||||
_core_cnode.move(initial_cspace, Cnode_index(sel));
|
||||
for (addr_t sel = bi.untyped.start; sel < bi.untyped.end; sel++)
|
||||
_core_cnode.move(initial_cspace, Cnode_index((uint32_t)sel));
|
||||
|
||||
/* move selectors of core image */
|
||||
addr_t const modules_start = reinterpret_cast<addr_t>(&_boot_modules_binaries_begin);
|
||||
addr_t const modules_end = reinterpret_cast<addr_t>(&_boot_modules_binaries_end);
|
||||
addr_t virt_addr = (addr_t)(&_prog_img_beg);
|
||||
|
||||
for (unsigned sel = bi.userImageFrames.start;
|
||||
sel < bi.userImageFrames.end;
|
||||
for (unsigned sel = (unsigned)bi.userImageFrames.start;
|
||||
sel < (unsigned)bi.userImageFrames.end;
|
||||
sel++, virt_addr += get_page_size()) {
|
||||
|
||||
/* remove mapping to boot modules, no access required within core */
|
||||
@@ -336,8 +334,8 @@ void Platform::_init_rom_modules()
|
||||
*/
|
||||
Cnode_base const initial_cspace(Cap_sel(seL4_CapInitThreadCNode), 32);
|
||||
for (unsigned i = 0; i < module_num_frames; i++)
|
||||
_phys_cnode.move(initial_cspace, Cnode_index(module_frame_sel + i),
|
||||
Cnode_index(dst_frame + i));
|
||||
_phys_cnode.move(initial_cspace, Cnode_index((uint32_t)module_frame_sel + i),
|
||||
Cnode_index((uint32_t)dst_frame + i));
|
||||
|
||||
log("boot module '", (char const *)header->name, "' "
|
||||
"(", header->size, " bytes)");
|
||||
|
||||
@@ -148,7 +148,7 @@ Cap_sel Platform_pd::alloc_sel()
|
||||
{
|
||||
Mutex::Guard guard(_sel_alloc_mutex);
|
||||
|
||||
return Cap_sel(_sel_alloc.alloc());
|
||||
return Cap_sel((uint32_t)_sel_alloc.alloc());
|
||||
}
|
||||
|
||||
|
||||
@@ -191,7 +191,7 @@ void Platform_pd::flush(addr_t virt_addr, size_t size, Core_local_addr)
|
||||
|
||||
Platform_pd::Platform_pd(Allocator &md_alloc, char const *label)
|
||||
:
|
||||
_id(pd_id_alloc().alloc()),
|
||||
_id((uint32_t)pd_id_alloc().alloc()),
|
||||
_page_table_registry(md_alloc),
|
||||
_page_directory_sel(platform_specific().core_sel_alloc().alloc()),
|
||||
_page_directory(_init_page_directory()),
|
||||
|
||||
@@ -222,7 +222,7 @@ Platform_thread::Platform_thread(size_t, const char *name, unsigned priority,
|
||||
_utcb(utcb),
|
||||
_pager_obj_sel(platform_specific().core_sel_alloc().alloc()),
|
||||
_location(location),
|
||||
_priority(Cpu_session::scale_priority(CONFIG_NUM_PRIORITIES, priority))
|
||||
_priority((uint16_t)(Cpu_session::scale_priority(CONFIG_NUM_PRIORITIES, priority)))
|
||||
|
||||
{
|
||||
static_assert(CONFIG_NUM_PRIORITIES == 256, " unknown priority configuration");
|
||||
|
||||
@@ -44,7 +44,7 @@ void Signal_source_component::submit(Signal_context_component &context,
|
||||
* signal will be delivered as result of the next
|
||||
* 'wait_for_signal' call.
|
||||
*/
|
||||
context.increment_signal_cnt(cnt);
|
||||
context.increment_signal_cnt((int)cnt);
|
||||
|
||||
if (context.enqueued())
|
||||
return;
|
||||
|
||||
@@ -29,7 +29,7 @@ long Genode::Vm_space::_map_page(Genode::Cap_sel const &idx,
|
||||
Map_attr const map_attr,
|
||||
bool)
|
||||
{
|
||||
seL4_ARM_Page const service = _idx_to_sel(idx.value());
|
||||
seL4_ARM_Page const service = _idx_to_sel(idx.value()).value();
|
||||
seL4_ARM_PageDirectory const pd = _pd_sel.value();
|
||||
seL4_CapRights_t const rights = map_attr.writeable
|
||||
? seL4_ReadWrite : seL4_CanRead;
|
||||
@@ -47,7 +47,7 @@ long Genode::Vm_space::_map_page(Genode::Cap_sel const &idx,
|
||||
|
||||
long Genode::Vm_space::_unmap_page(Genode::Cap_sel const &idx)
|
||||
{
|
||||
seL4_ARM_Page const service = _idx_to_sel(idx.value());
|
||||
seL4_ARM_Page const service = _idx_to_sel(idx.value()).value();
|
||||
return seL4_ARM_Page_Unmap(service);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ long Genode::Vm_space::_invalidate_page(Genode::Cap_sel const &idx,
|
||||
seL4_Word const start,
|
||||
seL4_Word const end)
|
||||
{
|
||||
seL4_ARM_Page const service = _idx_to_sel(idx.value());
|
||||
seL4_ARM_Page const service = _idx_to_sel(idx.value()).value();
|
||||
long error = seL4_ARM_Page_CleanInvalidate_Data(service, 0, end - start);
|
||||
|
||||
if (error == seL4_NoError) {
|
||||
|
||||
@@ -17,14 +17,12 @@
|
||||
/* core includes */
|
||||
#include <io_port_session_component.h>
|
||||
|
||||
#include <sel4/sel4.h>
|
||||
/* base-internal includes */
|
||||
#include <base/internal/sel4.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
/**************
|
||||
** Port API **
|
||||
**************/
|
||||
unsigned char Io_port_session_component::inb(unsigned short address)
|
||||
{
|
||||
/* check boundaries */
|
||||
|
||||
@@ -101,7 +101,7 @@ try
|
||||
_ep(ep),
|
||||
_constrained_md_ram_alloc(ram, _ram_quota_guard(), _cap_quota_guard()),
|
||||
_heap(_constrained_md_ram_alloc, local_rm),
|
||||
_pd_id(Platform_pd::pd_id_alloc().alloc()),
|
||||
_pd_id((uint32_t)Platform_pd::pd_id_alloc().alloc()),
|
||||
_vm_page_table(platform_specific().core_sel_alloc().alloc()),
|
||||
_vm_space(_vm_page_table,
|
||||
platform_specific().core_sel_alloc(),
|
||||
|
||||
@@ -19,7 +19,7 @@ long Genode::Vm_space::_map_page(Genode::Cap_sel const &idx,
|
||||
Map_attr const map_attr,
|
||||
bool const ept)
|
||||
{
|
||||
seL4_X86_Page const service = _idx_to_sel(idx.value());
|
||||
seL4_X86_Page const service = _idx_to_sel(idx.value()).value();
|
||||
seL4_X86_PageDirectory const pd = _pd_sel.value();
|
||||
seL4_CapRights_t const rights = map_attr.writeable ? seL4_ReadWrite
|
||||
: seL4_CanRead;
|
||||
@@ -40,7 +40,7 @@ long Genode::Vm_space::_map_page(Genode::Cap_sel const &idx,
|
||||
|
||||
long Genode::Vm_space::_unmap_page(Genode::Cap_sel const &idx)
|
||||
{
|
||||
seL4_X86_Page const service = _idx_to_sel(idx.value());
|
||||
seL4_X86_Page const service = _idx_to_sel(idx.value()).value();
|
||||
return seL4_X86_Page_Unmap(service);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ void Genode::Platform::_init_core_page_table_registry()
|
||||
seL4_BootInfo const &bi = sel4_boot_info();
|
||||
|
||||
addr_t virt_addr = (addr_t)(&_prog_img_beg);
|
||||
unsigned sel = bi.userImagePaging.start;
|
||||
unsigned sel = (unsigned)bi.userImagePaging.start;
|
||||
|
||||
/* we don't know the physical location of some objects XXX */
|
||||
enum { XXX_PHYS_UNKNOWN = ~0UL };
|
||||
|
||||
@@ -31,13 +31,13 @@ namespace Genode {
|
||||
{
|
||||
private:
|
||||
|
||||
addr_t _value;
|
||||
uint32_t _value;
|
||||
|
||||
public:
|
||||
|
||||
explicit Cap_sel(addr_t value) : _value(value) { }
|
||||
explicit Cap_sel(uint32_t value) : _value(value) { }
|
||||
|
||||
addr_t value() const { return _value; }
|
||||
uint32_t value() const { return _value; }
|
||||
|
||||
void print(Output &out) const { Genode::print(out, "sel=", _value); }
|
||||
};
|
||||
@@ -179,7 +179,7 @@ class Genode::Capability_space_sel4
|
||||
unsigned _index(Data const &data) const
|
||||
{
|
||||
addr_t const offset = (addr_t)&data - (addr_t)_caps_data;
|
||||
return offset / sizeof(_caps_data[0]);
|
||||
return (unsigned)(offset / sizeof(_caps_data[0]));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,9 +19,7 @@
|
||||
|
||||
/* base-internal includes */
|
||||
#include <base/internal/native_thread.h>
|
||||
|
||||
/* seL4 includes */
|
||||
#include <sel4/sel4.h>
|
||||
#include <base/internal/sel4.h>
|
||||
|
||||
|
||||
static inline void kernel_debugger_outstring(char const *msg)
|
||||
|
||||
25
repos/base-sel4/src/include/base/internal/sel4.h
Normal file
25
repos/base-sel4/src/include/base/internal/sel4.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* \brief seL4 kernel bindings
|
||||
* \author Norman Feske
|
||||
* \date 2021-12-02
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2021 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE__BASE__INTERNAL__SEL4_H_
|
||||
#define _INCLUDE__BASE__INTERNAL__SEL4_H_
|
||||
|
||||
/*
|
||||
* Disable -Wconversion warnings caused by seL4 headers
|
||||
*/
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#include <sel4/sel4.h>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#endif /* _INCLUDE__BASE__INTERNAL__SEL4_H_ */
|
||||
@@ -71,7 +71,7 @@ namespace {
|
||||
unsigned alloc()
|
||||
{
|
||||
Mutex::Guard guard(_mutex);
|
||||
return Bit_allocator::alloc();
|
||||
return (unsigned)Bit_allocator::alloc();
|
||||
}
|
||||
|
||||
void free(unsigned sel)
|
||||
|
||||
@@ -87,8 +87,8 @@ static seL4_MessageInfo_t new_seL4_message(Msgbuf_base const &msg)
|
||||
* Supply capabilities to kernel IPC message
|
||||
*/
|
||||
seL4_SetMR(MR_IDX_NUM_CAPS, msg.used_caps());
|
||||
size_t sel4_sel_cnt = 0;
|
||||
for (size_t i = 0; i < msg.used_caps(); i++) {
|
||||
unsigned sel4_sel_cnt = 0;
|
||||
for (unsigned i = 0; i < msg.used_caps(); i++) {
|
||||
|
||||
Native_capability const &cap = msg.cap(i);
|
||||
|
||||
@@ -107,17 +107,17 @@ static seL4_MessageInfo_t new_seL4_message(Msgbuf_base const &msg)
|
||||
* Pad unused capability slots with invalid capabilities to avoid
|
||||
* leakage of any information that happens to be in the IPC buffer.
|
||||
*/
|
||||
for (size_t i = msg.used_caps(); i < Msgbuf_base::MAX_CAPS_PER_MSG; i++)
|
||||
for (unsigned i = (unsigned)msg.used_caps(); i < Msgbuf_base::MAX_CAPS_PER_MSG; i++)
|
||||
seL4_SetMR(MR_IDX_CAPS + i, Rpc_obj_key::INVALID);
|
||||
|
||||
/*
|
||||
* Supply data payload
|
||||
*/
|
||||
size_t const num_data_mwords =
|
||||
align_natural(msg.data_size()) / sizeof(umword_t);
|
||||
unsigned const num_data_mwords =
|
||||
align_natural((unsigned)(msg.data_size() / sizeof(umword_t)));
|
||||
|
||||
umword_t const *src = (umword_t const *)msg.data();
|
||||
for (size_t i = 0; i < num_data_mwords; i++)
|
||||
for (unsigned i = 0; i < num_data_mwords; i++)
|
||||
seL4_SetMR(MR_IDX_DATA + i, *src++);
|
||||
|
||||
seL4_MessageInfo_t const msg_info =
|
||||
@@ -139,16 +139,17 @@ static void decode_seL4_message(seL4_MessageInfo_t const &msg_info,
|
||||
* You must not use any Genode primitives which may corrupt the IPCBuffer
|
||||
* during this step, e.g. Lock or RPC for output !!!
|
||||
*/
|
||||
size_t const num_caps = min(seL4_GetMR(MR_IDX_NUM_CAPS),
|
||||
(addr_t)Msgbuf_base::MAX_CAPS_PER_MSG);
|
||||
uint32_t const caps_extra = seL4_MessageInfo_get_extraCaps(msg_info);
|
||||
uint32_t const caps_unwrapped = seL4_MessageInfo_get_capsUnwrapped(msg_info);
|
||||
uint32_t const num_msg_words = seL4_MessageInfo_get_length(msg_info);
|
||||
unsigned const num_caps = min((unsigned)seL4_GetMR(MR_IDX_NUM_CAPS),
|
||||
(unsigned)Msgbuf_base::MAX_CAPS_PER_MSG);
|
||||
|
||||
uint32_t const caps_extra = (uint32_t)seL4_MessageInfo_get_extraCaps(msg_info);
|
||||
uint32_t const caps_unwrapped = (uint32_t)seL4_MessageInfo_get_capsUnwrapped(msg_info);
|
||||
uint32_t const num_msg_words = (uint32_t)seL4_MessageInfo_get_length(msg_info);
|
||||
|
||||
Rpc_obj_key rpc_obj_keys[Msgbuf_base::MAX_CAPS_PER_MSG];
|
||||
unsigned long arg_badges[Msgbuf_base::MAX_CAPS_PER_MSG];
|
||||
|
||||
for (size_t i = 0; i < num_caps; i++) {
|
||||
for (unsigned i = 0; i < num_caps; i++) {
|
||||
rpc_obj_keys[i] = Rpc_obj_key(seL4_GetMR(MR_IDX_CAPS + i));
|
||||
if (!rpc_obj_keys[i].valid())
|
||||
/*
|
||||
@@ -169,11 +170,11 @@ static void decode_seL4_message(seL4_MessageInfo_t const &msg_info,
|
||||
if (num_msg_words >= MR_IDX_DATA) {
|
||||
|
||||
/* copy data payload */
|
||||
size_t const max_words = dst_msg.capacity()/sizeof(umword_t);
|
||||
size_t const num_data_words = min(num_msg_words - MR_IDX_DATA, max_words);
|
||||
unsigned const max_words = (unsigned)(dst_msg.capacity() / sizeof(umword_t));
|
||||
unsigned const num_data_words = min(num_msg_words - MR_IDX_DATA, max_words);
|
||||
|
||||
umword_t *dst = (umword_t *)dst_msg.data();
|
||||
for (size_t i = 0; i < num_data_words; i++)
|
||||
for (unsigned i = 0; i < num_data_words; i++)
|
||||
*dst++ = seL4_GetMR(MR_IDX_DATA + i);
|
||||
|
||||
dst_msg.data_size(num_data_words*sizeof(umword_t));
|
||||
@@ -318,7 +319,7 @@ Rpc_exception_code Genode::ipc_call(Native_capability dst,
|
||||
|
||||
rcv_msg.reset();
|
||||
|
||||
unsigned const dst_sel = Capability_space::ipc_cap_data(dst).sel.value();
|
||||
unsigned const dst_sel = (unsigned)Capability_space::ipc_cap_data(dst).sel.value();
|
||||
|
||||
/**
|
||||
* Do not use Genode primitives after this point until the return which may
|
||||
@@ -327,7 +328,7 @@ Rpc_exception_code Genode::ipc_call(Native_capability dst,
|
||||
|
||||
seL4_MessageInfo_t const request = new_seL4_message(snd_msg);
|
||||
seL4_MessageInfo_t const reply_msg_info = seL4_Call(dst_sel, request);
|
||||
Rpc_exception_code const exc_code(seL4_GetMR(MR_IDX_EXC_CODE));
|
||||
Rpc_exception_code const exc_code((int)seL4_GetMR(MR_IDX_EXC_CODE));
|
||||
|
||||
decode_seL4_message(reply_msg_info, rcv_msg);
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ void prepare_init_main_thread() { }
|
||||
void Genode::Thread::_thread_bootstrap()
|
||||
{
|
||||
if (native_thread().ep_sel == 0) {
|
||||
native_thread().ep_sel = _stack->utcb().ep_sel();
|
||||
native_thread().lock_sel = _stack->utcb().lock_sel();
|
||||
native_thread().ep_sel = (unsigned)_stack->utcb().ep_sel();
|
||||
native_thread().lock_sel = (unsigned)_stack->utcb().lock_sel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,10 +27,10 @@
|
||||
#include <base/internal/native_thread.h>
|
||||
#include <base/internal/native_utcb.h>
|
||||
#include <base/internal/stack.h>
|
||||
#include <base/internal/sel4.h>
|
||||
|
||||
/* seL4 includes */
|
||||
#include <sel4_native_vcpu/sel4_native_vcpu.h>
|
||||
#include <sel4/sel4.h>
|
||||
#include <sel4/arch/vmenter.h>
|
||||
|
||||
using namespace Genode;
|
||||
@@ -222,7 +222,7 @@ struct Sel4_vcpu : Genode::Thread, Noncopyable
|
||||
if (res != SEL4_VMENTER_RESULT_FAULT)
|
||||
state.exit_reason = VMEXIT_RECALL;
|
||||
else
|
||||
state.exit_reason = seL4_GetMR(SEL4_VMENTER_FAULT_REASON_MR);
|
||||
state.exit_reason = (unsigned)seL4_GetMR(SEL4_VMENTER_FAULT_REASON_MR);
|
||||
|
||||
_read_sel4_state(service, state);
|
||||
|
||||
@@ -360,7 +360,7 @@ struct Sel4_vcpu : Genode::Thread, Noncopyable
|
||||
* Convert to AMD (and Genode) format comprising 16 bits.
|
||||
*/
|
||||
uint16_t _convert_ar_16(addr_t value) {
|
||||
return ((value & 0x1f000) >> 4) | (value & 0xff); }
|
||||
return (uint16_t)(((value & 0x1f000) >> 4) | (value & 0xff)); }
|
||||
|
||||
void _write_sel4_state(seL4_X86_VCPU const service, Vcpu_state &state)
|
||||
{
|
||||
@@ -455,7 +455,7 @@ struct Sel4_vcpu : Genode::Thread, Noncopyable
|
||||
else
|
||||
ctrl_0 &= ~Vmcs::IRQ_WINDOW;
|
||||
|
||||
state.ctrl_primary.charge(ctrl_0);
|
||||
state.ctrl_primary.charge((uint32_t)ctrl_0);
|
||||
}
|
||||
|
||||
if (state.inj_error.charged())
|
||||
@@ -554,16 +554,16 @@ struct Sel4_vcpu : Genode::Thread, Noncopyable
|
||||
}
|
||||
|
||||
if (state.pdpte_0.charged())
|
||||
_write_vmcs(service, Vmcs::PDPTE_0, state.pdpte_0.value());
|
||||
_write_vmcs(service, Vmcs::PDPTE_0, (addr_t)state.pdpte_0.value());
|
||||
|
||||
if (state.pdpte_1.charged())
|
||||
_write_vmcs(service, Vmcs::PDPTE_1, state.pdpte_1.value());
|
||||
_write_vmcs(service, Vmcs::PDPTE_1, (addr_t)state.pdpte_1.value());
|
||||
|
||||
if (state.pdpte_2.charged())
|
||||
_write_vmcs(service, Vmcs::PDPTE_2, state.pdpte_2.value());
|
||||
_write_vmcs(service, Vmcs::PDPTE_2, (addr_t)state.pdpte_2.value());
|
||||
|
||||
if (state.pdpte_3.charged())
|
||||
_write_vmcs(service, Vmcs::PDPTE_3, state.pdpte_3.value());
|
||||
_write_vmcs(service, Vmcs::PDPTE_3, (addr_t)state.pdpte_3.value());
|
||||
|
||||
if (state.sysenter_cs.charged())
|
||||
_write_vmcs(service, Vmcs::SYSENTER_CS, state.sysenter_cs.value());
|
||||
@@ -603,15 +603,15 @@ struct Sel4_vcpu : Genode::Thread, Noncopyable
|
||||
void _read_sel4_state(seL4_X86_VCPU const service, Vcpu_state &state)
|
||||
{
|
||||
state.ip.charge(seL4_GetMR(SEL4_VMENTER_CALL_EIP_MR));
|
||||
state.ctrl_primary.charge(seL4_GetMR(SEL4_VMENTER_CALL_CONTROL_PPC_MR));
|
||||
state.ctrl_primary.charge((uint32_t)seL4_GetMR(SEL4_VMENTER_CALL_CONTROL_PPC_MR));
|
||||
|
||||
state.ip_len.charge(seL4_GetMR(SEL4_VMENTER_FAULT_INSTRUCTION_LEN_MR));
|
||||
state.qual_primary.charge(seL4_GetMR(SEL4_VMENTER_FAULT_QUALIFICATION_MR));
|
||||
state.ip_len .charge(seL4_GetMR(SEL4_VMENTER_FAULT_INSTRUCTION_LEN_MR));
|
||||
state.qual_primary .charge(seL4_GetMR(SEL4_VMENTER_FAULT_QUALIFICATION_MR));
|
||||
state.qual_secondary.charge(seL4_GetMR(SEL4_VMENTER_FAULT_GUEST_PHYSICAL_MR));
|
||||
|
||||
state.flags.charge(seL4_GetMR(SEL4_VMENTER_FAULT_RFLAGS_MR));
|
||||
state.intr_state.charge(seL4_GetMR(SEL4_VMENTER_FAULT_GUEST_INT_MR));
|
||||
state.cr3.charge(seL4_GetMR(SEL4_VMENTER_FAULT_CR3_MR));
|
||||
state.flags .charge(seL4_GetMR(SEL4_VMENTER_FAULT_RFLAGS_MR));
|
||||
state.intr_state.charge((uint32_t)seL4_GetMR(SEL4_VMENTER_FAULT_GUEST_INT_MR));
|
||||
state.cr3 .charge(seL4_GetMR(SEL4_VMENTER_FAULT_CR3_MR));
|
||||
|
||||
state.ax.charge(seL4_GetMR(SEL4_VMENTER_FAULT_EAX));
|
||||
state.bx.charge(seL4_GetMR(SEL4_VMENTER_FAULT_EBX));
|
||||
@@ -629,13 +629,13 @@ struct Sel4_vcpu : Genode::Thread, Noncopyable
|
||||
_recent_gpr.edi = state.di.value();
|
||||
_recent_gpr.ebp = state.bp.value();
|
||||
|
||||
state.sp.charge(_read_vmcs(service, Vmcs::RSP));
|
||||
state.sp .charge(_read_vmcs(service, Vmcs::RSP));
|
||||
state.dr7.charge(_read_vmcs(service, Vmcs::DR7));
|
||||
|
||||
/* r8 - r15 not supported on seL4 */
|
||||
|
||||
{
|
||||
addr_t const cr0 = _read_vmcs(service, Vmcs::CR0);
|
||||
addr_t const cr0 = _read_vmcs(service, Vmcs::CR0);
|
||||
addr_t const cr0_shadow = _read_vmcs(service, Vmcs::CR0_SHADOW);
|
||||
state.cr0.charge((cr0 & ~cr0_mask) | (cr0_shadow & cr0_mask));
|
||||
|
||||
@@ -647,7 +647,7 @@ struct Sel4_vcpu : Genode::Thread, Noncopyable
|
||||
state.cr2.charge(state.cr2.value());
|
||||
|
||||
{
|
||||
addr_t const cr4 = _read_vmcs(service, Vmcs::CR4);
|
||||
addr_t const cr4 = _read_vmcs(service, Vmcs::CR4);
|
||||
addr_t const cr4_shadow = _read_vmcs(service, Vmcs::CR4_SHADOW);
|
||||
state.cr4.charge((cr4 & ~cr4_mask) | (cr4_shadow & cr4_mask));
|
||||
|
||||
@@ -715,15 +715,15 @@ struct Sel4_vcpu : Genode::Thread, Noncopyable
|
||||
if (state.exit_reason == VMEXIT_INVALID ||
|
||||
state.exit_reason == VMEXIT_RECALL)
|
||||
{
|
||||
state.inj_info.charge(_read_vmcs(service, Vmcs::INTR_INFO));
|
||||
state.inj_error.charge(_read_vmcs(service, Vmcs::INTR_ERROR));
|
||||
state.inj_info .charge((uint32_t)_read_vmcs(service, Vmcs::INTR_INFO));
|
||||
state.inj_error.charge((uint32_t)_read_vmcs(service, Vmcs::INTR_ERROR));
|
||||
} else {
|
||||
state.inj_info.charge(_read_vmcs(service, Vmcs::IDT_INFO));
|
||||
state.inj_error.charge(_read_vmcs(service, Vmcs::IDT_ERROR));
|
||||
state.inj_info .charge((uint32_t)_read_vmcs(service, Vmcs::IDT_INFO));
|
||||
state.inj_error.charge((uint32_t)_read_vmcs(service, Vmcs::IDT_ERROR));
|
||||
}
|
||||
|
||||
state.intr_state.charge(_read_vmcs(service, Vmcs::STATE_INTR));
|
||||
state.actv_state.charge(_read_vmcs(service, Vmcs::STATE_ACTV));
|
||||
state.intr_state.charge((uint32_t)_read_vmcs(service, Vmcs::STATE_INTR));
|
||||
state.actv_state.charge((uint32_t)_read_vmcs(service, Vmcs::STATE_ACTV));
|
||||
|
||||
state.pdpte_0.charge(_read_vmcs(service, Vmcs::PDPTE_0));
|
||||
state.pdpte_1.charge(_read_vmcs(service, Vmcs::PDPTE_1));
|
||||
|
||||
Reference in New Issue
Block a user