diff options
author | Alex Bennée <alex.bennee@linaro.org> | 2019-05-14 12:21:45 +0100 |
---|---|---|
committer | Alex Bennée <alex.bennee@linaro.org> | 2019-05-28 10:28:51 +0100 |
commit | 629a0b065af074a43176968e1e242b87fc3be39f (patch) | |
tree | af6aceef4d8b491372f5afafd48d76343351aa12 /target | |
parent | a131795f4c696083708767a2cb7e1168f73a1690 (diff) |
target/arm: correct return values for WRITE/READ in arm-semi
The documentation says the write should return the number of bytes not
written on an error (0 means everything was written). Read provides a
buffer length and the return value should be the buffer length - bytes
actually read. Remove the incorrect FIXME's and return the correct
values.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Diffstat (limited to 'target')
-rw-r--r-- | target/arm/arm-semi.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/target/arm/arm-semi.c b/target/arm/arm-semi.c index 86e6ec48c2..53e807ab72 100644 --- a/target/arm/arm-semi.c +++ b/target/arm/arm-semi.c @@ -331,13 +331,15 @@ target_ulong do_arm_semihosting(CPUARMState *env) } else { s = lock_user(VERIFY_READ, arg1, len, 1); if (!s) { - /* FIXME - should this error code be -TARGET_EFAULT ? */ - return (uint32_t)-1; + /* Return bytes not written on error */ + return len; } ret = set_swi_errno(ts, write(arg0, s, len)); unlock_user(s, arg1, 0); - if (ret == (uint32_t)-1) - return -1; + if (ret == (uint32_t)-1) { + ret = 0; + } + /* Return bytes not written */ return len - ret; } case TARGET_SYS_READ: @@ -352,15 +354,17 @@ target_ulong do_arm_semihosting(CPUARMState *env) } else { s = lock_user(VERIFY_WRITE, arg1, len, 0); if (!s) { - /* FIXME - should this error code be -TARGET_EFAULT ? */ - return (uint32_t)-1; + /* return bytes not read */ + return len; } do { ret = set_swi_errno(ts, read(arg0, s, len)); } while (ret == -1 && errno == EINTR); unlock_user(s, arg1, len); - if (ret == (uint32_t)-1) - return -1; + if (ret == (uint32_t)-1) { + ret = 0; + } + /* Return bytes not read */ return len - ret; } case TARGET_SYS_READC: |