Skip to content

Commit 54467c1

Browse files
committed
xtensa: ISS: split simcall implementation from semihosting interface
Disconnect existing ISS simcall implementation from the semihosting interface to allow for alternative implementations selectable at configure time. Signed-off-by: Max Filippov <[email protected]>
1 parent 4671076 commit 54467c1

File tree

2 files changed

+75
-68
lines changed

2 files changed

+75
-68
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/* Copyright (C) 2021 Cadence Design Systems Inc. */
3+
4+
#ifndef _XTENSA_PLATFORM_ISS_SIMCALL_ISS_H
5+
#define _XTENSA_PLATFORM_ISS_SIMCALL_ISS_H
6+
7+
/*
8+
* System call like services offered by the simulator host.
9+
*/
10+
11+
#define SYS_nop 0 /* unused */
12+
#define SYS_exit 1 /*x*/
13+
#define SYS_fork 2
14+
#define SYS_read 3 /*x*/
15+
#define SYS_write 4 /*x*/
16+
#define SYS_open 5 /*x*/
17+
#define SYS_close 6 /*x*/
18+
#define SYS_rename 7 /*x 38 - waitpid */
19+
#define SYS_creat 8 /*x*/
20+
#define SYS_link 9 /*x (not implemented on WIN32) */
21+
#define SYS_unlink 10 /*x*/
22+
#define SYS_execv 11 /* n/a - execve */
23+
#define SYS_execve 12 /* 11 - chdir */
24+
#define SYS_pipe 13 /* 42 - time */
25+
#define SYS_stat 14 /* 106 - mknod */
26+
#define SYS_chmod 15
27+
#define SYS_chown 16 /* 202 - lchown */
28+
#define SYS_utime 17 /* 30 - break */
29+
#define SYS_wait 18 /* n/a - oldstat */
30+
#define SYS_lseek 19 /*x*/
31+
#define SYS_getpid 20
32+
#define SYS_isatty 21 /* n/a - mount */
33+
#define SYS_fstat 22 /* 108 - oldumount */
34+
#define SYS_time 23 /* 13 - setuid */
35+
#define SYS_gettimeofday 24 /*x 78 - getuid (not implemented on WIN32) */
36+
#define SYS_times 25 /*X 43 - stime (Xtensa-specific implementation) */
37+
#define SYS_socket 26
38+
#define SYS_sendto 27
39+
#define SYS_recvfrom 28
40+
#define SYS_select_one 29 /* not compatible select, one file descriptor at the time */
41+
#define SYS_bind 30
42+
#define SYS_ioctl 31
43+
44+
#define SYS_iss_argc 1000 /* returns value of argc */
45+
#define SYS_iss_argv_size 1001 /* bytes needed for argv & arg strings */
46+
#define SYS_iss_set_argv 1002 /* saves argv & arg strings at given addr */
47+
48+
/*
49+
* SYS_select_one specifiers
50+
*/
51+
52+
#define XTISS_SELECT_ONE_READ 1
53+
#define XTISS_SELECT_ONE_WRITE 2
54+
#define XTISS_SELECT_ONE_EXCEPT 3
55+
56+
static int errno;
57+
58+
static inline int __simc(int a, int b, int c, int d)
59+
{
60+
register int a1 asm("a2") = a;
61+
register int b1 asm("a3") = b;
62+
register int c1 asm("a4") = c;
63+
register int d1 asm("a5") = d;
64+
__asm__ __volatile__ (
65+
"simcall\n"
66+
: "+r"(a1), "+r"(b1)
67+
: "r"(c1), "r"(d1)
68+
: "memory");
69+
errno = b1;
70+
return a1;
71+
}
72+
73+
#endif /* _XTENSA_PLATFORM_ISS_SIMCALL_ISS_H */

arch/xtensa/platforms/iss/include/platform/simcall.h

Lines changed: 2 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -6,78 +6,13 @@
66
* for more details.
77
*
88
* Copyright (C) 2001 Tensilica Inc.
9-
* Copyright (C) 2017 Cadence Design Systems Inc.
9+
* Copyright (C) 2017 - 2021 Cadence Design Systems Inc.
1010
*/
1111

1212
#ifndef _XTENSA_PLATFORM_ISS_SIMCALL_H
1313
#define _XTENSA_PLATFORM_ISS_SIMCALL_H
1414

15-
16-
/*
17-
* System call like services offered by the simulator host.
18-
*/
19-
20-
#define SYS_nop 0 /* unused */
21-
#define SYS_exit 1 /*x*/
22-
#define SYS_fork 2
23-
#define SYS_read 3 /*x*/
24-
#define SYS_write 4 /*x*/
25-
#define SYS_open 5 /*x*/
26-
#define SYS_close 6 /*x*/
27-
#define SYS_rename 7 /*x 38 - waitpid */
28-
#define SYS_creat 8 /*x*/
29-
#define SYS_link 9 /*x (not implemented on WIN32) */
30-
#define SYS_unlink 10 /*x*/
31-
#define SYS_execv 11 /* n/a - execve */
32-
#define SYS_execve 12 /* 11 - chdir */
33-
#define SYS_pipe 13 /* 42 - time */
34-
#define SYS_stat 14 /* 106 - mknod */
35-
#define SYS_chmod 15
36-
#define SYS_chown 16 /* 202 - lchown */
37-
#define SYS_utime 17 /* 30 - break */
38-
#define SYS_wait 18 /* n/a - oldstat */
39-
#define SYS_lseek 19 /*x*/
40-
#define SYS_getpid 20
41-
#define SYS_isatty 21 /* n/a - mount */
42-
#define SYS_fstat 22 /* 108 - oldumount */
43-
#define SYS_time 23 /* 13 - setuid */
44-
#define SYS_gettimeofday 24 /*x 78 - getuid (not implemented on WIN32) */
45-
#define SYS_times 25 /*X 43 - stime (Xtensa-specific implementation) */
46-
#define SYS_socket 26
47-
#define SYS_sendto 27
48-
#define SYS_recvfrom 28
49-
#define SYS_select_one 29 /* not compatible select, one file descriptor at the time */
50-
#define SYS_bind 30
51-
#define SYS_ioctl 31
52-
53-
#define SYS_iss_argc 1000 /* returns value of argc */
54-
#define SYS_iss_argv_size 1001 /* bytes needed for argv & arg strings */
55-
#define SYS_iss_set_argv 1002 /* saves argv & arg strings at given addr */
56-
57-
/*
58-
* SYS_select_one specifiers
59-
*/
60-
61-
#define XTISS_SELECT_ONE_READ 1
62-
#define XTISS_SELECT_ONE_WRITE 2
63-
#define XTISS_SELECT_ONE_EXCEPT 3
64-
65-
static int errno;
66-
67-
static inline int __simc(int a, int b, int c, int d)
68-
{
69-
register int a1 asm("a2") = a;
70-
register int b1 asm("a3") = b;
71-
register int c1 asm("a4") = c;
72-
register int d1 asm("a5") = d;
73-
__asm__ __volatile__ (
74-
"simcall\n"
75-
: "+r"(a1), "+r"(b1)
76-
: "r"(c1), "r"(d1)
77-
: "memory");
78-
errno = b1;
79-
return a1;
80-
}
15+
#include <platform/simcall-iss.h>
8116

8217
static inline int simc_exit(int exit_code)
8318
{
@@ -137,4 +72,3 @@ static inline void simc_argv(void *buf)
13772
}
13873

13974
#endif /* _XTENSA_PLATFORM_ISS_SIMCALL_H */
140-

0 commit comments

Comments
 (0)