1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright 2012 Lennart Poettering
7 Copyright 2013 Kay Sievers
9 systemd is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 2.1 of the License, or
12 (at your option) any later version.
14 systemd is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
19 You should have received a copy of the GNU Lesser General Public License
20 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 #include "boot-timestamps.h"
25 #include "acpi-fpdt.h"
28 int boot_timestamps(const dual_timestamp *n, dual_timestamp *firmware, dual_timestamp *loader) {
29 usec_t x = 0, y = 0, a;
37 dual_timestamp_get(&_n);
41 r = acpi_get_boot_usec(&x, &y);
44 r = efi_loader_get_boot_usec(&x, &y);
50 /* Let's convert this to timestamps where the firmware
51 * began/loader began working. To make this more confusing:
52 * since usec_t is unsigned and the kernel's monotonic clock
53 * begins at kernel initialization we'll actually initialize
54 * the monotonic timestamps here as negative of the actual
57 firmware->monotonic = y;
58 loader->monotonic = y - x;
60 a = n->monotonic + firmware->monotonic;
61 firmware->realtime = n->realtime > a ? n->realtime - a : 0;
63 a = n->monotonic + loader->monotonic;
64 loader->realtime = n->realtime > a ? n->realtime - a : 0;