mongoose/examples/ti/ek-tm4c1294xl-make-baremetal-builtin-rndis/syscalls.c

89 lines
1.5 KiB
C
Raw Normal View History

2022-11-11 05:44:53 +08:00
#include <sys/stat.h>
2023-03-03 03:47:09 +08:00
#include "hal.h"
2022-11-11 05:44:53 +08:00
int _fstat(int fd, struct stat *st) {
if (fd < 0) return -1;
st->st_mode = S_IFCHR;
return 0;
}
void *_sbrk(int incr) {
extern char _end;
static unsigned char *heap = NULL;
unsigned char *prev_heap;
2023-02-17 22:11:31 +08:00
unsigned char x = 0, *heap_end = (unsigned char *)((size_t) &x - 512);
(void) x;
2022-11-11 05:44:53 +08:00
if (heap == NULL) heap = (unsigned char *) &_end;
prev_heap = heap;
2023-02-17 22:11:31 +08:00
if (heap + incr > heap_end) return (void *) -1;
2022-11-11 05:44:53 +08:00
heap += incr;
return prev_heap;
}
int _open(const char *path) {
(void) path;
return -1;
}
int _close(int fd) {
(void) fd;
return -1;
}
int _isatty(int fd) {
(void) fd;
return 1;
}
int _lseek(int fd, int ptr, int dir) {
(void) fd, (void) ptr, (void) dir;
return 0;
}
void _exit(int status) {
(void) status;
for (;;) asm volatile("BKPT #0");
}
void _kill(int pid, int sig) {
(void) pid, (void) sig;
}
int _getpid(void) {
return -1;
}
int _write(int fd, char *ptr, int len) {
(void) fd, (void) ptr, (void) len;
2023-03-03 03:47:09 +08:00
if (fd == 1) uart_write_buf(UART_DEBUG, ptr, (size_t) len);
2022-11-11 05:44:53 +08:00
return -1;
}
int _read(int fd, char *ptr, int len) {
(void) fd, (void) ptr, (void) len;
return -1;
}
int _link(const char *a, const char *b) {
(void) a, (void) b;
return -1;
}
int _unlink(const char *a) {
(void) a;
return -1;
}
int _stat(const char *path, struct stat *st) {
(void) path, (void) st;
return -1;
}
int mkdir(const char *path, mode_t mode) {
(void) path, (void) mode;
return -1;
}
2023-03-03 03:47:09 +08:00
void _init(void) {}