rtc_drv: log 'set time' message on verbose

The "verbose" config attribute instructs the driver to log 'set time'
messages when the RTC updated initially or from the 'set_rtc' ROM.

Fixes #4526
This commit is contained in:
Roland Bär 2022-06-11 09:54:58 +02:00 committed by Christian Helmuth
parent 1c5db07342
commit 18b022bf6b
4 changed files with 18 additions and 5 deletions

View File

@ -1 +1 @@
2022-05-24 7314ffd53ce1d9f266a45b149455ffe4f39e26a7
2022-06-06 198a9b3ca1625083e8e5cc6893c2dc9c3ef7b254

View File

@ -1 +1 @@
2022-05-24 efd3414279424ba9af6316da0d14eaa16c334f8a
2022-06-06 4d3547ead19b82e81c31750cdbd4a3d19dbfa1b4

View File

@ -58,7 +58,7 @@ append config {
<resource name="RAM" quantum="1M"/>
<provides><service name="Rtc"/></provides>}
append_if $test_update config {
<config allow_setting_rtc="true"/>
<config allow_setting_rtc="true" verbose="yes"/>
<route>
<service name="ROM" label="set_rtc">
<child name="report_rom"/>

View File

@ -106,6 +106,9 @@ struct Rtc::Main
bool const _set_rtc {
_config_rom.xml().attribute_value("allow_setting_rtc", false) };
bool const _verbose {
_config_rom.xml().attribute_value("verbose", false) };
Constructible<Attached_rom_dataspace> _update_rom { };
struct Invalid_timestamp_xml : Exception {};
@ -124,7 +127,12 @@ struct Rtc::Main
}
try {
Rtc::set_time(env, _parse_xml(_config_rom.xml()));
Timestamp ts = _parse_xml(_config_rom.xml());
if (_verbose)
Genode::log("set time to ", ts);
Rtc::set_time(env, ts);
} catch (Invalid_timestamp_xml &) {}
env.parent().announce(env.ep().manage(root));
@ -189,7 +197,12 @@ void Rtc::Main::_handle_update()
Genode::Xml_node node = _update_rom->xml();
try {
Rtc::set_time(env, _parse_xml(node));
Timestamp ts = _parse_xml(node);
if (_verbose)
Genode::log("set time to ", ts);
Rtc::set_time(env, ts);
root.notify_clients();
} catch (Invalid_timestamp_xml &) {
Genode::warning("set_rtc: ignoring incomplete RTC update"); }