From f695df295da82c8ef801906ad8b00b0e8afa7502 Mon Sep 17 00:00:00 2001 From: Nathaniel Graff Date: Thu, 7 Mar 2019 09:27:31 -0800 Subject: Remove legacy BSP Signed-off-by: Nathaniel Graff --- bsp/libwrap/libwrap.mk | 56 -------------------------------------- bsp/libwrap/misc/write_hex.c | 19 ------------- bsp/libwrap/stdlib/malloc.c | 17 ------------ bsp/libwrap/sys/_exit.c | 17 ------------ bsp/libwrap/sys/close.c | 11 -------- bsp/libwrap/sys/execve.c | 11 -------- bsp/libwrap/sys/fork.c | 9 ------ bsp/libwrap/sys/fstat.c | 18 ------------ bsp/libwrap/sys/getpid.c | 8 ------ bsp/libwrap/sys/isatty.c | 13 --------- bsp/libwrap/sys/kill.c | 11 -------- bsp/libwrap/sys/link.c | 11 -------- bsp/libwrap/sys/lseek.c | 16 ----------- bsp/libwrap/sys/open.c | 11 -------- bsp/libwrap/sys/openat.c | 11 -------- bsp/libwrap/sys/puts.c | 28 ------------------- bsp/libwrap/sys/read.c | 32 ---------------------- bsp/libwrap/sys/sbrk.c | 18 ------------ bsp/libwrap/sys/stat.c | 12 -------- bsp/libwrap/sys/stub.h | 10 ------- bsp/libwrap/sys/times.c | 12 -------- bsp/libwrap/sys/unlink.c | 11 -------- bsp/libwrap/sys/wait.c | 9 ------ bsp/libwrap/sys/weak_under_alias.h | 7 ----- bsp/libwrap/sys/write.c | 31 --------------------- 25 files changed, 409 deletions(-) delete mode 100644 bsp/libwrap/libwrap.mk delete mode 100644 bsp/libwrap/misc/write_hex.c delete mode 100644 bsp/libwrap/stdlib/malloc.c delete mode 100644 bsp/libwrap/sys/_exit.c delete mode 100644 bsp/libwrap/sys/close.c delete mode 100644 bsp/libwrap/sys/execve.c delete mode 100644 bsp/libwrap/sys/fork.c delete mode 100644 bsp/libwrap/sys/fstat.c delete mode 100644 bsp/libwrap/sys/getpid.c delete mode 100644 bsp/libwrap/sys/isatty.c delete mode 100644 bsp/libwrap/sys/kill.c delete mode 100644 bsp/libwrap/sys/link.c delete mode 100644 bsp/libwrap/sys/lseek.c delete mode 100644 bsp/libwrap/sys/open.c delete mode 100644 bsp/libwrap/sys/openat.c delete mode 100644 bsp/libwrap/sys/puts.c delete mode 100644 bsp/libwrap/sys/read.c delete mode 100644 bsp/libwrap/sys/sbrk.c delete mode 100644 bsp/libwrap/sys/stat.c delete mode 100644 bsp/libwrap/sys/stub.h delete mode 100644 bsp/libwrap/sys/times.c delete mode 100644 bsp/libwrap/sys/unlink.c delete mode 100644 bsp/libwrap/sys/wait.c delete mode 100644 bsp/libwrap/sys/weak_under_alias.h delete mode 100644 bsp/libwrap/sys/write.c (limited to 'bsp/libwrap') diff --git a/bsp/libwrap/libwrap.mk b/bsp/libwrap/libwrap.mk deleted file mode 100644 index 71bba3d..0000000 --- a/bsp/libwrap/libwrap.mk +++ /dev/null @@ -1,56 +0,0 @@ -# See LICENSE for license details. - -ifndef _SIFIVE_MK_LIBWRAP -_SIFIVE_MK_LIBWRAP := # defined - -LIBWRAP_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -LIBWRAP_DIR := $(LIBWRAP_DIR:/=) - -LIBWRAP_SRCS := \ - stdlib/malloc.c \ - sys/open.c \ - sys/lseek.c \ - sys/read.c \ - sys/write.c \ - sys/fstat.c \ - sys/stat.c \ - sys/close.c \ - sys/link.c \ - sys/unlink.c \ - sys/execve.c \ - sys/fork.c \ - sys/getpid.c \ - sys/kill.c \ - sys/wait.c \ - sys/isatty.c \ - sys/times.c \ - sys/sbrk.c \ - sys/_exit.c \ - sys/puts.c \ - misc/write_hex.c - -LIBWRAP_SRCS := $(foreach f,$(LIBWRAP_SRCS),$(LIBWRAP_DIR)/$(f)) -LIBWRAP_OBJS := $(LIBWRAP_SRCS:.c=.o) - -LIBWRAP_SYMS := malloc free \ - open lseek read write fstat stat close link unlink \ - execve fork getpid kill wait \ - isatty times sbrk _exit puts - -LIBWRAP := libwrap.a - -LINK_DEPS += $(LIBWRAP) - -LDFLAGS += $(foreach s,$(LIBWRAP_SYMS),-Wl,--wrap=$(s)) -LDFLAGS += $(foreach s,$(LIBWRAP_SYMS),-Wl,--wrap=_$(s)) -LDFLAGS += -L. -Wl,--start-group -lwrap -lc -Wl,--end-group - -CLEAN_OBJS += $(LIBWRAP_OBJS) - -$(LIBWRAP_OBJS): %.o: %.c $(HEADERS) - $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $< - -$(LIBWRAP): $(LIBWRAP_OBJS) - $(AR) rcs $@ $^ - -endif # _SIFIVE_MK_LIBWRAP diff --git a/bsp/libwrap/misc/write_hex.c b/bsp/libwrap/misc/write_hex.c deleted file mode 100644 index a35ad7a..0000000 --- a/bsp/libwrap/misc/write_hex.c +++ /dev/null @@ -1,19 +0,0 @@ -/* See LICENSE of license details. */ - -#include -#include -#include "platform.h" - -void write_hex(int fd, unsigned long int hex) -{ - uint8_t ii; - uint8_t jj; - char towrite; - write(fd , "0x", 2); - for (ii = sizeof(unsigned long int) * 2 ; ii > 0; ii--) { - jj = ii - 1; - uint8_t digit = ((hex & (0xF << (jj*4))) >> (jj*4)); - towrite = digit < 0xA ? ('0' + digit) : ('A' + (digit - 0xA)); - write(fd, &towrite, 1); - } -} diff --git a/bsp/libwrap/stdlib/malloc.c b/bsp/libwrap/stdlib/malloc.c deleted file mode 100644 index 8f4f432..0000000 --- a/bsp/libwrap/stdlib/malloc.c +++ /dev/null @@ -1,17 +0,0 @@ -/* See LICENSE for license details. */ - -/* These functions are intended for embedded RV32 systems and are - obviously incorrect in general. */ - -void* __wrap_malloc(unsigned long sz) -{ - extern void* sbrk(long); - void* res = sbrk(sz); - if ((long)res == -1) - return 0; - return res; -} - -void __wrap_free(void* ptr) -{ -} diff --git a/bsp/libwrap/sys/_exit.c b/bsp/libwrap/sys/_exit.c deleted file mode 100644 index 011464f..0000000 --- a/bsp/libwrap/sys/_exit.c +++ /dev/null @@ -1,17 +0,0 @@ -/* See LICENSE of license details. */ - -#include -#include "platform.h" -#include "weak_under_alias.h" - -void __wrap_exit(int code) -{ - const char message[] = "\nProgam has exited with code:"; - - write(STDERR_FILENO, message, sizeof(message) - 1); - write_hex(STDERR_FILENO, code); - write(STDERR_FILENO, "\n", 1); - - for (;;); -} -weak_under_alias(exit); diff --git a/bsp/libwrap/sys/close.c b/bsp/libwrap/sys/close.c deleted file mode 100644 index 199fe51..0000000 --- a/bsp/libwrap/sys/close.c +++ /dev/null @@ -1,11 +0,0 @@ -/* See LICENSE of license details. */ - -#include -#include "stub.h" -#include "weak_under_alias.h" - -int __wrap_close(int fd) -{ - return _stub(EBADF); -} -weak_under_alias(close); diff --git a/bsp/libwrap/sys/execve.c b/bsp/libwrap/sys/execve.c deleted file mode 100644 index f7be25a..0000000 --- a/bsp/libwrap/sys/execve.c +++ /dev/null @@ -1,11 +0,0 @@ -/* See LICENSE of license details. */ - -#include -#include "stub.h" -#include "weak_under_alias.h" - -int __wrap_execve(const char* name, char* const argv[], char* const env[]) -{ - return _stub(ENOMEM); -} -weak_under_alias(execve); diff --git a/bsp/libwrap/sys/fork.c b/bsp/libwrap/sys/fork.c deleted file mode 100644 index 13a3e65..0000000 --- a/bsp/libwrap/sys/fork.c +++ /dev/null @@ -1,9 +0,0 @@ -/* See LICENSE of license details. */ - -#include -#include "stub.h" - -int fork(void) -{ - return _stub(EAGAIN); -} diff --git a/bsp/libwrap/sys/fstat.c b/bsp/libwrap/sys/fstat.c deleted file mode 100644 index ff82bf9..0000000 --- a/bsp/libwrap/sys/fstat.c +++ /dev/null @@ -1,18 +0,0 @@ -/* See LICENSE of license details. */ - -#include -#include -#include -#include "stub.h" -#include "weak_under_alias.h" - -int __wrap_fstat(int fd, struct stat* st) -{ - if (isatty(fd)) { - st->st_mode = S_IFCHR; - return 0; - } - - return _stub(EBADF); -} -weak_under_alias(fstat); diff --git a/bsp/libwrap/sys/getpid.c b/bsp/libwrap/sys/getpid.c deleted file mode 100644 index 195fbec..0000000 --- a/bsp/libwrap/sys/getpid.c +++ /dev/null @@ -1,8 +0,0 @@ -/* See LICENSE of license details. */ -#include "weak_under_alias.h" - -int __wrap_getpid(void) -{ - return 1; -} -weak_under_alias(getpid); diff --git a/bsp/libwrap/sys/isatty.c b/bsp/libwrap/sys/isatty.c deleted file mode 100644 index 7bb82ab..0000000 --- a/bsp/libwrap/sys/isatty.c +++ /dev/null @@ -1,13 +0,0 @@ -/* See LICENSE of license details. */ - -#include -#include "weak_under_alias.h" - -int __wrap_isatty(int fd) -{ - if (fd == STDOUT_FILENO || fd == STDERR_FILENO) - return 1; - - return 0; -} -weak_under_alias(isatty); diff --git a/bsp/libwrap/sys/kill.c b/bsp/libwrap/sys/kill.c deleted file mode 100644 index 18b9bd4..0000000 --- a/bsp/libwrap/sys/kill.c +++ /dev/null @@ -1,11 +0,0 @@ -/* See LICENSE of license details. */ - -#include -#include "stub.h" -#include "weak_under_alias.h" - -int __wrap_kill(int pid, int sig) -{ - return _stub(EINVAL); -} -weak_under_alias(kill); diff --git a/bsp/libwrap/sys/link.c b/bsp/libwrap/sys/link.c deleted file mode 100644 index 0cad551..0000000 --- a/bsp/libwrap/sys/link.c +++ /dev/null @@ -1,11 +0,0 @@ -/* See LICENSE of license details. */ - -#include -#include "stub.h" -#include "weak_under_alias.h" - -int __wrap_link(const char *old_name, const char *new_name) -{ - return _stub(EMLINK); -} -weak_under_alias(link); diff --git a/bsp/libwrap/sys/lseek.c b/bsp/libwrap/sys/lseek.c deleted file mode 100644 index 4131449..0000000 --- a/bsp/libwrap/sys/lseek.c +++ /dev/null @@ -1,16 +0,0 @@ -/* See LICENSE of license details. */ - -#include -#include -#include -#include "stub.h" -#include "weak_under_alias.h" - -off_t __wrap_lseek(int fd, off_t ptr, int dir) -{ - if (isatty(fd)) - return 0; - - return _stub(EBADF); -} -weak_under_alias(lseek); diff --git a/bsp/libwrap/sys/open.c b/bsp/libwrap/sys/open.c deleted file mode 100644 index c61415a..0000000 --- a/bsp/libwrap/sys/open.c +++ /dev/null @@ -1,11 +0,0 @@ -/* See LICENSE of license details. */ - -#include -#include "stub.h" -#include "weak_under_alias.h" - -int __wrap_open(const char* name, int flags, int mode) -{ - return _stub(ENOENT); -} -weak_under_alias(open); diff --git a/bsp/libwrap/sys/openat.c b/bsp/libwrap/sys/openat.c deleted file mode 100644 index 227c956..0000000 --- a/bsp/libwrap/sys/openat.c +++ /dev/null @@ -1,11 +0,0 @@ -/* See LICENSE of license details. */ - -#include -#include "stub.h" -#include "weak_under_alias.h" - -int __wrap_openat(int dirfd, const char* name, int flags, int mode) -{ - return _stub(ENOENT); -} -weak_under_alias(openat); diff --git a/bsp/libwrap/sys/puts.c b/bsp/libwrap/sys/puts.c deleted file mode 100644 index 50d6437..0000000 --- a/bsp/libwrap/sys/puts.c +++ /dev/null @@ -1,28 +0,0 @@ -/* See LICENSE of license details. */ - -#include -#include -#include -#include - -#include "platform.h" -#include "stub.h" -#include "weak_under_alias.h" - -int __wrap_puts(const char *s) -{ - while (*s != '\0') { - while (UART0_REG(UART_REG_TXFIFO) & 0x80000000) ; - UART0_REG(UART_REG_TXFIFO) = *s; - - if (*s == '\n') { - while (UART0_REG(UART_REG_TXFIFO) & 0x80000000) ; - UART0_REG(UART_REG_TXFIFO) = '\r'; - } - - ++s; - } - - return 0; -} -weak_under_alias(puts); diff --git a/bsp/libwrap/sys/read.c b/bsp/libwrap/sys/read.c deleted file mode 100644 index 3226cdb..0000000 --- a/bsp/libwrap/sys/read.c +++ /dev/null @@ -1,32 +0,0 @@ -/* See LICENSE of license details. */ - -#include -#include -#include -#include - -#include "platform.h" -#include "stub.h" -#include "weak_under_alias.h" - -ssize_t __wrap_read(int fd, void* ptr, size_t len) -{ - uint8_t * current = (uint8_t *)ptr; - volatile uint32_t * uart_rx = (uint32_t *)(UART0_CTRL_ADDR + UART_REG_RXFIFO); - volatile uint8_t * uart_rx_cnt = (uint8_t *)(UART0_CTRL_ADDR + UART_REG_RXCTRL + 2); - - ssize_t result = 0; - - if (isatty(fd)) { - for (current = (uint8_t *)ptr; - (current < ((uint8_t *)ptr) + len) && (*uart_rx_cnt > 0); - current ++) { - *current = *uart_rx; - result++; - } - return result; - } - - return _stub(EBADF); -} -weak_under_alias(read); diff --git a/bsp/libwrap/sys/sbrk.c b/bsp/libwrap/sys/sbrk.c deleted file mode 100644 index 12170b4..0000000 --- a/bsp/libwrap/sys/sbrk.c +++ /dev/null @@ -1,18 +0,0 @@ -/* See LICENSE of license details. */ - -#include -#include "weak_under_alias.h" - -void *__wrap_sbrk(ptrdiff_t incr) -{ - extern char _end[]; - extern char _heap_end[]; - static char *curbrk = _end; - - if ((curbrk + incr < _end) || (curbrk + incr > _heap_end)) - return NULL - 1; - - curbrk += incr; - return curbrk - incr; -} -weak_under_alias(sbrk); diff --git a/bsp/libwrap/sys/stat.c b/bsp/libwrap/sys/stat.c deleted file mode 100644 index 1576ca1..0000000 --- a/bsp/libwrap/sys/stat.c +++ /dev/null @@ -1,12 +0,0 @@ -/* See LICENSE of license details. */ - -#include -#include -#include "stub.h" -#include "weak_under_alias.h" - -int __wrap_stat(const char* file, struct stat* st) -{ - return _stub(EACCES); -} -weak_under_alias(stat); diff --git a/bsp/libwrap/sys/stub.h b/bsp/libwrap/sys/stub.h deleted file mode 100644 index fb5e5be..0000000 --- a/bsp/libwrap/sys/stub.h +++ /dev/null @@ -1,10 +0,0 @@ -/* See LICENSE of license details. */ -#ifndef _SIFIVE_SYS_STUB_H -#define _SIFIVE_SYS_STUB_H - -static inline int _stub(int err) -{ - return -1; -} - -#endif /* _SIFIVE_SYS_STUB_H */ diff --git a/bsp/libwrap/sys/times.c b/bsp/libwrap/sys/times.c deleted file mode 100644 index 55969a7..0000000 --- a/bsp/libwrap/sys/times.c +++ /dev/null @@ -1,12 +0,0 @@ -/* See LICENSE of license details. */ - -#include -#include -#include "stub.h" -#include "weak_under_alias.h" - -clock_t __wrap_times(struct tms* buf) -{ - return _stub(EACCES); -} -weak_under_alias(times); diff --git a/bsp/libwrap/sys/unlink.c b/bsp/libwrap/sys/unlink.c deleted file mode 100644 index 09f4da7..0000000 --- a/bsp/libwrap/sys/unlink.c +++ /dev/null @@ -1,11 +0,0 @@ -/* See LICENSE of license details. */ - -#include -#include "stub.h" -#include "weak_under_alias.h" - -int __wrap_unlink(const char* name) -{ - return _stub(ENOENT); -} -weak_under_alias(unlink); diff --git a/bsp/libwrap/sys/wait.c b/bsp/libwrap/sys/wait.c deleted file mode 100644 index ea3225b..0000000 --- a/bsp/libwrap/sys/wait.c +++ /dev/null @@ -1,9 +0,0 @@ -/* See LICENSE of license details. */ - -#include -#include "stub.h" - -int wait(int* status) -{ - return _stub(ECHILD); -} diff --git a/bsp/libwrap/sys/weak_under_alias.h b/bsp/libwrap/sys/weak_under_alias.h deleted file mode 100644 index 7629353..0000000 --- a/bsp/libwrap/sys/weak_under_alias.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _BSP_LIBWRAP_WEAK_UNDER_ALIAS_H -#define _BSP_LIBWRAP_WEAK_UNDER_ALIAS_H - -#define weak_under_alias(name) \ - extern __typeof (__wrap_##name) __wrap__##name __attribute__ ((weak, alias ("__wrap_"#name))) - -#endif diff --git a/bsp/libwrap/sys/write.c b/bsp/libwrap/sys/write.c deleted file mode 100644 index b1e9a7e..0000000 --- a/bsp/libwrap/sys/write.c +++ /dev/null @@ -1,31 +0,0 @@ -/* See LICENSE of license details. */ - -#include -#include -#include -#include - -#include "platform.h" -#include "stub.h" -#include "weak_under_alias.h" - -ssize_t __wrap_write(int fd, const void* ptr, size_t len) -{ - const uint8_t * current = (const char *)ptr; - - if (isatty(fd)) { - for (size_t jj = 0; jj < len; jj++) { - while (UART0_REG(UART_REG_TXFIFO) & 0x80000000) ; - UART0_REG(UART_REG_TXFIFO) = current[jj]; - - if (current[jj] == '\n') { - while (UART0_REG(UART_REG_TXFIFO) & 0x80000000) ; - UART0_REG(UART_REG_TXFIFO) = '\r'; - } - } - return len; - } - - return _stub(EBADF); -} -weak_under_alias(write); -- cgit v1.2.3