1 #include <BoardConsole.h>
18 static ssize_t stdin_read(
void *
opaque,
void * buf,
size_t count) {
22 static ssize_t stdout_write(
void *
opaque,
const void * buf,
size_t count) {
24 const char * data = (
const char *) buf;
26 for (i = 0; i < count; i++)
35 memset(fio_fds, 0,
sizeof(fio_fds));
36 fio_fds[0].
fdread = stdin_read;
37 fio_fds[1].
fdwrite = stdout_write;
38 fio_fds[2].
fdwrite = stdout_write;
43 if ((fd < 0) || (fd >=
MAX_FDS))
48 static int fio_is_open_int(
int fd) {
49 if ((fd < 0) || (fd >=
MAX_FDS))
59 static int fio_findfd() {
63 if (!fio_is_open_int(i))
73 r = fio_is_open_int(fd);
99 if (fio_is_open_int(fd)) {
101 r = fio_fds[fd].
fdread(fio_fds[fd].opaque, buf, count);
114 if (fio_is_open_int(fd)) {
116 r = fio_fds[fd].
fdwrite(fio_fds[fd].opaque, buf, count);
129 if (fio_is_open_int(fd)) {
131 r = fio_fds[fd].
fdseek(fio_fds[fd].opaque, offset, whence);
144 if (fio_is_open_int(fd)) {
146 r = fio_fds[fd].
fdclose(fio_fds[fd].opaque);
148 memset(fio_fds + fd, 0,
sizeof(
struct fddef_t));
157 if (fio_is_open_int(fd))
161 #define stdin_hash 0x0BA00421
162 #define stdout_hash 0x7FA08308
163 #define stderr_hash 0x7FA058A3
165 static int devfs_open(
void * opaque,
const char * path,
int flags,
int mode) {
166 uint32_t h =
hash_djb2((
const uint8_t *) path, -1);
180 if (flags & O_RDONLY)
189 DBGOUT(
"Registering devfs.\r\n");