From patchwork Tue Dec 19 05:38:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 10122515 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C00BE603B5 for ; Tue, 19 Dec 2017 05:50:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B05BB204C2 for ; Tue, 19 Dec 2017 05:50:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A487528E01; Tue, 19 Dec 2017 05:50:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, FROM_LOCAL_NOVOWEL, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 237D7204C2 for ; Tue, 19 Dec 2017 05:50:38 +0000 (UTC) Received: from localhost ([::1]:50860 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eRAnV-0001oJ-B4 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Dec 2017 00:50:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49645) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eRAdL-0001Bm-D9 for qemu-devel@nongnu.org; Tue, 19 Dec 2017 00:40:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eRAdK-00024n-6F for qemu-devel@nongnu.org; Tue, 19 Dec 2017 00:40:07 -0500 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:46894) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eRAdJ-00024A-TM for qemu-devel@nongnu.org; Tue, 19 Dec 2017 00:40:06 -0500 Received: by mail-wr0-x241.google.com with SMTP id g17so7782315wrd.13 for ; Mon, 18 Dec 2017 21:40:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Ztl/luh3LubEzkvZs96W+pl7nL9RcBX3J8JdtgUwB30=; b=BMONs2wIHsbCiSR5hmPTDHM+6KvJ58cBdsae/SpNw1NvzwCAeYHVKZPaY6ISp2ol/g 7U6i1jSbRQYMj8nmQt+J72m/35ZxyhnlhYrYxDKRtUbWkzU6FKvGNGgiEgBZmg33W/uQ 25llhFrVfg0U9hjgX//CUTxO+5v1pqHzgeDSOPFrUhJIFsKMkQMwg+PmGO2Edk84olPZ PeMHPTNoDoJgZpWosCTzkbXad7e9Cx3hLTSgChQrvyIrNzeukHRfhx7+ajRpFA0wsDRB cX3kERcg0ov22roojCng0ocmik9m/DJHom2t/nnxHHACqUNOIAFGdeXn+Em2qUE5nJQW x1/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Ztl/luh3LubEzkvZs96W+pl7nL9RcBX3J8JdtgUwB30=; b=n1975qzZXZfWdTXqIkNnJFDQwWBs4GcnaZxadzFRRdAzE9TVE37CDVKckhm2o/TMMv rzWUfbyU7spGr6K/bmsxzEOdV6GgfXlyg1OmDIXMdP1gD2rvbLAnQza2zmzwrEKrqIva VtvE2R5QZJtQ/FaIlYel3muga7H8jFZ9VO+h3Igke2diWXUn4ylqfAYbIJU3yEyxIJL1 QnSP49VF1+ES8C8o+/VIaUZZYiD/5vTmzcrIpENEI7p2VgY7tmjUxwc5RISF1tidMKvA mY+SsDLd5EyqN//KkqQqWQDhQDBkP6mBFjxZRPT+rMb8X1I3ukwA9KDJtX/JXhvQX5MI odaA== X-Gm-Message-State: AKGB3mJ5vN+IEg4TsOQJ3+wrcXxOCkivt7D90zWFE0aKFuNaPf6Wk0jC 8FCz2EDnaAAkOr8ifaX5Hz1f9g== X-Google-Smtp-Source: ACJfBovLYvNgqoq6Ko+arU172gH61nd6ygInZrERJTu7hAhyIn8YUkqaVlzuGzvtfsknN2SeTk5Qng== X-Received: by 10.46.32.7 with SMTP id g7mr1273280ljg.49.1513662004722; Mon, 18 Dec 2017 21:40:04 -0800 (PST) Received: from octofox.net (jcmvbkbc-1-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:1fa::2]) by smtp.gmail.com with ESMTPSA id f67sm673187lfb.83.2017.12.18.21.40.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 18 Dec 2017 21:40:04 -0800 (PST) From: Max Filippov To: qemu-devel@nongnu.org Date: Mon, 18 Dec 2017 21:38:50 -0800 Message-Id: <1513661932-6849-15-git-send-email-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1513661932-6849-1-git-send-email-jcmvbkbc@gmail.com> References: <1513661932-6849-1-git-send-email-jcmvbkbc@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [PATCH v2 14/16] target/xtensa: implement GPIO32 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Max Filippov , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP GPIO32 is not in the core ISA, but it was widely used in Diamond Cores. This implementation doesn't do actual I/O and doesn't handle the case of GPIO32 state being a part of coprocessor. Signed-off-by: Max Filippov --- target/xtensa/cpu.h | 1 + target/xtensa/translate.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h index 80e9b47e84e9..d9404aa50ab5 100644 --- a/target/xtensa/cpu.h +++ b/target/xtensa/cpu.h @@ -108,6 +108,7 @@ enum { }; enum { + EXPSTATE = 230, THREADPTR = 231, FCR = 232, FSR = 233, diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index da1f712badc7..a84bbf3bedc3 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -204,6 +204,7 @@ static const XtensaReg sregnames[256] = { }; static const XtensaReg uregnames[256] = { + [EXPSTATE] = XTENSA_REG_BITS("EXPSTATE", XTENSA_OPTION_ALL), [THREADPTR] = XTENSA_REG("THREADPTR", XTENSA_OPTION_THREAD_POINTER), [FCR] = XTENSA_REG("FCR", XTENSA_OPTION_FP_COPROCESSOR), [FSR] = XTENSA_REG("FSR", XTENSA_OPTION_FP_COPROCESSOR), @@ -1518,6 +1519,13 @@ static void translate_clamps(DisasContext *dc, const uint32_t arg[], } } +static void translate_clrb_expstate(DisasContext *dc, const uint32_t arg[], + const uint32_t par[]) +{ + /* TODO: GPIO32 may be a part of coprocessor */ + tcg_gen_andi_i32(cpu_UR[EXPSTATE], cpu_UR[EXPSTATE], ~(1u << arg[0])); +} + /* par[0]: privileged, par[1]: check memory access */ static void translate_dcache(DisasContext *dc, const uint32_t arg[], const uint32_t par[]) @@ -2013,6 +2021,15 @@ static void translate_quou(DisasContext *dc, const uint32_t arg[], } } +static void translate_read_impwire(DisasContext *dc, const uint32_t arg[], + const uint32_t par[]) +{ + if (gen_window_check1(dc, arg[0])) { + /* TODO: GPIO32 may be a part of coprocessor */ + tcg_gen_movi_i32(cpu_R[arg[0]], 0); + } +} + static void translate_rer(DisasContext *dc, const uint32_t arg[], const uint32_t par[]) { @@ -2157,6 +2174,13 @@ static void translate_rur(DisasContext *dc, const uint32_t arg[], } } +static void translate_setb_expstate(DisasContext *dc, const uint32_t arg[], + const uint32_t par[]) +{ + /* TODO: GPIO32 may be a part of coprocessor */ + tcg_gen_ori_i32(cpu_UR[EXPSTATE], cpu_UR[EXPSTATE], 1u << arg[0]); +} + static void translate_s32c1i(DisasContext *dc, const uint32_t arg[], const uint32_t par[]) { @@ -2445,6 +2469,15 @@ static void translate_wer(DisasContext *dc, const uint32_t arg[], } } +static void translate_wrmsk_expstate(DisasContext *dc, const uint32_t arg[], + const uint32_t par[]) +{ + if (gen_window_check2(dc, arg[0], arg[1])) { + /* TODO: GPIO32 may be a part of coprocessor */ + tcg_gen_and_i32(cpu_UR[EXPSTATE], cpu_R[arg[0]], cpu_R[arg[1]]); + } +} + static void translate_wsr(DisasContext *dc, const uint32_t arg[], const uint32_t par[]) { @@ -2706,6 +2739,9 @@ static const XtensaOpcodeOps core_ops[] = { .name = "clamps", .translate = translate_clamps, }, { + .name = "clrb_expstate", + .translate = translate_clrb_expstate, + }, { .name = "depbits", .translate = translate_depbits, }, { @@ -3268,6 +3304,9 @@ static const XtensaOpcodeOps core_ops[] = { .translate = translate_rtlb, .par = (const uint32_t[]){true, 1}, }, { + .name = "read_impwire", + .translate = translate_read_impwire, + }, { .name = "rems", .translate = translate_quos, .par = (const uint32_t[]){false}, @@ -3635,6 +3674,10 @@ static const XtensaOpcodeOps core_ops[] = { .name = "rsync", .translate = translate_nop, }, { + .name = "rur.expstate", + .translate = translate_rur, + .par = (const uint32_t[]){EXPSTATE}, + }, { .name = "rur.fcr", .translate = translate_rur, .par = (const uint32_t[]){FCR}, @@ -3685,6 +3728,9 @@ static const XtensaOpcodeOps core_ops[] = { .translate = translate_salt, .par = (const uint32_t[]){TCG_COND_LTU}, }, { + .name = "setb_expstate", + .translate = translate_setb_expstate, + }, { .name = "sext", .translate = translate_sext, }, { @@ -3775,6 +3821,9 @@ static const XtensaOpcodeOps core_ops[] = { .translate = translate_wtlb, .par = (const uint32_t[]){false}, }, { + .name = "wrmsk_expstate", + .translate = translate_wrmsk_expstate, + }, { .name = "wsr.176", .translate = translate_wsr, .par = (const uint32_t[]){176}, @@ -4083,6 +4132,10 @@ static const XtensaOpcodeOps core_ops[] = { .translate = translate_wsr, .par = (const uint32_t[]){WINDOW_START}, }, { + .name = "wur.expstate", + .translate = translate_wur, + .par = (const uint32_t[]){EXPSTATE}, + }, { .name = "wur.fcr", .translate = translate_wur, .par = (const uint32_t[]){FCR},