qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Magnus Damm" <magnus.damm@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] sh4: user space emulator patches
Date: Tue, 12 Jun 2007 18:11:23 +0900	[thread overview]
Message-ID: <aec7e5c30706120211j3f6a6ec2tf84ce07c9df95f3d@mail.gmail.com> (raw)

[-- 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

                 reply	other threads:[~2007-06-12  9:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aec7e5c30706120211j3f6a6ec2tf84ce07c9df95f3d@mail.gmail.com \
    --to=magnus.damm@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).