diff --git a/arch/arm/aarch64/CMakeLists.txt b/arch/arm/aarch64/CMakeLists.txt index a9abdbf666732affdbd8c120492ced9d758e7bc2..1913a1b0a9633db9509b87ff2279d6848713ccec 100644 --- a/arch/arm/aarch64/CMakeLists.txt +++ b/arch/arm/aarch64/CMakeLists.txt @@ -27,7 +27,7 @@ target_sources( if(SCP_HAVE_NEWLIB) target_compile_definitions(arch-aarch64 PUBLIC -DUSE_NEWLIB) target_sources(arch-aarch64 - PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src/arch_libc_hooks.c") + PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../common/src/arch_libc_hooks.c") target_link_options(arch-aarch64 PUBLIC "LINKER:--undefined=_sbrk" "LINKER:--undefined=_kill") diff --git a/arch/arm/armv8-a/CMakeLists.txt b/arch/arm/armv8-a/CMakeLists.txt index 50d858cde6c6eccc63a2c45131a3c69cb943baa6..fa92158b9bb1867f1d4c161b204131db9ceb4d98 100644 --- a/arch/arm/armv8-a/CMakeLists.txt +++ b/arch/arm/armv8-a/CMakeLists.txt @@ -1,6 +1,6 @@ # # Arm SCP/MCP Software -# Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. +# Copyright (c) 2021-2024, Arm Limited and Contributors. All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause # @@ -30,7 +30,11 @@ target_sources( if(SCP_HAVE_NEWLIB) target_compile_definitions(arch-armv8a PUBLIC -DUSE_NEWLIB) - target_link_options(arch-armv8a PUBLIC "LINKER:--undefined=_sbrk") + target_sources(arch-armv8a + PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../common/src/arch_libc_hooks.c") + target_link_options(arch-armv8a PUBLIC + "LINKER:--undefined=_sbrk" + "LINKER:--undefined=_kill") endif() # diff --git a/arch/arm/armv8-a/src/arch_libc.c b/arch/arm/armv8-a/src/arch_libc.c deleted file mode 100644 index 47da644c266afaaddd24d0b7437988a1a50549f8..0000000000000000000000000000000000000000 --- a/arch/arm/armv8-a/src/arch_libc.c +++ /dev/null @@ -1,279 +0,0 @@ -/* - * Renesas SCP/MCP Software - * Copyright (c) 2020-2021, Renesas Electronics Corporation. All rights - * reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include -#include - -#include -#include -#include -#include - -void *memset(void *s, int c, size_t count) -{ - char *xs = s; - while (count--) - *xs++ = (char)c; - return s; -} - -void *memcpy(void *dst, const void *src, size_t n) -{ - /* copy per 1 byte */ - const char *p = src; - char *q = dst; - - while (n--) { - *q++ = *p++; - } - - return dst; -} - -char *strncpy(char *dest, const char *src, size_t n) -{ - size_t i; - - for (i = 0; i < n && src[i] != 0; i++) - dest[i] = src[i]; - for (; i < n; i++) - dest[i] = '\0'; - - return dest; -} - -char *strchr(const char *str, int c) -{ - do { - if (*str == (char)c) - return (char *)str; - str++; - } while (*str); - - return NULL; -} - -size_t strlen(const char *str) -{ - char *tmp = (char *)str; - size_t counter = 0; - while (*tmp++) - ++counter; - return counter; -} - -static void uint_to_str(unsigned int i, char *buf, int base) -{ - char const digit_10[] = "0123456789"; - char const digit_16[] = "0123456789abcdef"; - unsigned int shifter = i; - char const *digit; - - if (base == 10) - digit = digit_10; - else - digit = digit_16; - - do { - ++buf; - shifter = shifter / base; - } while (shifter); - - *buf = '\0'; - - do { - *--buf = digit[i % base]; - i = i / base; - } while (i); -} - -static void int_to_str(int i, char *buf, int base) -{ - int sign = i; - - if (i < 0) { - i = -i; - buf++; - } - - uint_to_str((unsigned int)i, buf, base); - - if (sign < 0) - *--buf = '-'; -} - -static int isdigit(char c) -{ - return (int)(c >= '0' && c <= '9'); -} - -static int handle_num(char type, char *buf, va_list *args) -{ - int int_num; - unsigned int uint_num; - - switch (type) { - case 'u': - uint_num = va_arg(*args, unsigned int); - uint_to_str(uint_num, buf, 10); - break; - case 'd': - int_num = va_arg(*args, int); - int_to_str(int_num, buf, 10); - break; - case 'x': - uint_num = va_arg(*args, unsigned int); - uint_to_str(uint_num, buf, 16); - break; - default: - return 1; - break; - } - - return 0; -} - -int vsnprintf(char *str, size_t n, const char *format, va_list args) -{ - char *pos; - char *s; - char *tmp = str; - size_t length = 0; - int num_length, min_length; - char num_buf[12]; - int not_implemented; - - for (pos = (char *)format; *pos != '\0'; pos++) { - while ((*pos != '%') && (*pos != '\0') && (length < n)) { - *tmp++ = *pos++; - length++; - } - - if (length == n) - break; - - if (*pos == '\0') { - *tmp = '\0'; - break; - } - - pos++; - - not_implemented = 0; - - switch (*pos) { - case 's': - s = va_arg(args, char *); - strncpy(tmp, s, n - length); - break; - case '0': - if (isdigit(*(pos + 1)) && (*(pos + 1) > '0')) { - pos++; - } else { - not_implemented = 1; - break; - } - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - min_length = (int)(*pos - '0'); - - if (handle_num(*(pos + 1), num_buf, &args)) { - if (*(pos - 1) == '0') - pos--; - - not_implemented = 1; - break; - } - - num_length = (int)strlen(num_buf); - - if (num_length < min_length) { - while (num_length >= 0) - num_buf[min_length--] = num_buf[num_length--]; - - if (*(pos - 1) == '0') { - if (num_buf[0] == '-') { - min_length++; - while (min_length > 0) - num_buf[min_length--] = '0'; - } else { - while (min_length >= 0) - num_buf[min_length--] = '0'; - } - } else { - while (min_length >= 0) - num_buf[min_length--] = ' '; - } - } - strncpy(tmp, num_buf, n - length); - pos++; - break; - default: - if (handle_num(*pos, num_buf, &args)) - not_implemented = 1; - else - strncpy(tmp, num_buf, n - length); - break; - } - - if (not_implemented) { - va_arg(args, unsigned int); - *tmp++ = '%'; - length++; - pos--; - } else { - while ((*tmp != '\0') && (length < n)) { - tmp++; - length++; - } - } - } - - if (tmp == str) { - *tmp = '\0'; - } else if (length == n) { - tmp--; - if (*tmp != '\0') - *tmp = '\0'; - else - length--; - } else if (*(tmp - 1) != '\0') { - *tmp = '\0'; - } else { - length--; - } - - return (int)length; -} - -int snprintf(char *str, size_t size, const char *format, ...) -{ - int counter; - va_list args; - va_start(args, format); - counter = vsnprintf(str, size, format, args); - va_end(args); - return counter; -} - -void __assert_fail( - const char *assertion, - const char *file, - unsigned int line, - const char *function) -{ - while (1) - continue; -} diff --git a/arch/arm/aarch64/src/arch_libc_hooks.c b/arch/arm/common/src/arch_libc_hooks.c similarity index 100% rename from arch/arm/aarch64/src/arch_libc_hooks.c rename to arch/arm/common/src/arch_libc_hooks.c diff --git a/docker/Dockerfile b/docker/Dockerfile index ea6be68d065fa76782d6074752ab31532a00fe5f..cf9ff9206bdbcdd5f597c06d9041569dc9e05d59 100755 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -8,7 +8,7 @@ FROM ubuntu:20.04@sha256:9fa30fcef427e5e88c76bc41ad37b7cc573e1d79cecb23035e413c4be6e476ab AS common ARG ARM_NONE_EABI_VERSION="10.3-2021.10" -ARG AARCH64_NONE_ELF_VERSION="9.2-2019.12" +ARG AARCH64_NONE_ELF_VERSION="13.3.rel1" ARG CMAKE_VERSION="3.25.2" ARG LLVM_VERSION="13" ARG CPPCHECK_VERSION="2.8" diff --git a/docker/installer-scripts/install-gcc-aarch64-none-elf.sh b/docker/installer-scripts/install-gcc-aarch64-none-elf.sh index 2bf6526ce7d506395685706ba23b2251f92c8b83..59216e3ce9b15a31390ad47355a8cf7e2827ee91 100644 --- a/docker/installer-scripts/install-gcc-aarch64-none-elf.sh +++ b/docker/installer-scripts/install-gcc-aarch64-none-elf.sh @@ -11,9 +11,8 @@ tool_dir=$1 version=$2 hostarch=$(uname -m) -toolchain="gcc-arm-${version}-${hostarch}-aarch64-none-elf" -url="https://developer.arm.com/-/media/Files/downloads/gnu-a/${version}/binrel/${toolchain}.tar.xz" - +toolchain="arm-gnu-toolchain-${version}-${hostarch}-aarch64-none-elf" +url="https://developer.arm.com/-/media/Files/downloads/gnu/${version}/binrel/${toolchain}.tar.xz" echo -e "Installing ${toolchain}\n" # Create target folder