summaryrefslogtreecommitdiff
path: root/src/lib/timestamp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/timestamp.c')
-rw-r--r--src/lib/timestamp.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/lib/timestamp.c b/src/lib/timestamp.c
index 30f7c13fb8..2e14fdd647 100644
--- a/src/lib/timestamp.c
+++ b/src/lib/timestamp.c
@@ -2,6 +2,7 @@
* This file is part of the coreboot project.
*
* Copyright (C) 2011 The ChromiumOS Authors. All rights reserved.
+ * Copyright 2017 Siemens AG.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -327,6 +328,19 @@ void timestamp_rescale_table(uint16_t N, uint16_t M)
}
}
+/*
+ * Get the time in microseconds since boot (or more precise: since timestamp
+ * table was initialized).
+ */
+uint32_t get_us_since_boot(void)
+{
+ struct timestamp_table *ts = timestamp_table_get();
+
+ if (ts == NULL || ts->tick_freq_mhz == 0)
+ return 0;
+ return (timestamp_get() - ts->base_time) / ts->tick_freq_mhz;
+}
+
ROMSTAGE_CBMEM_INIT_HOOK(timestamp_sync_cache_to_cbmem)
RAMSTAGE_CBMEM_INIT_HOOK(timestamp_sync_cache_to_cbmem)