diff options
author | Dimitris Papastamos <dimitris.papastamos@arm.com> | 2018-08-15 10:49:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-15 10:49:57 +0100 |
commit | 07da0bf9768d5fcceb1bf946e8e2f18d790c84be (patch) | |
tree | 9703ebc7cce2c8d11ce577f76f3506ac6bb12e21 | |
parent | 7e8a891f39acdae8679d2daec22246c678576142 (diff) | |
parent | 6a23356c4f70d1407c094ea2ea3e21e8a657c1c3 (diff) | |
download | trusted-firmware-a-07da0bf9768d5fcceb1bf946e8e2f18d790c84be.tar.gz |
Merge pull request #1516 from antonio-nino-diaz-arm/an/printf
Replace stdio.h functions by TF functions
-rw-r--r-- | common/tf_snprintf.c | 17 | ||||
-rw-r--r-- | drivers/marvell/comphy/phy-comphy-cp110.c | 2 | ||||
-rw-r--r-- | drivers/partition/partition.c | 4 | ||||
-rw-r--r-- | drivers/st/clk/stm32mp1_clk.c | 2 | ||||
-rw-r--r-- | plat/hisilicon/hikey/hisi_ipc.c | 6 | ||||
-rw-r--r-- | plat/marvell/a8k/common/mss/mss_bl2_setup.c | 1 | ||||
-rw-r--r-- | services/spd/trusty/generic-arm64-smcall.c | 8 |
7 files changed, 28 insertions, 12 deletions
diff --git a/common/tf_snprintf.c b/common/tf_snprintf.c index a99ab7ab5d..6df137725a 100644 --- a/common/tf_snprintf.c +++ b/common/tf_snprintf.c @@ -8,6 +8,17 @@ #include <platform.h> #include <stdarg.h> +static void string_print(char **s, size_t n, size_t *chars_printed, + const char *str) +{ + while (*str) { + if (*chars_printed < n) + *(*s)++ = *str; + (*chars_printed)++; + str++; + } +} + static void unsigned_dec_print(char **s, size_t n, size_t *chars_printed, unsigned int unum) { @@ -32,6 +43,7 @@ static void unsigned_dec_print(char **s, size_t n, size_t *chars_printed, * The following type specifiers are supported: * * %d or %i - signed decimal format + * %s - string format * %u - unsigned decimal format * * The function panics on all other formats specifiers. @@ -45,6 +57,7 @@ int tf_snprintf(char *s, size_t n, const char *fmt, ...) va_list args; int num; unsigned int unum; + char *str; size_t chars_printed = 0; if (n == 1) { @@ -79,6 +92,10 @@ int tf_snprintf(char *s, size_t n, const char *fmt, ...) unsigned_dec_print(&s, n, &chars_printed, unum); break; + case 's': + str = va_arg(args, char *); + string_print(&s, n, &chars_printed, str); + break; case 'u': unum = va_arg(args, unsigned int); unsigned_dec_print(&s, n, &chars_printed, unum); diff --git a/drivers/marvell/comphy/phy-comphy-cp110.c b/drivers/marvell/comphy/phy-comphy-cp110.c index 8b78280b58..2b1770f087 100644 --- a/drivers/marvell/comphy/phy-comphy-cp110.c +++ b/drivers/marvell/comphy/phy-comphy-cp110.c @@ -18,7 +18,7 @@ /* #define DEBUG_COMPHY */ #ifdef DEBUG_COMPHY -#define debug(format...) printf(format) +#define debug(format...) tf_printf(format) #else #define debug(format, arg...) #endif diff --git a/drivers/partition/partition.c b/drivers/partition/partition.c index e2b468363b..5a338b8d9c 100644 --- a/drivers/partition/partition.c +++ b/drivers/partition/partition.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -24,7 +24,7 @@ static void dump_entries(int num) VERBOSE("Partition table with %d entries:\n", num); for (i = 0; i < num; i++) { - len = snprintf(name, EFI_NAMELEN, "%s", list.list[i].name); + len = tf_snprintf(name, EFI_NAMELEN, "%s", list.list[i].name); for (j = 0; j < EFI_NAMELEN - len - 1; j++) { name[len + j] = ' '; } diff --git a/drivers/st/clk/stm32mp1_clk.c b/drivers/st/clk/stm32mp1_clk.c index 7dff98b1b9..1dc08d8047 100644 --- a/drivers/st/clk/stm32mp1_clk.c +++ b/drivers/st/clk/stm32mp1_clk.c @@ -1344,7 +1344,7 @@ int stm32mp1_clk_init(void) for (i = (enum stm32mp1_pll_id)0; i < _PLL_NB; i++) { char name[12]; - sprintf(name, "st,pll@%d", i); + tf_snprintf(name, sizeof(name), "st,pll@%d", i); plloff[i] = fdt_rcc_subnode_offset(name); if (!fdt_check_node(plloff[i])) { diff --git a/plat/hisilicon/hikey/hisi_ipc.c b/plat/hisilicon/hikey/hisi_ipc.c index 0469a08b98..4936f83169 100644 --- a/plat/hisilicon/hikey/hisi_ipc.c +++ b/plat/hisilicon/hikey/hisi_ipc.c @@ -1,16 +1,16 @@ /* - * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #include <arch_helpers.h> +#include <debug.h> #include <hisi_ipc.h> #include <hisi_sram_map.h> #include <mmio.h> #include <platform_def.h> #include <stdarg.h> -#include <stdio.h> #include <string.h> static int ipc_init; @@ -63,7 +63,7 @@ int hisi_cpus_powered_off_besides_curr(unsigned int cpu) static void hisi_ipc_send(unsigned int ipc_num) { if (!ipc_init) { - printf("error ipc base is null!!!\n"); + tf_printf("error ipc base is null!!!\n"); return; } diff --git a/plat/marvell/a8k/common/mss/mss_bl2_setup.c b/plat/marvell/a8k/common/mss/mss_bl2_setup.c index 6688551f44..21541855ba 100644 --- a/plat/marvell/a8k/common/mss/mss_bl2_setup.c +++ b/plat/marvell/a8k/common/mss/mss_bl2_setup.c @@ -85,7 +85,6 @@ int bl2_plat_handle_scp_bl2(image_info_t *scp_bl2_image_info) int ret; INFO("BL2: Initiating SCP_BL2 transfer to SCP\n"); - printf("BL2: Initiating SCP_BL2 transfer to SCP\n"); /* initialize time (for delay functionality) */ plat_delay_timer_init(); diff --git a/services/spd/trusty/generic-arm64-smcall.c b/services/spd/trusty/generic-arm64-smcall.c index feeecaa49c..1362c1c686 100644 --- a/services/spd/trusty/generic-arm64-smcall.c +++ b/services/spd/trusty/generic-arm64-smcall.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -29,14 +29,14 @@ static void trusty_dputc(char ch, int secure) s->linebuf[s->l++] = ch; if (s->l == sizeof(s->linebuf) || ch == '\n') { if (secure) - printf("secure os: "); + tf_printf("secure os: "); else - printf("non-secure os: "); + tf_printf("non-secure os: "); for (i = 0; i < s->l; i++) { putchar(s->linebuf[i]); } if (ch != '\n') { - printf(" <...>\n"); + tf_printf(" <...>\n"); } s->l = 0; } |