update include path
This commit is contained in:
parent
9407d2cec5
commit
c94eb7c61a
|
@ -41,7 +41,7 @@ trap_entry:
|
||||||
csrr a0, mcause
|
csrr a0, mcause
|
||||||
csrr a1, mepc
|
csrr a1, mepc
|
||||||
mv a2, sp
|
mv a2, sp
|
||||||
call trap
|
call handle_trap
|
||||||
csrw mepc, a0
|
csrw mepc, a0
|
||||||
#ifndef __riscv_abi_rve
|
#ifndef __riscv_abi_rve
|
||||||
addi sp, sp, -8*REGBYTES
|
addi sp, sp, -8*REGBYTES
|
||||||
|
|
|
@ -1,60 +1,60 @@
|
||||||
|
#include <math.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
#include "encoding.h"
|
#include "encoding.h"
|
||||||
|
|
||||||
#define EBREAK_OPCODE 0x00100073
|
#if defined(SEMIHOSTING)
|
||||||
#define EBREAK_MCAUSE 0x00000003
|
#define EBREAK_OPCODE 0x00100073
|
||||||
|
#define EBREAK_MCAUSE 0x00000003
|
||||||
|
|
||||||
#define SLLI_X0_X0_0X1F_OPCODE 0x01f01013
|
#define SLLI_X0_X0_0X1F_OPCODE 0x01f01013
|
||||||
#define SRAI_X0_X0_0X07_OPCODE 0x40705013
|
#define SRAI_X0_X0_0X07_OPCODE 0x40705013
|
||||||
|
|
||||||
int sh_missing_host = 0;
|
int sh_missing_host = 0;
|
||||||
|
|
||||||
void trap()
|
void trap() { // ToDo: Check why macro CSR_MEPC and others are not
|
||||||
{ //ToDo: Check why macro CSR_MEPC and others are not resolved
|
// resolved
|
||||||
uint32_t mepc = read_csr(0x341); // Address of trap
|
uint32_t mepc = read_csr(0x341); // Address of trap
|
||||||
uint32_t mtval = read_csr(0x343); // Instruction value of trap
|
uint32_t mtval = read_csr(0x343); // Instruction value of trap
|
||||||
uint32_t mcause = read_csr(0x342); // Reason for the trap
|
uint32_t mcause = read_csr(0x342); // Reason for the trap
|
||||||
|
|
||||||
if (mcause == EBREAK_MCAUSE && mtval == EBREAK_OPCODE){
|
if (mcause == EBREAK_MCAUSE && mtval == EBREAK_OPCODE) {
|
||||||
// This trap was caused by an EBREAK...
|
// This trap was caused by an EBREAK...
|
||||||
|
|
||||||
int aligned = ((mepc-4) & 0x0f) == 0;
|
int aligned = ((mepc - 4) & 0x0f) == 0;
|
||||||
if (aligned
|
if (aligned && *(uint32_t *)mepc == EBREAK_OPCODE &&
|
||||||
&& *(uint32_t *)mepc == EBREAK_OPCODE
|
*(uint32_t *)(mepc - 4) == SLLI_X0_X0_0X1F_OPCODE &&
|
||||||
&& *(uint32_t *)(mepc-4) == SLLI_X0_X0_0X1F_OPCODE
|
*(uint32_t *)(mepc + 4) == SRAI_X0_X0_0X07_OPCODE) {
|
||||||
&& *(uint32_t *)(mepc+4) == SRAI_X0_X0_0X07_OPCODE)
|
// The EBREAK was part of the semihosting call. (See semihosting.c)
|
||||||
{
|
//
|
||||||
// The EBREAK was part of the semihosting call. (See semihosting.c)
|
// If a debugger were connected, this would have resulted in a CPU halt,
|
||||||
//
|
// and the debugger would have serviced the the semihosting call.
|
||||||
// If a debugger were connected, this would have resulted in a CPU halt,
|
//
|
||||||
// and the debugger would have serviced the the semihosting call.
|
// However, the semihosting function was called without a debugger being
|
||||||
//
|
// attached. The best course of action is to simply return from the trap
|
||||||
// However, the semihosting function was called without a debugger being
|
// and let the semihosting function continue after the call to EBREAK to
|
||||||
// attached. The best course of action is to simply return from the trap
|
// prevent the CPU from hanging in the trap handler.
|
||||||
// and let the semihosting function continue after the call to EBREAK to
|
write_csr(mepc, mepc + 4);
|
||||||
// prevent the CPU from hanging in the trap handler.
|
|
||||||
write_csr(mepc, mepc+4);
|
|
||||||
|
|
||||||
// Set a global variable to tell the semihosting code the the semihosting
|
// Set a global variable to tell the semihosting code the the semihosting
|
||||||
// call
|
// call
|
||||||
// didn't execute on the host.
|
// didn't execute on the host.
|
||||||
sh_missing_host = 1;
|
sh_missing_host = 1;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
// EBREAK was not part of a semihosting call. This should not have happened.
|
|
||||||
// Hang forever.
|
|
||||||
while(1)
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trap was issued for another reason than an EBREAK.
|
// EBREAK was not part of a semihosting call. This should not have happened.
|
||||||
// Replace the code below with whatever trap handler you'd normally use. (e.g. interrupt
|
// Hang forever.
|
||||||
// processing.)
|
while (1)
|
||||||
while(1)
|
;
|
||||||
;
|
}
|
||||||
}
|
|
||||||
|
// Trap was issued for another reason than an EBREAK.
|
||||||
|
// Replace the code below with whatever trap handler you'd normally use. (e.g.
|
||||||
|
// interrupt processing.)
|
||||||
|
while (1)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -1,9 +1,11 @@
|
||||||
/* See LICENSE of license details. */
|
/* See LICENSE of license details. */
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "weak_under_alias.h"
|
#include "weak_under_alias.h"
|
||||||
|
#include <unistd.h>
|
||||||
|
#if defined(SEMIHOSTING)
|
||||||
#include "semihosting.h"
|
#include "semihosting.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(BOARD_hifive1)
|
#if defined(BOARD_hifive1)
|
||||||
static volatile uint32_t tohost;
|
static volatile uint32_t tohost;
|
||||||
|
@ -15,21 +17,21 @@ extern volatile uint32_t fromhost;
|
||||||
|
|
||||||
void write_hex(int fd, uint32_t hex);
|
void write_hex(int fd, uint32_t hex);
|
||||||
|
|
||||||
void __wrap_exit(int code)
|
void __wrap_exit(int code) {
|
||||||
{
|
/*#if defined(SEMIHOSTING)
|
||||||
/*#if defined(SEMIHOSTING)
|
sh_exit();
|
||||||
sh_exit();
|
return;
|
||||||
return;
|
#endif*/
|
||||||
#endif*/
|
// volatile uint32_t* leds = (uint32_t*) (GPIO_BASE_ADDR + GPIO_OUT_OFFSET);
|
||||||
//volatile uint32_t* leds = (uint32_t*) (GPIO_BASE_ADDR + GPIO_OUT_OFFSET);
|
|
||||||
const char message[] = "\nProgam has exited with code:";
|
const char message[] = "\nProgam has exited with code:";
|
||||||
//*leds = (~(code));
|
//*leds = (~(code));
|
||||||
|
|
||||||
write(STDERR_FILENO, message, sizeof(message) - 1);
|
write(STDERR_FILENO, message, sizeof(message) - 1);
|
||||||
write_hex(STDERR_FILENO, code);
|
write_hex(STDERR_FILENO, code);
|
||||||
write(STDERR_FILENO, "\n", 1);
|
write(STDERR_FILENO, "\n", 1);
|
||||||
tohost = code+1;
|
tohost = code + 1;
|
||||||
write(STDERR_FILENO, "\x04", 1);
|
write(STDERR_FILENO, "\x04", 1);
|
||||||
for (;;);
|
for (;;)
|
||||||
|
;
|
||||||
}
|
}
|
||||||
weak_under_alias(exit);
|
weak_under_alias(exit);
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
/* See LICENSE of license details. */
|
/* See LICENSE of license details. */
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include "stub.h"
|
#include "stub.h"
|
||||||
#include "weak_under_alias.h"
|
#include "weak_under_alias.h"
|
||||||
|
#include <errno.h>
|
||||||
|
#if defined(SEMIHOSTING)
|
||||||
#include "semihosting.h"
|
#include "semihosting.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
int __wrap_close(int fd)
|
int __wrap_close(int fd) {
|
||||||
{
|
|
||||||
#if defined(SEMIHOTING)
|
#if defined(SEMIHOTING)
|
||||||
int i = sh_close(fd);
|
int i = sh_close(fd);
|
||||||
return i;
|
return i;
|
||||||
|
@ -15,4 +16,3 @@ int __wrap_close(int fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
weak_under_alias(close);
|
weak_under_alias(close);
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
/* See LICENSE of license details. */
|
/* See LICENSE of license details. */
|
||||||
|
|
||||||
#include "semihosting.h"
|
|
||||||
#include "weak_under_alias.h"
|
#include "weak_under_alias.h"
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#if defined(SEMIHOSTING)
|
||||||
|
#include "semihosting.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
int __wrap_isatty(int fd) {
|
int __wrap_isatty(int fd) {
|
||||||
#if defined(SEMIHOSTING)
|
#if defined(SEMIHOSTING)
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
/* See LICENSE of license details. */
|
/* See LICENSE of license details. */
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include "stub.h"
|
#include "stub.h"
|
||||||
#include "weak_under_alias.h"
|
#include "weak_under_alias.h"
|
||||||
#include "semihosting.h"
|
#include <errno.h>
|
||||||
|
#include <sys/types.h>
|
||||||
off_t __wrap_lseek(int fd, off_t ptr, int dir)
|
#include <unistd.h>
|
||||||
{
|
|
||||||
#if defined(SEMIHOSTING)
|
#if defined(SEMIHOSTING)
|
||||||
if(sh_istty(fd))
|
#include "semihosting.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
off_t __wrap_lseek(int fd, off_t ptr, int dir) {
|
||||||
|
#if defined(SEMIHOSTING)
|
||||||
|
if (sh_istty(fd))
|
||||||
return 0;
|
return 0;
|
||||||
sh_seek(fd, ptr);
|
sh_seek(fd, ptr);
|
||||||
return ptr;
|
return ptr;
|
||||||
|
@ -22,4 +23,3 @@ off_t __wrap_lseek(int fd, off_t ptr, int dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
weak_under_alias(lseek);
|
weak_under_alias(lseek);
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
/* See LICENSE of license details. */
|
/* See LICENSE of license details. */
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include "stub.h"
|
#include "stub.h"
|
||||||
#include "weak_under_alias.h"
|
#include "weak_under_alias.h"
|
||||||
|
#include <errno.h>
|
||||||
|
#if defined(SEMIHOSTING)
|
||||||
#include "semihosting.h"
|
#include "semihosting.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
int __wrap_open(const char* name, int flags, int mode)
|
int __wrap_open(const char *name, int flags, int mode) {
|
||||||
{
|
|
||||||
#if defined(SEMIHOSTING)
|
#if defined(SEMIHOSTING)
|
||||||
int fd = sh_open(name, mode);
|
int fd = sh_open(name, mode);
|
||||||
return fd;
|
return fd;
|
||||||
|
|
|
@ -3,60 +3,49 @@
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
//#include "semihosting.h"
|
|
||||||
|
|
||||||
#undef putchar
|
#undef putchar
|
||||||
int putchar(int ch)
|
int putchar(int ch) { return write(STDOUT_FILENO, &ch, 1) == 1 ? ch : -1; }
|
||||||
{
|
|
||||||
return write(STDOUT_FILENO, &ch, 1) == 1 ? ch : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t strnlen (const char *str, size_t n)
|
size_t strnlen(const char *str, size_t n) {
|
||||||
{
|
|
||||||
const char *start = str;
|
const char *start = str;
|
||||||
while (n-- > 0 && *str) str++;
|
while (n-- > 0 && *str)
|
||||||
|
str++;
|
||||||
return str - start;
|
return str - start;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fprintf_putch(int ch, void** data)
|
static void fprintf_putch(int ch, void **data) { putchar(ch); }
|
||||||
{
|
static void sprintf_putch(int ch, void **data) {
|
||||||
putchar(ch);
|
char **pstr = (char **)data;
|
||||||
}
|
|
||||||
static void sprintf_putch(int ch, void** data)
|
|
||||||
{
|
|
||||||
char** pstr = (char**)data;
|
|
||||||
**pstr = ch;
|
**pstr = ch;
|
||||||
(*pstr)++;
|
(*pstr)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned long getuint(va_list *ap, int lflag)
|
static unsigned long getuint(va_list *ap, int lflag) {
|
||||||
{
|
|
||||||
if (lflag)
|
if (lflag)
|
||||||
return va_arg(*ap, unsigned long);
|
return va_arg(*ap, unsigned long);
|
||||||
else
|
else
|
||||||
return va_arg(*ap, unsigned int);
|
return va_arg(*ap, unsigned int);
|
||||||
}
|
}
|
||||||
|
|
||||||
static long getint(va_list *ap, int lflag)
|
static long getint(va_list *ap, int lflag) {
|
||||||
{
|
|
||||||
if (lflag)
|
if (lflag)
|
||||||
return va_arg(*ap, long);
|
return va_arg(*ap, long);
|
||||||
else
|
else
|
||||||
return va_arg(*ap, int);
|
return va_arg(*ap, int);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void printnum(void (*putch)(int, void**), void **putdat,
|
static inline void printnum(void (*putch)(int, void **), void **putdat,
|
||||||
unsigned long num, unsigned base, int width, int padc)
|
unsigned long num, unsigned base, int width,
|
||||||
{
|
int padc) {
|
||||||
unsigned digs[sizeof(num)*8];
|
unsigned digs[sizeof(num) * 8];
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
while (1)
|
while (1) {
|
||||||
{
|
|
||||||
digs[pos++] = num % base;
|
digs[pos++] = num % base;
|
||||||
if (num < base)
|
if (num < base)
|
||||||
break;
|
break;
|
||||||
|
@ -70,9 +59,8 @@ static inline void printnum(void (*putch)(int, void**), void **putdat,
|
||||||
putch(digs[pos] + (digs[pos] >= 10 ? 'a' - 10 : '0'), putdat);
|
putch(digs[pos] + (digs[pos] >= 10 ? 'a' - 10 : '0'), putdat);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void print_double(void (*putch)(int, void**), void **putdat,
|
static inline void print_double(void (*putch)(int, void **), void **putdat,
|
||||||
double num, int width, int prec)
|
double num, int width, int prec) {
|
||||||
{
|
|
||||||
union {
|
union {
|
||||||
double d;
|
double d;
|
||||||
uint64_t u;
|
uint64_t u;
|
||||||
|
@ -88,30 +76,30 @@ static inline void print_double(void (*putch)(int, void**), void **putdat,
|
||||||
u.d *= 10;
|
u.d *= 10;
|
||||||
|
|
||||||
char buf[32], *pbuf = buf;
|
char buf[32], *pbuf = buf;
|
||||||
printnum(sprintf_putch, (void**)&pbuf, (unsigned long)u.d, 10, 0, 0);
|
printnum(sprintf_putch, (void **)&pbuf, (unsigned long)u.d, 10, 0, 0);
|
||||||
if (prec > 0) {
|
if (prec > 0) {
|
||||||
for (int i = 0; i < prec; i++) {
|
for (int i = 0; i < prec; i++) {
|
||||||
pbuf[-i] = pbuf[-i-1];
|
pbuf[-i] = pbuf[-i - 1];
|
||||||
}
|
}
|
||||||
pbuf[-prec] = '.';
|
pbuf[-prec] = '.';
|
||||||
pbuf++;
|
pbuf++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (char* p = buf; p < pbuf; p++)
|
for (char *p = buf; p < pbuf; p++)
|
||||||
putch(*p, putdat);
|
putch(*p, putdat);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vprintfmt(void (*putch)(int, void**), void **putdat, const char *fmt, va_list ap)
|
static void vprintfmt(void (*putch)(int, void **), void **putdat,
|
||||||
{
|
const char *fmt, va_list ap) {
|
||||||
register const char* p;
|
register const char *p;
|
||||||
const char* last_fmt;
|
const char *last_fmt;
|
||||||
register int ch;
|
register int ch;
|
||||||
unsigned long num;
|
unsigned long num;
|
||||||
int base, lflag, width, precision;
|
int base, lflag, width, precision;
|
||||||
char padc;
|
char padc;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
while ((ch = *(const char *) fmt) != '%') {
|
while ((ch = *(const char *)fmt) != '%') {
|
||||||
if (ch == '\0')
|
if (ch == '\0')
|
||||||
return;
|
return;
|
||||||
fmt++;
|
fmt++;
|
||||||
|
@ -126,13 +114,13 @@ static void vprintfmt(void (*putch)(int, void**), void **putdat, const char *fmt
|
||||||
precision = -1;
|
precision = -1;
|
||||||
lflag = 0;
|
lflag = 0;
|
||||||
reswitch:
|
reswitch:
|
||||||
switch (ch = *(const char *) fmt++) {
|
switch (ch = *(const char *)fmt++) {
|
||||||
|
|
||||||
// flag to pad on the right
|
// flag to pad on the right
|
||||||
case '-':
|
case '-':
|
||||||
padc = '-';
|
padc = '-';
|
||||||
goto reswitch;
|
goto reswitch;
|
||||||
|
|
||||||
// flag to pad with 0's instead of spaces
|
// flag to pad with 0's instead of spaces
|
||||||
case '0':
|
case '0':
|
||||||
padc = '0';
|
padc = '0';
|
||||||
|
@ -148,7 +136,7 @@ static void vprintfmt(void (*putch)(int, void**), void **putdat, const char *fmt
|
||||||
case '7':
|
case '7':
|
||||||
case '8':
|
case '8':
|
||||||
case '9':
|
case '9':
|
||||||
for (precision = 0; ; ++fmt) {
|
for (precision = 0;; ++fmt) {
|
||||||
precision = precision * 10 + ch - '0';
|
precision = precision * 10 + ch - '0';
|
||||||
ch = *fmt;
|
ch = *fmt;
|
||||||
if (ch < '0' || ch > '9')
|
if (ch < '0' || ch > '9')
|
||||||
|
@ -173,61 +161,62 @@ static void vprintfmt(void (*putch)(int, void**), void **putdat, const char *fmt
|
||||||
width = precision, precision = -1;
|
width = precision, precision = -1;
|
||||||
goto reswitch;
|
goto reswitch;
|
||||||
|
|
||||||
case 'l': // long flag
|
case 'l': // long flag
|
||||||
if (lflag)
|
if (lflag)
|
||||||
goto bad;
|
goto bad;
|
||||||
goto reswitch;
|
goto reswitch;
|
||||||
case 'c': // character
|
case 'c': // character
|
||||||
putch(va_arg(ap, int), putdat);
|
putch(va_arg(ap, int), putdat);
|
||||||
break;
|
break;
|
||||||
case 'f': // double
|
case 'f': // double
|
||||||
print_double(putch, putdat, va_arg(ap, double), width, precision);
|
print_double(putch, putdat, va_arg(ap, double), width, precision);
|
||||||
break;
|
break;
|
||||||
case 's': // string
|
case 's': // string
|
||||||
if ((p = va_arg(ap, char *)) == NULL)
|
if ((p = va_arg(ap, char *)) == NULL)
|
||||||
p = "(null)";
|
p = "(null)";
|
||||||
if (width > 0 && padc != '-')
|
if (width > 0 && padc != '-')
|
||||||
for (width -= strnlen(p, precision); width > 0; width--)
|
for (width -= strnlen(p, precision); width > 0; width--)
|
||||||
putch(padc, putdat);
|
putch(padc, putdat);
|
||||||
for (; (ch = *p) != '\0' && (precision < 0 || --precision >= 0); width--) {
|
for (; (ch = *p) != '\0' && (precision < 0 || --precision >= 0);
|
||||||
|
width--) {
|
||||||
putch(ch, putdat);
|
putch(ch, putdat);
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
for (; width > 0; width--)
|
for (; width > 0; width--)
|
||||||
putch(' ', putdat);
|
putch(' ', putdat);
|
||||||
break;
|
break;
|
||||||
case 'd': // (signed) decimal
|
case 'd': // (signed) decimal
|
||||||
num = getint(&ap, lflag);
|
num = getint(&ap, lflag);
|
||||||
if ((long) num < 0) {
|
if ((long)num < 0) {
|
||||||
putch('-', putdat);
|
putch('-', putdat);
|
||||||
num = -(long) num;
|
num = -(long)num;
|
||||||
}
|
}
|
||||||
base = 10;
|
base = 10;
|
||||||
goto signed_number;
|
goto signed_number;
|
||||||
case 'u': // unsigned decimal
|
case 'u': // unsigned decimal
|
||||||
base = 10;
|
base = 10;
|
||||||
goto unsigned_number;
|
goto unsigned_number;
|
||||||
case 'o': // (unsigned) octal
|
case 'o': // (unsigned) octal
|
||||||
// should do something with padding so it's always 3 octits
|
// should do something with padding so it's always 3 octits
|
||||||
base = 8;
|
base = 8;
|
||||||
goto unsigned_number;
|
goto unsigned_number;
|
||||||
case 'p':// pointer
|
case 'p': // pointer
|
||||||
lflag = 1;
|
lflag = 1;
|
||||||
putch('0', putdat);
|
putch('0', putdat);
|
||||||
putch('x', putdat);
|
putch('x', putdat);
|
||||||
/* fall through to 'x' */
|
/* fall through to 'x' */
|
||||||
__attribute__((fallthrough));
|
__attribute__((fallthrough));
|
||||||
case 'x': // (unsigned) hexadecimal
|
case 'x': // (unsigned) hexadecimal
|
||||||
base = 16;
|
base = 16;
|
||||||
unsigned_number:
|
unsigned_number:
|
||||||
num = getuint(&ap, lflag);
|
num = getuint(&ap, lflag);
|
||||||
signed_number:
|
signed_number:
|
||||||
printnum(putch, putdat, num, base, width, padc);
|
printnum(putch, putdat, num, base, width, padc);
|
||||||
break;
|
break;
|
||||||
case '%': // escaped '%' character
|
case '%': // escaped '%' character
|
||||||
putch(ch, putdat);
|
putch(ch, putdat);
|
||||||
break;
|
break;
|
||||||
default: // unrecognized escape sequence - just print it literally
|
default: // unrecognized escape sequence - just print it literally
|
||||||
bad:
|
bad:
|
||||||
putch('%', putdat);
|
putch('%', putdat);
|
||||||
fmt = last_fmt;
|
fmt = last_fmt;
|
||||||
|
@ -236,8 +225,7 @@ static void vprintfmt(void (*putch)(int, void**), void **putdat, const char *fmt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int __wrap_printf(const char* fmt, ...)
|
int __wrap_printf(const char *fmt, ...) {
|
||||||
{
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
|
|
||||||
|
@ -247,13 +235,12 @@ int __wrap_printf(const char* fmt, ...)
|
||||||
return 0; // incorrect return value, but who cares, anyway?
|
return 0; // incorrect return value, but who cares, anyway?
|
||||||
}
|
}
|
||||||
|
|
||||||
int __wrap_sprintf(char* str, const char* fmt, ...)
|
int __wrap_sprintf(char *str, const char *fmt, ...) {
|
||||||
{
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char* str0 = str;
|
char *str0 = str;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
|
|
||||||
vprintfmt(sprintf_putch, (void**)&str, fmt, ap);
|
vprintfmt(sprintf_putch, (void **)&str, fmt, ap);
|
||||||
*str = 0;
|
*str = 0;
|
||||||
|
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
|
@ -6,9 +6,11 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "semihosting.h"
|
|
||||||
#include "stub.h"
|
#include "stub.h"
|
||||||
#include "weak_under_alias.h"
|
#include "weak_under_alias.h"
|
||||||
|
#if defined(SEMIHOSTING)
|
||||||
|
#include "semihosting.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
int __wrap_puts(const char *s) {
|
int __wrap_puts(const char *s) {
|
||||||
#if defined(SEMIHOSTING)
|
#if defined(SEMIHOSTING)
|
||||||
|
|
|
@ -6,9 +6,11 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "semihosting.h"
|
|
||||||
#include "stub.h"
|
#include "stub.h"
|
||||||
#include "weak_under_alias.h"
|
#include "weak_under_alias.h"
|
||||||
|
#if defined(SEMIHOSTING)
|
||||||
|
#include "semihosting.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
ssize_t __wrap_read(int fd, void *ptr, size_t len) {
|
ssize_t __wrap_read(int fd, void *ptr, size_t len) {
|
||||||
uint8_t *current = (uint8_t *)ptr;
|
uint8_t *current = (uint8_t *)ptr;
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
/* See LICENSE of license details. */
|
/* See LICENSE of license details. */
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include "stub.h"
|
#include "stub.h"
|
||||||
#include "weak_under_alias.h"
|
#include "weak_under_alias.h"
|
||||||
|
#include <errno.h>
|
||||||
|
#if defined(SEMIHOSTING)
|
||||||
#include "semihosting.h"
|
#include "semihosting.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
int __wrap_unlink(const char* name)
|
int __wrap_unlink(const char *name) {
|
||||||
{
|
|
||||||
#if defined(SEMIHOSTING)
|
#if defined(SEMIHOSTING)
|
||||||
return sh_remove(name);
|
return sh_remove(name);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -6,9 +6,11 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "semihosting.h"
|
|
||||||
#include "stub.h"
|
#include "stub.h"
|
||||||
#include "weak_under_alias.h"
|
#include "weak_under_alias.h"
|
||||||
|
#if defined(SEMIHOSTING)
|
||||||
|
#include "semihosting.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
ssize_t __wrap_write(int fd, const void *ptr, size_t len) {
|
ssize_t __wrap_write(int fd, const void *ptr, size_t len) {
|
||||||
const uint8_t *current = (const uint8_t *)ptr;
|
const uint8_t *current = (const uint8_t *)ptr;
|
||||||
|
|
Loading…
Reference in New Issue