2007-09-16 23:08:06 +02:00
|
|
|
/*
|
2007-05-26 18:46:21 +02:00
|
|
|
* Helper routines to provide target memory access for semihosting
|
|
|
|
* syscalls in system emulation mode.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2007 CodeSourcery.
|
|
|
|
*
|
2011-06-26 04:21:35 +02:00
|
|
|
* This code is licensed under the GPL
|
2007-05-26 18:46:21 +02:00
|
|
|
*/
|
2016-06-29 15:29:06 +02:00
|
|
|
|
2022-04-28 05:48:41 +02:00
|
|
|
#ifndef SEMIHOSTING_SOFTMMU_UACCESS_H
|
|
|
|
#define SEMIHOSTING_SOFTMMU_UACCESS_H
|
2007-05-26 18:46:21 +02:00
|
|
|
|
2019-08-12 07:23:31 +02:00
|
|
|
#include "cpu.h"
|
|
|
|
|
2022-04-28 05:01:24 +02:00
|
|
|
#define get_user_u64(val, addr) \
|
|
|
|
({ uint64_t val_ = 0; \
|
|
|
|
int ret_ = cpu_memory_rw_debug(env_cpu(env), (addr), \
|
|
|
|
&val_, sizeof(val_), 0); \
|
|
|
|
(val) = tswap64(val_); ret_; })
|
2015-09-07 11:39:27 +02:00
|
|
|
|
2022-04-28 05:01:24 +02:00
|
|
|
#define get_user_u32(val, addr) \
|
|
|
|
({ uint32_t val_ = 0; \
|
|
|
|
int ret_ = cpu_memory_rw_debug(env_cpu(env), (addr), \
|
|
|
|
&val_, sizeof(val_), 0); \
|
|
|
|
(val) = tswap32(val_); ret_; })
|
2015-09-07 11:39:27 +02:00
|
|
|
|
2022-04-28 05:01:24 +02:00
|
|
|
#define get_user_u8(val, addr) \
|
|
|
|
({ uint8_t val_ = 0; \
|
|
|
|
int ret_ = cpu_memory_rw_debug(env_cpu(env), (addr), \
|
|
|
|
&val_, sizeof(val_), 0); \
|
|
|
|
(val) = val_; ret_; })
|
2007-11-16 11:46:05 +01:00
|
|
|
|
|
|
|
#define get_user_ual(arg, p) get_user_u32(arg, p)
|
2007-05-26 18:46:21 +02:00
|
|
|
|
2022-04-28 05:01:24 +02:00
|
|
|
#define put_user_u64(val, addr) \
|
|
|
|
({ uint64_t val_ = tswap64(val); \
|
|
|
|
cpu_memory_rw_debug(env_cpu(env), (addr), &val_, sizeof(val_), 1); })
|
|
|
|
|
|
|
|
#define put_user_u32(val, addr) \
|
|
|
|
({ uint32_t val_ = tswap32(val); \
|
|
|
|
cpu_memory_rw_debug(env_cpu(env), (addr), &val_, sizeof(val_), 1); })
|
2015-09-07 11:39:27 +02:00
|
|
|
|
2007-11-16 11:46:05 +01:00
|
|
|
#define put_user_ual(arg, p) put_user_u32(arg, p)
|
2007-05-26 18:46:21 +02:00
|
|
|
|
2022-04-28 05:44:17 +02:00
|
|
|
void *softmmu_lock_user(CPUArchState *env, target_ulong addr,
|
|
|
|
target_ulong len, bool copy);
|
2007-11-11 15:26:47 +01:00
|
|
|
#define lock_user(type, p, len, copy) softmmu_lock_user(env, p, len, copy)
|
2022-04-28 05:01:24 +02:00
|
|
|
|
2022-04-28 05:44:17 +02:00
|
|
|
char *softmmu_lock_user_string(CPUArchState *env, target_ulong addr);
|
2007-05-26 18:46:21 +02:00
|
|
|
#define lock_user_string(p) softmmu_lock_user_string(env, p)
|
2022-04-28 05:01:24 +02:00
|
|
|
|
2022-04-28 05:44:17 +02:00
|
|
|
void softmmu_unlock_user(CPUArchState *env, void *p,
|
|
|
|
target_ulong addr, target_ulong len);
|
2007-05-26 18:46:21 +02:00
|
|
|
#define unlock_user(s, args, len) softmmu_unlock_user(env, s, args, len)
|
2012-12-06 12:15:58 +01:00
|
|
|
|
2022-04-28 06:03:12 +02:00
|
|
|
ssize_t softmmu_strlen_user(CPUArchState *env, target_ulong addr);
|
|
|
|
#define target_strlen(p) softmmu_strlen_user(env, p)
|
|
|
|
|
2022-04-28 05:48:41 +02:00
|
|
|
#endif /* SEMIHOSTING_SOFTMMU_UACCESS_H */
|