lx_emul: allow setup of the persistent clock

This commit adds support to initialize the timekeeping for
the Linux subsystem with the value from the RTC.

Only the seconds part of timespec64 is supported.

Issue genodelabs/genode#4957
This commit is contained in:
Pirmin Duss 2023-07-07 15:07:14 +02:00 committed by Christian Helmuth
parent 9aa0de24af
commit f66a7db87f
3 changed files with 32 additions and 0 deletions

View File

@ -40,6 +40,7 @@ SRC_C += lx_emul/shadow/mm/slab_common.c
SRC_C += lx_emul/shadow/mm/slub.c
SRC_C += lx_emul/shadow/mm/vmstat.c
SRC_C += lx_emul/start.c
SRC_C += lx_emul/time_initial.c
SRC_C += lx_emul/virt_to_page.c
SRC_CC += lx_kit/console.cc

View File

@ -30,6 +30,8 @@ void lx_emul_time_handle(void);
void lx_emul_time_update_jiffies(void);
void lx_emul_time_initial(unsigned long long);
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,29 @@
/*
* \brief Lx_emul initial time (persistent clock)
* \author Pirmin Duss
* \date 2023-10-02
*/
/*
* Copyright (C) 2023 Genode Labs GmbH
* Copyright (C) 2023 gapfruit AG
*
* This file is distributed under the terms of the GNU General Public License
* version 2.
*/
#include <linux/time.h>
static unsigned long long genode_initial_ts_sec = 0;
void lx_emul_time_initial(unsigned long long seconds)
{
genode_initial_ts_sec = seconds;
}
void read_persistent_clock64(struct timespec64 *ts)
{
ts->tv_sec = genode_initial_ts_sec;
ts->tv_nsec = 0;
}