kvm: kvmctl: Fix user/main.c indenting
[qemu-kvm/fedora.git] / softmmu-semi.h
blob13c528bb84b886e6a85eb968679b0a21eb08a57d
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 licenced under the GPL
8 */
10 static inline uint32_t softmmu_tget32(CPUState *env, uint32_t addr)
12 uint32_t val;
14 cpu_memory_rw_debug(env, addr, (uint8_t *)&val, 4, 0);
15 return tswap32(val);
17 static inline uint32_t softmmu_tget8(CPUState *env, uint32_t addr)
19 uint8_t val;
21 cpu_memory_rw_debug(env, addr, &val, 1, 0);
22 return val;
24 #define tget32(p) softmmu_tget32(env, p)
25 #define tget8(p) softmmu_tget8(env, p)
27 static inline void softmmu_tput32(CPUState *env, uint32_t addr, uint32_t val)
29 val = tswap32(val);
30 cpu_memory_rw_debug(env, addr, (uint8_t *)&val, 4, 1);
32 #define tput32(p, val) softmmu_tput32(env, p, val)
34 static void *softmmu_lock_user(CPUState *env, uint32_t addr, uint32_t len,
35 int copy)
37 char *p;
38 /* TODO: Make this something that isn't fixed size. */
39 p = malloc(len);
40 if (copy)
41 cpu_memory_rw_debug(env, addr, p, len, 0);
42 return p;
44 #define lock_user(p, len, copy) softmmu_lock_user(env, p, len, copy)
45 static char *softmmu_lock_user_string(CPUState *env, uint32_t addr)
47 char *p;
48 char *s;
49 uint8_t c;
50 /* TODO: Make this something that isn't fixed size. */
51 s = p = malloc(1024);
52 do {
53 cpu_memory_rw_debug(env, addr, &c, 1, 0);
54 addr++;
55 *(p++) = c;
56 } while (c);
57 return s;
59 #define lock_user_string(p) softmmu_lock_user_string(env, p)
60 static void softmmu_unlock_user(CPUState *env, void *p, target_ulong addr,
61 target_ulong len)
63 if (len)
64 cpu_memory_rw_debug(env, addr, p, len, 1);
65 free(p);
67 #define unlock_user(s, args, len) softmmu_unlock_user(env, s, args, len)