simplified patches to fix current semihosting implementation. Not sure what i was doing before, but works ok on my arm9 target now :)
Cheers Spen
>From 253becbc1f753dfa4705d0e58631bc6df8632c79 Mon Sep 17 00:00:00 2001 From: Spencer Oliver <[email protected]> Date: Wed, 27 Jan 2010 21:20:18 +0000 Subject: [PATCH 1/2] ARM semihosting: fix writing to stdout SYS_FLEN would be called before a write on a descriptor to check its size. Currently lseek would fail with -1 when given the stdout/stderr descriptor. Changing to use fstat seems to be the standard way of handling this. Signed-off-by: Spencer Oliver <[email protected]> --- src/helper/system.h | 2 ++ src/target/arm_semihosting.c | 12 ++++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/helper/system.h b/src/helper/system.h index 169df1c..af19d01 100644 --- a/src/helper/system.h +++ b/src/helper/system.h @@ -50,6 +50,8 @@ #ifdef _WIN32 #include <winsock2.h> #include <ws2tcpip.h> +#include <sys/types.h> +#include <sys/stat.h> #endif // --- platform specific headers --- diff --git a/src/target/arm_semihosting.c b/src/target/arm_semihosting.c index f4244c8..1d0acd6 100644 --- a/src/target/arm_semihosting.c +++ b/src/target/arm_semihosting.c @@ -230,18 +230,14 @@ static int do_semihosting(struct target *target) return retval; else { int fd = target_buffer_get_u32(target, params+0); - off_t cur = lseek(fd, 0, SEEK_CUR); - if (cur == (off_t)-1) { + struct stat buf; + result = fstat(fd, &buf); + if (result == -1) { armv4_5->semihosting_errno = errno; result = -1; break; } - result = lseek(fd, 0, SEEK_END); - armv4_5->semihosting_errno = errno; - if (lseek(fd, cur, SEEK_SET) == (off_t)-1) { - armv4_5->semihosting_errno = errno; - result = -1; - } + result = buf.st_size; } break; -- 1.6.5.1.1367.gcd48
_______________________________________________ Openocd-development mailing list [email protected] https://lists.berlios.de/mailman/listinfo/openocd-development
