This allows a specific target to declare its implementation of semihosting.
Reviewed-by: Brian Cain <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Link: https://lore.kernel.org/qemu-devel/[email protected] Signed-off-by: Pierrick Bouvier <[email protected]> --- include/hw/core/cpu.h | 6 ++++++ include/semihosting/common-semi.h | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 76801444a16..456154df6f6 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -98,6 +98,9 @@ struct AccelCPUClass; /* see sysemu-cpu-ops.h */ struct SysemuCPUOps; +/* see semihosting/common-semi.h */ +struct SemihostingCPUOps; + /** * CPUClass: * @class_by_name: Callback to map -cpu command line model name to an @@ -186,6 +189,9 @@ struct CPUClass { #ifdef CONFIG_TCG /* when TCG is not available, this pointer is NULL */ const TCGCPUOps *tcg_ops; + + /* when target does not implement semihosting, this pointer is NULL */ + const struct SemihostingCPUOps *semi_ops; #endif /* diff --git a/include/semihosting/common-semi.h b/include/semihosting/common-semi.h index 1e7699d7bbd..f0f8185d8e6 100644 --- a/include/semihosting/common-semi.h +++ b/include/semihosting/common-semi.h @@ -34,6 +34,23 @@ #ifndef COMMON_SEMI_H #define COMMON_SEMI_H +typedef struct SemihostingCPUOps { + /* Return argument @argno */ + uint64_t (*arg)(const CPUState *cs, int argno); + /* Set return value for semihosting call */ + void (*set_ret)(CPUState *cs, uint64_t ret); + /* Set an error for a semihosting call */ + void (*set_err)(CPUState *cs, int err); + /* True if the guest is using the 64-bit semihosting ABI */ + bool (*is_64bit)(const CPUState *cs); + /* True if SYS_EXIT takes an extended parameter block */ + bool (*sys_exit_is_extended)(const CPUState *cs); + /* Return lowest address until which stack can grow */ + uint64_t (*stack_bottom)(const CPUState *cs); + /* True if SYS_SYNCCACHE is implemented */ + bool (*has_synccache)(const CPUState *cs); +} SemihostingCPUOps; + void common_semi_cb(CPUState *cs, uint64_t ret, int err); void do_common_semihosting(CPUState *cs); uint64_t common_semi_arg(CPUState *cs, int argno); -- 2.43.0
