summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagendra modadugu <ngm@google.com>2016-06-11 01:42:12 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-06-15 15:29:14 -0700
commit0201aa1620e89817acf84ff50532b3d4425c63cd (patch)
tree86a2ed5790fe23fc3704123dac53cfe1156d33b2
parentea1515ae13800b968933656728881ff330d38ebe (diff)
downloadchrome-ec-0201aa1620e89817acf84ff50532b3d4425c63cd.tar.gz
CR50: refactor debug_printf() for use as a library function
loader/key_ladder.c depends on debug_printf(). Refactor the printf function so that key_ladder.c need not depend on main.c. This change being made in preparation for a future change which introduces a dependency between RW and key_ladder.o BRANCH=none BUG=chrome-os-partner:43025,chrome-os-partner:47524 TEST=build succeeds Change-Id: I5c9bf7bd6dd9f76ab6410e6e797973bdb072ec16 Signed-off-by: nagendra modadugu <ngm@google.com> Reviewed-on: https://chromium-review.googlesource.com/351760 Commit-Ready: Nagendra Modadugu <ngm@google.com> Tested-by: Nagendra Modadugu <ngm@google.com> Reviewed-by: Bill Richardson <wfrichar@chromium.org>
-rw-r--r--chip/g/build.mk1
-rw-r--r--chip/g/loader/debug_printf.c28
-rw-r--r--chip/g/loader/main.c18
3 files changed, 29 insertions, 18 deletions
diff --git a/chip/g/build.mk b/chip/g/build.mk
index 12c3c9079d..d7e7b02cc3 100644
--- a/chip/g/build.mk
+++ b/chip/g/build.mk
@@ -78,6 +78,7 @@ ifneq ($(CONFIG_CUSTOMIZED_RO),)
custom-ro_objs-y = chip/g/clock.o
custom-ro_objs-y += chip/g/dcrypto/sha256.o
custom-ro_objs-y += chip/g/loader/key_ladder.o
+custom-ro_objs-y += chip/g/loader/debug_printf.o
custom-ro_objs-y += chip/g/loader/launch.o
custom-ro_objs-y += chip/g/loader/main.o
custom-ro_objs-y += chip/g/loader/rom_flash.o
diff --git a/chip/g/loader/debug_printf.c b/chip/g/loader/debug_printf.c
new file mode 100644
index 0000000000..4d7e67b7ec
--- /dev/null
+++ b/chip/g/loader/debug_printf.c
@@ -0,0 +1,28 @@
+/* Copyright 2016 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#include "debug_printf.h"
+
+#include "printf.h"
+#include "uart.h"
+
+#include "stddef.h"
+
+static int printchar(void *context, int c)
+{
+ if (c == '\n')
+ uart_write_char('\r');
+ uart_write_char(c);
+
+ return 0;
+}
+
+void debug_printf(const char *format, ...)
+{
+ va_list args;
+
+ va_start(args, format);
+ vfnprintf(printchar, NULL, format, args);
+ va_end(args);
+}
diff --git a/chip/g/loader/main.c b/chip/g/loader/main.c
index 985aa34a19..7381e52471 100644
--- a/chip/g/loader/main.c
+++ b/chip/g/loader/main.c
@@ -131,21 +131,3 @@ void interrupt_disable(void)
{
asm("cpsid i");
}
-
-static int printchar(void *context, int c)
-{
- if (c == '\n')
- uart_write_char('\r');
- uart_write_char(c);
-
- return 0;
-}
-
-void debug_printf(const char *format, ...)
-{
- va_list args;
-
- va_start(args, format);
- vfnprintf(printchar, NULL, format, args);
- va_end(args);
-}