mirror of
https://github.com/genodelabs/genode.git
synced 2025-05-11 13:03:11 +00:00
parent
5e862b2cd3
commit
cfd013a01a
@ -98,8 +98,7 @@ class Block::Request_stream : Genode::Noncopyable
|
|||||||
* If the request does not carry any payload, 'fn' is not
|
* If the request does not carry any payload, 'fn' is not
|
||||||
* called.
|
* called.
|
||||||
*/
|
*/
|
||||||
template <typename FN>
|
void with_content(Block::Request request, auto const &fn) const
|
||||||
void with_content(Block::Request request, FN const &fn) const
|
|
||||||
{
|
{
|
||||||
if (_valid_range_and_alignment(request))
|
if (_valid_range_and_alignment(request))
|
||||||
fn(_request_ptr(request), _request_size(request));
|
fn(_request_ptr(request), _request_size(request));
|
||||||
@ -148,8 +147,7 @@ class Block::Request_stream : Genode::Noncopyable
|
|||||||
* The 'Payload' interface allows the functor to access the content
|
* The 'Payload' interface allows the functor to access the content
|
||||||
* of a request by calling 'Payload::with_content'.
|
* of a request by calling 'Payload::with_content'.
|
||||||
*/
|
*/
|
||||||
template <typename FN>
|
void with_payload(auto const &fn) const { fn(_payload); }
|
||||||
void with_payload(FN const &fn) const { fn(_payload); }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call functor 'fn' with the pointer and size to the 'request' content
|
* Call functor 'fn' with the pointer and size to the 'request' content
|
||||||
@ -158,8 +156,7 @@ class Block::Request_stream : Genode::Noncopyable
|
|||||||
* in situations where the 'Payload' interface does not need to be
|
* in situations where the 'Payload' interface does not need to be
|
||||||
* propagated as argument.
|
* propagated as argument.
|
||||||
*/
|
*/
|
||||||
template <typename FN>
|
void with_content(Request const &request, auto const &fn) const
|
||||||
void with_content(Request const &request, FN const &fn) const
|
|
||||||
{
|
{
|
||||||
_payload.with_content(request, fn);
|
_payload.with_content(request, fn);
|
||||||
}
|
}
|
||||||
@ -174,8 +171,7 @@ class Block::Request_stream : Genode::Noncopyable
|
|||||||
* packet stream. If the request could not be accepted, the iteration
|
* packet stream. If the request could not be accepted, the iteration
|
||||||
* aborts and the request packet stays in the packet stream.
|
* aborts and the request packet stays in the packet stream.
|
||||||
*/
|
*/
|
||||||
template <typename FN>
|
void with_requests(auto const &fn)
|
||||||
void with_requests(FN const &fn)
|
|
||||||
{
|
{
|
||||||
Tx_sink &tx_sink = *_tx.sink();
|
Tx_sink &tx_sink = *_tx.sink();
|
||||||
|
|
||||||
@ -287,8 +283,7 @@ class Block::Request_stream : Genode::Noncopyable
|
|||||||
* iteration stops when the acknowledgement queue is fully populated or if
|
* iteration stops when the acknowledgement queue is fully populated or if
|
||||||
* the functor does not call 'Ack::submit'.
|
* the functor does not call 'Ack::submit'.
|
||||||
*/
|
*/
|
||||||
template <typename FN>
|
void try_acknowledge(auto const &fn)
|
||||||
void try_acknowledge(FN const &fn)
|
|
||||||
{
|
{
|
||||||
Tx_sink &tx_sink = *_tx.sink();
|
Tx_sink &tx_sink = *_tx.sink();
|
||||||
|
|
||||||
|
@ -118,8 +118,7 @@ struct Block::Connection : Genode::Connection<Session>, Session_client
|
|||||||
_operation.count - _position) };
|
_operation.count - _position) };
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename FN>
|
static void _with_offset_and_length(Job &job, auto const &fn)
|
||||||
static void _with_offset_and_length(Job &job, FN const &fn)
|
|
||||||
{
|
{
|
||||||
if (!Operation::has_payload(job._operation.type))
|
if (!Operation::has_payload(job._operation.type))
|
||||||
return;
|
return;
|
||||||
@ -131,8 +130,7 @@ struct Block::Connection : Genode::Connection<Session>, Session_client
|
|||||||
Genode::min(job._payload.bytes, operation.count * block_size));
|
Genode::min(job._payload.bytes, operation.count * block_size));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename POLICY>
|
void _submit(auto &policy, _JOB &job, Tx::Source &tx)
|
||||||
void _submit(POLICY &policy, _JOB &job, Tx::Source &tx)
|
|
||||||
{
|
{
|
||||||
if (!_tag.constructed())
|
if (!_tag.constructed())
|
||||||
return;
|
return;
|
||||||
@ -210,16 +208,14 @@ struct Block::Connection : Genode::Connection<Session>, Session_client
|
|||||||
*
|
*
|
||||||
* \return true if progress was made
|
* \return true if progress was made
|
||||||
*/
|
*/
|
||||||
template <typename POLICY>
|
bool _try_process_ack(auto &, Tx::Source &);
|
||||||
bool _try_process_ack(POLICY &, Tx::Source &);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Submit next pending job to server, if possible
|
* Submit next pending job to server, if possible
|
||||||
*
|
*
|
||||||
* \return true if a job was successfully submitted
|
* \return true if a job was successfully submitted
|
||||||
*/
|
*/
|
||||||
template <typename POLICY>
|
bool _try_submit_pending_job(auto &, Tx::Source &);
|
||||||
bool _try_submit_pending_job(POLICY &, Tx::Source &);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -260,8 +256,7 @@ struct Block::Connection : Genode::Connection<Session>, Session_client
|
|||||||
*
|
*
|
||||||
* \return true if progress was made
|
* \return true if progress was made
|
||||||
*/
|
*/
|
||||||
template <typename POLICY>
|
bool update_jobs(auto &policy)
|
||||||
bool update_jobs(POLICY &policy)
|
|
||||||
{
|
{
|
||||||
Tx::Source &tx = *_tx.source();
|
Tx::Source &tx = *_tx.source();
|
||||||
|
|
||||||
@ -330,8 +325,7 @@ struct Block::Connection : Genode::Connection<Session>, Session_client
|
|||||||
* This method is intended for the destruction of the jobs associated
|
* This method is intended for the destruction of the jobs associated
|
||||||
* with the connection before destructing the 'Connection' object.
|
* with the connection before destructing the 'Connection' object.
|
||||||
*/
|
*/
|
||||||
template <typename FN>
|
void dissolve_all_jobs(auto const &fn)
|
||||||
void dissolve_all_jobs(FN const &fn)
|
|
||||||
{
|
{
|
||||||
_pending.dequeue_all([&] (Genode::Fifo_element<_JOB> &elem) {
|
_pending.dequeue_all([&] (Genode::Fifo_element<_JOB> &elem) {
|
||||||
fn(elem.object()); });
|
fn(elem.object()); });
|
||||||
|
@ -98,8 +98,7 @@ struct Capture::Session : Genode::Session
|
|||||||
|
|
||||||
Rect rects[NUM_RECTS];
|
Rect rects[NUM_RECTS];
|
||||||
|
|
||||||
template <typename FN>
|
void for_each_rect(auto const &fn) const
|
||||||
void for_each_rect(FN const &fn) const
|
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; i < NUM_RECTS; i++)
|
for (unsigned i = 0; i < NUM_RECTS; i++)
|
||||||
if (rects[i].valid())
|
if (rects[i].valid())
|
||||||
|
@ -83,11 +83,7 @@ class Capture::Connection::Screen
|
|||||||
size(size), _connection(connection), _ds(rm, _connection.dataspace())
|
size(size), _connection(connection), _ds(rm, _connection.dataspace())
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
template <typename FN>
|
void with_texture(auto const &fn) const { fn(_texture); }
|
||||||
void with_texture(FN const &fn) const
|
|
||||||
{
|
|
||||||
fn(_texture);
|
|
||||||
}
|
|
||||||
|
|
||||||
void apply_to_surface(Surface<Pixel> &surface)
|
void apply_to_surface(Surface<Pixel> &surface)
|
||||||
{
|
{
|
||||||
|
@ -85,8 +85,7 @@ class Decorator::Window_stack : public Window_base::Draw_behind_fn
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename FN>
|
inline void update_model(Xml_node root_node, auto const &flush_fn);
|
||||||
inline void update_model(Xml_node root_node, FN const &flush);
|
|
||||||
|
|
||||||
bool schedule_animated_windows()
|
bool schedule_animated_windows()
|
||||||
{
|
{
|
||||||
@ -107,8 +106,7 @@ class Decorator::Window_stack : public Window_base::Draw_behind_fn
|
|||||||
*
|
*
|
||||||
* The functor is called with 'Window_base &' as argument.
|
* The functor is called with 'Window_base &' as argument.
|
||||||
*/
|
*/
|
||||||
template <typename FUNC>
|
void for_each_window(auto const &fn) { _windows.for_each(fn); }
|
||||||
void for_each_window(FUNC const &func) { _windows.for_each(func); }
|
|
||||||
|
|
||||||
void update_gui_views()
|
void update_gui_views()
|
||||||
{
|
{
|
||||||
@ -186,9 +184,8 @@ void Decorator::Window_stack::_draw_rec(Decorator::Canvas_base &canvas,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename FN>
|
|
||||||
void Decorator::Window_stack::update_model(Genode::Xml_node root_node,
|
void Decorator::Window_stack::update_model(Genode::Xml_node root_node,
|
||||||
FN const &flush_window_stack_changes)
|
auto const &flush_window_stack_changes_fn)
|
||||||
{
|
{
|
||||||
Abandoned_windows _abandoned_windows { };
|
Abandoned_windows _abandoned_windows { };
|
||||||
|
|
||||||
@ -280,7 +277,7 @@ void Decorator::Window_stack::update_model(Genode::Xml_node root_node,
|
|||||||
* Apply window-creation operations before destroying windows to prevent
|
* Apply window-creation operations before destroying windows to prevent
|
||||||
* flickering.
|
* flickering.
|
||||||
*/
|
*/
|
||||||
flush_window_stack_changes();
|
flush_window_stack_changes_fn();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Destroy abandoned window objects
|
* Destroy abandoned window objects
|
||||||
|
@ -90,8 +90,7 @@ class Event::Session_client : public Genode::Rpc_client<Session>
|
|||||||
_ds(local_rm, call<Rpc_dataspace>())
|
_ds(local_rm, call<Rpc_dataspace>())
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
template <typename FN>
|
void with_batch(auto const &fn)
|
||||||
void with_batch(FN const &fn)
|
|
||||||
{
|
{
|
||||||
Batch_impl batch { *this };
|
Batch_impl batch { *this };
|
||||||
|
|
||||||
|
@ -39,14 +39,13 @@ struct File_system::Connection : Genode::Connection<Session>, Session_client
|
|||||||
*
|
*
|
||||||
* \noapi
|
* \noapi
|
||||||
*/
|
*/
|
||||||
template <typename FUNC>
|
auto _retry(auto const &fn) -> decltype(fn())
|
||||||
auto _retry(FUNC func) -> decltype(func())
|
|
||||||
{
|
{
|
||||||
enum { UPGRADE_ATTEMPTS = ~0U };
|
enum { UPGRADE_ATTEMPTS = ~0U };
|
||||||
return Genode::retry<Out_of_ram>(
|
return Genode::retry<Out_of_ram>(
|
||||||
[&] () {
|
[&] () {
|
||||||
return Genode::retry<Out_of_caps>(
|
return Genode::retry<Out_of_caps>(
|
||||||
[&] () { return func(); },
|
[&] () { return fn(); },
|
||||||
[&] () { File_system::Connection::upgrade_caps(2); },
|
[&] () { File_system::Connection::upgrade_caps(2); },
|
||||||
UPGRADE_ATTEMPTS);
|
UPGRADE_ATTEMPTS);
|
||||||
},
|
},
|
||||||
|
@ -248,8 +248,7 @@ class File_system::Packet_descriptor : public Genode::Packet_descriptor
|
|||||||
size_t length() const { return _op != Opcode::WRITE_TIMESTAMP ? _length : 0; }
|
size_t length() const { return _op != Opcode::WRITE_TIMESTAMP ? _length : 0; }
|
||||||
bool succeeded() const { return _success; }
|
bool succeeded() const { return _success; }
|
||||||
|
|
||||||
template <typename FN>
|
void with_timestamp(auto const &fn) const
|
||||||
void with_timestamp(FN const &fn) const
|
|
||||||
{
|
{
|
||||||
if (_op == Opcode::WRITE_TIMESTAMP)
|
if (_op == Opcode::WRITE_TIMESTAMP)
|
||||||
fn(_modification_time);
|
fn(_modification_time);
|
||||||
|
@ -97,11 +97,8 @@ class Gui::Session_client : public Genode::Rpc_client<Session>
|
|||||||
* Only in the corner case when there is not space left in the command
|
* Only in the corner case when there is not space left in the command
|
||||||
* buffer, the 'execute' is called to make room in the buffer.
|
* buffer, the 'execute' is called to make room in the buffer.
|
||||||
*/
|
*/
|
||||||
template <typename CMD, typename... ARGS>
|
template <typename CMD>
|
||||||
void enqueue(ARGS... args)
|
void enqueue(auto &&... args) { enqueue(Command( CMD { args... } )); }
|
||||||
{
|
|
||||||
enqueue(Command( CMD { args... } ));
|
|
||||||
}
|
|
||||||
|
|
||||||
void enqueue(Command const &command)
|
void enqueue(Command const &command)
|
||||||
{
|
{
|
||||||
|
@ -55,8 +55,7 @@ struct I2c::Session : public Genode::Session
|
|||||||
|
|
||||||
Message() {}
|
Message() {}
|
||||||
|
|
||||||
template<typename ... ARGS>
|
Message(Type type, auto ... args)
|
||||||
Message(Type type, ARGS ... args)
|
|
||||||
: Byte_array(args...), type(type) {}
|
: Byte_array(args...), type(type) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -146,71 +146,61 @@ class Input::Event
|
|||||||
return release() && _attr.release.key == key;
|
return release() && _attr.release.key == key;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename FN>
|
void handle_press(auto const &fn) const
|
||||||
void handle_press(FN const &fn) const
|
|
||||||
{
|
{
|
||||||
if (press() && _valid(_attr.press.key))
|
if (press() && _valid(_attr.press.key))
|
||||||
fn(_attr.press.key, _attr.press.codepoint);
|
fn(_attr.press.key, _attr.press.codepoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename FN>
|
void handle_repeat(auto const &fn) const
|
||||||
void handle_repeat(FN const &fn) const
|
|
||||||
{
|
{
|
||||||
if (key_press(KEY_UNKNOWN) && _attr.press.codepoint.valid())
|
if (key_press(KEY_UNKNOWN) && _attr.press.codepoint.valid())
|
||||||
fn(_attr.press.codepoint);
|
fn(_attr.press.codepoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename FN>
|
void handle_release(auto const &fn) const
|
||||||
void handle_release(FN const &fn) const
|
|
||||||
{
|
{
|
||||||
if (release() && _valid(_attr.release.key))
|
if (release() && _valid(_attr.release.key))
|
||||||
fn(_attr.release.key);
|
fn(_attr.release.key);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename FN>
|
void handle_relative_motion(auto const &fn) const
|
||||||
void handle_relative_motion(FN const &fn) const
|
|
||||||
{
|
{
|
||||||
if (relative_motion())
|
if (relative_motion())
|
||||||
fn(_attr.rel_motion.x, _attr.rel_motion.y);
|
fn(_attr.rel_motion.x, _attr.rel_motion.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename FN>
|
void handle_absolute_motion(auto const &fn) const
|
||||||
void handle_absolute_motion(FN const &fn) const
|
|
||||||
{
|
{
|
||||||
if (absolute_motion())
|
if (absolute_motion())
|
||||||
fn(_attr.abs_motion.x, _attr.abs_motion.y);
|
fn(_attr.abs_motion.x, _attr.abs_motion.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename FN>
|
void handle_wheel(auto const &fn) const
|
||||||
void handle_wheel(FN const &fn) const
|
|
||||||
{
|
{
|
||||||
if (wheel())
|
if (wheel())
|
||||||
fn(_attr.wheel.x, _attr.wheel.y);
|
fn(_attr.wheel.x, _attr.wheel.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename FN>
|
void handle_touch(auto const &fn) const
|
||||||
void handle_touch(FN const &fn) const
|
|
||||||
{
|
{
|
||||||
if (touch())
|
if (touch())
|
||||||
fn(_attr.touch.id, _attr.touch.x, _attr.touch.y);
|
fn(_attr.touch.id, _attr.touch.x, _attr.touch.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename FN>
|
void handle_touch_release(auto const &fn) const
|
||||||
void handle_touch_release(FN const &fn) const
|
|
||||||
{
|
{
|
||||||
if (touch_release())
|
if (touch_release())
|
||||||
fn(_attr.touch_release.id);
|
fn(_attr.touch_release.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename FN>
|
void handle_seq_number(auto const &fn) const
|
||||||
void handle_seq_number(FN const &fn) const
|
|
||||||
{
|
{
|
||||||
if (seq_number())
|
if (seq_number())
|
||||||
fn(_attr.seq_number);
|
fn(_attr.seq_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename FN>
|
void handle_axis(auto const &fn) const
|
||||||
void handle_axis(FN const &fn) const
|
|
||||||
{
|
{
|
||||||
if (axis())
|
if (axis())
|
||||||
fn(_attr.axis.id, _attr.axis.value);
|
fn(_attr.axis.id, _attr.axis.value);
|
||||||
|
@ -56,17 +56,16 @@ class Input::Session_client : public Genode::Rpc_client<Session>
|
|||||||
/**
|
/**
|
||||||
* Flush and apply functor to pending events
|
* Flush and apply functor to pending events
|
||||||
*
|
*
|
||||||
* \param func functor in the form of f(Event const &e)
|
* \param fn functor in the form of f(Event const &e)
|
||||||
* \return number of events processed
|
* \return number of events processed
|
||||||
*/
|
*/
|
||||||
template <typename FUNC>
|
void for_each_event(auto const &fn)
|
||||||
void for_each_event(FUNC const &func)
|
|
||||||
{
|
{
|
||||||
Genode::size_t const n = Genode::min((Genode::size_t)call<Rpc_flush>(), _max_events);
|
Genode::size_t const n = Genode::min((Genode::size_t)call<Rpc_flush>(), _max_events);
|
||||||
|
|
||||||
Event const *ev_buf = _event_ds.local_addr<const Event>();
|
Event const *ev_buf = _event_ds.local_addr<const Event>();
|
||||||
for (Genode::size_t i = 0; i < n; ++i)
|
for (Genode::size_t i = 0; i < n; ++i)
|
||||||
func(ev_buf[i]);
|
fn(ev_buf[i]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -25,8 +25,7 @@ namespace Genode {
|
|||||||
|
|
||||||
struct Genode::Gdb_hex : Hex
|
struct Genode::Gdb_hex : Hex
|
||||||
{
|
{
|
||||||
template <typename T>
|
explicit Gdb_hex(auto value) : Hex(value, OMIT_PREFIX, PAD) { }
|
||||||
explicit Gdb_hex(T value) : Hex(value, OMIT_PREFIX, PAD) { }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -217,13 +217,12 @@ class Net::Dhcp_packet
|
|||||||
|
|
||||||
Dns_server(Genode::size_t len) : Option(CODE, (Genode::uint8_t)len) { }
|
Dns_server(Genode::size_t len) : Option(CODE, (Genode::uint8_t)len) { }
|
||||||
|
|
||||||
template <typename FUNC>
|
void for_each_address(auto const &fn) const
|
||||||
void for_each_address(FUNC && func) const
|
|
||||||
{
|
{
|
||||||
for (unsigned idx = 0;
|
for (unsigned idx = 0;
|
||||||
idx < len() / sizeof(_dns_servers[0]); idx++) {
|
idx < len() / sizeof(_dns_servers[0]); idx++) {
|
||||||
|
|
||||||
func(_dns_servers[idx]);
|
fn(_dns_servers[idx]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -243,10 +242,9 @@ class Net::Dhcp_packet
|
|||||||
|
|
||||||
Domain_name (Genode::size_t len) : Option(CODE, (Genode::uint8_t)len) { }
|
Domain_name (Genode::size_t len) : Option(CODE, (Genode::uint8_t)len) { }
|
||||||
|
|
||||||
template <typename FUNC>
|
void with_string(auto const &fn) const
|
||||||
void with_string(FUNC && func) const
|
|
||||||
{
|
{
|
||||||
func(_name, Option::len());
|
fn(_name, Option::len());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -427,12 +425,11 @@ class Net::Dhcp_packet
|
|||||||
_size_guard(size_guard)
|
_size_guard(size_guard)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
template <typename OPTION, typename... ARGS>
|
template <typename OPTION>
|
||||||
void append_option(ARGS &&... args)
|
void append_option(auto &&... args)
|
||||||
{
|
{
|
||||||
_size_guard.consume_head(sizeof(OPTION));
|
_size_guard.consume_head(sizeof(OPTION));
|
||||||
Genode::construct_at<OPTION>((void *)_base,
|
Genode::construct_at<OPTION>((void *)_base, args...);
|
||||||
static_cast<ARGS &&>(args)...);
|
|
||||||
_base += sizeof(OPTION);
|
_base += sizeof(OPTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -479,10 +476,9 @@ class Net::Dhcp_packet
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Call 'functor' of type 'FUNC' for each option (except END options)
|
* Call 'fn' of type 'FUNC' for each option (except END options)
|
||||||
*/
|
*/
|
||||||
template <typename FUNC>
|
void for_each_option(auto const &fn) const
|
||||||
void for_each_option(FUNC && functor) const
|
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; ; ) {
|
for (unsigned i = 0; ; ) {
|
||||||
Option &opt = *(Option*)&_opts[i];
|
Option &opt = *(Option*)&_opts[i];
|
||||||
@ -491,7 +487,7 @@ class Net::Dhcp_packet
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
functor(opt);
|
fn(opt);
|
||||||
i += 2 + opt.len();
|
i += 2 + opt.len();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,8 +53,7 @@ class Genode::Buffered_xml
|
|||||||
*
|
*
|
||||||
* \throw Allocation::Out_of_memory
|
* \throw Allocation::Out_of_memory
|
||||||
*/
|
*/
|
||||||
template <typename FN>
|
Allocation _generate(char const *node_name, auto const &fn, size_t size)
|
||||||
Allocation _generate(char const *node_name, FN const &fn, size_t size)
|
|
||||||
{
|
{
|
||||||
Allocation allocation { };
|
Allocation allocation { };
|
||||||
|
|
||||||
@ -103,14 +102,12 @@ class Genode::Buffered_xml
|
|||||||
*
|
*
|
||||||
* \throw Allocator::Out_of_memory
|
* \throw Allocator::Out_of_memory
|
||||||
*/
|
*/
|
||||||
template <typename FN>
|
Buffered_xml(Allocator &alloc, char const *name, auto const &fn, Min_size size)
|
||||||
Buffered_xml(Allocator &alloc, char const *name, FN const &fn, Min_size size)
|
|
||||||
:
|
:
|
||||||
_alloc(alloc), _allocation(_generate(name, fn, size.value))
|
_alloc(alloc), _allocation(_generate(name, fn, size.value))
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
template <typename FN>
|
Buffered_xml(Allocator &alloc, char const *name, auto const &fn)
|
||||||
Buffered_xml(Allocator &alloc, char const *name, FN const &fn)
|
|
||||||
:
|
:
|
||||||
Buffered_xml(alloc, name, fn, Min_size{4000})
|
Buffered_xml(alloc, name, fn, Min_size{4000})
|
||||||
{ }
|
{ }
|
||||||
@ -125,8 +122,7 @@ class Genode::Buffered_xml
|
|||||||
/**
|
/**
|
||||||
* Call functor 'fn' with 'Xml_node const &' as argument
|
* Call functor 'fn' with 'Xml_node const &' as argument
|
||||||
*/
|
*/
|
||||||
template <typename FN>
|
void with_xml_node(auto const &fn) const { fn(_xml); }
|
||||||
void with_xml_node(FN const &fn) const { fn(_xml); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _OS__BUFFERED_XML_H_ */
|
#endif /* _OS__BUFFERED_XML_H_ */
|
||||||
|
@ -124,13 +124,12 @@ class Genode::Reporter
|
|||||||
*/
|
*/
|
||||||
struct Xml_generator : public Genode::Xml_generator
|
struct Xml_generator : public Genode::Xml_generator
|
||||||
{
|
{
|
||||||
template <typename FUNC>
|
Xml_generator(Reporter &reporter, auto const &fn)
|
||||||
Xml_generator(Reporter &reporter, FUNC const &func)
|
|
||||||
:
|
:
|
||||||
Genode::Xml_generator(reporter._base(),
|
Genode::Xml_generator(reporter._base(),
|
||||||
reporter._size(),
|
reporter._size(),
|
||||||
reporter._xml_name.string(),
|
reporter._xml_name.string(),
|
||||||
func)
|
fn)
|
||||||
{
|
{
|
||||||
if (reporter.enabled())
|
if (reporter.enabled())
|
||||||
reporter._conn->report.submit(used());
|
reporter._conn->report.submit(used());
|
||||||
@ -188,8 +187,7 @@ class Genode::Expanding_reporter
|
|||||||
: _env(env), _type(type), _label(label), _buffer_size(size.value)
|
: _env(env), _type(type), _label(label), _buffer_size(size.value)
|
||||||
{ _construct(); }
|
{ _construct(); }
|
||||||
|
|
||||||
template <typename FN>
|
void generate(auto const &fn)
|
||||||
void generate(FN const &fn)
|
|
||||||
{
|
{
|
||||||
retry<Xml_generator::Buffer_exceeded>(
|
retry<Xml_generator::Buffer_exceeded>(
|
||||||
|
|
||||||
|
@ -24,9 +24,9 @@ namespace Genode {
|
|||||||
|
|
||||||
struct Xml_node_label_score;
|
struct Xml_node_label_score;
|
||||||
|
|
||||||
template <size_t N, typename MATCH_FN, typename NO_MATCH_FN>
|
template <size_t N>
|
||||||
void with_matching_policy(String<N> const &, Xml_node const &,
|
void with_matching_policy(String<N> const &, Xml_node const &,
|
||||||
MATCH_FN const &, NO_MATCH_FN const &);
|
auto const &, auto const &);
|
||||||
|
|
||||||
class Session_policy;
|
class Session_policy;
|
||||||
}
|
}
|
||||||
@ -169,11 +169,11 @@ struct Genode::Xml_node_label_score
|
|||||||
* argmument
|
* argmument
|
||||||
* \param no_match_fn functor called if no matching policy exists
|
* \param no_match_fn functor called if no matching policy exists
|
||||||
*/
|
*/
|
||||||
template <Genode::size_t N, typename MATCH_FN, typename NO_MATCH_FN>
|
template <Genode::size_t N>
|
||||||
void Genode::with_matching_policy(String<N> const &label,
|
void Genode::with_matching_policy(String<N> const &label,
|
||||||
Xml_node const &policies,
|
Xml_node const &policies,
|
||||||
MATCH_FN const &match_fn,
|
auto const &match_fn,
|
||||||
NO_MATCH_FN const &no_match_fn)
|
auto const &no_match_fn)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Find policy node that matches best
|
* Find policy node that matches best
|
||||||
|
@ -37,12 +37,8 @@ namespace Genode {
|
|||||||
}
|
}
|
||||||
template <typename>
|
template <typename>
|
||||||
class Watch_handler;
|
class Watch_handler;
|
||||||
template <typename FN>
|
void with_raw_file_content(Readonly_file const &, Byte_range_ptr const &, auto const &);
|
||||||
void with_raw_file_content(Readonly_file const &,
|
void with_xml_file_content(Readonly_file const &, Byte_range_ptr const &, auto const &);
|
||||||
Byte_range_ptr const &, FN const &);
|
|
||||||
template <typename FN>
|
|
||||||
void with_xml_file_content(Readonly_file const &,
|
|
||||||
Byte_range_ptr const &, FN const &);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -188,8 +184,7 @@ struct Genode::Directory : Noncopyable, Interface
|
|||||||
|
|
||||||
~Directory() { if (_handle) _handle->ds().close(_handle); }
|
~Directory() { if (_handle) _handle->ds().close(_handle); }
|
||||||
|
|
||||||
template <typename FN>
|
void for_each_entry(auto const &fn)
|
||||||
void for_each_entry(FN const &fn)
|
|
||||||
{
|
{
|
||||||
for (unsigned i = 0;; i++) {
|
for (unsigned i = 0;; i++) {
|
||||||
|
|
||||||
@ -231,8 +226,7 @@ struct Genode::Directory : Noncopyable, Interface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename FN>
|
void for_each_entry(auto const &fn) const
|
||||||
void for_each_entry(FN const &fn) const
|
|
||||||
{
|
{
|
||||||
auto const_fn = [&] (Entry const &e) { fn(e); };
|
auto const_fn = [&] (Entry const &e) { fn(e); };
|
||||||
const_cast<Directory &>(*this).for_each_entry(const_fn);
|
const_cast<Directory &>(*this).for_each_entry(const_fn);
|
||||||
@ -608,9 +602,8 @@ class Genode::Readonly_file : public File
|
|||||||
*
|
*
|
||||||
* \throw Truncated_during_read
|
* \throw Truncated_during_read
|
||||||
*/
|
*/
|
||||||
template <typename FN>
|
|
||||||
void Genode::with_raw_file_content(Readonly_file const &file,
|
void Genode::with_raw_file_content(Readonly_file const &file,
|
||||||
Byte_range_ptr const &range, FN const &fn)
|
Byte_range_ptr const &range, auto const &fn)
|
||||||
{
|
{
|
||||||
if (range.num_bytes == 0)
|
if (range.num_bytes == 0)
|
||||||
return;
|
return;
|
||||||
@ -628,9 +621,8 @@ void Genode::with_raw_file_content(Readonly_file const &file,
|
|||||||
* If the file does not contain valid XML, 'fn' is called with an
|
* If the file does not contain valid XML, 'fn' is called with an
|
||||||
* '<empty/>' node as argument.
|
* '<empty/>' node as argument.
|
||||||
*/
|
*/
|
||||||
template <typename FN>
|
|
||||||
void Genode::with_xml_file_content(Readonly_file const &file,
|
void Genode::with_xml_file_content(Readonly_file const &file,
|
||||||
Byte_range_ptr const &range, FN const &fn)
|
Byte_range_ptr const &range, auto const &fn)
|
||||||
{
|
{
|
||||||
with_raw_file_content(file, range, [&] (char const *ptr, size_t num_bytes) {
|
with_raw_file_content(file, range, [&] (char const *ptr, size_t num_bytes) {
|
||||||
|
|
||||||
@ -713,8 +705,7 @@ class Genode::File_content
|
|||||||
* If the file does not contain valid XML, 'fn' is called with an
|
* If the file does not contain valid XML, 'fn' is called with an
|
||||||
* '<empty/>' node as argument.
|
* '<empty/>' node as argument.
|
||||||
*/
|
*/
|
||||||
template <typename FN>
|
void xml(auto const &fn) const
|
||||||
void xml(FN const &fn) const
|
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if (_buffer.size) {
|
if (_buffer.size) {
|
||||||
@ -732,8 +723,8 @@ class Genode::File_content
|
|||||||
*
|
*
|
||||||
* \param STRING string type used for the line
|
* \param STRING string type used for the line
|
||||||
*/
|
*/
|
||||||
template <typename STRING, typename FN>
|
template <typename STRING>
|
||||||
void for_each_line(FN const &fn) const
|
void for_each_line(auto const &fn) const
|
||||||
{
|
{
|
||||||
char const *src = _buffer.ptr;
|
char const *src = _buffer.ptr;
|
||||||
char const *curr_line = src;
|
char const *curr_line = src;
|
||||||
@ -766,8 +757,7 @@ class Genode::File_content
|
|||||||
*
|
*
|
||||||
* If the buffer has a size of zero, 'fn' is not called.
|
* If the buffer has a size of zero, 'fn' is not called.
|
||||||
*/
|
*/
|
||||||
template <typename FN>
|
void bytes(auto const &fn) const
|
||||||
void bytes(FN const &fn) const
|
|
||||||
{
|
{
|
||||||
if (_buffer.size)
|
if (_buffer.size)
|
||||||
fn((char const *)_buffer.ptr, _buffer.size);
|
fn((char const *)_buffer.ptr, _buffer.size);
|
||||||
|
@ -625,8 +625,7 @@ struct Pci::Config : Genode::Mmio<0x45>
|
|||||||
read<Base_class_code>() == Base_class_code::BRIDGE;
|
read<Base_class_code>() == Base_class_code::BRIDGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename MEM_FN, typename IO_FN>
|
void for_each_bar(auto const &memory_fn, auto const &io_fn)
|
||||||
void for_each_bar(MEM_FN const & memory, IO_FN const & io)
|
|
||||||
{
|
{
|
||||||
Genode::size_t const reg_cnt =
|
Genode::size_t const reg_cnt =
|
||||||
(read<Header_type::Type>()) ? BASE_ADDRESS_COUNT_TYPE_1
|
(read<Header_type::Type>()) ? BASE_ADDRESS_COUNT_TYPE_1
|
||||||
@ -637,10 +636,10 @@ struct Pci::Config : Genode::Mmio<0x45>
|
|||||||
if (!reg0.valid())
|
if (!reg0.valid())
|
||||||
continue;
|
continue;
|
||||||
if (reg0.memory()) {
|
if (reg0.memory()) {
|
||||||
memory(reg0.addr(), reg0.size(), i, reg0.prefetchable());
|
memory_fn(reg0.addr(), reg0.size(), i, reg0.prefetchable());
|
||||||
if (reg0.bit64()) i++;
|
if (reg0.bit64()) i++;
|
||||||
} else
|
} else
|
||||||
io(reg0.addr(), reg0.size(), i);
|
io_fn(reg0.addr(), reg0.size(), i);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -55,8 +55,7 @@ class Platform::Connection : public Genode::Connection<Session>,
|
|||||||
|
|
||||||
void _handle_io() {}
|
void _handle_io() {}
|
||||||
|
|
||||||
template <typename FN>
|
Capability<Device_interface> _wait_for_device(auto const &fn)
|
||||||
Capability<Device_interface> _wait_for_device(FN const & fn)
|
|
||||||
{
|
{
|
||||||
for (;;) {
|
for (;;) {
|
||||||
/* repeatedly check for availability of device */
|
/* repeatedly check for availability of device */
|
||||||
@ -117,8 +116,7 @@ class Platform::Connection : public Genode::Connection<Session>,
|
|||||||
return Client::alloc_dma_buffer(size, cache); });
|
return Client::alloc_dma_buffer(size, cache); });
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename FN>
|
void with_xml(auto const &fn)
|
||||||
void with_xml(FN const & fn)
|
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if (_ds.constructed() && _ds->local_addr<void const>()) {
|
if (_ds.constructed() && _ds->local_addr<void const>()) {
|
||||||
|
@ -146,18 +146,16 @@ struct Genode::Smbios_entry_point
|
|||||||
|
|
||||||
namespace Genode::Smbios_table
|
namespace Genode::Smbios_table
|
||||||
{
|
{
|
||||||
template <typename PHY_MEM_FUNC,
|
bool smbios_3(addr_t const anchor,
|
||||||
typename EP_FUNC>
|
addr_t const ep_phy,
|
||||||
bool smbios_3(addr_t const anchor,
|
auto const &phy_mem_fn,
|
||||||
addr_t const ep_phy,
|
auto const &handle_ep_fn)
|
||||||
PHY_MEM_FUNC const &phy_mem,
|
|
||||||
EP_FUNC const &handle_ep)
|
|
||||||
{
|
{
|
||||||
if (memcmp((char *)anchor, "_SM3_", 5)) {
|
if (memcmp((char *)anchor, "_SM3_", 5)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Smbios_3_entry_point const &ep { *(Smbios_3_entry_point *)
|
Smbios_3_entry_point const &ep { *(Smbios_3_entry_point *)
|
||||||
phy_mem(ep_phy, sizeof(Smbios_3_entry_point)) };
|
phy_mem_fn(ep_phy, sizeof(Smbios_3_entry_point)) };
|
||||||
|
|
||||||
if (!ep.length_valid()) {
|
if (!ep.length_valid()) {
|
||||||
warning("SMBIOS 3 entry point has bad length");
|
warning("SMBIOS 3 entry point has bad length");
|
||||||
@ -172,22 +170,20 @@ namespace Genode::Smbios_table
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
log("SMBIOS 3 table (entry point: ", Hex(anchor), " structures: ", Hex(ep.struct_table_addr), ")");
|
log("SMBIOS 3 table (entry point: ", Hex(anchor), " structures: ", Hex(ep.struct_table_addr), ")");
|
||||||
handle_ep(ep);
|
handle_ep_fn(ep);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename PHY_MEM_FUNC,
|
bool smbios(addr_t const anchor,
|
||||||
typename EP_FUNC>
|
addr_t const ep_phy,
|
||||||
bool smbios(addr_t const anchor,
|
auto const &phy_mem_fn,
|
||||||
addr_t const ep_phy,
|
auto const &handle_ep_fn)
|
||||||
PHY_MEM_FUNC const &phy_mem,
|
|
||||||
EP_FUNC const &handle_ep)
|
|
||||||
{
|
{
|
||||||
if (memcmp((char *)anchor, "_SM_", 4)) {
|
if (memcmp((char *)anchor, "_SM_", 4)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Smbios_entry_point const &ep { *(Smbios_entry_point *)
|
Smbios_entry_point const &ep { *(Smbios_entry_point *)
|
||||||
phy_mem(ep_phy, sizeof(Smbios_entry_point)) };
|
phy_mem_fn(ep_phy, sizeof(Smbios_entry_point)) };
|
||||||
|
|
||||||
if (!ep.length_valid()) {
|
if (!ep.length_valid()) {
|
||||||
warning("SMBIOS entry point has bad length");
|
warning("SMBIOS entry point has bad length");
|
||||||
@ -206,87 +202,77 @@ namespace Genode::Smbios_table
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
log("SMBIOS table (entry point: ", Hex(anchor), " structures: ", Hex(ep.struct_table_addr), ")");
|
log("SMBIOS table (entry point: ", Hex(anchor), " structures: ", Hex(ep.struct_table_addr), ")");
|
||||||
handle_ep(ep);
|
handle_ep_fn(ep);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename PHY_MEM_FUNC,
|
bool dmi(addr_t const anchor,
|
||||||
typename EP_FUNC>
|
addr_t const ep_phy,
|
||||||
bool dmi(addr_t const anchor,
|
auto const &phy_mem_fn,
|
||||||
addr_t const ep_phy,
|
auto const &handle_ep_fn)
|
||||||
PHY_MEM_FUNC const &phy_mem,
|
|
||||||
EP_FUNC const &handle_ep)
|
|
||||||
{
|
{
|
||||||
if (memcmp((char *)anchor, "_DMI_", 5)) {
|
if (memcmp((char *)anchor, "_DMI_", 5)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Dmi_entry_point const &ep { *(Dmi_entry_point *)
|
Dmi_entry_point const &ep { *(Dmi_entry_point *)
|
||||||
phy_mem(ep_phy, sizeof(Dmi_entry_point)) };
|
phy_mem_fn(ep_phy, sizeof(Dmi_entry_point)) };
|
||||||
|
|
||||||
if (!ep.checksum_correct()) {
|
if (!ep.checksum_correct()) {
|
||||||
warning("DMI entry point has bad checksum");
|
warning("DMI entry point has bad checksum");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
log("DMI table (entry point: ", Hex(anchor), " structures: ", Hex(ep.struct_table_addr), ")");
|
log("DMI table (entry point: ", Hex(anchor), " structures: ", Hex(ep.struct_table_addr), ")");
|
||||||
handle_ep(ep);
|
handle_ep_fn(ep);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename PHY_MEM_FUNC,
|
void from_scan(auto const &phy_mem_fn,
|
||||||
typename SMBIOS_3_FUNC,
|
auto const &handle_smbios_3_ep_fn,
|
||||||
typename SMBIOS_FUNC,
|
auto const &handle_smbios_ep_fn,
|
||||||
typename DMI_FUNC>
|
auto const &handle_dmi_ep_fn)
|
||||||
void from_scan(PHY_MEM_FUNC const &phy_mem,
|
|
||||||
SMBIOS_3_FUNC const &handle_smbios_3_ep,
|
|
||||||
SMBIOS_FUNC const &handle_smbios_ep,
|
|
||||||
DMI_FUNC const &handle_dmi_ep)
|
|
||||||
{
|
{
|
||||||
enum { SCAN_BASE_PHY = 0xf0000 };
|
enum { SCAN_BASE_PHY = 0xf0000 };
|
||||||
enum { SCAN_SIZE = 0x10000 };
|
enum { SCAN_SIZE = 0x10000 };
|
||||||
enum { SCAN_SIZE_SMBIOS = 0xfff0 };
|
enum { SCAN_SIZE_SMBIOS = 0xfff0 };
|
||||||
enum { SCAN_STEP = 0x10 };
|
enum { SCAN_STEP = 0x10 };
|
||||||
|
|
||||||
addr_t const scan_base { (addr_t)phy_mem(SCAN_BASE_PHY, SCAN_SIZE) };
|
addr_t const scan_base { (addr_t)phy_mem_fn(SCAN_BASE_PHY, SCAN_SIZE) };
|
||||||
try {
|
try {
|
||||||
addr_t const scan_end { scan_base + SCAN_SIZE };
|
addr_t const scan_end { scan_base + SCAN_SIZE };
|
||||||
size_t const scan_end_smbios { scan_base + SCAN_SIZE_SMBIOS };
|
size_t const scan_end_smbios { scan_base + SCAN_SIZE_SMBIOS };
|
||||||
|
|
||||||
for (addr_t curr { scan_base }; curr < scan_end_smbios; curr += SCAN_STEP ) {
|
for (addr_t curr { scan_base }; curr < scan_end_smbios; curr += SCAN_STEP ) {
|
||||||
if (smbios_3(curr, SCAN_BASE_PHY + (curr - scan_base), phy_mem, handle_smbios_3_ep)) {
|
if (smbios_3(curr, SCAN_BASE_PHY + (curr - scan_base), phy_mem_fn, handle_smbios_3_ep_fn)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (addr_t curr { scan_base }; curr < scan_end_smbios; curr += SCAN_STEP ) {
|
for (addr_t curr { scan_base }; curr < scan_end_smbios; curr += SCAN_STEP ) {
|
||||||
if (smbios(curr, SCAN_BASE_PHY + (curr - scan_base), phy_mem, handle_smbios_ep)) {
|
if (smbios(curr, SCAN_BASE_PHY + (curr - scan_base), phy_mem_fn, handle_smbios_ep_fn)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (addr_t curr { scan_base }; curr < scan_end; curr += SCAN_STEP ) {
|
for (addr_t curr { scan_base }; curr < scan_end; curr += SCAN_STEP ) {
|
||||||
if (dmi(curr, SCAN_BASE_PHY + (curr - scan_base), phy_mem, handle_dmi_ep)) {
|
if (dmi(curr, SCAN_BASE_PHY + (curr - scan_base), phy_mem_fn, handle_dmi_ep_fn)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (...) { }
|
} catch (...) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename PHY_MEM_FUNC,
|
void from_pointer(addr_t const table_phy,
|
||||||
typename SMBIOS_3_FUNC,
|
auto const &phy_mem_fn,
|
||||||
typename SMBIOS_FUNC,
|
auto const &handle_smbios_3_ep_fn,
|
||||||
typename DMI_FUNC>
|
auto const &handle_smbios_ep_fn,
|
||||||
void from_pointer(addr_t const table_phy,
|
auto const &handle_dmi_ep_fn)
|
||||||
PHY_MEM_FUNC const &phy_mem,
|
|
||||||
SMBIOS_3_FUNC const &handle_smbios_3_ep,
|
|
||||||
SMBIOS_FUNC const &handle_smbios_ep,
|
|
||||||
DMI_FUNC const &handle_dmi_ep)
|
|
||||||
{
|
{
|
||||||
addr_t const anchor { (addr_t)phy_mem(table_phy, 5) };
|
addr_t const anchor { (addr_t)phy_mem_fn(table_phy, 5) };
|
||||||
if (smbios_3(anchor, table_phy, phy_mem, handle_smbios_3_ep)) {
|
if (smbios_3(anchor, table_phy, phy_mem_fn, handle_smbios_3_ep_fn)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (smbios(anchor, table_phy, phy_mem, handle_smbios_ep)) {
|
if (smbios(anchor, table_phy, phy_mem_fn, handle_smbios_ep_fn)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dmi(anchor, table_phy, phy_mem, handle_dmi_ep);
|
dmi(anchor, table_phy, phy_mem_fn, handle_dmi_ep_fn);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -57,9 +57,7 @@ namespace Terminal {
|
|||||||
flush_ok();
|
flush_ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... ARGS>
|
void print(auto &&... args) { Output::out_args(*this, args...); }
|
||||||
void print(ARGS &&... args) {
|
|
||||||
Output::out_args(*this, args...); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Ascii
|
struct Ascii
|
||||||
|
@ -37,8 +37,7 @@ class Trace_buffer
|
|||||||
/**
|
/**
|
||||||
* Call functor for each entry that wasn't yet processed
|
* Call functor for each entry that wasn't yet processed
|
||||||
*/
|
*/
|
||||||
template <typename FUNC>
|
void for_each_new_entry(auto const &fn, bool update = true)
|
||||||
void for_each_new_entry(FUNC && functor, bool update = true)
|
|
||||||
{
|
{
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
@ -72,7 +71,7 @@ class Trace_buffer
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* functor may return false to continue processing later on */
|
/* functor may return false to continue processing later on */
|
||||||
if (!functor(entry))
|
if (!fn(entry))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,8 +42,7 @@ class Usb::Connection : public Genode::Connection<Session>, public Usb::Client
|
|||||||
|
|
||||||
void _handle_io() { }
|
void _handle_io() { }
|
||||||
|
|
||||||
template <typename FN>
|
Device_capability _wait_for_device(auto const & fn)
|
||||||
Device_capability _wait_for_device(FN const & fn)
|
|
||||||
{
|
{
|
||||||
for (;;) {
|
for (;;) {
|
||||||
/* repeatedly check for availability of device */
|
/* repeatedly check for availability of device */
|
||||||
@ -84,8 +83,7 @@ class Usb::Connection : public Genode::Connection<Session>, public Usb::Client
|
|||||||
|
|
||||||
void sigh(Signal_context_capability sigh) { _rom.sigh(sigh); }
|
void sigh(Signal_context_capability sigh) { _rom.sigh(sigh); }
|
||||||
|
|
||||||
template <typename FN>
|
void with_xml(auto const & fn)
|
||||||
void with_xml(FN const & fn)
|
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
try {
|
try {
|
||||||
|
@ -129,13 +129,11 @@ class Usb::Urb_handler
|
|||||||
: 0;
|
: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename URB,
|
template <typename URB>
|
||||||
typename OUT_FN,
|
void _submit(URB &urb,
|
||||||
typename ISOC_OUT_FN>
|
Tx::Source &tx,
|
||||||
void _submit(URB &urb,
|
auto const &out_fn,
|
||||||
Tx::Source &tx,
|
auto const &isoc_out_fn)
|
||||||
OUT_FN const &out_fn,
|
|
||||||
ISOC_OUT_FN const &isoc_out_fn)
|
|
||||||
{
|
{
|
||||||
if (!_tag.constructed())
|
if (!_tag.constructed())
|
||||||
return;
|
return;
|
||||||
@ -169,14 +167,12 @@ class Usb::Urb_handler
|
|||||||
tx.try_submit_packet(p);
|
tx.try_submit_packet(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename URB,
|
template <typename URB>
|
||||||
typename IN_FN,
|
|
||||||
typename ISOC_IN_FN>
|
|
||||||
void _in_results(URB &urb,
|
void _in_results(URB &urb,
|
||||||
Packet_descriptor p,
|
Packet_descriptor p,
|
||||||
Tx::Source &tx,
|
Tx::Source &tx,
|
||||||
IN_FN const &in_fn,
|
auto const &in_fn,
|
||||||
ISOC_IN_FN const &isoc_in_fn)
|
auto const &isoc_in_fn)
|
||||||
{
|
{
|
||||||
if (!_isoc_packets) {
|
if (!_isoc_packets) {
|
||||||
Const_byte_range_ptr src { (const char*)tx.packet_content(p),
|
Const_byte_range_ptr src { (const char*)tx.packet_content(p),
|
||||||
@ -235,18 +231,12 @@ class Usb::Urb_handler
|
|||||||
Id_space<Urb> _tags { };
|
Id_space<Urb> _tags { };
|
||||||
Fifo<Fifo_element<Urb>> _pending { };
|
Fifo<Fifo_element<Urb>> _pending { };
|
||||||
|
|
||||||
template <typename URB,
|
template <typename>
|
||||||
typename IN_FN,
|
bool _try_process_ack(Tx::Source &, auto const &,
|
||||||
typename ISOC_IN_FN,
|
auto const &, auto const &);
|
||||||
typename CPL_FN>
|
|
||||||
bool _try_process_ack(Tx::Source &, IN_FN const &,
|
|
||||||
ISOC_IN_FN const &, CPL_FN const &);
|
|
||||||
|
|
||||||
template <typename URB,
|
template <typename>
|
||||||
typename OUT_FN,
|
bool _try_submit_pending_urb(Tx::Source &, auto const &, auto const &);
|
||||||
typename ISOC_OUT_FN>
|
|
||||||
bool _try_submit_pending_urb(Tx::Source &, OUT_FN const &,
|
|
||||||
ISOC_OUT_FN const &);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -261,17 +251,12 @@ class Usb::Urb_handler
|
|||||||
*
|
*
|
||||||
* \return true if progress was made
|
* \return true if progress was made
|
||||||
*/
|
*/
|
||||||
template <typename URB,
|
template <typename URB>
|
||||||
typename OUT_FN,
|
bool update_urbs(auto const &out_fn,
|
||||||
typename IN_FN,
|
auto const &in_fn,
|
||||||
typename ISOC_OUT_FN,
|
auto const &isoc_out_fn,
|
||||||
typename ISOC_IN_FN,
|
auto const &isoc_in_fn,
|
||||||
typename CPL_FN>
|
auto const &complete_fn)
|
||||||
bool update_urbs(OUT_FN const &out_fn,
|
|
||||||
IN_FN const &in_fn,
|
|
||||||
ISOC_OUT_FN const &isoc_out_fn,
|
|
||||||
ISOC_IN_FN const &isoc_in_fn,
|
|
||||||
CPL_FN const &complete_fn)
|
|
||||||
{
|
{
|
||||||
typename Tx::Source &tx = *_tx.source();
|
typename Tx::Source &tx = *_tx.source();
|
||||||
|
|
||||||
@ -411,17 +396,12 @@ class Usb::Interface
|
|||||||
void sigh(Signal_context_capability cap) {
|
void sigh(Signal_context_capability cap) {
|
||||||
_urb_handler.sigh(cap); }
|
_urb_handler.sigh(cap); }
|
||||||
|
|
||||||
template <typename URB,
|
template <typename URB>
|
||||||
typename OUT_FN,
|
bool update_urbs(auto const &out_fn,
|
||||||
typename IN_FN,
|
auto const &in_fn,
|
||||||
typename ISOC_OUT_FN,
|
auto const &isoc_out_fn,
|
||||||
typename ISOC_IN_FN,
|
auto const &isoc_in_fn,
|
||||||
typename CPL_FN>
|
auto const &complete_fn)
|
||||||
bool update_urbs(OUT_FN const &out_fn,
|
|
||||||
IN_FN const &in_fn,
|
|
||||||
ISOC_OUT_FN const &isoc_out_fn,
|
|
||||||
ISOC_IN_FN const &isoc_in_fn,
|
|
||||||
CPL_FN const &complete_fn)
|
|
||||||
{
|
{
|
||||||
return _urb_handler.update_urbs<URB>(out_fn, in_fn, isoc_out_fn,
|
return _urb_handler.update_urbs<URB>(out_fn, in_fn, isoc_out_fn,
|
||||||
isoc_in_fn, complete_fn);
|
isoc_in_fn, complete_fn);
|
||||||
@ -575,12 +555,11 @@ struct Usb::Interface::Alt_setting : Device::Urb
|
|||||||
|
|
||||||
|
|
||||||
template <typename SESSION>
|
template <typename SESSION>
|
||||||
template <typename URB, typename IN_FN, typename ISOC_IN_FN, typename CPL_FN>
|
template <typename URB>
|
||||||
bool
|
bool Usb::Urb_handler<SESSION>::_try_process_ack(Tx::Source &tx,
|
||||||
Usb::Urb_handler<SESSION>::_try_process_ack(Tx::Source &tx,
|
auto const &in_fn,
|
||||||
IN_FN const &in_fn,
|
auto const &isoc_in,
|
||||||
ISOC_IN_FN const &isoc_in,
|
auto const &complete_fn)
|
||||||
CPL_FN const &complete_fn)
|
|
||||||
{
|
{
|
||||||
if (!tx.ack_avail())
|
if (!tx.ack_avail())
|
||||||
return false;
|
return false;
|
||||||
@ -610,11 +589,10 @@ Usb::Urb_handler<SESSION>::_try_process_ack(Tx::Source &tx,
|
|||||||
|
|
||||||
|
|
||||||
template <typename SESSION>
|
template <typename SESSION>
|
||||||
template <typename URB, typename OUT_FN, typename ISOC_FN>
|
template <typename URB>
|
||||||
bool
|
bool Usb::Urb_handler<SESSION>::_try_submit_pending_urb(Tx::Source &tx,
|
||||||
Usb::Urb_handler<SESSION>::_try_submit_pending_urb(Tx::Source &tx,
|
auto const &out_fn,
|
||||||
OUT_FN const &out_fn,
|
auto const &isoc_fn)
|
||||||
ISOC_FN const &isoc_fn)
|
|
||||||
{
|
{
|
||||||
if (_pending.empty())
|
if (_pending.empty())
|
||||||
return false;
|
return false;
|
||||||
@ -732,8 +710,7 @@ inline Usb::Device::Name Usb::Device::_first_device_name()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename FN>
|
void Usb::Device::_for_each_iface(auto const & fn)
|
||||||
void Usb::Device::_for_each_iface(FN const & fn)
|
|
||||||
{
|
{
|
||||||
_session.with_xml([&] (Xml_node & xml) {
|
_session.with_xml([&] (Xml_node & xml) {
|
||||||
xml.for_each_sub_node("device", [&] (Xml_node node) {
|
xml.for_each_sub_node("device", [&] (Xml_node node) {
|
||||||
|
@ -17,18 +17,17 @@
|
|||||||
/**
|
/**
|
||||||
* Calculate quadratic bezier curve
|
* Calculate quadratic bezier curve
|
||||||
*
|
*
|
||||||
* \param draw_line functor to be called to draw a line segment
|
* \param draw_line_fn functor to be called to draw a line segment
|
||||||
* \param levels number of sub divisions
|
* \param levels number of sub divisions
|
||||||
*
|
*
|
||||||
* The coordinates are specified in clock-wise order with point 1 being
|
* The coordinates are specified in clock-wise order with point 1 being
|
||||||
* the start and point 3 the end of the curve.
|
* the start and point 3 the end of the curve.
|
||||||
*/
|
*/
|
||||||
template <typename FUNC>
|
|
||||||
static inline void bezier(long x1, long y1, long x2, long y2, long x3, long y3,
|
static inline void bezier(long x1, long y1, long x2, long y2, long x3, long y3,
|
||||||
FUNC const &draw_line, unsigned levels)
|
auto const &draw_line_fn, unsigned levels)
|
||||||
{
|
{
|
||||||
if (levels-- == 0) {
|
if (levels-- == 0) {
|
||||||
draw_line(x1, y1, x3, y3);
|
draw_line_fn(x1, y1, x3, y3);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,8 +35,8 @@ static inline void bezier(long x1, long y1, long x2, long y2, long x3, long y3,
|
|||||||
x23 = (x2 + x3) / 2, y23 = (y2 + y3) / 2,
|
x23 = (x2 + x3) / 2, y23 = (y2 + y3) / 2,
|
||||||
x123 = (x12 + x23) / 2, y123 = (y12 + y23) / 2;
|
x123 = (x12 + x23) / 2, y123 = (y12 + y23) / 2;
|
||||||
|
|
||||||
bezier(x1, y1, x12, y12, x123, y123, draw_line, levels);
|
bezier(x1, y1, x12, y12, x123, y123, draw_line_fn, levels);
|
||||||
bezier(x123, y123, x23, y23, x3, y3, draw_line, levels);
|
bezier(x123, y123, x23, y23, x3, y3, draw_line_fn, levels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -47,13 +46,12 @@ static inline void bezier(long x1, long y1, long x2, long y2, long x3, long y3,
|
|||||||
* The arguments correspond to those of the quadratic version but with point 4
|
* The arguments correspond to those of the quadratic version but with point 4
|
||||||
* being the end of the curve.
|
* being the end of the curve.
|
||||||
*/
|
*/
|
||||||
template <typename FUNC>
|
|
||||||
static inline void bezier(long x1, long y1, long x2, long y2,
|
static inline void bezier(long x1, long y1, long x2, long y2,
|
||||||
long x3, long y3, long x4, long y4,
|
long x3, long y3, long x4, long y4,
|
||||||
FUNC const &draw_line, unsigned levels)
|
auto const &draw_line_fn, unsigned levels)
|
||||||
{
|
{
|
||||||
if (levels-- == 0) {
|
if (levels-- == 0) {
|
||||||
draw_line(x1, y1, x4, y4);
|
draw_line_fn(x1, y1, x4, y4);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,8 +62,8 @@ static inline void bezier(long x1, long y1, long x2, long y2,
|
|||||||
x234 = (x23 + x34) / 2, y234 = (y23 + y34) / 2,
|
x234 = (x23 + x34) / 2, y234 = (y23 + y34) / 2,
|
||||||
x1234 = (x123 + x234) / 2, y1234 = (y123 + y234) / 2;
|
x1234 = (x123 + x234) / 2, y1234 = (y123 + y234) / 2;
|
||||||
|
|
||||||
bezier(x1, y1, x12, y12, x123, y123, x1234, y1234, draw_line, levels);
|
bezier(x1, y1, x12, y12, x123, y123, x1234, y1234, draw_line_fn, levels);
|
||||||
bezier(x1234, y1234, x234, y234, x34, y34, x4, y4, draw_line, levels);
|
bezier(x1234, y1234, x234, y234, x34, y34, x4, y4, draw_line_fn, levels);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _INCLUDE__GEMS__BEZIER_H_ */
|
#endif /* _INCLUDE__GEMS__BEZIER_H_ */
|
||||||
|
@ -77,8 +77,7 @@ class Genode::Dirty_rect
|
|||||||
* The functor 'fn' takes a 'Rect const &' as argument.
|
* The functor 'fn' takes a 'Rect const &' as argument.
|
||||||
* This method resets the dirty rectangles.
|
* This method resets the dirty rectangles.
|
||||||
*/
|
*/
|
||||||
template <typename FN>
|
void flush(auto const &fn)
|
||||||
void flush(FN const &fn)
|
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Merge rectangles if their compound is smaller than sum of their
|
* Merge rectangles if their compound is smaller than sum of their
|
||||||
|
@ -29,8 +29,7 @@ namespace Genode {
|
|||||||
/**
|
/**
|
||||||
* Return the number of characters needed when rendering 'args' as text
|
* Return the number of characters needed when rendering 'args' as text
|
||||||
*/
|
*/
|
||||||
template <typename... ARGS>
|
static unsigned printed_length(auto &&... args)
|
||||||
static unsigned printed_length(ARGS &&... args)
|
|
||||||
{
|
{
|
||||||
struct _Output : Output
|
struct _Output : Output
|
||||||
{
|
{
|
||||||
|
@ -170,9 +170,9 @@ class Vfs::Dir_file_system : public File_system
|
|||||||
* \param fn functor that takes a file-system reference and
|
* \param fn functor that takes a file-system reference and
|
||||||
* the path as arguments
|
* the path as arguments
|
||||||
*/
|
*/
|
||||||
template <typename RES, typename FN>
|
template <typename RES>
|
||||||
RES _dir_op(RES const no_entry, RES const no_perm, RES const ok,
|
RES _dir_op(RES const no_entry, RES const no_perm, RES const ok,
|
||||||
char const *path, FN const &fn)
|
char const *path, auto const &fn)
|
||||||
{
|
{
|
||||||
path = _sub_path(path);
|
path = _sub_path(path);
|
||||||
|
|
||||||
|
@ -149,9 +149,8 @@ class Vfs::Vfs_handle
|
|||||||
*
|
*
|
||||||
* XXX: may not be necesarry if the method above is virtual.
|
* XXX: may not be necesarry if the method above is virtual.
|
||||||
*/
|
*/
|
||||||
template <typename FUNC>
|
void apply_handler(auto const &fn) const {
|
||||||
void apply_handler(FUNC const &func) const {
|
if (_handler_ptr) fn(*_handler_ptr); }
|
||||||
if (_handler_ptr) func(*_handler_ptr); }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notify application through response handler
|
* Notify application through response handler
|
||||||
|
@ -104,8 +104,7 @@ class Virtio::Device
|
|||||||
Device_mmio _isr { _bar_range("irq_status") };
|
Device_mmio _isr { _bar_range("irq_status") };
|
||||||
size_t _notify_offset_multiplier { 0 };
|
size_t _notify_offset_multiplier { 0 };
|
||||||
|
|
||||||
template <typename FN>
|
void with_virtio_range(String<16> type, auto const &fn)
|
||||||
void with_virtio_range(String<16> type, FN const & fn)
|
|
||||||
{
|
{
|
||||||
_plat.update();
|
_plat.update();
|
||||||
_plat.with_xml([&] (Xml_node xml) {
|
_plat.with_xml([&] (Xml_node xml) {
|
||||||
|
@ -429,8 +429,7 @@ class Virtio::Queue
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename FN>
|
void read_data(auto const &fn)
|
||||||
void read_data(FN const &fn)
|
|
||||||
{
|
{
|
||||||
if (!has_used_buffers())
|
if (!has_used_buffers())
|
||||||
return;
|
return;
|
||||||
@ -470,12 +469,12 @@ class Virtio::Queue
|
|||||||
return *((Header_type *)(desc_data));
|
return *((Header_type *)(desc_data));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename REPLY_TYPE, typename WAIT_REPLY_FN, typename REPLY_FN>
|
template <typename REPLY_TYPE>
|
||||||
bool write_data_read_reply(Header_type const &header,
|
bool write_data_read_reply(Header_type const &header,
|
||||||
char const *data,
|
char const *data,
|
||||||
size_t data_size,
|
size_t data_size,
|
||||||
WAIT_REPLY_FN const &wait_for_reply,
|
auto const &wait_for_reply_fn,
|
||||||
REPLY_FN const &read_reply)
|
auto const &read_reply_fn)
|
||||||
{
|
{
|
||||||
static_assert(!TRAITS::device_write_only);
|
static_assert(!TRAITS::device_write_only);
|
||||||
static_assert(TRAITS::has_data_payload);
|
static_assert(TRAITS::has_data_payload);
|
||||||
@ -521,7 +520,7 @@ class Virtio::Queue
|
|||||||
_avail->idx = _avail->idx + 1;
|
_avail->idx = _avail->idx + 1;
|
||||||
_avail->flags = Avail::Flags::NO_INTERRUPT;
|
_avail->flags = Avail::Flags::NO_INTERRUPT;
|
||||||
|
|
||||||
wait_for_reply();
|
wait_for_reply_fn();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure wait call did what it was supposed to do.
|
* Make sure wait call did what it was supposed to do.
|
||||||
@ -536,16 +535,16 @@ class Virtio::Queue
|
|||||||
*/
|
*/
|
||||||
ack_all_transfers();
|
ack_all_transfers();
|
||||||
|
|
||||||
return read_reply(*reinterpret_cast<REPLY_TYPE const *>(reply_buffer.local_addr));
|
return read_reply_fn(*reinterpret_cast<REPLY_TYPE const *>(reply_buffer.local_addr));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename REPLY_TYPE, typename WAIT_REPLY_FN, typename REPLY_FN>
|
template <typename REPLY_TYPE>
|
||||||
bool write_data_read_reply(Header_type const &header,
|
bool write_data_read_reply(Header_type const &header,
|
||||||
WAIT_REPLY_FN const &wait_for_reply,
|
auto const &wait_for_reply_fn,
|
||||||
REPLY_FN const &read_reply)
|
auto const &read_reply_fn)
|
||||||
{
|
{
|
||||||
return write_data_read_reply<REPLY_TYPE>(
|
return write_data_read_reply<REPLY_TYPE>(
|
||||||
header, nullptr, 0, wait_for_reply, read_reply);
|
header, nullptr, 0, wait_for_reply_fn, read_reply_fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print(Output& output) const
|
void print(Output& output) const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user