This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
redboot fileio tweak
- From: Mark Salter <msalter at redhat dot com>
- To: ecos-patches at sources dot redhat dot com
- Date: Mon, 26 Aug 2002 21:40:09 -0400
- Subject: redboot fileio tweak
Index: redboot/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/ChangeLog,v
retrieving revision 1.73
diff -u -p -5 -r1.73 ChangeLog
--- redboot/current/ChangeLog 27 Aug 2002 01:31:49 -0000 1.73
+++ redboot/current/ChangeLog 27 Aug 2002 01:36:29 -0000
@@ -1,8 +1,10 @@
2002-08-22 Mark Salter <msalter@redhat.com>
* src/net/net_io.c (net_io_putc): Don't flush on every \n.
+ * src/syscall.c (__do_syscall): Allow fileio support to fall back
+ to non-fileio behavior if program is not being run by gdb.
2002-08-20 Thomas Koeller <thomas@koeller.dyndns.org>
* cdl/redboot.cdl:
* include/redboot.h:
Index: redboot/current/src/syscall.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/src/syscall.c,v
retrieving revision 1.7
diff -u -p -5 -r1.7 syscall.c
--- redboot/current/src/syscall.c 23 May 2002 23:08:32 -0000 1.7
+++ redboot/current/src/syscall.c 27 Aug 2002 01:36:29 -0000
@@ -248,11 +248,10 @@ static void sys_timer_init(void)
cyg_drv_interrupt_unmask(CYGNUM_HAL_INTERRUPT_RTC);
}
-#ifndef CYGPKG_HAL_GDB_FILEIO
//
// read -- read bytes from the serial port. Ignore fd, since
// we only have stdin.
static int
sys_read(int fd, char *buf, int nbytes)
@@ -323,12 +322,10 @@ sys_lseek(int fd, int offset, int whenc
{
return (-NEWLIB_EIO);
}
-#endif // ifdef CYGPKG_HAL_GDB_FILEIO
-
#define NS_PER_TICK (CYGNUM_HAL_RTC_NUMERATOR/CYGNUM_HAL_RTC_DENOMINATOR)
#define TICKS_PER_SEC (1000000000ULL / NS_PER_TICK)
// This needs to match newlib HZ which is normally 60.
#define HZ (60ULL)
@@ -442,146 +439,166 @@ __do_syscall(CYG_ADDRWORD func,
int err = 0;
*sig = 0;
switch (func) {
-#ifdef CYGPKG_HAL_GDB_FILEIO // File I/O over the GDB remote protocol
case SYS_open:
{
+#ifdef CYGPKG_HAL_GDB_FILEIO // File I/O over the GDB remote protocol
__externC int cyg_hal_gdbfileio_open( const char *name, int flags,
int mode, int *sig );
- err = cyg_hal_gdbfileio_open((const char *)arg1, (int)arg2, (int)arg3,
- (int *)sig);
+ if (gdb_active)
+ err = cyg_hal_gdbfileio_open((const char *)arg1, (int)arg2, (int)arg3,
+ (int *)sig);
+ else
+#endif
+ err = sys_open((const char *)arg1, (int)arg2, (int)arg3);
break;
}
case SYS_read:
{
+#ifdef CYGPKG_HAL_GDB_FILEIO // File I/O over the GDB remote protocol
__externC int cyg_hal_gdbfileio_read( int fd, void *buf, size_t count,
int *sig );
- err = cyg_hal_gdbfileio_read((int)arg1, (void *)arg2, (size_t)arg3,
- (int *)sig);
+ if (gdb_active)
+ err = cyg_hal_gdbfileio_read((int)arg1, (void *)arg2, (size_t)arg3,
+ (int *)sig);
+ else
+#endif
+ err = sys_read((int)arg1, (char *)arg2, (int)arg3);
break;
}
case SYS_write:
{
+#ifdef CYGPKG_HAL_GDB_FILEIO // File I/O over the GDB remote protocol
__externC int cyg_hal_gdbfileio_write( int fd, const void *buf,
size_t count, int *sig );
- err = cyg_hal_gdbfileio_write((int)arg1, (const void *)arg2,
- (size_t)arg3, (int *)sig);
+ if (gdb_active)
+ err = cyg_hal_gdbfileio_write((int)arg1, (const void *)arg2,
+ (size_t)arg3, (int *)sig);
+ else
+#endif
+ err = sys_write((int)arg1, (char *)arg2, (int)arg3);
break;
}
case SYS_close:
{
+#ifdef CYGPKG_HAL_GDB_FILEIO // File I/O over the GDB remote protocol
__externC int cyg_hal_gdbfileio_close( int fd, int *sig );
- err = cyg_hal_gdbfileio_close((int)arg1, (int *)sig);
+ if (gdb_active)
+ err = cyg_hal_gdbfileio_close((int)arg1, (int *)sig);
+ else
+#endif
+ err = sys_close((int)arg1);
break;
}
case SYS_lseek:
{
+#ifdef CYGPKG_HAL_GDB_FILEIO // File I/O over the GDB remote protocol
__externC int cyg_hal_gdbfileio_lseek( int fd, long offset,
int whence, int *sig );
- err = cyg_hal_gdbfileio_lseek((int)arg1, (long)arg2, (int)arg3,
- (int *)sig);
+ if (gdb_active)
+ err = cyg_hal_gdbfileio_lseek((int)arg1, (long)arg2, (int)arg3,
+ (int *)sig);
+ else
+#endif
+ err = sys_lseek((int)arg1, (int)arg2, (int)arg3);
break;
}
case SYS_stat:
{
+#ifdef CYGPKG_HAL_GDB_FILEIO // File I/O over the GDB remote protocol
__externC int cyg_hal_gdbfileio_stat( const char *pathname,
void *statbuf, int *sig );
- err = cyg_hal_gdbfileio_stat((const char *)arg1, (void *)arg2,
- (int *)sig);
+ if (gdb_active)
+ err = cyg_hal_gdbfileio_stat((const char *)arg1, (void *)arg2,
+ (int *)sig);
+ else
+#endif
+ err = -NEWLIB_ENOSYS;
break;
}
case SYS_fstat:
{
+#ifdef CYGPKG_HAL_GDB_FILEIO // File I/O over the GDB remote protocol
__externC int cyg_hal_gdbfileio_fstat( int fd, void *statbuf,
int *sig );
- err = cyg_hal_gdbfileio_fstat((int)arg1, (void *)arg2,
- (int *)sig);
+ if (gdb_active)
+ err = cyg_hal_gdbfileio_fstat((int)arg1, (void *)arg2,
+ (int *)sig);
+ else
+#endif
+ {
+ struct newlib_stat *st = (struct newlib_stat *)arg2;
+ st->st_mode = NEWLIB_S_IFCHR;
+ st->st_blksize = 4096;
+ err = 0;
+ }
break;
}
case SYS_rename:
{
+#ifdef CYGPKG_HAL_GDB_FILEIO // File I/O over the GDB remote protocol
__externC int cyg_hal_gdbfileio_rename( const char *oldpath,
const char *newpath,
int *sig );
- err = cyg_hal_gdbfileio_rename((const char *)arg1, (const char *)arg2,
- (int *)sig);
+ if (gdb_active)
+ err = cyg_hal_gdbfileio_rename((const char *)arg1, (const char *)arg2,
+ (int *)sig);
+ else
+#endif
+ err = -NEWLIB_ENOSYS;
break;
}
case SYS_unlink:
{
+#ifdef CYGPKG_HAL_GDB_FILEIO // File I/O over the GDB remote protocol
__externC int cyg_hal_gdbfileio_unlink( const char *pathname,
int *sig );
- err = cyg_hal_gdbfileio_unlink((const char *)arg1, (int *)sig);
+ if (gdb_active)
+ err = cyg_hal_gdbfileio_unlink((const char *)arg1, (int *)sig);
+ else
+#endif
+ err = -NEWLIB_ENOSYS;
break;
}
case SYS_isatty:
{
+#ifdef CYGPKG_HAL_GDB_FILEIO // File I/O over the GDB remote protocol
__externC int cyg_hal_gdbfileio_isatty( int fd, int *sig );
- err = cyg_hal_gdbfileio_isatty((int)arg1, (int *)sig);
+ if (gdb_active)
+ err = cyg_hal_gdbfileio_isatty((int)arg1, (int *)sig);
+ else
+#endif
+ err = 1;
break;
}
case SYS_system:
{
+#ifdef CYGPKG_HAL_GDB_FILEIO // File I/O over the GDB remote protocol
__externC int cyg_hal_gdbfileio_system( const char *command,
int *sig );
- err = cyg_hal_gdbfileio_system((const char *)arg1, (int *)sig);
+ if (gdb_active)
+ err = cyg_hal_gdbfileio_system((const char *)arg1, (int *)sig);
+ else
+#endif
+ err = -1;
break;
}
case SYS_gettimeofday:
{
+#ifdef CYGPKG_HAL_GDB_FILEIO // File I/O over the GDB remote protocol
__externC int cyg_hal_gdbfileio_gettimeofday( void *tv, void *tz,
int *sig );
- err = cyg_hal_gdbfileio_gettimeofday((void *)arg1, (void *)arg2,
- (int *)sig);
- break;
- }
-#else
- case SYS_read:
- err = sys_read((int)arg1, (char *)arg2, (int)arg3);
- break;
- case SYS_write:
- err = sys_write((int)arg1, (char *)arg2, (int)arg3);
- break;
- case SYS_open:
- err = sys_open((const char *)arg1, (int)arg2, (int)arg3);
- break;
- case SYS_close:
- err = sys_close((int)arg1);
- break;
- case SYS_lseek:
- err = sys_lseek((int)arg1, (int)arg2, (int)arg3);
- break;
- case SYS_rename:
- err = -NEWLIB_ENOSYS;
- break;
- case SYS_unlink:
- err = -NEWLIB_ENOSYS;
- break;
- case SYS_isatty:
- err = 1;
- break;
- case SYS_system:
- err = -1;
- break;
- case SYS_gettimeofday:
- err = 0;
- break;
- case SYS_stat:
- err = -NEWLIB_ENOSYS;
- break;
- case SYS_fstat:
- {
- struct newlib_stat *st = (struct newlib_stat *)arg2;
- st->st_mode = NEWLIB_S_IFCHR;
- st->st_blksize = 4096;
- err = 0;
+ if (gdb_active)
+ err = cyg_hal_gdbfileio_gettimeofday((void *)arg1, (void *)arg2,
+ (int *)sig);
+ else
+#endif
+ err = 0;
break;
}
-#endif // !CYGPKG_HAL_GDB_FILEIO
-
case SYS_utime:
// FIXME. Some libglosses depend on this behavior.
err = sys_times((unsigned long *)arg1);
break;