mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-24 15:31:22 +01:00
lib: Rename string.x to sbi_string.x
All string functions are part of libsbi. It makes more sense to rename them to sbi_string.x as the libsbi can be linked with external libraries that can have similar implementation. Signed-off-by: Atish Patra <atish.patra@wdc.com> Acked-by: Anup Patel <anup.patel@wdc.com>
This commit is contained in:
39
include/sbi/sbi_string.h
Normal file
39
include/sbi/sbi_string.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2019 Western Digital Corporation or its affiliates.
|
||||
*
|
||||
* Authors:
|
||||
* Atish Patra <atish.patra@wdc.com>
|
||||
*/
|
||||
|
||||
#ifndef __STRING_H__
|
||||
#define __STRING_H__
|
||||
|
||||
#include <sbi/sbi_types.h>
|
||||
|
||||
int sbi_strcmp(const char *a, const char *b);
|
||||
|
||||
size_t sbi_strlen(const char *str);
|
||||
|
||||
size_t sbi_strnlen(const char *str, size_t count);
|
||||
|
||||
char *sbi_strcpy(char *dest, const char *src);
|
||||
|
||||
char *sbi_strncpy(char *dest, const char *src, size_t count);
|
||||
|
||||
char *sbi_strchr(const char *s, int c);
|
||||
|
||||
char *sbi_strrchr(const char *s, int c);
|
||||
|
||||
void *sbi_memset(void *s, int c, size_t count);
|
||||
|
||||
void *sbi_memcpy(void *dest, const void *src, size_t count);
|
||||
|
||||
void *sbi_memmove(void *dest, const void *src, size_t count);
|
||||
|
||||
int sbi_memcmp(const void *s1, const void *s2, size_t count);
|
||||
|
||||
void *sbi_memchr(const void *s, int c, size_t count);
|
||||
|
||||
#endif
|
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2019 Western Digital Corporation or its affiliates.
|
||||
*
|
||||
* Authors:
|
||||
* Atish Patra <atish.patra@wdc.com>
|
||||
*/
|
||||
|
||||
#ifndef __STRING_H__
|
||||
#define __STRING_H__
|
||||
|
||||
#include <sbi/sbi_types.h>
|
||||
|
||||
int strcmp(const char *a, const char *b);
|
||||
|
||||
size_t strlen(const char *str);
|
||||
|
||||
size_t strnlen(const char *str, size_t count);
|
||||
|
||||
char *strcpy(char *dest, const char *src);
|
||||
|
||||
char *strncpy(char *dest, const char *src, size_t count);
|
||||
|
||||
char *strchr(const char *s, int c);
|
||||
|
||||
char *strrchr(const char *s, int c);
|
||||
|
||||
void *memset(void *s, int c, size_t count);
|
||||
|
||||
void *memcpy(void *dest, const void *src, size_t count);
|
||||
|
||||
void *memmove(void *dest, const void *src, size_t count);
|
||||
|
||||
int memcmp(const void *s1, const void *s2, size_t count);
|
||||
|
||||
void *memchr(const void *s, int c, size_t count);
|
||||
|
||||
#endif
|
@@ -1,15 +0,0 @@
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Copyright (c) 2019 Western Digital Corporation or its affiliates.
|
||||
#
|
||||
# Authors:
|
||||
# Atish Patra<atish.patra@wdc.com>
|
||||
#
|
||||
|
||||
libc_files = string.o
|
||||
|
||||
$(foreach file, $(libc_files), \
|
||||
$(eval CFLAGS_$(file) = -I$(src)/../../sbi/libc))
|
||||
|
||||
libsbi-objs-y += $(addprefix libc/,$(libc_files))
|
@@ -27,3 +27,4 @@ libsbi-objs-y += sbi_system.o
|
||||
libsbi-objs-y += sbi_timer.o
|
||||
libsbi-objs-y += sbi_tlb.o
|
||||
libsbi-objs-y += sbi_trap.o
|
||||
libsbi-objs-y += sbi_string.o
|
||||
|
@@ -10,7 +10,7 @@
|
||||
#include <sbi/riscv_locks.h>
|
||||
#include <sbi/sbi_error.h>
|
||||
#include <sbi/sbi_fifo.h>
|
||||
#include <sbi/string.h>
|
||||
#include <sbi/sbi_string.h>
|
||||
|
||||
void sbi_fifo_init(struct sbi_fifo *fifo, void *queue_mem, u16 entries,
|
||||
u16 entry_size)
|
||||
@@ -20,7 +20,7 @@ void sbi_fifo_init(struct sbi_fifo *fifo, void *queue_mem, u16 entries,
|
||||
fifo->entry_size = entry_size;
|
||||
SPIN_LOCK_INIT(&fifo->qlock);
|
||||
fifo->avail = fifo->tail = 0;
|
||||
memset(fifo->queue, 0, entries * entry_size);
|
||||
sbi_memset(fifo->queue, 0, entries * entry_size);
|
||||
}
|
||||
|
||||
/* Note: must be called with fifo->qlock held */
|
||||
@@ -76,7 +76,7 @@ static inline void __sbi_fifo_reset(struct sbi_fifo *fifo)
|
||||
{
|
||||
fifo->avail = 0;
|
||||
fifo->tail = 0;
|
||||
memset(fifo->queue, 0, fifo->num_entries * fifo->entry_size);
|
||||
sbi_memset(fifo->queue, 0, fifo->num_entries * fifo->entry_size);
|
||||
}
|
||||
|
||||
bool sbi_fifo_reset(struct sbi_fifo *fifo)
|
||||
@@ -149,7 +149,7 @@ int sbi_fifo_enqueue(struct sbi_fifo *fifo, void *data)
|
||||
if (head >= fifo->num_entries)
|
||||
head = head - fifo->num_entries;
|
||||
|
||||
memcpy(fifo->queue + head * fifo->entry_size, data, fifo->entry_size);
|
||||
sbi_memcpy(fifo->queue + head * fifo->entry_size, data, fifo->entry_size);
|
||||
|
||||
fifo->avail++;
|
||||
|
||||
@@ -170,7 +170,7 @@ int sbi_fifo_dequeue(struct sbi_fifo *fifo, void *data)
|
||||
return SBI_ENOENT;
|
||||
}
|
||||
|
||||
memcpy(data, fifo->queue + (u32)fifo->tail * fifo->entry_size,
|
||||
sbi_memcpy(data, fifo->queue + (u32)fifo->tail * fifo->entry_size,
|
||||
fifo->entry_size);
|
||||
|
||||
fifo->avail--;
|
||||
|
@@ -19,7 +19,6 @@
|
||||
#include <sbi/sbi_platform.h>
|
||||
#include <sbi/sbi_timer.h>
|
||||
#include <sbi/sbi_tlb.h>
|
||||
#include <sbi/string.h>
|
||||
|
||||
static unsigned long ipi_data_off;
|
||||
|
||||
|
@@ -12,9 +12,9 @@
|
||||
* bugs as well. Use any optimized routines from newlib or glibc if required.
|
||||
*/
|
||||
|
||||
#include <sbi/string.h>
|
||||
#include <sbi/sbi_string.h>
|
||||
|
||||
int strcmp(const char *a, const char *b)
|
||||
int sbi_strcmp(const char *a, const char *b)
|
||||
{
|
||||
/* search first diff or end of string */
|
||||
for (; *a == *b && *a != '\0'; a++, b++)
|
||||
@@ -23,7 +23,7 @@ int strcmp(const char *a, const char *b)
|
||||
return *a - *b;
|
||||
}
|
||||
|
||||
size_t strlen(const char *str)
|
||||
size_t sbi_strlen(const char *str)
|
||||
{
|
||||
unsigned long ret = 0;
|
||||
|
||||
@@ -35,7 +35,7 @@ size_t strlen(const char *str)
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t strnlen(const char *str, size_t count)
|
||||
size_t sbi_strnlen(const char *str, size_t count)
|
||||
{
|
||||
unsigned long ret = 0;
|
||||
|
||||
@@ -48,7 +48,7 @@ size_t strnlen(const char *str, size_t count)
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *strcpy(char *dest, const char *src)
|
||||
char *sbi_strcpy(char *dest, const char *src)
|
||||
{
|
||||
char *ret = dest;
|
||||
|
||||
@@ -59,7 +59,7 @@ char *strcpy(char *dest, const char *src)
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *strncpy(char *dest, const char *src, size_t count)
|
||||
char *sbi_strncpy(char *dest, const char *src, size_t count)
|
||||
{
|
||||
char *ret = dest;
|
||||
|
||||
@@ -70,7 +70,7 @@ char *strncpy(char *dest, const char *src, size_t count)
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *strchr(const char *s, int c)
|
||||
char *sbi_strchr(const char *s, int c)
|
||||
{
|
||||
while (*s != '\0' && *s != (char)c)
|
||||
s++;
|
||||
@@ -81,9 +81,9 @@ char *strchr(const char *s, int c)
|
||||
return (char *)s;
|
||||
}
|
||||
|
||||
char *strrchr(const char *s, int c)
|
||||
char *sbi_strrchr(const char *s, int c)
|
||||
{
|
||||
const char *last = s + strlen(s);
|
||||
const char *last = s + sbi_strlen(s);
|
||||
|
||||
while (last > s && *last != (char)c)
|
||||
last--;
|
||||
@@ -93,7 +93,7 @@ char *strrchr(const char *s, int c)
|
||||
else
|
||||
return (char *)last;
|
||||
}
|
||||
void *memset(void *s, int c, size_t count)
|
||||
void *sbi_memset(void *s, int c, size_t count)
|
||||
{
|
||||
char *temp = s;
|
||||
|
||||
@@ -105,7 +105,7 @@ void *memset(void *s, int c, size_t count)
|
||||
return s;
|
||||
}
|
||||
|
||||
void *memcpy(void *dest, const void *src, size_t count)
|
||||
void *sbi_memcpy(void *dest, const void *src, size_t count)
|
||||
{
|
||||
char *temp1 = dest;
|
||||
const char *temp2 = src;
|
||||
@@ -118,7 +118,7 @@ void *memcpy(void *dest, const void *src, size_t count)
|
||||
return dest;
|
||||
}
|
||||
|
||||
void *memmove(void *dest, const void *src, size_t count)
|
||||
void *sbi_memmove(void *dest, const void *src, size_t count)
|
||||
{
|
||||
char *temp1 = (char *)dest;
|
||||
const char *temp2 = (char *)src;
|
||||
@@ -144,7 +144,7 @@ void *memmove(void *dest, const void *src, size_t count)
|
||||
return dest;
|
||||
}
|
||||
|
||||
int memcmp(const void *s1, const void *s2, size_t count)
|
||||
int sbi_memcmp(const void *s1, const void *s2, size_t count)
|
||||
{
|
||||
const char *temp1 = s1;
|
||||
const char *temp2 = s2;
|
||||
@@ -160,7 +160,7 @@ int memcmp(const void *s1, const void *s2, size_t count)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *memchr(const void *s, int c, size_t count)
|
||||
void *sbi_memchr(const void *s, int c, size_t count)
|
||||
{
|
||||
const unsigned char *temp = s;
|
||||
|
@@ -16,7 +16,7 @@
|
||||
#include <sbi/sbi_bitops.h>
|
||||
#include <sbi/sbi_scratch.h>
|
||||
#include <sbi/sbi_tlb.h>
|
||||
#include <sbi/string.h>
|
||||
#include <sbi/sbi_string.h>
|
||||
|
||||
static unsigned long ipi_tlb_fifo_off;
|
||||
static unsigned long ipi_tlb_fifo_mem_off;
|
||||
@@ -190,7 +190,7 @@ void sbi_tlb_fifo_process(struct sbi_scratch *scratch, u32 event)
|
||||
sbi_tlb_fifo_sfence_vma(&tinfo);
|
||||
else if (tinfo.type == SBI_TLB_FLUSH_VMA_ASID)
|
||||
sbi_tlb_fifo_sfence_vma_asid(&tinfo);
|
||||
memset(&tinfo, 0, SBI_TLB_INFO_SIZE);
|
||||
sbi_memset(&tinfo, 0, SBI_TLB_INFO_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -10,7 +10,7 @@
|
||||
#include <sbi/riscv_io.h>
|
||||
#include <sbi/riscv_encoding.h>
|
||||
#include <sbi/sbi_console.h>
|
||||
#include <sbi/string.h>
|
||||
#include <sbi/sbi_string.h>
|
||||
#include <sbi_utils/tinyfdt.h>
|
||||
#include <sbi_utils/irqchip/plic.h>
|
||||
|
||||
@@ -54,7 +54,7 @@ static void plic_fdt_fixup_prop(const struct fdt_node *node,
|
||||
|
||||
if (!prop)
|
||||
return;
|
||||
if (strcmp(prop->name, "interrupts-extended"))
|
||||
if (sbi_strcmp(prop->name, "interrupts-extended"))
|
||||
return;
|
||||
|
||||
cells = prop->value;
|
||||
|
@@ -52,7 +52,7 @@
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sbi/string.h>
|
||||
#include <sbi/sbi_string.h>
|
||||
#include <sbi/sbi_types.h>
|
||||
|
||||
#define INT_MAX ((int)(~0U >> 1))
|
||||
@@ -66,6 +66,18 @@
|
||||
#define FDT_BITWISE
|
||||
#endif
|
||||
|
||||
#define memmove sbi_memmove
|
||||
#define memcpy sbi_memcpy
|
||||
#define memcmp sbi_memcmp
|
||||
#define memchr sbi_memchr
|
||||
#define memset sbi_memset
|
||||
#define strchr sbi_strchr
|
||||
#define strrchr sbi_strrchr
|
||||
#define strcpy sbi_strcpy
|
||||
#define strcmp sbi_strcmp
|
||||
#define strlen sbi_strlen
|
||||
#define strnlen sbi_strnlen
|
||||
|
||||
typedef uint16_t FDT_BITWISE fdt16_t;
|
||||
typedef uint32_t FDT_BITWISE fdt32_t;
|
||||
typedef uint64_t FDT_BITWISE fdt64_t;
|
||||
|
@@ -7,7 +7,7 @@
|
||||
* Anup Patel <anup.patel@wdc.com>
|
||||
*/
|
||||
|
||||
#include <sbi/string.h>
|
||||
#include <sbi/sbi_string.h>
|
||||
#include <sbi_utils/tinyfdt.h>
|
||||
|
||||
#define FDT_MAGIC 0xd00dfeed
|
||||
@@ -48,10 +48,10 @@ int fdt_prop_string_index(const struct fdt_prop *prop, const char *str)
|
||||
end = p + prop->len;
|
||||
|
||||
for (i = 0; p < end; i++, p += l) {
|
||||
l = strlen(p) + 1;
|
||||
l = sbi_strlen(p) + 1;
|
||||
if (p + l > end)
|
||||
return -1;
|
||||
if (strcmp(str, p) == 0)
|
||||
if (sbi_strcmp(str, p) == 0)
|
||||
return i; /* Found it; return index */
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ static void recursive_iter(char **data, struct recursive_iter_info *info,
|
||||
node.parent = parent;
|
||||
node.name = *data;
|
||||
|
||||
*data += strlen(*data) + 1;
|
||||
*data += sbi_strlen(*data) + 1;
|
||||
while ((ulong)(*data) % sizeof(u32) != 0)
|
||||
(*data)++;
|
||||
|
||||
@@ -154,7 +154,7 @@ static void match_iter(const struct fdt_node *node, const struct fdt_prop *prop,
|
||||
data += sizeof(u32);
|
||||
|
||||
/* Skip node name */
|
||||
data += strlen(data) + 1;
|
||||
data += sbi_strlen(data) + 1;
|
||||
while ((ulong)(data) % sizeof(u32) != 0)
|
||||
data++;
|
||||
|
||||
@@ -228,7 +228,7 @@ static int match_compat(const struct fdt_node *node,
|
||||
if (!prop)
|
||||
return 0;
|
||||
|
||||
if (strcmp(prop->name, "compatible"))
|
||||
if (sbi_strcmp(prop->name, "compatible"))
|
||||
return 0;
|
||||
|
||||
if (fdt_prop_string_index(prop, cinfo->compat) < 0)
|
||||
|
Reference in New Issue
Block a user