On 10/14/2026 12:45 PM, Philippe Mathieu-Daudé wrote:
> On 14/10/26 20:25, Pierrick Bouvier wrote:
>> This allows a specific target to declare its implementation of
>> semihosting.
>>
>> Reviewed-by: Brian Cain <[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/semihosting/common-semi.h b/include/semihosting/
>> common-semi.h
>> index 1e7699d7bbd..618f60f76e7 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)(CPUState *cs, int argno);
> 
> To be cleaned on top: const
> 
>> +    /* 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)(CPUState *cs);
> 
> const
> 
>> +    /* True if SYS_EXIT takes an extended parameter block */
>> +    bool (*sys_exit_is_extended)(CPUState *cs);
> 
> const
> 
>> +    /* Return lowest address until which stack can grow */
>> +    uint64_t (*stack_bottom)(CPUState *cs);
> 
> const
> 
>> +    /* True if SYS_SYNCCACHE is implemented */
>> +    bool (*has_synccache)(CPUState *cs);
> 
> const
> 
>> +} SemihostingCPUOps;
>> +
> 
> 

It's a nice intention, but this triggers more changes since some usage
of cs will be inherently unconst, for instance riscv_cpu_mxl.
Yes, we could patch all the callees to reflect real constness, but it's
beyond the scope of this series IMHO. I'll keep it as it is for now.

Regards,
Pierrick

Reply via email to