2007-09-17 01:08:06 +04:00
|
|
|
/*
|
2007-05-26 20:46:21 +04:00
|
|
|
* Helper routines to provide target memory access for semihosting
|
|
|
|
* syscalls in system emulation mode.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2007 CodeSourcery.
|
|
|
|
*
|
2011-06-26 06:21:35 +04:00
|
|
|
* This code is licensed under the GPL
|
2007-05-26 20:46:21 +04:00
|
|
|
*/
|
2016-06-29 16:29:06 +03:00
|
|
|
|
2022-04-28 06:48:41 +03:00
|
|
|
#ifndef SEMIHOSTING_SOFTMMU_UACCESS_H
|
|
|
|
#define SEMIHOSTING_SOFTMMU_UACCESS_H
|
2007-05-26 20:46:21 +04:00
|
|
|
|
2019-08-12 08:23:31 +03:00
|
|
|
#include "cpu.h"
|
|
|
|
|
2022-04-28 06:01:24 +03: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 12:39:27 +03:00
|
|
|
|
2022-04-28 06:01:24 +03: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 12:39:27 +03:00
|
|
|
|
2022-04-28 06:01:24 +03: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 13:46:05 +03:00
|
|
|
|
|
|
|
#define get_user_ual(arg, p) get_user_u32(arg, p)
|
2007-05-26 20:46:21 +04:00
|
|
|
|
2022-04-28 06:01:24 +03: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 12:39:27 +03:00
|
|
|
|
2007-11-16 13:46:05 +03:00
|
|
|
#define put_user_ual(arg, p) put_user_u32(arg, p)
|
2007-05-26 20:46:21 +04:00
|
|
|
|
2022-04-28 06:44:17 +03:00
|
|
|
void *softmmu_lock_user(CPUArchState *env, target_ulong addr,
|
|
|
|
target_ulong len, bool copy);
|
2007-11-11 17:26:47 +03:00
|
|
|
#define lock_user(type, p, len, copy) softmmu_lock_user(env, p, len, copy)
|
2022-04-28 06:01:24 +03:00
|
|
|
|
2022-04-28 06:44:17 +03:00
|
|
|
char *softmmu_lock_user_string(CPUArchState *env, target_ulong addr);
|
2007-05-26 20:46:21 +04:00
|
|
|
#define lock_user_string(p) softmmu_lock_user_string(env, p)
|
2022-04-28 06:01:24 +03:00
|
|
|
|
2022-04-28 06:44:17 +03:00
|
|
|
void softmmu_unlock_user(CPUArchState *env, void *p,
|
|
|
|
target_ulong addr, target_ulong len);
|
2007-05-26 20:46:21 +04:00
|
|
|
#define unlock_user(s, args, len) softmmu_unlock_user(env, s, args, len)
|
2012-12-06 15:15:58 +04:00
|
|
|
|
2022-04-28 07:03:12 +03:00
|
|
|
ssize_t softmmu_strlen_user(CPUArchState *env, target_ulong addr);
|
|
|
|
#define target_strlen(p) softmmu_strlen_user(env, p)
|
|
|
|
|
2022-04-28 06:48:41 +03:00
|
|
|
#endif /* SEMIHOSTING_SOFTMMU_UACCESS_H */
|