From fc494bfe3fb6363e1077dc035eb119970d84a9d1 Mon Sep 17 00:00:00 2001 From: Zhaoming Luo Date: Tue, 24 Dec 2024 09:57:51 +0800 Subject: kern: Add a mach host operation which returns elapsed time since bootup Add host_get_uptime64() mach interface operation. It can be used to get the time passed since the boot up. * doc/mach.texi: Add the documentation for the operation * include/mach/mach_host.defs: Add the interface * include/mach/time_value.h: Extend the mappable time variable * kern/mach_clock.c: Operation implementation * kern/mach_clock.h: Add a new variable for storing uptime Signed-off-by: Zhaoming Luo Message-ID: <20241224015751.1282-1-zhmingluo@163.com> --- include/mach/mach_host.defs | 7 +++++++ include/mach/time_value.h | 2 ++ 2 files changed, 9 insertions(+) (limited to 'include') diff --git a/include/mach/mach_host.defs b/include/mach/mach_host.defs index 8fd9d6b3..501ca0f6 100644 --- a/include/mach/mach_host.defs +++ b/include/mach/mach_host.defs @@ -386,3 +386,10 @@ routine host_adjust_time64( routine host_get_kernel_version( host : host_t; out kernel_version : new_kernel_version_t); + +/* + * Get the uptime on this host. + */ +routine host_get_uptime64( + host : host_t; + out uptime : time_value64_t); diff --git a/include/mach/time_value.h b/include/mach/time_value.h index e08707bc..7378c2cf 100644 --- a/include/mach/time_value.h +++ b/include/mach/time_value.h @@ -172,6 +172,8 @@ typedef struct mapped_time_value { integer_t check_seconds; struct time_value64 time_value; int64_t check_seconds64; + struct time_value64 uptime_value; + int64_t check_upseconds64; } mapped_time_value_t; /* Macros for converting between struct timespec and time_value_t. */ -- cgit v1.2.3