Jiaxun Yang | 8c519dc | 2024-06-18 14:56:05 +0100 | [diff] [blame] | 1 | /* |
| 2 | * include/asm-xtensa/platform-iss/simcall.h |
| 3 | * |
| 4 | * This file is subject to the terms and conditions of the GNU General Public |
| 5 | * License. See the file "COPYING" in the main directory of this archive |
| 6 | * for more details. |
| 7 | * |
| 8 | * Copyright (C) 2001 Tensilica Inc. |
| 9 | * Copyright (C) 2017 - 2021 Cadence Design Systems Inc. |
| 10 | */ |
| 11 | |
| 12 | #ifndef _XTENSA_PLATFORM_ISS_SIMCALL_H |
| 13 | #define _XTENSA_PLATFORM_ISS_SIMCALL_H |
| 14 | |
| 15 | #include <linux/bug.h> |
| 16 | |
| 17 | #ifdef CONFIG_XTENSA_SIMCALL_ISS |
| 18 | #include <asm/platform/simcall-iss.h> |
| 19 | #endif |
| 20 | #ifdef CONFIG_XTENSA_SIMCALL_GDBIO |
| 21 | #include <asm/platform/simcall-gdbio.h> |
| 22 | #endif |
| 23 | |
| 24 | static inline int simc_exit(int exit_code) |
| 25 | { |
| 26 | #ifdef SYS_exit |
| 27 | return __simc(SYS_exit, exit_code, 0, 0); |
| 28 | #else |
| 29 | WARN_ONCE(1, "%s: not implemented\n", __func__); |
| 30 | return -1; |
| 31 | #endif |
| 32 | } |
| 33 | |
| 34 | static inline int simc_open(const char *file, int flags, int mode) |
| 35 | { |
| 36 | return __simc(SYS_open, (int) file, flags, mode); |
| 37 | } |
| 38 | |
| 39 | static inline int simc_close(int fd) |
| 40 | { |
| 41 | return __simc(SYS_close, fd, 0, 0); |
| 42 | } |
| 43 | |
| 44 | static inline int simc_ioctl(int fd, int request, void *arg) |
| 45 | { |
| 46 | #ifdef SYS_ioctl |
| 47 | return __simc(SYS_ioctl, fd, request, (int) arg); |
| 48 | #else |
| 49 | WARN_ONCE(1, "%s: not implemented\n", __func__); |
| 50 | return -1; |
| 51 | #endif |
| 52 | } |
| 53 | |
| 54 | static inline int simc_read(int fd, void *buf, size_t count) |
| 55 | { |
| 56 | return __simc(SYS_read, fd, (int) buf, count); |
| 57 | } |
| 58 | |
| 59 | static inline int simc_write(int fd, const void *buf, size_t count) |
| 60 | { |
| 61 | return __simc(SYS_write, fd, (int) buf, count); |
| 62 | } |
| 63 | |
| 64 | static inline int simc_poll(int fd) |
| 65 | { |
| 66 | #ifdef SYS_select_one |
| 67 | long timeval[2] = { 0, 0 }; |
| 68 | |
| 69 | return __simc(SYS_select_one, fd, XTISS_SELECT_ONE_READ, (int)&timeval); |
| 70 | #else |
| 71 | WARN_ONCE(1, "%s: not implemented\n", __func__); |
| 72 | return -1; |
| 73 | #endif |
| 74 | } |
| 75 | |
| 76 | static inline int simc_lseek(int fd, uint32_t off, int whence) |
| 77 | { |
| 78 | return __simc(SYS_lseek, fd, off, whence); |
| 79 | } |
| 80 | |
| 81 | static inline int simc_argc(void) |
| 82 | { |
| 83 | #ifdef SYS_iss_argc |
| 84 | return __simc(SYS_iss_argc, 0, 0, 0); |
| 85 | #else |
| 86 | WARN_ONCE(1, "%s: not implemented\n", __func__); |
| 87 | return 0; |
| 88 | #endif |
| 89 | } |
| 90 | |
| 91 | static inline int simc_argv_size(void) |
| 92 | { |
| 93 | #ifdef SYS_iss_argv_size |
| 94 | return __simc(SYS_iss_argv_size, 0, 0, 0); |
| 95 | #else |
| 96 | WARN_ONCE(1, "%s: not implemented\n", __func__); |
| 97 | return 0; |
| 98 | #endif |
| 99 | } |
| 100 | |
| 101 | static inline void simc_argv(void *buf) |
| 102 | { |
| 103 | #ifdef SYS_iss_set_argv |
| 104 | __simc(SYS_iss_set_argv, (int)buf, 0, 0); |
| 105 | #else |
| 106 | WARN_ONCE(1, "%s: not implemented\n", __func__); |
| 107 | #endif |
| 108 | } |
| 109 | |
| 110 | #endif /* _XTENSA_PLATFORM_ISS_SIMCALL_H */ |