summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Honscheid <honscheid@google.com>2022-09-21 12:46:12 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-09-26 21:59:20 +0000
commitc354a13e5b538dda714191d694091eac34b90bc4 (patch)
treef5574ec5db591ad88b250dcb83862df6f73d799f
parent55ef7a03129eb301a51c5539672d910d1243187f (diff)
downloadchrome-ec-c354a13e5b538dda714191d694091eac34b90bc4.tar.gz
zephyr: #ifdef code in `common/timer.c` not used in Zephyr
Several functions in `common/timer.c` are not used in Zephyr-based builds. Exclude these with `#ifndef CONFIG_ZEPHYR`. BRANCH=None BUG=b:247608485 TEST=./twister LOW_COVERAGE_REASON=No new code; Minor re-org of non-Zephyr functions Signed-off-by: Tristan Honscheid <honscheid@google.com> Change-Id: I2858f8b9b59b279f8b786abca26a3b2471db59cc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3910979 Reviewed-by: Keith Short <keithshort@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
-rw-r--r--common/timer.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/common/timer.c b/common/timer.c
index eea773619b..d0fd1eca6e 100644
--- a/common/timer.c
+++ b/common/timer.c
@@ -37,16 +37,19 @@ extern __error("k_usleep() should only be called from Zephyr code") int32_t
/* High 32-bits of the 64-bit timestamp counter. */
STATIC_IF_NOT(CONFIG_HWTIMER_64BIT) volatile uint32_t clksrc_high;
+/* Hardware timer routine IRQ number */
+static int timer_irq;
+
+#ifndef CONFIG_ZEPHYR
/* Bitmap of currently running timers */
static uint32_t timer_running;
+BUILD_ASSERT((sizeof(timer_running) * 8) > TASK_ID_COUNT);
+
/* Deadlines of all timers */
static timestamp_t timer_deadline[TASK_ID_COUNT];
static uint32_t next_deadline = 0xffffffff;
-/* Hardware timer routine IRQ number */
-static int timer_irq;
-
static void expire_timer(task_id_t tskid)
{
/* we are done with this timer */
@@ -55,18 +58,6 @@ static void expire_timer(task_id_t tskid)
task_set_event(tskid, TASK_EVENT_TIMER);
}
-int timestamp_expired(timestamp_t deadline, const timestamp_t *now)
-{
- timestamp_t now_val;
-
- if (!now) {
- now_val = get_time();
- now = &now_val;
- }
-
- return ((int64_t)(now->val - deadline.val) >= 0);
-}
-
void process_timers(int overflow)
{
uint32_t check_timer, running_t0;
@@ -109,6 +100,19 @@ void process_timers(int overflow)
next_deadline = next.le.lo;
} while (next.val <= get_time().val);
}
+#endif /* !defined(CONFIG_ZEPHYR) */
+
+int timestamp_expired(timestamp_t deadline, const timestamp_t *now)
+{
+ timestamp_t now_val;
+
+ if (!now) {
+ now_val = get_time();
+ now = &now_val;
+ }
+
+ return ((int64_t)(now->val - deadline.val) >= 0);
+}
#ifndef CONFIG_HW_SPECIFIC_UDELAY
void udelay(unsigned us)
@@ -300,7 +304,6 @@ void timer_print_info(void)
{
timestamp_t t = get_time();
uint64_t deadline = (uint64_t)t.le.hi << 32 | __hw_clock_event_get();
- int tskid;
ccprintf("Time: 0x%016llx us, %11.6lld s\n"
"Deadline: 0x%016llx -> %11.6lld s from now\n"
@@ -308,7 +311,8 @@ void timer_print_info(void)
t.val, t.val, deadline, deadline - t.val);
cflush();
- for (tskid = 0; tskid < TASK_ID_COUNT; tskid++) {
+#ifndef CONFIG_ZEPHYR
+ for (int tskid = 0; tskid < TASK_ID_COUNT; tskid++) {
if (timer_running & BIT(tskid)) {
ccprintf(" Tsk %2d 0x%016llx -> %11.6lld\n", tskid,
timer_deadline[tskid].val,
@@ -316,6 +320,7 @@ void timer_print_info(void)
cflush();
}
}
+#endif /* !defined(CONFIG_ZEPHYR) */
}
void timer_init(void)
@@ -323,8 +328,6 @@ void timer_init(void)
const timestamp_t *ts;
int size, version;
- BUILD_ASSERT(TASK_ID_COUNT < sizeof(timer_running) * 8);
-
/* Restore time from before sysjump */
ts = (const timestamp_t *)system_get_jump_tag(TIMER_SYSJUMP_TAG,
&version, &size);