Skip to content

Commit d52b5cf

Browse files
committed
semihosting lseek doesn't use whence.
This addresses a failure in the pico-libc, test-fread-fwrite test. Per the spec: SYS_SEEK (0x0A) Seeks to a specified position in a file using an offset specified from the start of the file. The file is assumed to be a byte array and the offset is given in bytes. Entry On entry, r1 contains a pointer to a two-word data block: word 1 This is a handle for a seekable file object. word 2 The absolute byte position to search to. Change-Id: Ie3e7ea07a5623ee178a98484bbf1cdbdd3363a01 Signed-off-by: Sid Manning <[email protected]>
1 parent 9335bd0 commit d52b5cf

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

target/hexagon/hexswi.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
/* non-arm-compatible semihosting calls */
3030
#define HEXAGON_SPECIFIC_SWI_FLAGS \
31+
DEF_SWI_FLAG(SEEK, 0x0A) \
3132
DEF_SWI_FLAG(EXCEPTION, 0x18) \
3233
DEF_SWI_FLAG(READ_CYCLES, 0x40) \
3334
DEF_SWI_FLAG(PROF_ON, 0x41) \
@@ -325,6 +326,18 @@ static void sim_handle_trap0(CPUHexagonState *env)
325326
semi_cb(cs, 0, 0);
326327
break;
327328

329+
case HEX_SYS_SEEK:
330+
{
331+
int fd;
332+
target_ulong off;
333+
int whence = 0;
334+
hexagon_read_memory(env, swi_info, 4, &fd, retaddr);
335+
hexagon_read_memory(env, swi_info + 4, 4, &off, retaddr);
336+
semihost_sys_lseek(env_cpu(env), common_semi_ftell_cb, fd, off,
337+
whence);
338+
}
339+
break;
340+
328341
case HEX_SYS_STAT:
329342
case HEX_SYS_FSTAT:
330343
{

0 commit comments

Comments
 (0)