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>
This commit is contained in:
nagendra modadugu
2016-06-11 01:42:12 -07:00
committed by chrome-bot
parent ea1515ae13
commit 0201aa1620
3 changed files with 29 additions and 18 deletions

View File

@@ -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

View File

@@ -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);
}

View File

@@ -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);
}