update include paths
This commit is contained in:
		@@ -1,6 +1,6 @@
 | 
				
			|||||||
#include <stdint.h>
 | 
					 | 
				
			||||||
#include <stdarg.h>
 | 
					#include <stdarg.h>
 | 
				
			||||||
#include <stddef.h>
 | 
					#include <stddef.h>
 | 
				
			||||||
 | 
					#include <stdint.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include <sys/types.h>
 | 
					#include <sys/types.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -35,54 +35,56 @@
 | 
				
			|||||||
#define RISCV_SEMIHOSTING_CALL_NUMBER 7
 | 
					#define RISCV_SEMIHOSTING_CALL_NUMBER 7
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct {
 | 
					typedef struct {
 | 
				
			||||||
    char* str;
 | 
					  char *str;
 | 
				
			||||||
  int mode;
 | 
					  int mode;
 | 
				
			||||||
  size_t length;
 | 
					  size_t length;
 | 
				
			||||||
} OpenVector;
 | 
					} OpenVector;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct {
 | 
					typedef struct {
 | 
				
			||||||
    char* old;
 | 
					  char *old;
 | 
				
			||||||
  int old_len;
 | 
					  int old_len;
 | 
				
			||||||
    char* new;
 | 
					  char *new;
 | 
				
			||||||
  int new_len;
 | 
					  int new_len;
 | 
				
			||||||
} RenameVector;
 | 
					} RenameVector;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct {
 | 
					typedef struct {
 | 
				
			||||||
    char* path;
 | 
					  char *path;
 | 
				
			||||||
  size_t len;
 | 
					  size_t len;
 | 
				
			||||||
} RemoveVector;
 | 
					} RemoveVector;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct{
 | 
					typedef struct {
 | 
				
			||||||
  int fd;
 | 
					  int fd;
 | 
				
			||||||
  off_t pos;
 | 
					  off_t pos;
 | 
				
			||||||
} SeekVector;
 | 
					} SeekVector;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static inline int __attribute__ ((always_inline)) call_host(int reason, void* arg) {
 | 
					static inline int __attribute__((always_inline))
 | 
				
			||||||
 | 
					call_host(int reason, void *arg) {
 | 
				
			||||||
#if 1
 | 
					#if 1
 | 
				
			||||||
  // This must always be set back to 0 to cover the case where a host wasn't
 | 
					  // This must always be set back to 0 to cover the case where a host wasn't
 | 
				
			||||||
  // initially present, but only connected while the program was already up and
 | 
					  // initially present, but only connected while the program was already up and
 | 
				
			||||||
    // running. In that case, trap() suddenly won't be called anymore, so we have to
 | 
					  // running. In that case, trap() suddenly won't be called anymore, so we have
 | 
				
			||||||
    // clear this variable *before* EBREAK is called.
 | 
					  // to clear this variable *before* EBREAK is called.
 | 
				
			||||||
  sh_missing_host = 0;
 | 
					  sh_missing_host = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    register int value asm ("a0") = reason;
 | 
					  register int value asm("a0") = reason;
 | 
				
			||||||
    register void* ptr asm ("a1") = arg;
 | 
					  register void *ptr asm("a1") = arg;
 | 
				
			||||||
    asm volatile (
 | 
					  asm volatile(
 | 
				
			||||||
      // Workaround for RISC-V lack of multiple EBREAKs.
 | 
					      // Workaround for RISC-V lack of multiple EBREAKs.
 | 
				
			||||||
      " .option push \n"
 | 
					      " .option push \n"
 | 
				
			||||||
      " .option norvc \n"
 | 
					      " .option norvc \n"
 | 
				
			||||||
      // Force 16-byte alignment to make sure that the 3 instruction fall
 | 
					      // Force 16-byte alignment to make sure that the 3 instruction fall
 | 
				
			||||||
        // within the same virtual page. If you the instruction straddle a page boundary
 | 
					      // within the same virtual page. If you the instruction straddle a page
 | 
				
			||||||
        // the debugger fetching the instructions could lead to a page fault.
 | 
					      // boundary the debugger fetching the instructions could lead to a page
 | 
				
			||||||
        // Note: align 4 means, align by 2 to the power of 4!
 | 
					      // fault. Note: align 4 means, align by 2 to the power of 4!
 | 
				
			||||||
      " .align 4 \n"
 | 
					      " .align 4 \n"
 | 
				
			||||||
      " slli x0, x0, 0x1f \n"
 | 
					      " slli x0, x0, 0x1f \n"
 | 
				
			||||||
      " ebreak \n"
 | 
					      " ebreak \n"
 | 
				
			||||||
      " srai x0, x0, 0x07 \n"
 | 
					      " srai x0, x0, 0x07 \n"
 | 
				
			||||||
      " .option pop \n"
 | 
					      " .option pop \n"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        : "=r" (value) /* Outputs */
 | 
					      : "=r"(value) /* Outputs */
 | 
				
			||||||
        : "0" (value), "r" (ptr), [swi] "i" (RISCV_SEMIHOSTING_CALL_NUMBER) /* Inputs */
 | 
					      : "0"(value),
 | 
				
			||||||
 | 
					        "r"(ptr), [swi] "i"(RISCV_SEMIHOSTING_CALL_NUMBER) /* Inputs */
 | 
				
			||||||
      : "memory"                                           /* Clobbers */
 | 
					      : "memory"                                           /* Clobbers */
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
  return value;
 | 
					  return value;
 | 
				
			||||||
@@ -91,15 +93,11 @@ static inline int __attribute__ ((always_inline)) call_host(int reason, void* ar
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int sh_errno(void) {
 | 
					int sh_errno(void) { return call_host(SEMIHOSTING_SYS_ERRNO, (void *)NULL); }
 | 
				
			||||||
    return call_host(SEMIHOSTING_SYS_ERRNO, (void*)NULL);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
int sh_time(void) {
 | 
					int sh_time(void) { return call_host(SEMIHOSTING_SYS_TIME, (void *)NULL); }
 | 
				
			||||||
    return call_host(SEMIHOSTING_SYS_TIME, (void*)NULL);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
int sh_remove(char* path) {
 | 
					int sh_remove(char *path) {
 | 
				
			||||||
  size_t len = strlen(path);
 | 
					  size_t len = strlen(path);
 | 
				
			||||||
  RemoveVector vec = {path, len};
 | 
					  RemoveVector vec = {path, len};
 | 
				
			||||||
  return call_host(SEMIHOSTING_SYS_REMOVE, &vec);
 | 
					  return call_host(SEMIHOSTING_SYS_REMOVE, &vec);
 | 
				
			||||||
@@ -111,7 +109,7 @@ void sh_seek(int file_handle, off_t pos) {
 | 
				
			|||||||
  return;
 | 
					  return;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void sh_write(char* str, int file_handle) {
 | 
					void sh_write(char *str, int file_handle) {
 | 
				
			||||||
  size_t length = strlen(str);
 | 
					  size_t length = strlen(str);
 | 
				
			||||||
  OpenVector vec = {str, file_handle, length};
 | 
					  OpenVector vec = {str, file_handle, length};
 | 
				
			||||||
  call_host(SEMIHOSTING_SYS_WRITE, &vec);
 | 
					  call_host(SEMIHOSTING_SYS_WRITE, &vec);
 | 
				
			||||||
@@ -123,24 +121,20 @@ int sh_close(int file_handle) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void sh_exit(void) {
 | 
					void sh_exit(void) {
 | 
				
			||||||
    call_host(SEMIHOSTING_SYS_EXIT, (void*)NULL);
 | 
					  call_host(SEMIHOSTING_SYS_EXIT, (void *)NULL);
 | 
				
			||||||
  return;
 | 
					  return;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void sh_exit_extended(void) {
 | 
					void sh_exit_extended(void) {
 | 
				
			||||||
    call_host(SEMIHOSTING_SYS_EXIT_EXTENDED, (void*)NULL);
 | 
					  call_host(SEMIHOSTING_SYS_EXIT_EXTENDED, (void *)NULL);
 | 
				
			||||||
  return;
 | 
					  return;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int sh_flen(int file_handle) {
 | 
					int sh_flen(int file_handle) {
 | 
				
			||||||
  return call_host(SEMIHOSTING_SYS_FLEN, file_handle);
 | 
					  return call_host(SEMIHOSTING_SYS_FLEN, file_handle);
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int sh_iserror(int num) {
 | 
					int sh_iserror(int num) { return call_host(SEMIHOSTING_SYS_ISERROR, num); }
 | 
				
			||||||
    return call_host(SEMIHOSTING_SYS_ISERROR, num);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
int sh_istty(int file_handle) {
 | 
					int sh_istty(int file_handle) {
 | 
				
			||||||
  return call_host(SEMIHOSTING_SYS_ISTTY, file_handle);
 | 
					  return call_host(SEMIHOSTING_SYS_ISTTY, file_handle);
 | 
				
			||||||
@@ -152,7 +146,7 @@ int sh_remove(char* path) {
 | 
				
			|||||||
    return call_host(SEMIHOSTING_SYS_REMOVE, &vec);
 | 
					    return call_host(SEMIHOSTING_SYS_REMOVE, &vec);
 | 
				
			||||||
}*/
 | 
					}*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void sh_rename(char* old, char* new) {
 | 
					void sh_rename(char *old, char *new) {
 | 
				
			||||||
  int old_len = strlen(old);
 | 
					  int old_len = strlen(old);
 | 
				
			||||||
  int new_len = strlen(new);
 | 
					  int new_len = strlen(new);
 | 
				
			||||||
  RenameVector vec = {old, old_len, new, new_len};
 | 
					  RenameVector vec = {old, old_len, new, new_len};
 | 
				
			||||||
@@ -160,42 +154,38 @@ void sh_rename(char* old, char* new) {
 | 
				
			|||||||
  return;
 | 
					  return;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void sh_write0(const char* buf)
 | 
					void sh_write0(const char *buf) {
 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  // Print zero-terminated string
 | 
					  // Print zero-terminated string
 | 
				
			||||||
    call_host(SEMIHOSTING_SYS_WRITE0, (void*) buf);
 | 
					  call_host(SEMIHOSTING_SYS_WRITE0, (void *)buf);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void sh_writec(char c)
 | 
					void sh_writec(char c) {
 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  // Print single character
 | 
					  // Print single character
 | 
				
			||||||
    call_host(SEMIHOSTING_SYS_WRITEC, (void*)&c);
 | 
					  call_host(SEMIHOSTING_SYS_WRITEC, (void *)&c);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
char sh_readc(void)
 | 
					char sh_readc(void) {
 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  // Read character from keyboard. (Blocking operation!)
 | 
					  // Read character from keyboard. (Blocking operation!)
 | 
				
			||||||
    char c = call_host(SEMIHOSTING_SYS_READC, (void*)NULL);
 | 
					  char c = call_host(SEMIHOSTING_SYS_READC, (void *)NULL);
 | 
				
			||||||
  return c;
 | 
					  return c;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int sh_open(char* str, int mode) {
 | 
					int sh_open(char *str, int mode) {
 | 
				
			||||||
    //mode = 0;
 | 
					  // mode = 0;
 | 
				
			||||||
    //int length = 44;
 | 
					  // int length = 44;
 | 
				
			||||||
  size_t length = strlen(str);
 | 
					  size_t length = strlen(str);
 | 
				
			||||||
  OpenVector vec = {str, mode, length};
 | 
					  OpenVector vec = {str, mode, length};
 | 
				
			||||||
  return call_host(SEMIHOSTING_SYS_OPEN, &vec);
 | 
					  return call_host(SEMIHOSTING_SYS_OPEN, &vec);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void sh_read(char* buf, int file_handle, size_t length) {
 | 
					int sh_read(char *buf, int file_handle, size_t length) {
 | 
				
			||||||
  OpenVector vec = {buf, file_handle, length};
 | 
					  OpenVector vec = {buf, file_handle, length};
 | 
				
			||||||
  int i = call_host(SEMIHOSTING_SYS_READ, &vec);
 | 
					  int i = call_host(SEMIHOSTING_SYS_READ, &vec);
 | 
				
			||||||
  return i;
 | 
					  return i;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int sh_clock(void)
 | 
					int sh_clock(void) {
 | 
				
			||||||
{
 | 
					  int clock = call_host(SEMIHOSTING_SYS_CLOCK, (void *)NULL);
 | 
				
			||||||
    int clock = call_host(SEMIHOSTING_SYS_CLOCK, (void*)NULL);
 | 
					 | 
				
			||||||
  return clock;
 | 
					  return clock;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,20 +1,20 @@
 | 
				
			|||||||
#ifndef SEMIHOSTING_H
 | 
					#ifndef SEMIHOSTING_H
 | 
				
			||||||
#define SEMIHOSTING_H
 | 
					#define SEMIHOSTING_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <unistd.h>
 | 
					 | 
				
			||||||
#include <sys/types.h>
 | 
					#include <sys/types.h>
 | 
				
			||||||
//int32_t trace_write(const char* buf, uint32_t nbyte);
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					// int32_t trace_write(const char* buf, uint32_t nbyte);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void sh_seek(int, off_t);
 | 
					void sh_seek(int, off_t);
 | 
				
			||||||
void sh_write0(const char* buf);
 | 
					void sh_write0(const char *buf);
 | 
				
			||||||
void sh_writec(char c);
 | 
					void sh_writec(char c);
 | 
				
			||||||
char sh_readc(void);
 | 
					char sh_readc(void);
 | 
				
			||||||
int sh_clock(void);
 | 
					int sh_clock(void);
 | 
				
			||||||
void sh_read(char*, int, size_t);
 | 
					int sh_read(char *, int, size_t);
 | 
				
			||||||
void sh_write(char*, int);
 | 
					void sh_write(char *, int);
 | 
				
			||||||
int sh_open(char*, int);
 | 
					int sh_open(char *, int);
 | 
				
			||||||
void sh_rename(char*, char*);
 | 
					void sh_rename(char *, char *);
 | 
				
			||||||
int sh_remove(char*);
 | 
					int sh_remove(char *);
 | 
				
			||||||
int sh_istty(int);
 | 
					int sh_istty(int);
 | 
				
			||||||
int sh_iserror(int);
 | 
					int sh_iserror(int);
 | 
				
			||||||
int sh_flen(int);
 | 
					int sh_flen(int);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,12 +5,10 @@
 | 
				
			|||||||
#include <sys/types.h>
 | 
					#include <sys/types.h>
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "../../include/tgc-vp/devices/uart.h"
 | 
					 | 
				
			||||||
#include "../../env/tgc-vp/platform.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"
 | 
				
			||||||
#include "semihosting.h"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
int __wrap_puts(const char *s) {
 | 
					int __wrap_puts(const char *s) {
 | 
				
			||||||
#if defined(SEMIHOSTING)
 | 
					#if defined(SEMIHOSTING)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,24 +1,20 @@
 | 
				
			|||||||
/* See LICENSE of license details. */
 | 
					/* See LICENSE of license details. */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <stdint.h>
 | 
					 | 
				
			||||||
#include <errno.h>
 | 
					#include <errno.h>
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <stdint.h>
 | 
				
			||||||
#include <sys/types.h>
 | 
					#include <sys/types.h>
 | 
				
			||||||
#if defined(BOARD_ehrenberg)
 | 
					#include <unistd.h>
 | 
				
			||||||
#include "platform.h"
 | 
					
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#include "../../include/tgc-vp/devices/uart.h"
 | 
					 | 
				
			||||||
#include "/scratch/gabriel/repos/Firmwares/bare-metal-bsp/env/tgc-vp/platform.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"
 | 
				
			||||||
#include "semihosting.h"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
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;
 | 
				
			||||||
#if defined(SEMIHOSTING)
 | 
					#if defined(SEMIHOSTING)
 | 
				
			||||||
    sh_read(current, fd, len);
 | 
					  int i = sh_read(current, fd, len);
 | 
				
			||||||
    return;
 | 
					  return i;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#if defined(BOARD_hifive1)
 | 
					#if defined(BOARD_hifive1)
 | 
				
			||||||
  volatile uint32_t *uart_rx = (uint32_t *)(UART0_CTRL_ADDR + UART_REG_RXFIFO);
 | 
					  volatile uint32_t *uart_rx = (uint32_t *)(UART0_CTRL_ADDR + UART_REG_RXFIFO);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,17 +5,15 @@
 | 
				
			|||||||
#include <sys/types.h>
 | 
					#include <sys/types.h>
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "../../include/tgc-vp/devices/uart.h"
 | 
					 | 
				
			||||||
#include "../../env/tgc-vp/platform.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"
 | 
				
			||||||
#include "semihosting.h"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
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;
 | 
				
			||||||
#if defined(SEMIHOSTING)
 | 
					#if defined(SEMIHOSTING)
 | 
				
			||||||
  if(isatty(fd)) {
 | 
					  if (isatty(fd)) {
 | 
				
			||||||
    for (size_t jj = 0; jj < len; jj++) {
 | 
					    for (size_t jj = 0; jj < len; jj++) {
 | 
				
			||||||
      sh_writec(current[jj]);
 | 
					      sh_writec(current[jj]);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -24,7 +22,7 @@ ssize_t __wrap_write(int fd, const void* ptr, size_t len) {
 | 
				
			|||||||
    sh_write(current, fd);
 | 
					    sh_write(current, fd);
 | 
				
			||||||
    return len;
 | 
					    return len;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  //return len;
 | 
					  // return len;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
  if (isatty(fd)) {
 | 
					  if (isatty(fd)) {
 | 
				
			||||||
    for (size_t jj = 0; jj < len; jj++) {
 | 
					    for (size_t jj = 0; jj < len; jj++) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user