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
10 #ifndef SOFTMMU_SEMI_H
11 #define SOFTMMU_SEMI_H
15 static inline uint64_t softmmu_tget64(CPUArchState
*env
, target_ulong addr
)
19 cpu_memory_rw_debug(env_cpu(env
), addr
, (uint8_t *)&val
, 8, 0);
23 static inline uint32_t softmmu_tget32(CPUArchState
*env
, target_ulong addr
)
27 cpu_memory_rw_debug(env_cpu(env
), addr
, (uint8_t *)&val
, 4, 0);
31 static inline uint32_t softmmu_tget8(CPUArchState
*env
, target_ulong addr
)
35 cpu_memory_rw_debug(env_cpu(env
), addr
, &val
, 1, 0);
39 #define get_user_u64(arg, p) ({ arg = softmmu_tget64(env, p); 0; })
40 #define get_user_u32(arg, p) ({ arg = softmmu_tget32(env, p) ; 0; })
41 #define get_user_u8(arg, p) ({ arg = softmmu_tget8(env, p) ; 0; })
42 #define get_user_ual(arg, p) get_user_u32(arg, p)
44 static inline void softmmu_tput64(CPUArchState
*env
,
45 target_ulong addr
, uint64_t val
)
48 cpu_memory_rw_debug(env_cpu(env
), addr
, (uint8_t *)&val
, 8, 1);
51 static inline void softmmu_tput32(CPUArchState
*env
,
52 target_ulong addr
, uint32_t val
)
55 cpu_memory_rw_debug(env_cpu(env
), addr
, (uint8_t *)&val
, 4, 1);
57 #define put_user_u64(arg, p) ({ softmmu_tput64(env, p, arg) ; 0; })
58 #define put_user_u32(arg, p) ({ softmmu_tput32(env, p, arg) ; 0; })
59 #define put_user_ual(arg, p) put_user_u32(arg, p)
61 static void *softmmu_lock_user(CPUArchState
*env
,
62 target_ulong addr
, target_ulong len
, int copy
)
65 /* TODO: Make this something that isn't fixed size. */
68 cpu_memory_rw_debug(env_cpu(env
), addr
, p
, len
, 0);
72 #define lock_user(type, p, len, copy) softmmu_lock_user(env, p, len, copy)
73 static char *softmmu_lock_user_string(CPUArchState
*env
, target_ulong addr
)
78 /* TODO: Make this something that isn't fixed size. */
84 cpu_memory_rw_debug(env_cpu(env
), addr
, &c
, 1, 0);
90 #define lock_user_string(p) softmmu_lock_user_string(env, p)
91 static void softmmu_unlock_user(CPUArchState
*env
, void *p
, target_ulong addr
,
95 cpu_memory_rw_debug(env_cpu(env
), addr
, p
, len
, 1);
99 #define unlock_user(s, args, len) softmmu_unlock_user(env, s, args, len)