125 lines
2.0 KiB
C
125 lines
2.0 KiB
C
#include <unistd.h>
|
|
#include <errno.h>
|
|
#include "sys/stat.h"
|
|
#include "reent.h"
|
|
#include "bsp_init.h"
|
|
#include "libc.h"
|
|
#include "string.h"
|
|
|
|
|
|
|
|
// 寻找指定名称的设备
|
|
extern const unsigned int libc_dev_start;
|
|
extern const unsigned int libc_dev_end;
|
|
const libc_device_file *libc_find_dev(const char *name)
|
|
{
|
|
libc_device_file *start=(libc_device_file *)&libc_dev_start;
|
|
libc_device_file *end=(libc_device_file *)&libc_dev_end;
|
|
|
|
libc_device_file *ptr=0;
|
|
for(ptr=start;ptr<end;ptr++)
|
|
{
|
|
if(strcmp(ptr->name,name)==0)
|
|
return ptr;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int _close(int fd) {
|
|
(void)fd;
|
|
return -1; // 不支持文件操作
|
|
}
|
|
|
|
int _read(int fd, char *buf, int nbytes) {
|
|
(void)fd; (void)buf; (void)nbytes;
|
|
return -1;
|
|
}
|
|
|
|
int _write(int fd, const char *buf, int nbytes) {
|
|
(void)fd; (void)buf; (void)nbytes;
|
|
return -1;
|
|
}
|
|
|
|
off_t _lseek(int fd, off_t offset, int whence) {
|
|
(void)fd; (void)offset; (void)whence;
|
|
return -1;
|
|
}
|
|
|
|
int _isatty(int fd) {
|
|
(void)fd;
|
|
return 1; // 假设是终端设备
|
|
}
|
|
|
|
int _open(const char *path, int flags, ...) {
|
|
(void)path; (void)flags;
|
|
return -1;
|
|
}
|
|
|
|
int _fstat(int fd, struct stat *st) {
|
|
(void)fd; (void)st;
|
|
return -1;
|
|
}
|
|
|
|
int _stat(const char *path, struct stat *st) {
|
|
(void)path; (void)st;
|
|
return -1;
|
|
}
|
|
|
|
int _unlink(const char *name) {
|
|
(void)name;
|
|
return -1;
|
|
}
|
|
|
|
int _link(const char *old, const char *new) {
|
|
(void)old; (void)new;
|
|
return -1;
|
|
}
|
|
|
|
int _execve(const char *name, char *const *argv, char *const *env) {
|
|
(void)name; (void)argv; (void)env;
|
|
errno = ENOSYS;
|
|
return -1;
|
|
}
|
|
|
|
int _fork(void) {
|
|
errno = ENOSYS;
|
|
return -1;
|
|
}
|
|
|
|
int _getpid(void) {
|
|
return 1;
|
|
}
|
|
|
|
int _wait(int *status) {
|
|
(void)status;
|
|
errno = ECHILD;
|
|
return -1;
|
|
}
|
|
|
|
int _times(struct tms *buf) {
|
|
(void)buf;
|
|
return -1;
|
|
}
|
|
|
|
int _kill(int pid, int sig) {
|
|
(void)pid; (void)sig;
|
|
errno = EINVAL;
|
|
return -1;
|
|
}
|
|
|
|
void *_sbrk(ptrdiff_t incr) {
|
|
(void)incr;
|
|
errno = ENOMEM;
|
|
return (void *)-1;
|
|
} |