xref: /qemu/include/semihosting/semihost.h (revision afb81fe8)
16b5fe137SPhilippe Mathieu-Daudé /*
26b5fe137SPhilippe Mathieu-Daudé  * Semihosting support
36b5fe137SPhilippe Mathieu-Daudé  *
46b5fe137SPhilippe Mathieu-Daudé  * Copyright (c) 2015 Imagination Technologies
56b5fe137SPhilippe Mathieu-Daudé  *
66b5fe137SPhilippe Mathieu-Daudé  * This library is free software; you can redistribute it and/or
76b5fe137SPhilippe Mathieu-Daudé  * modify it under the terms of the GNU Lesser General Public
86b5fe137SPhilippe Mathieu-Daudé  * License as published by the Free Software Foundation; either
96b5fe137SPhilippe Mathieu-Daudé  * version 2.1 of the License, or (at your option) any later version.
106b5fe137SPhilippe Mathieu-Daudé  *
116b5fe137SPhilippe Mathieu-Daudé  * This library is distributed in the hope that it will be useful,
126b5fe137SPhilippe Mathieu-Daudé  * but WITHOUT ANY WARRANTY; without even the implied warranty of
136b5fe137SPhilippe Mathieu-Daudé  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
146b5fe137SPhilippe Mathieu-Daudé  * Lesser General Public License for more details.
156b5fe137SPhilippe Mathieu-Daudé  *
166b5fe137SPhilippe Mathieu-Daudé  * You should have received a copy of the GNU Lesser General Public
176b5fe137SPhilippe Mathieu-Daudé  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
186b5fe137SPhilippe Mathieu-Daudé  */
196b5fe137SPhilippe Mathieu-Daudé 
206b5fe137SPhilippe Mathieu-Daudé #ifndef SEMIHOST_H
216b5fe137SPhilippe Mathieu-Daudé #define SEMIHOST_H
226b5fe137SPhilippe Mathieu-Daudé 
236b5fe137SPhilippe Mathieu-Daudé typedef enum SemihostingTarget {
246b5fe137SPhilippe Mathieu-Daudé     SEMIHOSTING_TARGET_AUTO = 0,
256b5fe137SPhilippe Mathieu-Daudé     SEMIHOSTING_TARGET_NATIVE,
266b5fe137SPhilippe Mathieu-Daudé     SEMIHOSTING_TARGET_GDB
276b5fe137SPhilippe Mathieu-Daudé } SemihostingTarget;
286b5fe137SPhilippe Mathieu-Daudé 
296b5fe137SPhilippe Mathieu-Daudé #ifdef CONFIG_USER_ONLY
semihosting_enabled(bool is_user)305202861bSPeter Maydell static inline bool semihosting_enabled(bool is_user)
316b5fe137SPhilippe Mathieu-Daudé {
326b5fe137SPhilippe Mathieu-Daudé     return true;
336b5fe137SPhilippe Mathieu-Daudé }
346b5fe137SPhilippe Mathieu-Daudé 
semihosting_get_target(void)356b5fe137SPhilippe Mathieu-Daudé static inline SemihostingTarget semihosting_get_target(void)
366b5fe137SPhilippe Mathieu-Daudé {
376b5fe137SPhilippe Mathieu-Daudé     return SEMIHOSTING_TARGET_AUTO;
386b5fe137SPhilippe Mathieu-Daudé }
396b5fe137SPhilippe Mathieu-Daudé 
semihosting_get_arg(int i)406b5fe137SPhilippe Mathieu-Daudé static inline const char *semihosting_get_arg(int i)
416b5fe137SPhilippe Mathieu-Daudé {
426b5fe137SPhilippe Mathieu-Daudé     return NULL;
436b5fe137SPhilippe Mathieu-Daudé }
446b5fe137SPhilippe Mathieu-Daudé 
semihosting_get_argc(void)456b5fe137SPhilippe Mathieu-Daudé static inline int semihosting_get_argc(void)
466b5fe137SPhilippe Mathieu-Daudé {
476b5fe137SPhilippe Mathieu-Daudé     return 0;
486b5fe137SPhilippe Mathieu-Daudé }
496b5fe137SPhilippe Mathieu-Daudé 
semihosting_get_cmdline(void)506b5fe137SPhilippe Mathieu-Daudé static inline const char *semihosting_get_cmdline(void)
516b5fe137SPhilippe Mathieu-Daudé {
526b5fe137SPhilippe Mathieu-Daudé     return NULL;
536b5fe137SPhilippe Mathieu-Daudé }
546b5fe137SPhilippe Mathieu-Daudé #else /* !CONFIG_USER_ONLY */
555202861bSPeter Maydell /**
565202861bSPeter Maydell  * semihosting_enabled:
575202861bSPeter Maydell  * @is_user: true if guest code is in usermode (i.e. not privileged)
585202861bSPeter Maydell  *
595202861bSPeter Maydell  * Return true if guest code is allowed to make semihosting calls.
605202861bSPeter Maydell  */
615202861bSPeter Maydell bool semihosting_enabled(bool is_user);
626b5fe137SPhilippe Mathieu-Daudé SemihostingTarget semihosting_get_target(void);
636b5fe137SPhilippe Mathieu-Daudé const char *semihosting_get_arg(int i);
646b5fe137SPhilippe Mathieu-Daudé int semihosting_get_argc(void);
656b5fe137SPhilippe Mathieu-Daudé const char *semihosting_get_cmdline(void);
666b5fe137SPhilippe Mathieu-Daudé void semihosting_arg_fallback(const char *file, const char *cmd);
676b5fe137SPhilippe Mathieu-Daudé /* for vl.c hooks */
686b5fe137SPhilippe Mathieu-Daudé void qemu_semihosting_enable(void);
69afb81fe8SPhilippe Mathieu-Daudé int qemu_semihosting_config_options(const char *optstr);
70fb08790bSRichard Henderson void qemu_semihosting_chardev_init(void);
71fb08790bSRichard Henderson void qemu_semihosting_console_init(Chardev *);
726b5fe137SPhilippe Mathieu-Daudé #endif /* CONFIG_USER_ONLY */
73e4a4aaa5SRichard Henderson void qemu_semihosting_guestfd_init(void);
746b5fe137SPhilippe Mathieu-Daudé 
756b5fe137SPhilippe Mathieu-Daudé #endif /* SEMIHOST_H */
76