LCOV - code coverage report
Current view: top level - shared - boot-timestamps.c (source / functions) Hit Total Coverage
Test: systemd_full.info Lines: 12 19 63.2 %
Date: 2019-08-23 13:36:53 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 5 14 35.7 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: LGPL-2.1+ */
       2                 :            : 
       3                 :            : #include "acpi-fpdt.h"
       4                 :            : #include "boot-timestamps.h"
       5                 :            : #include "efivars.h"
       6                 :            : #include "macro.h"
       7                 :            : #include "time-util.h"
       8                 :            : 
       9                 :          4 : int boot_timestamps(const dual_timestamp *n, dual_timestamp *firmware, dual_timestamp *loader) {
      10                 :          4 :         usec_t x = 0, y = 0, a;
      11                 :            :         int r;
      12                 :            :         dual_timestamp _n;
      13                 :            : 
      14         [ -  + ]:          4 :         assert(firmware);
      15         [ -  + ]:          4 :         assert(loader);
      16                 :            : 
      17         [ +  - ]:          4 :         if (!n) {
      18                 :          4 :                 dual_timestamp_get(&_n);
      19                 :          4 :                 n = &_n;
      20                 :            :         }
      21                 :            : 
      22                 :          4 :         r = acpi_get_boot_usec(&x, &y);
      23         [ +  - ]:          4 :         if (r < 0) {
      24                 :          4 :                 r = efi_loader_get_boot_usec(&x, &y);
      25         [ +  - ]:          4 :                 if (r < 0)
      26                 :          4 :                         return r;
      27                 :            :         }
      28                 :            : 
      29                 :            :         /* Let's convert this to timestamps where the firmware
      30                 :            :          * began/loader began working. To make this more confusing:
      31                 :            :          * since usec_t is unsigned and the kernel's monotonic clock
      32                 :            :          * begins at kernel initialization we'll actually initialize
      33                 :            :          * the monotonic timestamps here as negative of the actual
      34                 :            :          * value. */
      35                 :            : 
      36                 :          0 :         firmware->monotonic = y;
      37                 :          0 :         loader->monotonic = y - x;
      38                 :            : 
      39                 :          0 :         a = n->monotonic + firmware->monotonic;
      40         [ #  # ]:          0 :         firmware->realtime = n->realtime > a ? n->realtime - a : 0;
      41                 :            : 
      42                 :          0 :         a = n->monotonic + loader->monotonic;
      43         [ #  # ]:          0 :         loader->realtime = n->realtime > a ? n->realtime - a : 0;
      44                 :            : 
      45                 :          0 :         return 0;
      46                 :            : }

Generated by: LCOV version 1.14