RISC-V: Add gdb sim and newlib nano support. Fix a few misc minor bugs.

This commit is contained in:
Jim Wilson
2017-12-26 12:30:27 -08:00
parent 28d5b98038
commit 9588ff7555
4 changed files with 111 additions and 6 deletions

View File

@@ -1,3 +1,31 @@
#ifdef USING_SIM_SPECS
// Gdb simulator requires that sbrk be implemented without a syscall.
extern char _end[]; /* _end is set in the linker command file */
char *heap_ptr;
/*
* sbrk -- changes heap size size. Get nbytes more
* RAM. We just increment a pointer in what's
* left of memory on the board.
*/
char *
_sbrk (nbytes)
int nbytes;
{
char *base;
if (!heap_ptr)
heap_ptr = (char *)&_end;
base = heap_ptr;
heap_ptr += nbytes;
return base;
}
#else
// QEMU uses a syscall.
#include <machine/syscall.h>
#include <sys/types.h>
#include "internal_syscall.h"
@@ -25,3 +53,4 @@ _sbrk(ptrdiff_t incr)
heap_end += incr;
return (void *)(heap_end - incr);
}
#endif