00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 static inline uint32_t softmmu_tget32(CPUState *env, uint32_t addr)
00011 {
00012 uint32_t val;
00013
00014 cpu_memory_rw_debug(env, addr, (uint8_t *)&val, 4, 0);
00015 return tswap32(val);
00016 }
00017 static inline uint32_t softmmu_tget8(CPUState *env, uint32_t addr)
00018 {
00019 uint8_t val;
00020
00021 cpu_memory_rw_debug(env, addr, &val, 1, 0);
00022 return val;
00023 }
00024
00025 #define get_user_u32(arg, p) ({ arg = softmmu_tget32(env, p) ; 0; })
00026 #define get_user_u8(arg, p) ({ arg = softmmu_tget8(env, p) ; 0; })
00027 #define get_user_ual(arg, p) get_user_u32(arg, p)
00028
00029 static inline void softmmu_tput32(CPUState *env, uint32_t addr, uint32_t val)
00030 {
00031 val = tswap32(val);
00032 cpu_memory_rw_debug(env, addr, (uint8_t *)&val, 4, 1);
00033 }
00034 #define put_user_u32(arg, p) ({ softmmu_tput32(env, p, arg) ; 0; })
00035 #define put_user_ual(arg, p) put_user_u32(arg, p)
00036
00037 static void *softmmu_lock_user(CPUState *env, uint32_t addr, uint32_t len,
00038 int copy)
00039 {
00040 uint8_t *p;
00041
00042 p = malloc(len);
00043 if (copy)
00044 cpu_memory_rw_debug(env, addr, p, len, 0);
00045 return p;
00046 }
00047 #define lock_user(type, p, len, copy) softmmu_lock_user(env, p, len, copy)
00048 static char *softmmu_lock_user_string(CPUState *env, uint32_t addr)
00049 {
00050 char *p;
00051 char *s;
00052 uint8_t c;
00053
00054 s = p = malloc(1024);
00055 do {
00056 cpu_memory_rw_debug(env, addr, &c, 1, 0);
00057 addr++;
00058 *(p++) = c;
00059 } while (c);
00060 return s;
00061 }
00062 #define lock_user_string(p) softmmu_lock_user_string(env, p)
00063 static void softmmu_unlock_user(CPUState *env, void *p, target_ulong addr,
00064 target_ulong len)
00065 {
00066 if (len)
00067 cpu_memory_rw_debug(env, addr, p, len, 1);
00068 free(p);
00069 }
00070 #define unlock_user(s, args, len) softmmu_unlock_user(env, s, args, len)