-#ifndef GEMU_H
-#define GEMU_H
+#ifndef QEMU_H
+#define QEMU_H
#include "thunk.h"
#include <signal.h>
+#include <string.h>
#include "syscall_defs.h"
-#include "cpu-" TARGET_ARCH ".h"
-#include "syscall-" TARGET_ARCH ".h"
+#include "cpu.h"
+#include "syscall.h"
+#include "gdbstub.h"
/* This struct is used to hold certain information about the image.
* Basically, it replicates in user space what would be certain
};
#endif
+#ifdef TARGET_ARM
+/* FPU emulator */
+#include "nwfpe/fpa11.h"
+#endif
+
/* NOTE: we force a big alignment so that the stack stored after is
aligned too */
typedef struct TaskState {
struct TaskState *next;
+#ifdef TARGET_ARM
+ /* FPA state */
+ FPA11 fpa;
+ /* Extra fields for semihosted binaries. */
+ uint32_t stack_base;
+ uint32_t heap_base;
+ uint32_t heap_limit;
+ int swi_errno;
+#endif
#ifdef TARGET_I386
struct target_vm86plus_struct *target_v86;
struct vm86_saved_state vm86_saved_regs;
struct target_pt_regs * regs, struct image_info *infop);
void target_set_brk(char *new_brk);
+long do_brk(char *new_brk);
void syscall_init(void);
long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
long arg4, long arg5, long arg6);
unsigned long new_addr);
int target_msync(unsigned long start, unsigned long len, int flags);
-#endif
+/* user access */
+
+#define VERIFY_READ 0
+#define VERIFY_WRITE 1
+
+#define access_ok(type,addr,size) (1)
+
+#define __put_user(x,ptr)\
+({\
+ int size = sizeof(*ptr);\
+ switch(size) {\
+ case 1:\
+ stb(ptr, (typeof(*ptr))(x));\
+ break;\
+ case 2:\
+ stw(ptr, (typeof(*ptr))(x));\
+ break;\
+ case 4:\
+ stl(ptr, (typeof(*ptr))(x));\
+ break;\
+ case 8:\
+ stq(ptr, (typeof(*ptr))(x));\
+ break;\
+ default:\
+ abort();\
+ }\
+ 0;\
+})
+
+#define __get_user(x, ptr) \
+({\
+ int size = sizeof(*ptr);\
+ switch(size) {\
+ case 1:\
+ x = (typeof(*ptr))ldub((void *)ptr);\
+ break;\
+ case 2:\
+ x = (typeof(*ptr))lduw((void *)ptr);\
+ break;\
+ case 4:\
+ x = (typeof(*ptr))ldl((void *)ptr);\
+ break;\
+ case 8:\
+ x = (typeof(*ptr))ldq((void *)ptr);\
+ break;\
+ default:\
+ abort();\
+ }\
+ 0;\
+})
+
+static inline unsigned long __copy_to_user(void *dst, const void *src,
+ unsigned long size)
+{
+ memcpy(dst, src, size);
+ return 0;
+}
+
+static inline unsigned long __copy_from_user(void *dst, const void *src,
+ unsigned long size)
+{
+ memcpy(dst, src, size);
+ return 0;
+}
+
+static inline unsigned long __clear_user(void *dst, unsigned long size)
+{
+ memset(dst, 0, size);
+ return 0;
+}
+
+#define put_user(x,ptr)\
+({\
+ int __ret;\
+ if (access_ok(VERIFY_WRITE, ptr, sizeof(*ptr)))\
+ __ret = __put_user(x, ptr);\
+ else\
+ __ret = -EFAULT;\
+ __ret;\
+})
+
+#define get_user(x,ptr)\
+({\
+ int __ret;\
+ if (access_ok(VERIFY_READ, ptr, sizeof(*ptr)))\
+ __ret = __get_user(x, ptr);\
+ else\
+ __ret = -EFAULT;\
+ __ret;\
+})
+
+static inline unsigned long copy_to_user(void *dst, const void *src,
+ unsigned long size)
+{
+ if (access_ok(VERIFY_WRITE, dst, size))
+ return __copy_to_user(dst, src, size);
+ else
+ return size;
+}
+
+static inline unsigned long copy_from_user(void *dst, const void *src,
+ unsigned long size)
+{
+ if (access_ok(VERIFY_READ, src, size))
+ return __copy_from_user(dst, src, size);
+ else
+ return size;
+}
+
+static inline unsigned long clear_user(void *dst, unsigned long size)
+{
+ if (access_ok(VERIFY_WRITE, dst, size))
+ return __clear_user(dst, size);
+ else
+ return size;
+}
+
+#endif /* QEMU_H */