1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 10:12:45 +01:00

cpu/fe310: Use newlib_syscalls_default stub implementations

This switches the fe310 to use the common newlib_syscalls_default
implementation.
This commit is contained in:
Koen Zandberg 2021-01-26 13:42:52 +01:00
parent ad20733f01
commit 128423edc6
No known key found for this signature in database
GPG Key ID: 0895A893E6D2985B
5 changed files with 1 additions and 188 deletions

View File

@ -4,8 +4,4 @@ MODULE = cpu
# add a list of subdirectories, that should also be built # add a list of subdirectories, that should also be built
DIRS = periph vendor DIRS = periph vendor
ifneq (1,$(PICOLIBC))
DIRS += nano
endif
include $(RIOTBASE)/Makefile.base include $(RIOTBASE)/Makefile.base

View File

@ -2,7 +2,7 @@ ifneq (,$(filter picolibc,$(FEATURES_USED)))
USEMODULE += picolibc USEMODULE += picolibc
else else
USEMODULE += newlib_nano USEMODULE += newlib_nano
USEMODULE += newlib_syscalls_fe310 USEMODULE += newlib_syscalls_default
endif endif
USEMODULE += sifive_drivers_fe310 USEMODULE += sifive_drivers_fe310

View File

@ -115,10 +115,6 @@ void cpu_init(void)
/* Initialize stdio */ /* Initialize stdio */
stdio_init(); stdio_init();
#ifndef _PICOLIBC__
/* Initialize newlib-nano library stubs */
nanostubs_init();
#endif /* PICOLIBC */
/* Initialize static peripheral */ /* Initialize static peripheral */
periph_init(); periph_init();

View File

@ -1,3 +0,0 @@
MODULE = newlib_syscalls_fe310
include $(RIOTBASE)/Makefile.base

View File

@ -1,176 +0,0 @@
/*
* Copyright (C) 2017 Ken Rabold
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup cpu_fe310
* @{
*
* @file nanostubs.c
* @brief Implementation of the Newlib-nano for SiFive FE310
*
* @author Ken Rabold
* @}
*/
#include <reent.h>
#include <errno.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/unistd.h>
#include "sched.h"
#include "thread.h"
#include "irq.h"
#include "cpu.h"
#include "stdio_uart.h"
extern char _sheap; /* Heap markers from fe310.ld file */
extern char _eheap;
char *heap_top = &_sheap + 4;
/**
* @brief Initialize the Newlib-nano functions (also forces inclusion of stubs for linking)
*/
void nanostubs_init(void)
{
#if defined(MODULE_STDIO_UART)
/* STDIO redirected to UART, no line buffering */
setvbuf(stdout, NULL, _IONBF, 0);
#endif
}
void _init(void)
{
}
void _fini(void)
{
}
void *_sbrk(ptrdiff_t incr)
{
unsigned int state = irq_disable();
void *res = heap_top;
/* Allocate memory from heap */
if ((heap_top + incr > &_eheap) || (heap_top + incr < &_sheap)) {
errno = ENOMEM;
res = (void *) -1;
}
else {
heap_top += incr;
}
irq_restore(state);
return res;
}
int _open(const char *name, int flags, int mode)
{
(void) name;
(void) flags;
(void) mode;
errno = ENODEV;
return -1;
}
_ssize_t _read(int fd, void *buffer, size_t count)
{
#if defined(MODULE_STDIO_UART)
if (fd == STDIN_FILENO) {
return stdio_read(buffer, count);
}
errno = EBADF;
return -1;
#else
(void) fd;
(void) buffer;
(void) count;
errno = ENODEV;
return -1;
#endif
}
_ssize_t _write(int fd, const void *data, size_t count)
{
#if defined(MODULE_STDIO_UART)
if (fd == STDOUT_FILENO || fd == STDERR_FILENO) {
return stdio_write(data, count);
}
errno = EBADF;
return -1;
#else
(void) fd;
(void) data;
(void) count;
errno = ENODEV;
return -1;
#endif
}
int _close(int fd)
{
(void) fd;
errno = ENODEV;
return -1;
}
int _isatty(int fd)
{
errno = 0;
if (fd == STDIN_FILENO || fd == STDOUT_FILENO || fd == STDERR_FILENO) {
return 1;
}
return 0;
}
int _fstat(int fd, struct stat *st)
{
(void) fd;
(void) st;
errno = ENODEV;
return -1;
}
_off_t _lseek(int fd, _off_t pos, int dir)
{
(void) fd;
(void) pos;
(void) dir;
errno = ENODEV;
return -1;
}
int _gettimeofday(struct timeval *tp, void *tzp)
{
(void) tp;
(void) tzp;
errno = EINVAL;
return -1;
}
int _getpid(void)
{
return thread_getpid();
}
int _kill(int pid, int sig)
{
(void) pid;
(void) sig;
errno = EINVAL;
return -1;
}
void _exit(int _status)
{
(void) _status;
while(1);
}