* [Qemu-devel] sh4: user space emulator patches
@ 2007-06-12 9:11 Magnus Damm
0 siblings, 0 replies; only message in thread
From: Magnus Damm @ 2007-06-12 9:11 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 591 bytes --]
Hi everyone,
Here comes a batch of patches for the sh4 user space emulator. I have
another 10 patches in my local queue that are specific to the sh4 user
space emulator, and when I'm done with them I'll spend time on fixing
up the sh4 system emulator. Maybe it's time for some CVS write access?
Unless people enjoy committing patches for me that is. =)
- sh4: add missing cpu_halted symbol
- sh4: set FD bit in SR to emulate kernel behaviour
- sh4: setup stack properly, fixes wrong argc value problem
- sh4: use correct data structures for stat syscalls
Please apply.
Thanks!
/ magnus
[-- Attachment #2: qemu-cvs_20070607-sh4-cpu_halted.patch --]
[-- Type: application/octet-stream, Size: 1089 bytes --]
sh4: add missing cpu_halted symbol
The sh4 user space emulator is missing an implementation of cpu_halted().
Without this patch is it impossible to execute the qemu-sh4 binary.
Signed-off-by: Magnus Damm <damm@igel.co.jp>
--- 0002/target-sh4/cpu.h
+++ work/target-sh4/cpu.h 2007-06-07 15:07:28.000000000 +0900
@@ -115,6 +115,7 @@ typedef struct CPUSH4State {
jmp_buf jmp_env;
int user_mode_only;
int interrupt_request;
+ int halted;
int exception_index;
CPU_COMMON tlb_t utlb[UTLB_SIZE]; /* unified translation table */
tlb_t itlb[ITLB_SIZE]; /* instruction translation table */
--- 0001/target-sh4/exec.h
+++ work/target-sh4/exec.h 2007-06-07 15:07:06.000000000 +0900
@@ -36,6 +36,16 @@ register uint32_t T1 asm(AREG2);
#include "cpu.h"
#include "exec-all.h"
+static inline int cpu_halted(CPUState *env) {
+ if (!env->halted)
+ return 0;
+ if (env->interrupt_request & CPU_INTERRUPT_HARD) {
+ env->halted = 0;
+ return 0;
+ }
+ return EXCP_HALTED;
+}
+
#ifndef CONFIG_USER_ONLY
#include "softmmu_exec.h"
#endif
[-- Attachment #3: qemu-cvs_20070523-sh4-sr-fd-set.patch --]
[-- Type: application/octet-stream, Size: 580 bytes --]
sh4: set FD bit in SR to emulate kernel behaviour
The FD bit in SR is set by the kernel to trap floating point instructions.
Signed-off-by: Magnus Damm <damm@igel.co.jp>
--- 0005/target-sh4/translate.c
+++ work/target-sh4/translate.c 2007-05-23 16:09:41.000000000 +0900
@@ -125,7 +125,7 @@ void cpu_dump_state(CPUState * env, FILE
void cpu_sh4_reset(CPUSH4State * env)
{
#if defined(CONFIG_USER_ONLY)
- env->sr = 0x00000000;
+ env->sr = SR_FD; /* FD - kernel does lazy fpu context switch */
#else
env->sr = 0x700000F0; /* MD, RB, BL, I3-I0 */
#endif
[-- Attachment #4: qemu-cvs_20070523-sh4-argc-stack.patch --]
[-- Type: application/octet-stream, Size: 551 bytes --]
sh4: setup stack properly, fixes wrong argc value problem
The stack setup code is currently incorrect so argc is not passed properly
to the emulated binary.
Signed-off-by: Magnus Damm <damm@igel.co.jp>
--- 0001/linux-user/elfload.c
+++ work/linux-user/elfload.c 2007-05-23 17:44:29.000000000 +0900
@@ -325,7 +325,7 @@ static inline void init_thread(struct ta
{
/* Check other registers XXXXX */
regs->pc = infop->entry;
- regs->regs[15] = infop->start_stack - 16 * 4;
+ regs->regs[15] = infop->start_stack;
}
#define USE_ELF_CORE_DUMP
[-- Attachment #5: qemu-cvs_20070611-sh4-syscall-stat.patch --]
[-- Type: application/octet-stream, Size: 2170 bytes --]
sh4: use correct data structures for stat syscalls
The current stat syscalls are not emulated correctly under sh4. This patch
fixes this by using the same data structure as the sh4 kernel.
Signed-off-by: Magnus Damm <damm@igel.co.jp>
--- 0001/linux-user/syscall_defs.h
+++ work/linux-user/syscall_defs.h 2007-06-11 14:05:25.000000000 +0900
@@ -869,7 +869,7 @@ struct target_winsize {
#define TARGET_MAP_NORESERVE 0x4000 /* don't check for reservations */
#endif
-#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SH4)
+#if defined(TARGET_I386) || defined(TARGET_ARM)
struct target_stat {
unsigned short st_dev;
unsigned short __pad1;
@@ -1242,6 +1242,65 @@ struct target_stat64 {
target_long __unused[3];
};
+#elif defined(TARGET_SH4)
+
+struct target_stat {
+ target_ulong st_dev;
+ target_ulong st_ino;
+ unsigned short st_mode;
+ unsigned short st_nlink;
+ unsigned short st_uid;
+ unsigned short st_gid;
+ target_ulong st_rdev;
+ target_ulong st_size;
+ target_ulong st_blksize;
+ target_ulong st_blocks;
+ target_ulong target_st_atime;
+ target_ulong target_st_atime_nsec;
+ target_ulong target_st_mtime;
+ target_ulong target_st_mtime_nsec;
+ target_ulong target_st_ctime;
+ target_ulong target_st_ctime_nsec;
+ target_ulong __unused4;
+ target_ulong __unused5;
+};
+
+/* This matches struct stat64 in glibc2.1, hence the absolutely
+ * insane amounts of padding around dev_t's.
+ */
+struct target_stat64 {
+ unsigned long long st_dev;
+ unsigned char __pad0[4];
+
+#define TARGET_STAT64_HAS_BROKEN_ST_INO 1
+ target_ulong __st_ino;
+
+ unsigned int st_mode;
+ unsigned int st_nlink;
+
+ target_ulong st_uid;
+ target_ulong st_gid;
+
+ unsigned long long st_rdev;
+ unsigned char __pad3[4];
+
+ long long st_size;
+ target_ulong st_blksize;
+
+ unsigned long long st_blocks; /* Number 512-byte blocks allocated. */
+
+ target_ulong target_st_atime;
+ target_ulong target_st_atime_nsec;
+
+ target_ulong target_st_mtime;
+ target_ulong target_st_mtime_nsec;
+
+ target_ulong target_st_ctime;
+ target_ulong target_st_ctime_nsec;
+
+ unsigned long long st_ino;
+};
+
#else
#error unsupported CPU
#endif
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-06-12 9:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-12 9:11 [Qemu-devel] sh4: user space emulator patches Magnus Damm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).