From: Chen Gang S <gang.chen@sunrus.com.cn>
To: Peter Maydell <peter.maydell@linaro.org>,
Riku Voipio <riku.voipio@iki.fi>,
Chris Metcalf <cmetcalf@ezchip.com>,
"walt@tilera.com" <walt@tilera.com>
Cc: qemu-devel <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH 5/5] linux-user: Support tile architecture in linux-user
Date: Fri, 13 Feb 2015 05:20:53 +0800 [thread overview]
Message-ID: <54DD1935.60301@sunrus.com.cn> (raw)
In-Reply-To: <54DD17BC.5040006@sunrus.com.cn>
Add main working flow feature and loading elf64 tilegx binary feature,
based on Linux kernel tilegx 64-bit implementation.
After this patch, qemu can successfully load elf64 tilegx binary for
linux-user, and the working flow reaches 1st instruction "__start".
Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
include/elf.h | 2 ++
linux-user/elfload.c | 23 +++++++++++++++++
linux-user/main.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 98 insertions(+)
diff --git a/include/elf.h b/include/elf.h
index a516584..9a16d5a 100644
--- a/include/elf.h
+++ b/include/elf.h
@@ -133,6 +133,8 @@ typedef int64_t Elf64_Sxword;
#define EM_AARCH64 183
+#define EM_TILEGX 191 /* Tile */
+
/* This is the info that is needed to parse the dynamic section of the file */
#define DT_NULL 0
#define DT_NEEDED 1
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 399c021..fc68701 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -1189,6 +1189,29 @@ static inline void init_thread(struct target_pt_regs *regs, struct image_info *i
#endif /* TARGET_S390X */
+#ifdef TARGET_TILE
+
+/* 42 bits real used address, a half for user mode */
+#define ELF_START_MMAP (0x00000020000000000ULL)
+
+#define elf_check_arch(x) ((x) == EM_TILEGX)
+
+#define ELF_CLASS ELFCLASS64
+#define ELF_DATA ELFDATA2LSB
+#define ELF_ARCH EM_TILE
+
+static inline void init_thread(struct target_pt_regs *regs,
+ struct image_info *infop)
+{
+ regs->lr = infop->entry;
+ regs->sp = infop->start_stack;
+
+}
+
+#define ELF_EXEC_PAGESIZE 65536 /* Tilegx page size is 64KB */
+
+#endif /* TARGET_TILE */
+
#ifndef ELF_PLATFORM
#define ELF_PLATFORM (NULL)
#endif
diff --git a/linux-user/main.c b/linux-user/main.c
index d92702a..4921f47 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -3418,6 +3418,20 @@ void cpu_loop(CPUS390XState *env)
#endif /* TARGET_S390X */
+#ifdef TARGET_TILE
+void cpu_loop(CPUTLState *env)
+{
+ CPUState *cs = CPU(tile_env_get_cpu(env));
+
+ while (1) {
+ cpu_exec_start(cs);
+ cpu_tile_exec(env);
+ cpu_exec_end(cs);
+ process_pending_signals(env);
+ }
+}
+#endif
+
THREAD CPUState *thread_cpu;
void task_settid(TaskState *ts)
@@ -4392,6 +4406,65 @@ int main(int argc, char **argv, char **envp)
env->psw.mask = regs->psw.mask;
env->psw.addr = regs->psw.addr;
}
+#elif defined(TARGET_TILE)
+ {
+ env->regs[0] = regs->r0;
+ env->regs[1] = regs->r1;
+ env->regs[2] = regs->r2;
+ env->regs[3] = regs->r3;
+ env->regs[4] = regs->r4;
+ env->regs[5] = regs->r5;
+ env->regs[6] = regs->r6;
+ env->regs[7] = regs->r7;
+ env->regs[8] = regs->r8;
+ env->regs[9] = regs->r9;
+ env->regs[10] = regs->r10;
+ env->regs[11] = regs->r11;
+ env->regs[12] = regs->r12;
+ env->regs[13] = regs->r13;
+ env->regs[14] = regs->r14;
+ env->regs[15] = regs->r15;
+ env->regs[16] = regs->r16;
+ env->regs[17] = regs->r17;
+ env->regs[18] = regs->r18;
+ env->regs[19] = regs->r19;
+ env->regs[20] = regs->r20;
+ env->regs[21] = regs->r21;
+ env->regs[22] = regs->r22;
+ env->regs[23] = regs->r23;
+ env->regs[24] = regs->r24;
+ env->regs[25] = regs->r25;
+ env->regs[26] = regs->r26;
+ env->regs[27] = regs->r27;
+ env->regs[28] = regs->r28;
+ env->regs[29] = regs->r29;
+ env->regs[30] = regs->r30;
+ env->regs[31] = regs->r31;
+ env->regs[32] = regs->r32;
+ env->regs[33] = regs->r33;
+ env->regs[34] = regs->r34;
+ env->regs[35] = regs->r35;
+ env->regs[36] = regs->r36;
+ env->regs[37] = regs->r37;
+ env->regs[38] = regs->r38;
+ env->regs[39] = regs->r39;
+ env->regs[40] = regs->r40;
+ env->regs[41] = regs->r41;
+ env->regs[42] = regs->r42;
+ env->regs[43] = regs->r43;
+ env->regs[44] = regs->r44;
+ env->regs[45] = regs->r45;
+ env->regs[46] = regs->r46;
+ env->regs[47] = regs->r47;
+ env->regs[48] = regs->r48;
+ env->regs[49] = regs->r49;
+ env->regs[50] = regs->r50;
+ env->regs[51] = regs->r51;
+ env->regs[52] = regs->r52; /* TILE_R_BP */
+ env->regs[53] = regs->tp; /* TILE_R_TP */
+ env->regs[54] = regs->sp; /* TILE_R_SP */
+ env->regs[55] = regs->lr; /* TILE_R_PC */
+ }
#else
#error unsupported target CPU
#endif
--
1.9.3 (Apple Git-50)
prev parent reply other threads:[~2015-02-12 21:13 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-12 21:14 [Qemu-devel] [PATCH 0/5] tile: Can load elf64 tilegx binary successfully for linux-user Chen Gang S
2015-02-12 21:15 ` [Qemu-devel] [PATCH 1/5] target-tile: Firstly add to qemu with minimized features Chen Gang S
2015-02-13 23:50 ` Chen Gang S
2015-02-14 0:26 ` Peter Maydell
2015-02-14 2:40 ` Richard Henderson
2015-02-14 3:14 ` Chen Gang S
2015-02-14 3:08 ` Chen Gang S
2015-02-14 3:08 ` Peter Maydell
2015-02-14 3:37 ` Chris Metcalf
2015-02-14 5:47 ` Peter Maydell
2015-02-14 15:53 ` Chen Gang S
2015-02-16 3:40 ` Chen Gang S
2015-02-16 14:44 ` Chen Gang S
2015-02-16 15:00 ` Chris Metcalf
2015-02-16 23:40 ` Chen Gang S
2015-02-16 15:24 ` Max Filippov
2015-02-16 23:08 ` Chen Gang S
2015-02-16 23:46 ` Peter Maydell
2015-02-17 0:11 ` Chris Metcalf
2015-02-17 2:48 ` Chen Gang S
2015-02-17 3:11 ` Chen Gang S
2015-02-17 3:18 ` Chen Gang S
2015-02-17 0:29 ` Chris Metcalf
2015-02-17 2:03 ` Chen Gang S
2015-04-27 21:12 ` [Qemu-devel] [Consult] About SPRs information Chen Gang
2015-04-27 22:04 ` Richard Henderson
2015-04-28 20:19 ` Chen Gang
2015-04-28 21:32 ` Chen Gang
2015-04-28 21:43 ` Peter Maydell
2015-04-29 13:32 ` Chen Gang
2015-05-02 2:42 ` Chen Gang
2015-05-02 4:09 ` Chen Gang
2015-05-03 14:30 ` Chen Gang
2015-05-07 21:05 ` Chen Gang
2015-05-08 3:14 ` Peter Maydell
2015-05-08 23:18 ` Chen Gang
2015-02-14 15:43 ` [Qemu-devel] [PATCH 1/5] target-tile: Firstly add to qemu with minimized features Chen Gang S
2015-02-12 21:17 ` [Qemu-devel] [PATCH 3/5] linux-user: tile: Add target features support within qemu Chen Gang S
2015-02-12 21:18 ` [Qemu-devel] [PATCH 4/5] linux-user: Support tile architecture in syscall Chen Gang S
2015-02-12 21:20 ` Chen Gang S [this message]
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=54DD1935.60301@sunrus.com.cn \
--to=gang.chen@sunrus.com.cn \
--cc=cmetcalf@ezchip.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=riku.voipio@iki.fi \
--cc=walt@tilera.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.