summaryrefslogtreecommitdiff
path: root/common/printf.c
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2021-01-08 15:07:05 -0700
committerCommit Bot <commit-bot@chromium.org>2021-01-09 01:40:05 +0000
commitba9df2aa09deeae5d851c59469d782b1a7a0efe4 (patch)
tree6c7b2e8fcc6f4c6644e04a21c6d303372a10a056 /common/printf.c
parent61a46cf57de2a1805c5e686ead580958b9cbc667 (diff)
downloadchrome-ec-ba9df2aa09deeae5d851c59469d782b1a7a0efe4.tar.gz
zephyr: switch to platform/ec printf format implementation
Prior to this change, the cprints and cprintf shim implementations used Zephyr's printk to do the output formatting. Our EC code has some custom printf specifiers not supported by Zephyr's printk. We've already attempted to send some of our custom specifiers upstream, but upstream does not want them: https://github.com/zephyrproject-rtos/zephyr/pull/28882 The logical thing to do would be to bring in the vfnprintf function from our EC to the Zephyr build, and use that to do the output formatting instead. That's what this CL does. The binary cost of brining in this second printf implementation appears to be minimal (952 bytes on volteer). BUG=b:177065615 BRANCH=none TEST=on posix-ec and volteer, run gettime and observe output no longer contains %.6lld, but instead the correct system time Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I53cd4edf129223c12a2c5e7d0519623a8d07a328 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2618575
Diffstat (limited to 'common/printf.c')
-rw-r--r--common/printf.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/common/printf.c b/common/printf.c
index f876a1da19..039a83a92f 100644
--- a/common/printf.c
+++ b/common/printf.c
@@ -275,7 +275,9 @@ int vfnprintf(int (*addchar)(void *context, int c), void *context,
continue;
/* %pT - print a timestamp. */
if (ptrspec == 'T' &&
- !IS_ENABLED(NO_UINT64_SUPPORT)) {
+ !IS_ENABLED(NO_UINT64_SUPPORT) &&
+ (!IS_ENABLED(CONFIG_ZEPHYR) ||
+ IS_ENABLED(CONFIG_PLATFORM_EC_TIMER))) {
flags |= PF_64BIT;
if (ptrval == PRINTF_TIMESTAMP_NOW)
v = get_time().val;
@@ -461,6 +463,12 @@ int vfnprintf(int (*addchar)(void *context, int c), void *context,
return EC_SUCCESS;
}
+/*
+ * These symbols are already defined by the Zephyr OS kernel, and we
+ * don't want to use the EC implementation.
+ */
+#ifndef CONFIG_ZEPHYR
+
/* Context for snprintf() */
struct snprintf_context {
char *str;
@@ -516,3 +524,5 @@ int vsnprintf(char *str, int size, const char *format, va_list args)
return (rv == EC_SUCCESS) ? (ctx.str - str) : -rv;
}
+
+#endif /* !CONFIG_ZEPHYR */