OSDN Git Service

semihosting: Change internal common-semi interfaces to use CPUState *
authorKeith Packard <keithp@keithp.com>
Fri, 8 Jan 2021 22:42:50 +0000 (22:42 +0000)
committerAlex Bennée <alex.bennee@linaro.org>
Mon, 18 Jan 2021 10:05:06 +0000 (10:05 +0000)
commit3c37cfe0b1e8a49e6a48c53a4685618a60b981df
tree984a23dc805dab5c2a689da4bca32d1749ddbc4a
parent0bb446d8b09332e51e6c22a8e36b9ceda2a1bf4d
semihosting: Change internal common-semi interfaces to use CPUState *

This makes all of the internal interfaces architecture-independent and
renames the internal functions to use the 'common_semi' prefix instead
of 'arm' or 'arm_semi'.

To do this, some new architecture-specific internal helper functions
were created:

    static inline target_ulong
    common_semi_arg(CPUState *cs, int argno)

Returns the argno'th semihosting argument, where argno can be
either 0 or 1.

    static inline void
    common_semi_set_ret(CPUState *cs, target_ulong ret)

Sets the semihosting return value.

    static inline bool
    common_semi_sys_exit_extended(CPUState *cs, int nr)

This detects whether the specified semihosting call, which
is either TARGET_SYS_EXIT or TARGET_SYS_EXIT_EXTENDED should
be executed using the TARGET_SYS_EXIT_EXTENDED semantics.

    static inline target_ulong
    common_semi_rambase(CPUState *cs)

Returns the base of RAM region used for heap and stack. This
is used to construct plausible values for the SYS_HEAPINFO
call.

In addition, several existing functions have been changed to flag
areas of code which are architecture specific:

    static target_ulong
    common_semi_flen_buf(CPUState *cs)

Returns the current stack pointer minus 64, which is
where a stat structure will be placed on the stack

    #define GET_ARG(n)

This fetches arguments from the semihosting command's argument
block. The address of this is available implicitly through the
local 'args' variable. This is *mostly* architecture
independent, but does depend on the current ABI's notion of
the size of a 'long' parameter, which may need run-time checks
(as it does on AARCH64)

    #define SET_ARG(n, val)

This mirrors GET_ARG and stores data back into the argument
block.

Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-Id: <20210107170717.2098982-4-keithp@keithp.com>
Message-Id: <20210108224256.2321-15-alex.bennee@linaro.org>
hw/semihosting/arm-compat-semi.c