further semihosting support
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "semihosting.h"
|
||||
|
||||
@ -33,7 +34,7 @@
|
||||
|
||||
#define RISCV_SEMIHOSTING_CALL_NUMBER 7
|
||||
|
||||
/*typedef struct {
|
||||
typedef struct {
|
||||
char* str;
|
||||
int mode;
|
||||
size_t length;
|
||||
@ -48,9 +49,13 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
char* path;
|
||||
int len;
|
||||
size_t len;
|
||||
} RemoveVector;
|
||||
*/
|
||||
|
||||
typedef struct{
|
||||
int fd;
|
||||
off_t pos;
|
||||
} SeekVector;
|
||||
|
||||
static inline int __attribute__ ((always_inline)) call_host(int reason, void* arg) {
|
||||
#if 1
|
||||
@ -86,17 +91,22 @@ static inline int __attribute__ ((always_inline)) call_host(int reason, void* ar
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
int sh_errno(void) {
|
||||
return call_host(SEMIHOSTING_SYS_ERRNO, (void*)NULL);
|
||||
}
|
||||
|
||||
int sh_time(void) {
|
||||
return call_host(SEMIHOSTING_SYS_TIME, (void*)NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void sh_seek(int file_handle, int pos) {
|
||||
int vec[2] = {file_handle, pos};
|
||||
int sh_remove(char* path) {
|
||||
size_t len = strlen(path);
|
||||
RemoveVector vec = {path, len};
|
||||
return call_host(SEMIHOSTING_SYS_REMOVE, &vec);
|
||||
}
|
||||
|
||||
void sh_seek(int file_handle, off_t pos) {
|
||||
SeekVector vec = {file_handle, pos};
|
||||
call_host(SEMIHOSTING_SYS_SEEK, &vec);
|
||||
return;
|
||||
}
|
||||
@ -135,13 +145,12 @@ int sh_iserror(int num) {
|
||||
int sh_istty(int file_handle) {
|
||||
return call_host(SEMIHOSTING_SYS_ISTTY, file_handle);
|
||||
}
|
||||
|
||||
/*
|
||||
int sh_remove(char* path) {
|
||||
int len = strlen(path);
|
||||
size_t len = strlen(path);
|
||||
RemoveVector vec = {path, len};
|
||||
return call_host(SEMIHOSTING_SYS_REMOVE, &vec);
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
void sh_rename(char* old, char* new) {
|
||||
int old_len = strlen(old);
|
||||
@ -175,18 +184,22 @@ int sh_open(char* str, int mode) {
|
||||
//int length = 44;
|
||||
size_t length = strlen(str);
|
||||
OpenVector vec = {str, mode, length};
|
||||
int i = call_host(SEMIHOSTING_SYS_OPEN, &vec);
|
||||
return i;
|
||||
return call_host(SEMIHOSTING_SYS_OPEN, &vec);
|
||||
}
|
||||
|
||||
void sh_read(char* buf, int file_handle, size_t length) {
|
||||
OpenVector vec = {buf, file_handle, length};
|
||||
int i = call_host(SEMIHOSTING_SYS_READ, &vec);
|
||||
return i;
|
||||
} */
|
||||
}
|
||||
|
||||
int sh_clock(void)
|
||||
{
|
||||
int clock = call_host(SEMIHOSTING_SYS_CLOCK, (void*)NULL);
|
||||
return clock;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void sh_write(char* str, int file_handle) {
|
||||
return;
|
||||
}*/
|
@ -1,8 +1,11 @@
|
||||
#ifndef SEMIHOSTING_H
|
||||
#define SEMIHOSTING_H
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
//int32_t trace_write(const char* buf, uint32_t nbyte);
|
||||
|
||||
void sh_seek(int, off_t);
|
||||
void sh_write0(const char* buf);
|
||||
void sh_writec(char c);
|
||||
char sh_readc(void);
|
||||
|
Reference in New Issue
Block a user