summaryrefslogtreecommitdiff
path: root/fw/fe310/bsp
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2022-09-04 18:08:36 +0200
committerUros Majstorovic <majstor@majstor.org>2022-09-04 18:08:36 +0200
commit4db0527c16502103e04c4091dbd803c55538b52f (patch)
tree5cb69f87c38c6beb090b7534949f54f66244a2a9 /fw/fe310/bsp
parent4a78984a753790330f838917d189dc39c0fba2d9 (diff)
read/write doeas not block when uart is disabled
Diffstat (limited to 'fw/fe310/bsp')
-rw-r--r--fw/fe310/bsp/gloss/sys_read.c4
-rw-r--r--fw/fe310/bsp/gloss/sys_sbrk.c10
-rw-r--r--fw/fe310/bsp/gloss/sys_write.c4
3 files changed, 11 insertions, 7 deletions
diff --git a/fw/fe310/bsp/gloss/sys_read.c b/fw/fe310/bsp/gloss/sys_read.c
index 1857fc6..cc14f2a 100644
--- a/fw/fe310/bsp/gloss/sys_read.c
+++ b/fw/fe310/bsp/gloss/sys_read.c
@@ -4,11 +4,13 @@
#include "platform.h"
+#include "soc/uart.h"
+
/* Read from a file. */
ssize_t
_read(int fd, void *ptr, size_t len)
{
- if (fd != STDIN_FILENO) {
+ if ((fd != STDIN_FILENO) || !eos_uart_enabled()) {
errno = ENOSYS;
return -1;
}
diff --git a/fw/fe310/bsp/gloss/sys_sbrk.c b/fw/fe310/bsp/gloss/sys_sbrk.c
index ce10c90..e789ec1 100644
--- a/fw/fe310/bsp/gloss/sys_sbrk.c
+++ b/fw/fe310/bsp/gloss/sys_sbrk.c
@@ -6,9 +6,9 @@
* about it. Note that there is no error checking anywhere in this file, users
* will simply get the relevant error when actually trying to use the memory
* that's been allocated. */
-extern char metal_segment_heap_target_start;
-extern char metal_segment_heap_target_end;
-static char *brk = &metal_segment_heap_target_start;
+extern char __heap_start;
+extern char __heap_end;
+static char *brk = &__heap_start;
int
_brk(void *addr)
@@ -23,12 +23,12 @@ _sbrk(ptrdiff_t incr)
char *old = brk;
/* If __heap_size == 0, we can't allocate memory on the heap */
- if(&metal_segment_heap_target_start == &metal_segment_heap_target_end) {
+ if(&__heap_start == &__heap_end) {
return (void *)-1;
}
/* Don't move the break past the end of the heap */
- if ((brk + incr) <= &metal_segment_heap_target_end) {
+ if ((brk + incr) <= &__heap_end) {
brk += incr;
} else {
return (void *)-1;
diff --git a/fw/fe310/bsp/gloss/sys_write.c b/fw/fe310/bsp/gloss/sys_write.c
index 458f9a4..e2bb832 100644
--- a/fw/fe310/bsp/gloss/sys_write.c
+++ b/fw/fe310/bsp/gloss/sys_write.c
@@ -4,13 +4,15 @@
#include "platform.h"
+#include "soc/uart.h"
+
#define PUTC(c) { while (UART0_REG(UART_REG_TXFIFO) & 0x80000000); UART0_REG(UART_REG_TXFIFO) = (c); }
/* Write to a file. */
ssize_t
_write(int fd, const void *ptr, size_t len)
{
- if ((fd != STDOUT_FILENO) && (fd != STDERR_FILENO)) {
+ if ((fd != STDOUT_FILENO) && (fd != STDERR_FILENO) || !eos_uart_enabled()) {
errno = ENOSYS;
return -1;
}