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
13 static inline uint64_t softmmu_tget64(CPUArchState
*env
, target_ulong addr
)
17 cpu_memory_rw_debug(ENV_GET_CPU(env
), addr
, (uint8_t *)&val
, 8, 0);
21 static inline uint32_t softmmu_tget32(CPUArchState
*env
, target_ulong addr
)
25 cpu_memory_rw_debug(ENV_GET_CPU(env
), addr
, (uint8_t *)&val
, 4, 0);
29 static inline uint32_t softmmu_tget8(CPUArchState
*env
, target_ulong addr
)
33 cpu_memory_rw_debug(ENV_GET_CPU(env
), addr
, &val
, 1, 0);
37 #define get_user_u64(arg, p) ({ arg = softmmu_tget64(env, p); 0; })
38 #define get_user_u32(arg, p) ({ arg = softmmu_tget32(env, p) ; 0; })
39 #define get_user_u8(arg, p) ({ arg = softmmu_tget8(env, p) ; 0; })
40 #define get_user_ual(arg, p) get_user_u32(arg, p)
42 static inline void softmmu_tput64(CPUArchState
*env
,
43 target_ulong addr
, uint64_t val
)
46 cpu_memory_rw_debug(ENV_GET_CPU(env
), addr
, (uint8_t *)&val
, 8, 1);
49 static inline void softmmu_tput32(CPUArchState
*env
,
50 target_ulong addr
, uint32_t val
)
53 cpu_memory_rw_debug(ENV_GET_CPU(env
), addr
, (uint8_t *)&val
, 4, 1);
55 #define put_user_u64(arg, p) ({ softmmu_tput64(env, p, arg) ; 0; })
56 #define put_user_u32(arg, p) ({ softmmu_tput32(env, p, arg) ; 0; })
57 #define put_user_ual(arg, p) put_user_u32(arg, p)
59 static void *softmmu_lock_user(CPUArchState
*env
,
60 target_ulong addr
, target_ulong len
, int copy
)
63 /* TODO: Make this something that isn't fixed size. */
66 cpu_memory_rw_debug(ENV_GET_CPU(env
), addr
, p
, len
, 0);
70 #define lock_user(type, p, len, copy) softmmu_lock_user(env, p, len, copy)
71 static char *softmmu_lock_user_string(CPUArchState
*env
, target_ulong addr
)
76 /* TODO: Make this something that isn't fixed size. */
82 cpu_memory_rw_debug(ENV_GET_CPU(env
), addr
, &c
, 1, 0);
88 #define lock_user_string(p) softmmu_lock_user_string(env, p)
89 static void softmmu_unlock_user(CPUArchState
*env
, void *p
, target_ulong addr
,
93 cpu_memory_rw_debug(ENV_GET_CPU(env
), addr
, p
, len
, 1);
97 #define unlock_user(s, args, len) softmmu_unlock_user(env, s, args, len)