vfio/container: Move space field to base container
[qemu/ar7.git] / include / semihosting / uaccess.h
blob3963eafc3e224c405e44e4b8aaee8a7c68c79e8f
1 /*
2 * Helper routines to provide target memory access for semihosting
3 * syscalls in system emulation mode.
5 * Copyright (c) 2007 CodeSourcery.
7 * This code is licensed under the GPL
8 */
10 #ifndef SEMIHOSTING_UACCESS_H
11 #define SEMIHOSTING_UACCESS_H
13 #ifdef CONFIG_USER_ONLY
14 #error Cannot include semihosting/uaccess.h from user emulation
15 #endif
17 #include "cpu.h"
19 #define get_user_u64(val, addr) \
20 ({ uint64_t val_ = 0; \
21 int ret_ = cpu_memory_rw_debug(env_cpu(env), (addr), \
22 &val_, sizeof(val_), 0); \
23 (val) = tswap64(val_); ret_; })
25 #define get_user_u32(val, addr) \
26 ({ uint32_t val_ = 0; \
27 int ret_ = cpu_memory_rw_debug(env_cpu(env), (addr), \
28 &val_, sizeof(val_), 0); \
29 (val) = tswap32(val_); ret_; })
31 #define get_user_u8(val, addr) \
32 ({ uint8_t val_ = 0; \
33 int ret_ = cpu_memory_rw_debug(env_cpu(env), (addr), \
34 &val_, sizeof(val_), 0); \
35 (val) = val_; ret_; })
37 #define get_user_ual(arg, p) get_user_u32(arg, p)
39 #define put_user_u64(val, addr) \
40 ({ uint64_t val_ = tswap64(val); \
41 cpu_memory_rw_debug(env_cpu(env), (addr), &val_, sizeof(val_), 1); })
43 #define put_user_u32(val, addr) \
44 ({ uint32_t val_ = tswap32(val); \
45 cpu_memory_rw_debug(env_cpu(env), (addr), &val_, sizeof(val_), 1); })
47 #define put_user_ual(arg, p) put_user_u32(arg, p)
49 void *uaccess_lock_user(CPUArchState *env, target_ulong addr,
50 target_ulong len, bool copy);
51 #define lock_user(type, p, len, copy) uaccess_lock_user(env, p, len, copy)
53 char *uaccess_lock_user_string(CPUArchState *env, target_ulong addr);
54 #define lock_user_string(p) uaccess_lock_user_string(env, p)
56 void uaccess_unlock_user(CPUArchState *env, void *p,
57 target_ulong addr, target_ulong len);
58 #define unlock_user(s, args, len) uaccess_unlock_user(env, s, args, len)
60 ssize_t uaccess_strlen_user(CPUArchState *env, target_ulong addr);
61 #define target_strlen(p) uaccess_strlen_user(env, p)
63 #endif /* SEMIHOSTING_SOFTMMU_UACCESS_H */