2015-04-21 17:21:11 +02:00
|
|
|
/*
|
|
|
|
* \brief Muen subject information API impl
|
|
|
|
* \author Reto Buerki
|
|
|
|
* \date 2015-04-21
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 13:23:52 +01:00
|
|
|
* Copyright (C) 2015-2017 Genode Labs GmbH
|
2015-04-21 17:21:11 +02:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
2017-02-20 13:23:52 +01:00
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
2015-04-21 17:21:11 +02:00
|
|
|
*/
|
|
|
|
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
#include <base/log.h>
|
2016-10-04 11:56:16 +02:00
|
|
|
#include <base/snprintf.h>
|
2015-04-21 17:21:11 +02:00
|
|
|
#include <util/string.h>
|
|
|
|
|
2015-07-02 16:25:51 +02:00
|
|
|
#include <muen/sinfo.h>
|
2015-04-21 17:21:11 +02:00
|
|
|
|
2015-07-02 16:25:51 +02:00
|
|
|
#include "musinfo.h"
|
2015-06-02 12:11:50 +02:00
|
|
|
|
2016-10-10 16:51:10 +02:00
|
|
|
static_assert(sizeof(subject_info_type) <= Sinfo::SIZE,
|
|
|
|
"Size of subject info type larger than Sinfo::SIZE.");
|
|
|
|
|
2015-04-21 17:21:11 +02:00
|
|
|
/* Log channel information */
|
|
|
|
static bool log_channel(
|
|
|
|
const struct Genode::Sinfo::Channel_info * const channel,
|
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
if (channel->has_event || channel->has_vector) {
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
Genode::log("muen-sinfo: [",
|
|
|
|
channel->writable ? "writer" : "reader", " with ",
|
|
|
|
channel->has_event ? "event " : "vector", " ",
|
|
|
|
channel->has_event ? channel->event_number : channel->vector,
|
|
|
|
"] ", channel->name);
|
2015-04-21 17:21:11 +02:00
|
|
|
} else {
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
Genode::log("muen-sinfo: [",
|
|
|
|
channel->writable ? "writer" : "reader", " with no ",
|
|
|
|
channel->writable ? "event " : "vector", " ",
|
|
|
|
"] ", channel->name);
|
2015-04-21 17:21:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-06-02 12:11:50 +02:00
|
|
|
|
2016-10-04 11:56:16 +02:00
|
|
|
static const char * const content_names[] = {
|
|
|
|
"uninitialized", "fill", "file",
|
|
|
|
};
|
|
|
|
|
|
|
|
uint8_t no_hash[Sinfo::HASH_LENGTH] = {0};
|
|
|
|
|
|
|
|
/* Return true if given buffer contains a hash */
|
|
|
|
static bool hash_available(const uint8_t * const first)
|
|
|
|
{
|
|
|
|
return memcmp(first, no_hash, Sinfo::HASH_LENGTH) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Convert given hash to hex string */
|
|
|
|
static const char * const hash_to_hex(char *buffer, const unsigned char *first)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < Sinfo::HASH_LENGTH; i++)
|
|
|
|
snprintf(&buffer[i * 2], 3, "%02x", (unsigned int)*first++);
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-21 17:21:11 +02:00
|
|
|
/* Log memory region information */
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
static bool log_memregion(const struct Genode::Sinfo::Memregion_info * const region,
|
|
|
|
void *data)
|
|
|
|
{
|
2016-10-04 11:56:16 +02:00
|
|
|
char hash_str[65];
|
|
|
|
|
|
|
|
Genode::log("muen-sinfo: [", content_names[region->content],
|
|
|
|
", addr ", Genode::Hex(region->address),
|
|
|
|
" size ", Genode::Hex(region->size), " ",
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
region->writable ? "rw" : "ro",
|
|
|
|
region->executable ? "x" : "-",
|
|
|
|
"] ", region->name);
|
2016-10-04 11:56:16 +02:00
|
|
|
|
|
|
|
if (region->content == Sinfo::CONTENT_FILL)
|
|
|
|
Genode::log("muen-sinfo: [pattern ", region->pattern, "]");
|
|
|
|
if (hash_available(region->hash))
|
|
|
|
Genode::log("muen-sinfo: [hash 0x",
|
|
|
|
hash_to_hex(hash_str, region->hash), "]");
|
|
|
|
|
2015-04-21 17:21:11 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-06-02 12:11:50 +02:00
|
|
|
|
2015-04-21 17:21:11 +02:00
|
|
|
/* Returns true if the given resource is a memory region */
|
|
|
|
static bool is_memregion(const struct resource_type * const resource)
|
|
|
|
{
|
|
|
|
return resource->memregion_idx != NO_RESOURCE;
|
|
|
|
}
|
|
|
|
|
2015-06-02 12:11:50 +02:00
|
|
|
|
2015-04-21 17:21:11 +02:00
|
|
|
/* Returns true if the given resource is a channel */
|
|
|
|
static bool is_channel(const struct resource_type * const resource)
|
|
|
|
{
|
|
|
|
return is_memregion(resource) && resource->channel_info_idx != NO_RESOURCE;
|
|
|
|
}
|
|
|
|
|
2015-06-02 12:11:50 +02:00
|
|
|
|
2015-07-02 16:25:51 +02:00
|
|
|
Sinfo::Sinfo(const addr_t base_addr)
|
2016-02-16 17:08:14 +01:00
|
|
|
{
|
2015-07-02 16:25:51 +02:00
|
|
|
sinfo = ((subject_info_type *)base_addr);
|
2016-02-16 17:08:14 +01:00
|
|
|
|
2015-04-21 17:21:11 +02:00
|
|
|
if (!check_magic()) {
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
Genode::error("muen-sinfo: Subject information MAGIC mismatch");
|
2015-04-21 17:21:11 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-02 12:11:50 +02:00
|
|
|
|
2015-04-21 17:21:11 +02:00
|
|
|
bool Sinfo::check_magic(void)
|
|
|
|
{
|
|
|
|
return sinfo != 0 && sinfo->magic == MUEN_SUBJECT_INFO_MAGIC;
|
|
|
|
}
|
|
|
|
|
2015-06-02 12:11:50 +02:00
|
|
|
|
2015-04-21 17:21:11 +02:00
|
|
|
bool Sinfo::get_channel_info(const char * const name,
|
2015-06-02 12:11:50 +02:00
|
|
|
struct Channel_info *channel)
|
2015-04-21 17:21:11 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!check_magic())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for (i = 0; i < sinfo->resource_count; i++) {
|
|
|
|
if (is_channel(&sinfo->resources[i]) &&
|
|
|
|
strcmp(sinfo->resources[i].name.data, name) == 0) {
|
|
|
|
fill_channel_data(i, channel);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-06-02 12:11:50 +02:00
|
|
|
|
2015-04-21 17:21:11 +02:00
|
|
|
bool Sinfo::get_memregion_info(const char * const name,
|
2015-06-02 12:11:50 +02:00
|
|
|
struct Memregion_info *memregion)
|
2015-04-21 17:21:11 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!check_magic())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for (i = 0; i < sinfo->resource_count; i++) {
|
|
|
|
if (is_memregion(&sinfo->resources[i]) &&
|
|
|
|
strcmp(sinfo->resources[i].name.data, name) == 0) {
|
|
|
|
fill_memregion_data(i, memregion);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-06-02 12:11:50 +02:00
|
|
|
|
2016-02-16 17:08:14 +01:00
|
|
|
bool Sinfo::get_dev_info(const uint16_t sid, struct Dev_info *dev)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!check_magic())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for (i = 0; i < sinfo->dev_info_count; i++) {
|
|
|
|
if (sinfo->dev_info[i].sid == sid) {
|
|
|
|
fill_dev_data(i, dev);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-21 17:21:11 +02:00
|
|
|
bool Sinfo::for_each_channel(Channel_cb func, void *data)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct Channel_info current_channel;
|
|
|
|
|
|
|
|
if (!check_magic())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for (i = 0; i < sinfo->resource_count; i++) {
|
|
|
|
if (is_channel(&sinfo->resources[i])) {
|
|
|
|
fill_channel_data(i, ¤t_channel);
|
|
|
|
if (!func(¤t_channel, data))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-06-02 12:11:50 +02:00
|
|
|
|
2015-04-21 17:21:11 +02:00
|
|
|
bool Sinfo::for_each_memregion(Memregion_cb func, void *data)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct Memregion_info current_region;
|
|
|
|
|
|
|
|
if (!check_magic())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for (i = 0; i < sinfo->resource_count; i++) {
|
|
|
|
if (is_memregion(&sinfo->resources[i])) {
|
|
|
|
fill_memregion_data(i, ¤t_region);
|
|
|
|
if (!func(¤t_region, data))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-06-02 12:11:50 +02:00
|
|
|
|
2015-04-21 17:21:11 +02:00
|
|
|
uint64_t Sinfo::get_tsc_khz(void)
|
|
|
|
{
|
|
|
|
if (!check_magic())
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return sinfo->tsc_khz;
|
|
|
|
}
|
|
|
|
|
2015-06-02 12:11:50 +02:00
|
|
|
|
2015-04-21 17:21:11 +02:00
|
|
|
uint64_t Sinfo::get_sched_start(void)
|
|
|
|
{
|
|
|
|
if (!check_magic())
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return sinfo->tsc_schedule_start;
|
|
|
|
}
|
|
|
|
|
2015-06-02 12:11:50 +02:00
|
|
|
|
2015-04-21 17:21:11 +02:00
|
|
|
uint64_t Sinfo::get_sched_end(void)
|
|
|
|
{
|
|
|
|
if (!check_magic())
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return sinfo->tsc_schedule_end;
|
|
|
|
}
|
2015-07-02 16:25:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
void Sinfo::log_status()
|
|
|
|
{
|
|
|
|
if (!sinfo) {
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
Genode::log("Sinfo API not initialized");
|
2015-07-02 16:25:51 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!check_magic()) {
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
Genode::log("Sinfo MAGIC not found");
|
2015-07-02 16:25:51 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
Genode::log("muen-sinfo: Subject information exports ",
|
|
|
|
sinfo->memregion_count, " memory region(s)");
|
2015-07-02 16:25:51 +02:00
|
|
|
for_each_memregion(log_memregion, 0);
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
Genode::log("muen-sinfo: Subject information exports ",
|
|
|
|
sinfo->channel_info_count, " channel(s)");
|
2015-07-02 16:25:51 +02:00
|
|
|
for_each_channel(log_channel, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Sinfo::fill_memregion_data(uint8_t idx, struct Memregion_info *region)
|
|
|
|
{
|
|
|
|
const struct resource_type resource = sinfo->resources[idx];
|
|
|
|
const struct memregion_type memregion =
|
|
|
|
sinfo->memregions[resource.memregion_idx - 1];
|
|
|
|
|
|
|
|
memset(®ion->name, 0, MAX_NAME_LENGTH + 1);
|
|
|
|
memcpy(®ion->name, resource.name.data, resource.name.length);
|
|
|
|
|
2016-10-04 11:56:16 +02:00
|
|
|
memcpy(®ion->hash, memregion.hash, HASH_LENGTH);
|
|
|
|
|
|
|
|
region->content = memregion.content;
|
2015-07-02 16:25:51 +02:00
|
|
|
region->address = memregion.address;
|
|
|
|
region->size = memregion.size;
|
2016-10-04 11:56:16 +02:00
|
|
|
region->pattern = memregion.pattern;
|
2015-07-02 16:25:51 +02:00
|
|
|
region->writable = memregion.flags & MEM_WRITABLE_FLAG;
|
|
|
|
region->executable = memregion.flags & MEM_EXECUTABLE_FLAG;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Sinfo::fill_channel_data(uint8_t idx, struct Channel_info *channel)
|
|
|
|
{
|
|
|
|
const struct resource_type resource = sinfo->resources[idx];
|
|
|
|
const struct memregion_type memregion =
|
|
|
|
sinfo->memregions[resource.memregion_idx - 1];
|
|
|
|
const struct channel_info_type channel_info =
|
|
|
|
sinfo->channels_info[resource.channel_info_idx - 1];
|
|
|
|
|
|
|
|
memset(&channel->name, 0, MAX_NAME_LENGTH + 1);
|
|
|
|
memcpy(&channel->name, resource.name.data, resource.name.length);
|
|
|
|
|
|
|
|
channel->address = memregion.address;
|
|
|
|
channel->size = memregion.size;
|
|
|
|
channel->writable = memregion.flags & MEM_WRITABLE_FLAG;
|
|
|
|
|
|
|
|
channel->has_event = channel_info.flags & CHAN_EVENT_FLAG;
|
|
|
|
channel->event_number = channel_info.event;
|
|
|
|
channel->has_vector = channel_info.flags & CHAN_VECTOR_FLAG;
|
|
|
|
channel->vector = channel_info.vector;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Sinfo::fill_dev_data(uint8_t idx, struct Dev_info *dev)
|
|
|
|
{
|
|
|
|
const struct dev_info_type dev_info = sinfo->dev_info[idx];
|
|
|
|
|
|
|
|
dev->sid = dev_info.sid;
|
|
|
|
dev->irte_start = dev_info.irte_start;
|
|
|
|
dev->irq_start = dev_info.irq_start;
|
|
|
|
dev->ir_count = dev_info.ir_count;
|
|
|
|
dev->msi_capable = dev_info.flags & DEV_MSI_FLAG;
|
|
|
|
}
|