From 7c3ca6e8bf3f2cc8b91e1e6a50d3042c8d90cb34 Mon Sep 17 00:00:00 2001 From: Andress Barajas Date: Fri, 22 Nov 2024 14:29:01 -0800 Subject: [PATCH 1/2] Clean fs_dcload.* --- kernel/arch/dreamcast/fs/fs_dcload.c | 120 +++++++++---------- kernel/arch/dreamcast/include/dc/fs_dcload.h | 116 ++++++++---------- 2 files changed, 105 insertions(+), 131 deletions(-) diff --git a/kernel/arch/dreamcast/fs/fs_dcload.c b/kernel/arch/dreamcast/fs/fs_dcload.c index 0f0ce09c9..60b53b0d6 100644 --- a/kernel/arch/dreamcast/fs/fs_dcload.c +++ b/kernel/arch/dreamcast/fs/fs_dcload.c @@ -32,7 +32,7 @@ printf goes to the dc-tool console #include #include -static spinlock_t mutex = SPINLOCK_INITIALIZER; +static spinlock_t dcload_lock = SPINLOCK_INITIALIZER; #define dclsc(...) ({ \ int old = 0, rv; \ @@ -48,12 +48,12 @@ static spinlock_t mutex = SPINLOCK_INITIALIZER; }) /* Printk replacement */ -int dcload_write_buffer(const uint8 *data, int len, int xlat) { +int dcload_write_buffer(const uint8_t *data, int len, int xlat) { (void)xlat; - spinlock_lock(&mutex); + spinlock_lock(&dcload_lock); dclsc(DCLOAD_WRITE, 1, data, len); - spinlock_unlock(&mutex); + spinlock_unlock(&dcload_lock); return len; } @@ -62,34 +62,34 @@ int dcload_read_cons(void) { return -1; } -size_t dcload_gdbpacket(const char* in_buf, size_t in_size, char* out_buf, size_t out_size) { +size_t dcload_gdbpacket(const char *in_buf, size_t in_size, char *out_buf, size_t out_size) { size_t ret = -1; - spinlock_lock(&mutex); + spinlock_lock(&dcload_lock); - /* we have to pack the sizes together because the dcloadsyscall handler + /* We have to pack the sizes together because the dcloadsyscall handler can only take 4 parameters */ ret = dclsc(DCLOAD_GDBPACKET, in_buf, (in_size << 16) | (out_size & 0xffff), out_buf); - spinlock_unlock(&mutex); + spinlock_unlock(&dcload_lock); return ret; } static char *dcload_path = NULL; -void *dcload_open(vfs_handler_t * vfs, const char *fn, int mode) { + +void *dcload_open(vfs_handler_t *vfs, const char *fn, int mode) { int hnd = 0; - uint32 h; + uint32_t h; int dcload_mode = 0; int mm = (mode & O_MODE_MASK); (void)vfs; - spinlock_lock(&mutex); + spinlock_lock(&dcload_lock); if(mode & O_DIR) { - if(fn[0] == '\0') { + if(fn[0] == '\0') fn = "/"; - } hnd = dclsc(DCLOAD_OPENDIR, fn); @@ -128,95 +128,95 @@ void *dcload_open(vfs_handler_t * vfs, const char *fn, int mode) { h = hnd; - spinlock_unlock(&mutex); + spinlock_unlock(&dcload_lock); return (void *)h; } -int dcload_close(void * h) { - uint32 hnd = (uint32)h; +int dcload_close(void *h) { + uint32_t hnd = (uint32_t)h; - spinlock_lock(&mutex); + spinlock_lock(&dcload_lock); if(hnd) { if(hnd > 100) /* hack */ dclsc(DCLOAD_CLOSEDIR, hnd); else { - hnd--; /* KOS uses 0 for error, not -1 */ + hnd--; /* KOS uses 0 for error, not -1 */ dclsc(DCLOAD_CLOSE, hnd); } } - spinlock_unlock(&mutex); + spinlock_unlock(&dcload_lock); return 0; } -ssize_t dcload_read(void * h, void *buf, size_t cnt) { +ssize_t dcload_read(void *h, void *buf, size_t cnt) { ssize_t ret = -1; - uint32 hnd = (uint32)h; + uint32_t hnd = (uint32_t)h; - spinlock_lock(&mutex); + spinlock_lock(&dcload_lock); if(hnd) { hnd--; /* KOS uses 0 for error, not -1 */ ret = dclsc(DCLOAD_READ, hnd, buf, cnt); } - spinlock_unlock(&mutex); + spinlock_unlock(&dcload_lock); return ret; } -ssize_t dcload_write(void * h, const void *buf, size_t cnt) { +ssize_t dcload_write(void *h, const void *buf, size_t cnt) { ssize_t ret = -1; - uint32 hnd = (uint32)h; + uint32_t hnd = (uint32_t)h; - spinlock_lock(&mutex); + spinlock_lock(&dcload_lock); if(hnd) { hnd--; /* KOS uses 0 for error, not -1 */ ret = dclsc(DCLOAD_WRITE, hnd, buf, cnt); } - spinlock_unlock(&mutex); + spinlock_unlock(&dcload_lock); return ret; } -off_t dcload_seek(void * h, off_t offset, int whence) { +off_t dcload_seek(void *h, off_t offset, int whence) { off_t ret = -1; - uint32 hnd = (uint32)h; + uint32_t hnd = (uint32_t)h; - spinlock_lock(&mutex); + spinlock_lock(&dcload_lock); if(hnd) { hnd--; /* KOS uses 0 for error, not -1 */ ret = dclsc(DCLOAD_LSEEK, hnd, offset, whence); } - spinlock_unlock(&mutex); + spinlock_unlock(&dcload_lock); return ret; } -off_t dcload_tell(void * h) { +off_t dcload_tell(void *h) { off_t ret = -1; - uint32 hnd = (uint32)h; + uint32_t hnd = (uint32_t)h; - spinlock_lock(&mutex); + spinlock_lock(&dcload_lock); if(hnd) { hnd--; /* KOS uses 0 for error, not -1 */ ret = dclsc(DCLOAD_LSEEK, hnd, 0, SEEK_CUR); } - spinlock_unlock(&mutex); + spinlock_unlock(&dcload_lock); return ret; } -size_t dcload_total(void * h) { +size_t dcload_total(void *h) { size_t ret = -1; size_t cur; - uint32 hnd = (uint32)h; + uint32_t hnd = (uint32_t)h; - spinlock_lock(&mutex); + spinlock_lock(&dcload_lock); if(hnd) { hnd--; /* KOS uses 0 for error, not -1 */ @@ -225,25 +225,25 @@ size_t dcload_total(void * h) { dclsc(DCLOAD_LSEEK, hnd, cur, SEEK_SET); } - spinlock_unlock(&mutex); + spinlock_unlock(&dcload_lock); return ret; } /* Not thread-safe, but that's ok because neither is the FS */ static dirent_t dirent; -dirent_t *dcload_readdir(void * h) { +dirent_t *dcload_readdir(void *h) { dirent_t *rv = NULL; dcload_dirent_t *dcld; dcload_stat_t filestat; char *fn; - uint32 hnd = (uint32)h; + uint32_t hnd = (uint32_t)h; if(hnd < 100) { errno = EBADF; return NULL; } - spinlock_lock(&mutex); + spinlock_lock(&dcload_lock); dcld = (dcload_dirent_t *)dclsc(DCLOAD_READDIR, hnd); @@ -273,38 +273,37 @@ dirent_t *dcload_readdir(void * h) { free(fn); } - spinlock_unlock(&mutex); + spinlock_unlock(&dcload_lock); return rv; } -int dcload_rename(vfs_handler_t * vfs, const char *fn1, const char *fn2) { +int dcload_rename(vfs_handler_t *vfs, const char *fn1, const char *fn2) { int ret; (void)vfs; - spinlock_lock(&mutex); + spinlock_lock(&dcload_lock); /* really stupid hack, since I didn't put rename() in dcload */ - ret = dclsc(DCLOAD_LINK, fn1, fn2); if(!ret) ret = dclsc(DCLOAD_UNLINK, fn1); - spinlock_unlock(&mutex); + spinlock_unlock(&dcload_lock); return ret; } -int dcload_unlink(vfs_handler_t * vfs, const char *fn) { +int dcload_unlink(vfs_handler_t *vfs, const char *fn) { int ret; (void)vfs; - spinlock_lock(&mutex); + spinlock_lock(&dcload_lock); ret = dclsc(DCLOAD_UNLINK, fn); - spinlock_unlock(&mutex); + spinlock_unlock(&dcload_lock); return ret; } @@ -327,9 +326,9 @@ static int dcload_stat(vfs_handler_t *vfs, const char *path, struct stat *st, return 0; } - spinlock_lock(&mutex); + spinlock_lock(&dcload_lock); retval = dclsc(DCLOAD_STAT, path, &filestat); - spinlock_unlock(&mutex); + spinlock_unlock(&dcload_lock); if(!retval) { memset(st, 0, sizeof(struct stat)); @@ -421,8 +420,8 @@ static vfs_handler_t vh = { NULL /* fstat */ }; -// We have to provide a minimal interface in case dcload usage is -// disabled through init flags. +/* We have to provide a minimal interface in case dcload usage is + disabled through init flags. */ static int never_detected(void) { return 0; } @@ -462,13 +461,13 @@ void fs_dcload_init_console(void) { dbgio_dcload.write_buffer = dcload_write_buffer; // dbgio_dcload.read = dcload_read_cons; - // We actually need to detect here to make sure we're not on - // dcload-serial, or scif_init must not proceed. + /* We actually need to detect here to make sure we're not on + dcload-serial, or scif_init must not proceed. */ if(*DCLOADMAGICADDR != DCLOADMAGICVALUE) return; /* dcload IP will always return -1 here. Serial will return 0 and make - no change since it already holds 0 as 'no mem assigned */ + no change since it already holds 0 as 'no mem assigned */ if(dclsc(DCLOAD_ASSIGNWRKMEM, 0) == -1) { dcload_type = DCLOAD_TYPE_IP; } @@ -486,7 +485,7 @@ void fs_dcload_init_console(void) { /* Call fs_dcload_init_console() before calling fs_dcload_init() */ void fs_dcload_init(void) { - // This was already done in init_console. + /* This was already done in init_console. */ if(dcload_type == DCLOAD_TYPE_NONE) return; @@ -494,11 +493,6 @@ void fs_dcload_init(void) { if((dcload_type == DCLOAD_TYPE_IP) && (__kos_init_flags & INIT_NET)) { dbglog(DBG_INFO, "dc-load console+kosnet, will switch to internal ethernet\n"); return; - /* if(old_printk) { - dbgio_set_printk(old_printk); - old_printk = 0; - } - return -1; */ } /* Register with VFS */ diff --git a/kernel/arch/dreamcast/include/dc/fs_dcload.h b/kernel/arch/dreamcast/include/dc/fs_dcload.h index 460d79069..af5819c9d 100644 --- a/kernel/arch/dreamcast/include/dc/fs_dcload.h +++ b/kernel/arch/dreamcast/include/dc/fs_dcload.h @@ -1,7 +1,7 @@ /* KallistiOS ##version## kernel/arch/dreamcast/include/dc/fs_dcload.h - (c)2002 Andrew Kieschnick + Copyright (C) 2002 Andrew Kieschnick */ @@ -20,12 +20,9 @@ #ifndef __DC_FS_DCLOAD_H #define __DC_FS_DCLOAD_H -/* Definitions for the "dcload" file system */ - #include __BEGIN_DECLS -#include #include #include @@ -43,10 +40,10 @@ extern dbgio_handler_t dbgio_dcload; /* dcload magic value */ /** \brief The dcload magic value! */ -#define DCLOADMAGICVALUE 0xdeadbeef +#define DCLOADMAGICVALUE 0xdeadbeef /** \brief The address of the dcload magic value */ -#define DCLOADMAGICADDR (unsigned int *)0x8c004004 +#define DCLOADMAGICADDR (uint32_t *)0x8c004004 /* Are we using dc-load-serial or dc-load-ip? */ #define DCLOAD_TYPE_NONE -1 /**< \brief No dcload connection */ @@ -58,85 +55,68 @@ extern int dcload_type; /* \cond */ /* Available dcload console commands */ - -#define DCLOAD_READ 0 -#define DCLOAD_WRITE 1 -#define DCLOAD_OPEN 2 -#define DCLOAD_CLOSE 3 -#define DCLOAD_CREAT 4 -#define DCLOAD_LINK 5 -#define DCLOAD_UNLINK 6 -#define DCLOAD_CHDIR 7 -#define DCLOAD_CHMOD 8 -#define DCLOAD_LSEEK 9 -#define DCLOAD_FSTAT 10 -#define DCLOAD_TIME 11 -#define DCLOAD_STAT 12 -#define DCLOAD_UTIME 13 +#define DCLOAD_READ 0 +#define DCLOAD_WRITE 1 +#define DCLOAD_OPEN 2 +#define DCLOAD_CLOSE 3 +#define DCLOAD_CREAT 4 +#define DCLOAD_LINK 5 +#define DCLOAD_UNLINK 6 +#define DCLOAD_CHDIR 7 +#define DCLOAD_CHMOD 8 +#define DCLOAD_LSEEK 9 +#define DCLOAD_FSTAT 10 +#define DCLOAD_TIME 11 +#define DCLOAD_STAT 12 +#define DCLOAD_UTIME 13 #define DCLOAD_ASSIGNWRKMEM 14 -#define DCLOAD_EXIT 15 -#define DCLOAD_OPENDIR 16 -#define DCLOAD_CLOSEDIR 17 -#define DCLOAD_READDIR 18 -#define DCLOAD_GETHOSTINFO 19 -#define DCLOAD_GDBPACKET 20 +#define DCLOAD_EXIT 15 +#define DCLOAD_OPENDIR 16 +#define DCLOAD_CLOSEDIR 17 +#define DCLOAD_READDIR 18 +#define DCLOAD_GETHOSTINFO 19 +#define DCLOAD_GDBPACKET 20 /* dcload syscall function */ - -int dcloadsyscall(unsigned int syscall, ...); +int dcloadsyscall(uint32_t syscall, ...); /* dcload dirent */ - struct dcload_dirent { - long d_ino; /* inode number */ - off_t d_off; /* offset to the next dirent */ - unsigned short d_reclen;/* length of this record */ - unsigned char d_type; /* type of file */ - char d_name[256]; /* filename */ + int d_ino; /* inode number */ + off_t d_off; /* offset to the next dirent */ + uint16_t d_reclen; /* length of this record */ + uint8_t d_type; /* type of file */ + char d_name[256]; /* filename */ }; typedef struct dcload_dirent dcload_dirent_t; /* dcload stat */ - -struct dcload_stat { - unsigned short st_dev; - unsigned short st_ino; +typedef struct dcload_stat { + uint16_t st_dev; + uint16_t st_ino; int st_mode; - unsigned short st_nlink; - unsigned short st_uid; - unsigned short st_gid; - unsigned short st_rdev; - long st_size; - long atime; - long st_spare1; - long mtime; - long st_spare2; - long ctime; - long st_spare3; - long st_blksize; - long st_blocks; - long st_spare4[2]; -}; - -typedef struct dcload_stat dcload_stat_t; + uint16_t st_nlink; + uint16_t st_uid; + uint16_t st_gid; + uint16_t st_rdev; + int st_size; + int atime; + int st_spare1; + int mtime; + int st_spare2; + int ctime; + int st_spare3; + int st_blksize; + int st_blocks; + int st_spare4[2]; +} dcload_stat_t; /* Printk replacement */ void dcload_printk(const char *str); /* GDB tunnel */ -size_t dcload_gdbpacket(const char* in_buf, size_t in_size, char* out_buf, size_t out_size); - -/* File functions */ -void* dcload_open(vfs_handler_t * vfs, const char *fn, int mode); -int dcload_close(void * hnd); -ssize_t dcload_read(void * hnd, void *buf, size_t cnt); -off_t dcload_seek(void * hnd, off_t offset, int whence); -off_t dcload_tell(void * hnd); -size_t dcload_total(void * hnd); -dirent_t* dcload_readdir(void * hnd); -int dcload_rename(vfs_handler_t * vfs, const char *fn1, const char *fn2); -int dcload_unlink(vfs_handler_t * vfs, const char *fn); +size_t dcload_gdbpacket(const char *in_buf, size_t in_size, char *out_buf, size_t out_size); /* Init func */ void fs_dcload_init_console(void); From 9a717fb59af3976f87273328fb96db195daf6d25 Mon Sep 17 00:00:00 2001 From: Andress Barajas Date: Sat, 23 Nov 2024 22:32:55 -0800 Subject: [PATCH 2/2] Add stdin dcload capabilities No changes required on the dcload side. Works for both serial and IP. --- kernel/arch/dreamcast/fs/fs_dcload.c | 95 ++++++++++++++++++---------- kernel/libc/newlib/newlib_read.c | 14 ++-- 2 files changed, 70 insertions(+), 39 deletions(-) diff --git a/kernel/arch/dreamcast/fs/fs_dcload.c b/kernel/arch/dreamcast/fs/fs_dcload.c index 60b53b0d6..8ebfab2dc 100644 --- a/kernel/arch/dreamcast/fs/fs_dcload.c +++ b/kernel/arch/dreamcast/fs/fs_dcload.c @@ -47,32 +47,55 @@ static spinlock_t dcload_lock = SPINLOCK_INITIALIZER; rv; \ }) +int dcload_write_char(int ch) { + spinlock_lock(&dcload_lock); + dclsc(DCLOAD_WRITE, STDOUT_FILENO, &ch, 1); + spinlock_unlock(&dcload_lock); + + return ch; +} + /* Printk replacement */ int dcload_write_buffer(const uint8_t *data, int len, int xlat) { (void)xlat; spinlock_lock(&dcload_lock); - dclsc(DCLOAD_WRITE, 1, data, len); + dclsc(DCLOAD_WRITE, STDOUT_FILENO, data, len); spinlock_unlock(&dcload_lock); return len; } -int dcload_read_cons(void) { - return -1; +int dcload_read_char(void) { + uint8_t chr; + + spinlock_lock(&dcload_lock); + dclsc(DCLOAD_READ, STDIN_FILENO, &chr, 1); + spinlock_unlock(&dcload_lock); + + return chr; } -size_t dcload_gdbpacket(const char *in_buf, size_t in_size, char *out_buf, size_t out_size) { - size_t ret = -1; +int dcload_read_buffer(uint8_t *data, int len) { + ssize_t rv = -1; spinlock_lock(&dcload_lock); + rv = dclsc(DCLOAD_READ, STDIN_FILENO, data, len); + spinlock_unlock(&dcload_lock); + + return rv; +} + +size_t dcload_gdbpacket(const char *in_buf, size_t in_size, char *out_buf, size_t out_size) { + size_t rv = -1; + spinlock_lock(&dcload_lock); /* We have to pack the sizes together because the dcloadsyscall handler can only take 4 parameters */ - ret = dclsc(DCLOAD_GDBPACKET, in_buf, (in_size << 16) | (out_size & 0xffff), out_buf); - + rv = dclsc(DCLOAD_GDBPACKET, in_buf, (in_size << 16) | (out_size & 0xffff), out_buf); spinlock_unlock(&dcload_lock); - return ret; + + return rv; } static char *dcload_path = NULL; @@ -152,67 +175,67 @@ int dcload_close(void *h) { } ssize_t dcload_read(void *h, void *buf, size_t cnt) { - ssize_t ret = -1; + ssize_t rv = -1; uint32_t hnd = (uint32_t)h; spinlock_lock(&dcload_lock); if(hnd) { hnd--; /* KOS uses 0 for error, not -1 */ - ret = dclsc(DCLOAD_READ, hnd, buf, cnt); + rv = dclsc(DCLOAD_READ, hnd, buf, cnt); } spinlock_unlock(&dcload_lock); - return ret; + return rv; } ssize_t dcload_write(void *h, const void *buf, size_t cnt) { - ssize_t ret = -1; + ssize_t rv = -1; uint32_t hnd = (uint32_t)h; spinlock_lock(&dcload_lock); if(hnd) { hnd--; /* KOS uses 0 for error, not -1 */ - ret = dclsc(DCLOAD_WRITE, hnd, buf, cnt); + rv = dclsc(DCLOAD_WRITE, hnd, buf, cnt); } spinlock_unlock(&dcload_lock); - return ret; + return rv; } off_t dcload_seek(void *h, off_t offset, int whence) { - off_t ret = -1; + off_t rv = -1; uint32_t hnd = (uint32_t)h; spinlock_lock(&dcload_lock); if(hnd) { hnd--; /* KOS uses 0 for error, not -1 */ - ret = dclsc(DCLOAD_LSEEK, hnd, offset, whence); + rv = dclsc(DCLOAD_LSEEK, hnd, offset, whence); } spinlock_unlock(&dcload_lock); - return ret; + return rv; } off_t dcload_tell(void *h) { - off_t ret = -1; + off_t rv = -1; uint32_t hnd = (uint32_t)h; spinlock_lock(&dcload_lock); if(hnd) { hnd--; /* KOS uses 0 for error, not -1 */ - ret = dclsc(DCLOAD_LSEEK, hnd, 0, SEEK_CUR); + rv = dclsc(DCLOAD_LSEEK, hnd, 0, SEEK_CUR); } spinlock_unlock(&dcload_lock); - return ret; + return rv; } size_t dcload_total(void *h) { - size_t ret = -1; + size_t rv = -1; size_t cur; uint32_t hnd = (uint32_t)h; @@ -221,12 +244,12 @@ size_t dcload_total(void *h) { if(hnd) { hnd--; /* KOS uses 0 for error, not -1 */ cur = dclsc(DCLOAD_LSEEK, hnd, 0, SEEK_CUR); - ret = dclsc(DCLOAD_LSEEK, hnd, 0, SEEK_END); + rv = dclsc(DCLOAD_LSEEK, hnd, 0, SEEK_END); dclsc(DCLOAD_LSEEK, hnd, cur, SEEK_SET); } spinlock_unlock(&dcload_lock); - return ret; + return rv; } /* Not thread-safe, but that's ok because neither is the FS */ @@ -278,40 +301,40 @@ dirent_t *dcload_readdir(void *h) { } int dcload_rename(vfs_handler_t *vfs, const char *fn1, const char *fn2) { - int ret; + int rv; (void)vfs; spinlock_lock(&dcload_lock); /* really stupid hack, since I didn't put rename() in dcload */ - ret = dclsc(DCLOAD_LINK, fn1, fn2); + rv = dclsc(DCLOAD_LINK, fn1, fn2); - if(!ret) - ret = dclsc(DCLOAD_UNLINK, fn1); + if(!rv) + rv = dclsc(DCLOAD_UNLINK, fn1); spinlock_unlock(&dcload_lock); - return ret; + return rv; } int dcload_unlink(vfs_handler_t *vfs, const char *fn) { - int ret; + int rv; (void)vfs; spinlock_lock(&dcload_lock); - ret = dclsc(DCLOAD_UNLINK, fn); + rv = dclsc(DCLOAD_UNLINK, fn); spinlock_unlock(&dcload_lock); - return ret; + return rv; } static int dcload_stat(vfs_handler_t *vfs, const char *path, struct stat *st, int flag) { dcload_stat_t filestat; size_t len = strlen(path); - int retval; + int rv; (void)flag; @@ -327,10 +350,10 @@ static int dcload_stat(vfs_handler_t *vfs, const char *path, struct stat *st, } spinlock_lock(&dcload_lock); - retval = dclsc(DCLOAD_STAT, path, &filestat); + rv = dclsc(DCLOAD_STAT, path, &filestat); spinlock_unlock(&dcload_lock); - if(!retval) { + if(!rv) { memset(st, 0, sizeof(struct stat)); st->st_dev = (dev_t)((ptr_t)vfs); st->st_ino = filestat.st_ino; @@ -458,8 +481,10 @@ void fs_dcload_init_console(void) { memcpy(&dbgio_dcload, &dbgio_null, sizeof(dbgio_dcload)); dbgio_dcload.name = dbgio_dcload_name; dbgio_dcload.detected = fs_dcload_detected; + dbgio_dcload.write = dcload_write_char; dbgio_dcload.write_buffer = dcload_write_buffer; - // dbgio_dcload.read = dcload_read_cons; + dbgio_dcload.read = dcload_read_char; + dbgio_dcload.read_buffer = dcload_read_buffer; /* We actually need to detect here to make sure we're not on dcload-serial, or scif_init must not proceed. */ diff --git a/kernel/libc/newlib/newlib_read.c b/kernel/libc/newlib/newlib_read.c index d0cd8a2ce..fed03ab92 100644 --- a/kernel/libc/newlib/newlib_read.c +++ b/kernel/libc/newlib/newlib_read.c @@ -1,13 +1,19 @@ /* KallistiOS ##version## - newlib_read.c - Copyright (C)2004 Megan Potter - + newlib_read.c + Copyright (C) 2004 Megan Potter + Copyright (C) 2024 Andress Barajas */ #include +#include + +#include -long _read_r(void * reent, int fd, void * buf, size_t cnt) { +long _read_r(void *reent, int fd, void *buf, size_t cnt) { (void)reent; + if(fd == STDIN_FILENO) + return dbgio_read_buffer((uint8 *)buf, cnt); + return fs_read(fd, buf, cnt); }