From 4a079c752beef8c2e8072b55a267d4b597b1e05b Mon Sep 17 00:00:00 2001 From: Carlo Caione Date: Fri, 23 Aug 2019 18:28:36 +0100 Subject: meson: Rename platform directory to amlogic Meson is the internal code name for the SoC family. The correct name for the platform should be Amlogic. Change the name of the platform directory. Signed-off-by: Carlo Caione Change-Id: Icc140e1ea137f12117acbf64c7dcb1a8b66b345d --- tools/amlogic/Makefile | 49 ++++++++++++++++++++++++++ tools/amlogic/doimage.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++++ tools/meson/Makefile | 49 -------------------------- tools/meson/doimage.c | 94 ------------------------------------------------- 4 files changed, 143 insertions(+), 143 deletions(-) create mode 100644 tools/amlogic/Makefile create mode 100644 tools/amlogic/doimage.c delete mode 100644 tools/meson/Makefile delete mode 100644 tools/meson/doimage.c (limited to 'tools') diff --git a/tools/amlogic/Makefile b/tools/amlogic/Makefile new file mode 100644 index 00000000..1a1d1f81 --- /dev/null +++ b/tools/amlogic/Makefile @@ -0,0 +1,49 @@ +# +# Copyright (C) 2019 Remi Pommarel +# +# SPDX-License-Identifier: BSD-3-Clause +# https://spdx.org/licenses +# +MAKE_HELPERS_DIRECTORY := ../../make_helpers/ +include ${MAKE_HELPERS_DIRECTORY}build_macros.mk +include ${MAKE_HELPERS_DIRECTORY}build_env.mk + +PROJECT := doimage${BIN_EXT} +OBJECTS := doimage.o +V := 0 + +HOSTCCFLAGS := -Wall -Werror -pedantic -std=c99 -D_GNU_SOURCE + +ifeq (${DEBUG},1) + HOSTCCFLAGS += -g -O0 -DDEBUG +else + HOSTCCFLAGS += -O2 +endif + +ifeq (${V},0) + Q := @ +else + Q := +endif + +HOSTCC := gcc + +.PHONY: all clean distclean + +all: ${PROJECT} + +${PROJECT}: ${OBJECTS} Makefile + @echo " HOSTLD $@" + ${Q}${HOSTCC} ${OBJECTS} -o $@ + @${ECHO_BLANK_LINE} + @echo "Built $@ successfully" + @${ECHO_BLANK_LINE} + +%.o: %.c Makefile + @echo " HOSTCC $<" + ${Q}${HOSTCC} -c ${HOSTCCFLAGS} $< -o $@ + +clean: + $(call SHELL_DELETE_ALL, ${PROJECT} ${OBJECTS}) + +distclean: clean diff --git a/tools/amlogic/doimage.c b/tools/amlogic/doimage.c new file mode 100644 index 00000000..b304038d --- /dev/null +++ b/tools/amlogic/doimage.c @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2019, Remi Pommarel + * + * SPDX-License-Identifier: BSD-3-Clause + */ +#include +#include +#include +#include +#include +#include + +#define DEFAULT_PROGNAME "doimage" +#define PROGNAME(argc, argv) (((argc) >= 1) ? ((argv)[0]) : DEFAULT_PROGNAME) + +#define BL31_MAGIC 0x12348765 +#define BL31_LOADADDR 0x05100000 +#define BUFLEN 512 + +static inline void usage(char const *prog) +{ + fprintf(stderr, "Usage: %s \n", prog); +} + +static inline int fdwrite(int fd, uint8_t *data, size_t len) +{ + ssize_t nr; + size_t l; + int ret = -1; + + for (l = 0; l < len; l += nr) { + nr = write(fd, data + l, len - l); + if (nr < 0) { + perror("Cannot write to bl31.img"); + goto out; + } + } + + ret = 0; +out: + return ret; +} + +int main(int argc, char **argv) +{ + int fin, fout, ret = -1; + ssize_t len; + uint32_t data; + uint8_t buf[BUFLEN]; + + if (argc != 3) { + usage(PROGNAME(argc, argv)); + goto out; + } + + fin = open(argv[1], O_RDONLY); + if (fin < 0) { + perror("Cannot open bl31.bin"); + goto out; + } + + fout = open(argv[2], O_WRONLY | O_CREAT, 0660); + if (fout < 0) { + perror("Cannot open bl31.img"); + goto closefin; + } + + data = htole32(BL31_MAGIC); + if (fdwrite(fout, (uint8_t *)&data, sizeof(data)) < 0) + goto closefout; + + lseek(fout, 8, SEEK_SET); + data = htole32(BL31_LOADADDR); + if (fdwrite(fout, (uint8_t *)&data, sizeof(data)) < 0) + goto closefout; + + lseek(fout, 0x200, SEEK_SET); + while ((len = read(fin, buf, sizeof(buf))) > 0) + if (fdwrite(fout, buf, len) < 0) + goto closefout; + if (len < 0) { + perror("Cannot read bl31.bin"); + goto closefout; + } + + ret = 0; + +closefout: + close(fout); +closefin: + close(fin); +out: + return ret; +} diff --git a/tools/meson/Makefile b/tools/meson/Makefile deleted file mode 100644 index 1a1d1f81..00000000 --- a/tools/meson/Makefile +++ /dev/null @@ -1,49 +0,0 @@ -# -# Copyright (C) 2019 Remi Pommarel -# -# SPDX-License-Identifier: BSD-3-Clause -# https://spdx.org/licenses -# -MAKE_HELPERS_DIRECTORY := ../../make_helpers/ -include ${MAKE_HELPERS_DIRECTORY}build_macros.mk -include ${MAKE_HELPERS_DIRECTORY}build_env.mk - -PROJECT := doimage${BIN_EXT} -OBJECTS := doimage.o -V := 0 - -HOSTCCFLAGS := -Wall -Werror -pedantic -std=c99 -D_GNU_SOURCE - -ifeq (${DEBUG},1) - HOSTCCFLAGS += -g -O0 -DDEBUG -else - HOSTCCFLAGS += -O2 -endif - -ifeq (${V},0) - Q := @ -else - Q := -endif - -HOSTCC := gcc - -.PHONY: all clean distclean - -all: ${PROJECT} - -${PROJECT}: ${OBJECTS} Makefile - @echo " HOSTLD $@" - ${Q}${HOSTCC} ${OBJECTS} -o $@ - @${ECHO_BLANK_LINE} - @echo "Built $@ successfully" - @${ECHO_BLANK_LINE} - -%.o: %.c Makefile - @echo " HOSTCC $<" - ${Q}${HOSTCC} -c ${HOSTCCFLAGS} $< -o $@ - -clean: - $(call SHELL_DELETE_ALL, ${PROJECT} ${OBJECTS}) - -distclean: clean diff --git a/tools/meson/doimage.c b/tools/meson/doimage.c deleted file mode 100644 index b304038d..00000000 --- a/tools/meson/doimage.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2019, Remi Pommarel - * - * SPDX-License-Identifier: BSD-3-Clause - */ -#include -#include -#include -#include -#include -#include - -#define DEFAULT_PROGNAME "doimage" -#define PROGNAME(argc, argv) (((argc) >= 1) ? ((argv)[0]) : DEFAULT_PROGNAME) - -#define BL31_MAGIC 0x12348765 -#define BL31_LOADADDR 0x05100000 -#define BUFLEN 512 - -static inline void usage(char const *prog) -{ - fprintf(stderr, "Usage: %s \n", prog); -} - -static inline int fdwrite(int fd, uint8_t *data, size_t len) -{ - ssize_t nr; - size_t l; - int ret = -1; - - for (l = 0; l < len; l += nr) { - nr = write(fd, data + l, len - l); - if (nr < 0) { - perror("Cannot write to bl31.img"); - goto out; - } - } - - ret = 0; -out: - return ret; -} - -int main(int argc, char **argv) -{ - int fin, fout, ret = -1; - ssize_t len; - uint32_t data; - uint8_t buf[BUFLEN]; - - if (argc != 3) { - usage(PROGNAME(argc, argv)); - goto out; - } - - fin = open(argv[1], O_RDONLY); - if (fin < 0) { - perror("Cannot open bl31.bin"); - goto out; - } - - fout = open(argv[2], O_WRONLY | O_CREAT, 0660); - if (fout < 0) { - perror("Cannot open bl31.img"); - goto closefin; - } - - data = htole32(BL31_MAGIC); - if (fdwrite(fout, (uint8_t *)&data, sizeof(data)) < 0) - goto closefout; - - lseek(fout, 8, SEEK_SET); - data = htole32(BL31_LOADADDR); - if (fdwrite(fout, (uint8_t *)&data, sizeof(data)) < 0) - goto closefout; - - lseek(fout, 0x200, SEEK_SET); - while ((len = read(fin, buf, sizeof(buf))) > 0) - if (fdwrite(fout, buf, len) < 0) - goto closefout; - if (len < 0) { - perror("Cannot read bl31.bin"); - goto closefout; - } - - ret = 0; - -closefout: - close(fout); -closefin: - close(fin); -out: - return ret; -} -- cgit v1.2.3