From 00f77d9ba0465fe7baf65df487195880555db597 Mon Sep 17 00:00:00 2001 From: Atish Patra Date: Thu, 17 Jan 2019 16:42:41 -0800 Subject: [PATCH] platform: Remove string functions from tinyfdt.c There are couple of string function defined in platform code. We no longer need them as we can directly link minimal libc. Every platform required to inclde this as PLIC driver required libc functions. Signed-off-by: Atish Patra --- platform/common/irqchip/plic.c | 3 ++- platform/common/tinyfdt.c | 32 +++++++------------------------- platform/kendryte/k210/config.mk | 3 +++ platform/qemu/sifive_u/config.mk | 3 +++ platform/qemu/virt/config.mk | 3 +++ 5 files changed, 18 insertions(+), 26 deletions(-) diff --git a/platform/common/irqchip/plic.c b/platform/common/irqchip/plic.c index 8a1e08ea..0a2a0367 100644 --- a/platform/common/irqchip/plic.c +++ b/platform/common/irqchip/plic.c @@ -10,6 +10,7 @@ #include #include #include +#include #define PLIC_PRIORITY_BASE 0x0 #define PLIC_PENDING_BASE 0x1000 @@ -53,7 +54,7 @@ static void plic_fdt_fixup_prop(const struct fdt_node *node, if (!prop) return; - if (fdt_strcmp(prop->name, "interrupts-extended")) + if (strcmp(prop->name, "interrupts-extended")) return; cells = prop->value; diff --git a/platform/common/tinyfdt.c b/platform/common/tinyfdt.c index 4f6017cc..a3c1fcf0 100644 --- a/platform/common/tinyfdt.c +++ b/platform/common/tinyfdt.c @@ -7,7 +7,8 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include +#include #define FDT_MAGIC 0xd00dfeed #define FDT_VERSION 17 @@ -39,25 +40,6 @@ u32 fdt_rev32(u32 v) ((v & 0xFF000000) >> 24); } -ulong fdt_strlen(const char *str) -{ - ulong ret = 0; - - while (*str != '\0') { - ret++; - str++; - } - - return ret; -} - -int fdt_strcmp(const char *a, const char *b) -{ - /* search first diff or end of string */ - for (; *a == *b && *a != '\0'; a++, b++); - return *a - *b; -} - int fdt_prop_string_index(const struct fdt_prop *prop, const char *str) { @@ -69,10 +51,10 @@ int fdt_prop_string_index(const struct fdt_prop *prop, end = p + prop->len; for (i = 0; p < end; i++, p += l) { - l = fdt_strlen(p) + 1; + l = strlen(p) + 1; if (p + l > end) return -1; - if (fdt_strcmp(str, p) == 0) + if (strcmp(str, p) == 0) return i; /* Found it; return index */ } @@ -105,7 +87,7 @@ static void recursive_iter(char **data, struct recursive_iter_info *info, node.parent = parent; node.name = *data; - *data += fdt_strlen(*data) + 1; + *data += strlen(*data) + 1; while ((ulong)(*data) % sizeof(u32) != 0) (*data)++; @@ -179,7 +161,7 @@ static void match_iter(const struct fdt_node *node, data += sizeof(u32); /* Skip node name */ - data += fdt_strlen(data) + 1; + data += strlen(data) + 1; while ((ulong)(data) % sizeof(u32) != 0) data++; @@ -256,7 +238,7 @@ static int match_compat(const struct fdt_node *node, if (!prop) return 0; - if (fdt_strcmp(prop->name, "compatible")) + if (strcmp(prop->name, "compatible")) return 0; if (fdt_prop_string_index(prop, cinfo->compat) < 0) diff --git a/platform/kendryte/k210/config.mk b/platform/kendryte/k210/config.mk index 4a5b5920..b8510cbb 100644 --- a/platform/kendryte/k210/config.mk +++ b/platform/kendryte/k210/config.mk @@ -24,3 +24,6 @@ FW_PAYLOAD=y FW_PAYLOAD_OFFSET=0x10000 #FW_PAYLOAD_FDT_ADDR=0x80040000 +# External Libraries to include +PLATFORM_INCLUDE_LIBC=y + diff --git a/platform/qemu/sifive_u/config.mk b/platform/qemu/sifive_u/config.mk index 630098e5..59d3d064 100644 --- a/platform/qemu/sifive_u/config.mk +++ b/platform/qemu/sifive_u/config.mk @@ -26,3 +26,6 @@ FW_JUMP_FDT_ADDR=0x82200000 FW_PAYLOAD=y FW_PAYLOAD_OFFSET=0x200000 FW_PAYLOAD_FDT_ADDR=0x82200000 + +# External Libraries to include +PLATFORM_INCLUDE_LIBC=y diff --git a/platform/qemu/virt/config.mk b/platform/qemu/virt/config.mk index 927422c1..bb162e01 100644 --- a/platform/qemu/virt/config.mk +++ b/platform/qemu/virt/config.mk @@ -26,3 +26,6 @@ FW_JUMP_FDT_ADDR=0x82200000 FW_PAYLOAD=y FW_PAYLOAD_OFFSET=0x200000 FW_PAYLOAD_FDT_ADDR=0x82200000 + +# External Libraries to include +PLATFORM_INCLUDE_LIBC=y