From patchwork Sat Dec 10 15:54:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 632902 Delivered-To: patch@linaro.org Received: by 2002:a17:906:82c7:b0:7c1:1f1c:138d with SMTP id a7csp1886068ejy; Sat, 10 Dec 2022 07:56:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf66izj8Hp4cA8jOv0cQRcBwHZKPjKTyttjiiWQE0R0xYJ08Vt60LWnEBb7Mu42zGunIs0AZ X-Received: by 2002:a05:6102:3c88:b0:3ac:4d15:6e01 with SMTP id c8-20020a0561023c8800b003ac4d156e01mr5951374vsv.20.1670687764377; Sat, 10 Dec 2022 07:56:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670687764; cv=none; d=google.com; s=arc-20160816; b=BJ27SbKcdFna9+euIh30NTjqXm3T4s/MIR9xpT0L1OfqR1xrQkXGnK5tR5j4tk9wfu puxF7j+3EVbCd9LuQLtbJHnoo2vYMXw5YjNL5iRzMAD8sYz/069tMAo5oSRwLIJOVVjN YHdScJygptfFZpx6mKI0+pJND8n3Fs99ajCip/OmfZ1L1DoufsHSRT9R0vwEUL4oKfVZ ZO3KM+XwAHD7ixs6RcZO6KgMsxkY3LU6zkRq7t+VgcHNvKCgkDjcFZDBo1XlX3m4BtFK DT/4cB6Rd09y/s7y4xWyxLnPYyEAlbKFPMTzgAIsp6csSBjw1Fni254YRurHWC4HcsZS udQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iKz4mcswYkRci+UIrMG/hIhKLFd8Jngr0Cb+SmfdDdk=; b=owol1pxEKzniML2Q1PvVHZrcdRDrzG0fTzzzZP3hacNneeqyLSBcSZ4rAeiViicOJs jCMX/l1f54Hs9sur4SIwxgJo2bKql1vSFXwFf4+j6cgIHwycMBZynoWCr2jw3WEpY3iL 6vkU8XPsyDAASNQ2ricptmLACBNHwXi5iZRGscUIgbkCbZP01+WllOqlw8V7fsecNzCi +OX45q5LpS/EuZKY2xdynp73GMwrEuA48FXfJNWJsFLukj0WabxE/rX6Pi8wEFJtZqO4 S+ix1SThy9AzdOcswhOa2cZ3BIz0gCL543N8TNyWW0Zpo4VaNKQ2+/8yMj1Onm6V8Hl2 aARw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BlaqyMTc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id br27-20020a05622a1e1b00b003a51d7d02aesi2554560qtb.13.2022.12.10.07.56.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 10 Dec 2022 07:56:04 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BlaqyMTc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p42CQ-0003Xk-DS; Sat, 10 Dec 2022 10:55:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p42CJ-0003SS-Mo for qemu-devel@nongnu.org; Sat, 10 Dec 2022 10:55:35 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p42CI-0004Og-7i for qemu-devel@nongnu.org; Sat, 10 Dec 2022 10:55:31 -0500 Received: by mail-wm1-x335.google.com with SMTP id v124-20020a1cac82000000b003cf7a4ea2caso1842217wme.5 for ; Sat, 10 Dec 2022 07:55:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iKz4mcswYkRci+UIrMG/hIhKLFd8Jngr0Cb+SmfdDdk=; b=BlaqyMTcK21rg7Q9vSGSZB/5WPJEpRxDVaJzsd8TFiVEm41CLVSf2Os6NCXPQ1uC3a R1GwDQCoo/M/r1aymiY2HnaNyRx9DrrdZZ9b5YcwSvuXZgZQemtDn4nsghRf9pWekocU 8idPQtzxc0udc53ZK8NS7/BCktaXV5Zl+2Yk5kbf4Rj7YH9brqLzyWOL6GP7jdiJ0mND k8qy30NO24j3KAwUjthBDiGSURhHOVNHvnzK85ExAEbegkCRes0miIf/gZgBKRB8dnat dfyil7ihq5iNpM5FPQPkQe12ouJh+iTwYwkGr8phS6yFZwM+cOWfkkm2SR8PkfdfwQ00 8ytw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iKz4mcswYkRci+UIrMG/hIhKLFd8Jngr0Cb+SmfdDdk=; b=DXBUPhtWeIL16oiOcwtrFAt2m23bUaQ0z/eG0DbnnZwu4aWh/uwCkVrhmu9HmBwmID 7DtUQfG41DBguuRhVVDkd1eISgNpnh8qKU+EG9VghNhj5kRBImYGbxXPeKaX0C6FQTPh gSyh/0bd9c+j2MwzjNbOx9sMJ1mxkxltmhfCxAC+1tr+fLHFs8qBTjMUtFTRwEcshX3v e2wKNDTPaJypXTELy4o5o54/VYk5S8mhKcxCf1aZ8sbU9yHZtkzd7+lW7nBrh9klBYrT Zpo0ByWj07/iIOygGGlkjt/lnVZC335JhDD0wge353JnrgDlzwqzzV9ro24eQbql+Db5 unww== X-Gm-Message-State: ANoB5pkk3gRFLh3p++yfLB6Bg1yJgMvXkMnItBiy9cm8PCas+PF+ILcC IqiErWjrtMUWYXj7DHrvS5PI7HDWYsthmHzuHIo= X-Received: by 2002:a05:600c:34ce:b0:3cf:f9a7:fadf with SMTP id d14-20020a05600c34ce00b003cff9a7fadfmr7626204wmq.38.1670687728039; Sat, 10 Dec 2022 07:55:28 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id l7-20020a5d5267000000b00241cfe6e286sm4059497wrc.98.2022.12.10.07.55.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 10 Dec 2022 07:55:27 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Milica Lazarevic , Dragan Mladjenovic , Aurelien Jarno , Djordje Todorovic , Jiaxun Yang , Bernhard Beschow Subject: [PATCH-for-8.0 4/7] hw/mips/bootloader: Implement nanoMIPS LUI opcode Date: Sat, 10 Dec 2022 16:54:59 +0100 Message-Id: <20221210155502.74609-5-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221210155502.74609-1-philmd@linaro.org> References: <20221210155502.74609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé --- hw/mips/bootloader.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/hw/mips/bootloader.c b/hw/mips/bootloader.c index 7f7d938f2e..997e74ee52 100644 --- a/hw/mips/bootloader.c +++ b/hw/mips/bootloader.c @@ -120,11 +120,34 @@ static void bl_gen_jalr(void **p, bl_reg rs) bl_gen_r_type(p, 0, rs, 0, BL_REG_RA, 0, 0x09); } +static void bl_gen_lui_nm(void **ptr, bl_reg rt, uint32_t imm20) +{ + uint16_t *p = (uint16_t *)*ptr; + uint32_t insn = 0; + + insn = deposit32(insn, 26, 6, 0b111000); + insn = deposit32(insn, 21, 5, rt); + insn = deposit32(insn, 12, 9, extract32(imm20, 12, 9)); + insn = deposit32(insn, 2, 10, extract32(imm20, 21, 10)); + insn = deposit32(insn, 0, 1, sextract32(imm20, 31, 1)); + + stw_p(p, insn >> 16); + p++; + stw_p(p, insn >> 0); + p++; + + *ptr = p; +} + static void bl_gen_lui(void **p, bl_reg rt, uint32_t imm32) { - /* R6: It's a alias of AUI with RS = 0 */ - assert(imm32 <= UINT16_MAX); - bl_gen_i_type(p, 0x0f, 0, rt, extract32(imm32, 16, 16)); + if (bootcpu_supports_isa(ISA_NANOMIPS32)) { + bl_gen_lui_nm(p, rt, imm32); + } else { + /* R6: It's a alias of AUI with RS = 0 */ + assert(imm32 <= UINT16_MAX); + bl_gen_i_type(p, 0x0f, 0, rt, extract32(imm32, 16, 16)); + } } static void bl_gen_ori(void **p, bl_reg rt, bl_reg rs, uint16_t imm)