From patchwork Fri Mar 20 15:28:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Gang X-Patchwork-Id: 452686 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 29C541401AC for ; Sat, 21 Mar 2015 02:29:24 +1100 (AEDT) Received: from localhost ([::1]:44403 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YYyrS-0003Fd-CI for incoming@patchwork.ozlabs.org; Fri, 20 Mar 2015 11:29:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56250) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YYyr5-0002hp-Dd for qemu-devel@nongnu.org; Fri, 20 Mar 2015 11:29:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YYyr2-0004YR-47 for qemu-devel@nongnu.org; Fri, 20 Mar 2015 11:28:59 -0400 Received: from blu004-omc1s38.hotmail.com ([65.55.116.49]:57738) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YYyr2-0004YM-0y for qemu-devel@nongnu.org; Fri, 20 Mar 2015 11:28:56 -0400 Received: from BLU436-SMTP241 ([65.55.116.7]) by BLU004-OMC1S38.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.22751); Fri, 20 Mar 2015 08:28:55 -0700 X-TMN: [a7AVrNeaffjsb9bOQka2x/LUbCSOh2Fe] X-Originating-Email: [xili_gchen_5257@hotmail.com] Message-ID: Date: Fri, 20 Mar 2015 23:28:45 +0800 From: Chen Gang User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: "rth@twiddle.net" , =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= , Chris Metcalf , Peter Maydell , Riku Voipio , "walt@tilera.com" References: <550C3B78.3050802@hotmail.com> In-Reply-To: <550C3B78.3050802@hotmail.com> X-OriginalArrivalTime: 20 Mar 2015 15:28:54.0349 (UTC) FILETIME=[9334BFD0:01D06322] X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 65.55.116.49 Cc: qemu-devel Subject: [Qemu-devel] [PATCH 5/6 v7] linux-user: Support tilegx architecture in linux-user X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add main working flow feature, system call processing feature, and elf64 tilegx binary loading feature, based on Linux kernel tilegx 64-bit implementation. Signed-off-by: Chen Gang --- include/elf.h | 2 ++ linux-user/elfload.c | 23 ++++++++++++++ linux-user/main.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+) diff --git a/include/elf.h b/include/elf.h index 3e75f05..154144e 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-Gx */ + /* 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..2571cb8 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_TILEGX + +/* 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_TILEGX + +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 /* TILE-Gx page size is 64KB */ + +#endif /* TARGET_TILEGX */ + #ifndef ELF_PLATFORM #define ELF_PLATFORM (NULL) #endif diff --git a/linux-user/main.c b/linux-user/main.c index 6e446de..ecfc80b 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -3418,6 +3418,32 @@ void cpu_loop(CPUS390XState *env) #endif /* TARGET_S390X */ +#ifdef TARGET_TILEGX +void cpu_loop(CPUTLGState *env) +{ + CPUState *cs = CPU(tilegx_env_get_cpu(env)); + int trapnr; + + while (1) { + cpu_exec_start(cs); + trapnr = cpu_tilegx_exec(env); + cpu_exec_end(cs); + switch (trapnr) { + case TILEGX_EXCP_SYSCALL: + env->regs[TILEGX_R_RE] = do_syscall(env, env->regs[TILEGX_R_NR], + env->regs[0], env->regs[1], + env->regs[2], env->regs[3], + env->regs[4], env->regs[5], + env->regs[6], env->regs[7]); + break; + default: + exit(-1); + } + process_pending_signals(env); + } +} +#endif + THREAD CPUState *thread_cpu; void task_settid(TaskState *ts) @@ -4392,6 +4418,66 @@ int main(int argc, char **argv, char **envp) env->psw.mask = regs->psw.mask; env->psw.addr = regs->psw.addr; } +#elif defined(TARGET_TILEGX) + { + 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; /* TILEGX_R_BP */ + env->regs[53] = regs->tp; /* TILEGX_R_TP */ + env->regs[54] = regs->sp; /* TILEGX_R_SP */ + env->regs[55] = regs->lr; /* TILEGX_R_LR */ + env->pc = regs->lr; + } #else #error unsupported target CPU #endif