From patchwork Sat Dec 10 15:54:56 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: 13070365 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AE6CDC4332F for ; Sat, 10 Dec 2022 15:56:03 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p42CF-0003PL-Cz; Sat, 10 Dec 2022 10:55:27 -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 1p42C5-0003MU-MD for qemu-devel@nongnu.org; Sat, 10 Dec 2022 10:55:19 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p42C3-0004GI-Ht for qemu-devel@nongnu.org; Sat, 10 Dec 2022 10:55:17 -0500 Received: by mail-wm1-x336.google.com with SMTP id o15so1936295wmr.4 for ; Sat, 10 Dec 2022 07:55:12 -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=nWm8sNYh82p69beZ7suEXNMk1EYMXcOVTbGuJ5uURmo=; b=ZGItBjrQOZ7FV9Jav3PMjzhf/h97b/fFDFa4vb4gv8E3sKxkzps8uAGOxOC6t+Br+8 sTnu38IlwL0mF30Q2MRoZuY1HpsUIDLgD6qywqnlT6zy8O2FXtUHoNedBmG5IGCGhmGL pNztmZwXSot8OczTdHu+QkrXYOY671HhhdELV/e/ooBvEB5JWCuzcIRaFlXrSoe4Itmu EqA3BT23+IX/6QnVXotK3JalPpVniJG8KqhkkSOyPhnigq9+PhyCDmLRZOAQMagrJ/U4 oYFaV5puce6RoAn7WVQxoWT/58OxWykIcoqeOT0PLSfVFevO/9GetsQ2B9HHnddmFwob 4UGA== 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=nWm8sNYh82p69beZ7suEXNMk1EYMXcOVTbGuJ5uURmo=; b=WESMDMGgw9LWvKBS95RNSwfDGoWiIU7evmbYAXXspTb5JkmBQQoloCUoo92Xr8CSvy i/didd1B2vPXh3y7W6NKanr40Dj6xuHeMrGutVV+Jgh4F6nrmXpeZmNCANnaLpMwYf6i AXoE2jQ+r87H4Lm20ApYViyVDVnSP52Eon5v4/am9aH+U2SurNto7P4S3nGY3NbXRCEH JgeYranIMGz+/b8wuM795JoxN54JvhE5Lco9NVM+7Lsa5V3eitd7cCJW8kN3UUTJeSI+ lQLiagIfBVkmkA1rszSFHmKnUNk3+17hNjJUCHwAO+vtMFf4IK0hieTkdQsql2EAlAbc XUqQ== X-Gm-Message-State: ANoB5pn8fxzg0r0/v3YRtCZFovY5Yj4F9liuJVtl38J5emTf3OLdYUwZ CzTG9142j/WKipm4/mve+c92Wugg8hiGhjHw8NA= X-Google-Smtp-Source: AA0mqf6bgC2Vi8OXMU2R+1vZDngEnudtyT5iRjopvy/BFdy36PxBDQu+auGLSUaVVLCSeC112yM+kg== X-Received: by 2002:a1c:f617:0:b0:3c6:e60f:3f4f with SMTP id w23-20020a1cf617000000b003c6e60f3f4fmr8022726wmc.6.1670687711135; Sat, 10 Dec 2022 07:55:11 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id h67-20020a1c2146000000b003d1de805de5sm3231329wmh.16.2022.12.10.07.55.09 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 10 Dec 2022 07:55:10 -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 1/7] hw/mips/bootloader: Handle buffers as opaque arrays Date: Sat, 10 Dec 2022 16:54:56 +0100 Message-Id: <20221210155502.74609-2-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::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org It is irrelevant to the API what the buffers to fill are made of. In particular, some MIPS ISA have 16-bit wide instructions. Signed-off-by: Philippe Mathieu-Daudé --- hw/mips/bootloader.c | 55 +++++++++++++++++++++--------------- hw/mips/malta.c | 19 +++++++------ include/hw/mips/bootloader.h | 10 +++---- 3 files changed, 48 insertions(+), 36 deletions(-) diff --git a/hw/mips/bootloader.c b/hw/mips/bootloader.c index f5f42f2bf2..fc14eb0894 100644 --- a/hw/mips/bootloader.c +++ b/hw/mips/bootloader.c @@ -55,16 +55,20 @@ static bool bootcpu_supports_isa(uint64_t isa_mask) } /* Base types */ -static void bl_gen_nop(uint32_t **p) +static void bl_gen_nop(void **ptr) { - stl_p(*p, 0); - *p = *p + 1; + uint32_t *p = (uint32_t *)*ptr; + + stl_p(p, 0); + p++; + *ptr = p; } -static void bl_gen_r_type(uint32_t **p, uint8_t opcode, +static void bl_gen_r_type(void **ptr, uint8_t opcode, bl_reg rs, bl_reg rt, bl_reg rd, uint8_t shift, uint8_t funct) { + uint32_t *p = (uint32_t *)*ptr; uint32_t insn = 0; insn = deposit32(insn, 26, 6, opcode); @@ -74,13 +78,16 @@ static void bl_gen_r_type(uint32_t **p, uint8_t opcode, insn = deposit32(insn, 6, 5, shift); insn = deposit32(insn, 0, 6, funct); - stl_p(*p, insn); - *p = *p + 1; + stl_p(p, insn); + p++; + + *ptr = p; } -static void bl_gen_i_type(uint32_t **p, uint8_t opcode, +static void bl_gen_i_type(void **ptr, uint8_t opcode, bl_reg rs, bl_reg rt, uint16_t imm) { + uint32_t *p = (uint32_t *)*ptr; uint32_t insn = 0; insn = deposit32(insn, 26, 6, opcode); @@ -88,12 +95,14 @@ static void bl_gen_i_type(uint32_t **p, uint8_t opcode, insn = deposit32(insn, 16, 5, rt); insn = deposit32(insn, 0, 16, imm); - stl_p(*p, insn); - *p = *p + 1; + stl_p(p, insn); + p++; + + *ptr = p; } /* Single instructions */ -static void bl_gen_dsll(uint32_t **p, bl_reg rd, bl_reg rt, uint8_t sa) +static void bl_gen_dsll(void **p, bl_reg rd, bl_reg rt, uint8_t sa) { if (bootcpu_supports_isa(ISA_MIPS3)) { bl_gen_r_type(p, 0, 0, rt, rd, sa, 0x38); @@ -102,28 +111,28 @@ static void bl_gen_dsll(uint32_t **p, bl_reg rd, bl_reg rt, uint8_t sa) } } -static void bl_gen_jalr(uint32_t **p, bl_reg rs) +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(uint32_t **p, bl_reg rt, uint16_t imm) +static void bl_gen_lui(void **p, bl_reg rt, uint16_t imm) { /* R6: It's a alias of AUI with RS = 0 */ bl_gen_i_type(p, 0x0f, 0, rt, imm); } -static void bl_gen_ori(uint32_t **p, bl_reg rt, bl_reg rs, uint16_t imm) +static void bl_gen_ori(void **p, bl_reg rt, bl_reg rs, uint16_t imm) { bl_gen_i_type(p, 0x0d, rs, rt, imm); } -static void bl_gen_sw(uint32_t **p, bl_reg rt, uint8_t base, uint16_t offset) +static void bl_gen_sw(void **p, bl_reg rt, uint8_t base, uint16_t offset) { bl_gen_i_type(p, 0x2b, base, rt, offset); } -static void bl_gen_sd(uint32_t **p, bl_reg rt, uint8_t base, uint16_t offset) +static void bl_gen_sd(void **p, bl_reg rt, uint8_t base, uint16_t offset) { if (bootcpu_supports_isa(ISA_MIPS3)) { bl_gen_i_type(p, 0x3f, base, rt, offset); @@ -133,13 +142,13 @@ static void bl_gen_sd(uint32_t **p, bl_reg rt, uint8_t base, uint16_t offset) } /* Pseudo instructions */ -static void bl_gen_li(uint32_t **p, bl_reg rt, uint32_t imm) +static void bl_gen_li(void **p, bl_reg rt, uint32_t imm) { bl_gen_lui(p, rt, extract32(imm, 16, 16)); bl_gen_ori(p, rt, rt, extract32(imm, 0, 16)); } -static void bl_gen_dli(uint32_t **p, bl_reg rt, uint64_t imm) +static void bl_gen_dli(void **p, bl_reg rt, uint64_t imm) { bl_gen_li(p, rt, extract64(imm, 32, 32)); bl_gen_dsll(p, rt, rt, 16); @@ -148,7 +157,7 @@ static void bl_gen_dli(uint32_t **p, bl_reg rt, uint64_t imm) bl_gen_ori(p, rt, rt, extract64(imm, 0, 16)); } -static void bl_gen_load_ulong(uint32_t **p, bl_reg rt, target_ulong imm) +static void bl_gen_load_ulong(void **p, bl_reg rt, target_ulong imm) { if (bootcpu_supports_isa(ISA_MIPS3)) { bl_gen_dli(p, rt, imm); /* 64bit */ @@ -158,14 +167,14 @@ static void bl_gen_load_ulong(uint32_t **p, bl_reg rt, target_ulong imm) } /* Helpers */ -void bl_gen_jump_to(uint32_t **p, target_ulong jump_addr) +void bl_gen_jump_to(void **p, target_ulong jump_addr) { bl_gen_load_ulong(p, BL_REG_T9, jump_addr); bl_gen_jalr(p, BL_REG_T9); bl_gen_nop(p); /* delay slot */ } -void bl_gen_jump_kernel(uint32_t **p, +void bl_gen_jump_kernel(void **p, bool set_sp, target_ulong sp, bool set_a0, target_ulong a0, bool set_a1, target_ulong a1, @@ -192,7 +201,7 @@ void bl_gen_jump_kernel(uint32_t **p, bl_gen_jump_to(p, kernel_addr); } -void bl_gen_write_ulong(uint32_t **p, target_ulong addr, target_ulong val) +void bl_gen_write_ulong(void **p, target_ulong addr, target_ulong val) { bl_gen_load_ulong(p, BL_REG_K0, val); bl_gen_load_ulong(p, BL_REG_K1, addr); @@ -203,14 +212,14 @@ void bl_gen_write_ulong(uint32_t **p, target_ulong addr, target_ulong val) } } -void bl_gen_write_u32(uint32_t **p, target_ulong addr, uint32_t val) +void bl_gen_write_u32(void **p, target_ulong addr, uint32_t val) { bl_gen_li(p, BL_REG_K0, val); bl_gen_load_ulong(p, BL_REG_K1, addr); bl_gen_sw(p, BL_REG_K0, BL_REG_K1, 0x0); } -void bl_gen_write_u64(uint32_t **p, target_ulong addr, uint64_t val) +void bl_gen_write_u64(void **p, target_ulong addr, uint64_t val) { bl_gen_dli(p, BL_REG_K0, val); bl_gen_load_ulong(p, BL_REG_K1, addr); diff --git a/hw/mips/malta.c b/hw/mips/malta.c index 1f4e0c7acc..944730af98 100644 --- a/hw/mips/malta.c +++ b/hw/mips/malta.c @@ -838,6 +838,7 @@ static void write_bootloader(uint8_t *base, uint64_t run_addr, uint64_t kernel_entry) { uint32_t *p; + void *v; /* Small bootloader */ p = (uint32_t *)base; @@ -880,38 +881,39 @@ static void write_bootloader(uint8_t *base, uint64_t run_addr, #else #define cpu_to_gt32 cpu_to_be32 #endif + v = p; /* move GT64120 registers from 0x14000000 to 0x1be00000 */ - bl_gen_write_u32(&p, /* GT_ISD */ + bl_gen_write_u32(&v, /* GT_ISD */ cpu_mips_phys_to_kseg1(NULL, 0x14000000 + 0x68), cpu_to_gt32(0x1be00000 << 3)); /* setup MEM-to-PCI0 mapping */ /* setup PCI0 io window to 0x18000000-0x181fffff */ - bl_gen_write_u32(&p, /* GT_PCI0IOLD */ + bl_gen_write_u32(&v, /* GT_PCI0IOLD */ cpu_mips_phys_to_kseg1(NULL, 0x1be00000 + 0x48), cpu_to_gt32(0x18000000 << 3)); - bl_gen_write_u32(&p, /* GT_PCI0IOHD */ + bl_gen_write_u32(&v, /* GT_PCI0IOHD */ cpu_mips_phys_to_kseg1(NULL, 0x1be00000 + 0x50), cpu_to_gt32(0x08000000 << 3)); /* setup PCI0 mem windows */ - bl_gen_write_u32(&p, /* GT_PCI0M0LD */ + bl_gen_write_u32(&v, /* GT_PCI0M0LD */ cpu_mips_phys_to_kseg1(NULL, 0x1be00000 + 0x58), cpu_to_gt32(0x10000000 << 3)); - bl_gen_write_u32(&p, /* GT_PCI0M0HD */ + bl_gen_write_u32(&v, /* GT_PCI0M0HD */ cpu_mips_phys_to_kseg1(NULL, 0x1be00000 + 0x60), cpu_to_gt32(0x07e00000 << 3)); - bl_gen_write_u32(&p, /* GT_PCI0M1LD */ + bl_gen_write_u32(&v, /* GT_PCI0M1LD */ cpu_mips_phys_to_kseg1(NULL, 0x1be00000 + 0x80), cpu_to_gt32(0x18200000 << 3)); - bl_gen_write_u32(&p, /* GT_PCI0M1HD */ + bl_gen_write_u32(&v, /* GT_PCI0M1HD */ cpu_mips_phys_to_kseg1(NULL, 0x1be00000 + 0x88), cpu_to_gt32(0x0bc00000 << 3)); #undef cpu_to_gt32 - bl_gen_jump_kernel(&p, + bl_gen_jump_kernel(&v, true, ENVP_VADDR - 64, /* * If semihosting is used, arguments have already been @@ -922,6 +924,7 @@ static void write_bootloader(uint8_t *base, uint64_t run_addr, true, ENVP_VADDR + 8, true, loaderparams.ram_low_size, kernel_entry); + p = (uint32_t *)v; /* YAMON subroutines */ p = (uint32_t *) (base + 0x800); diff --git a/include/hw/mips/bootloader.h b/include/hw/mips/bootloader.h index fffb0b7da8..c32f6c2835 100644 --- a/include/hw/mips/bootloader.h +++ b/include/hw/mips/bootloader.h @@ -11,16 +11,16 @@ #include "exec/cpu-defs.h" -void bl_gen_jump_to(uint32_t **p, target_ulong jump_addr); -void bl_gen_jump_kernel(uint32_t **p, +void bl_gen_jump_to(void **ptr, target_ulong jump_addr); +void bl_gen_jump_kernel(void **ptr, bool set_sp, target_ulong sp, bool set_a0, target_ulong a0, bool set_a1, target_ulong a1, bool set_a2, target_ulong a2, bool set_a3, target_ulong a3, target_ulong kernel_addr); -void bl_gen_write_ulong(uint32_t **p, target_ulong addr, target_ulong val); -void bl_gen_write_u32(uint32_t **p, target_ulong addr, uint32_t val); -void bl_gen_write_u64(uint32_t **p, target_ulong addr, uint64_t val); +void bl_gen_write_ulong(void **ptr, target_ulong addr, target_ulong val); +void bl_gen_write_u32(void **ptr, target_ulong addr, uint32_t val); +void bl_gen_write_u64(void **ptr, target_ulong addr, uint64_t val); #endif From patchwork Sat Dec 10 15:54:57 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: 13070369 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 044CFC4708E for ; Sat, 10 Dec 2022 15:56:03 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p42CO-0003Rp-3L; Sat, 10 Dec 2022 10:55:36 -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 1p42C9-0003O0-Hh for qemu-devel@nongnu.org; Sat, 10 Dec 2022 10:55:21 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p42C7-0004IU-Dr for qemu-devel@nongnu.org; Sat, 10 Dec 2022 10:55:21 -0500 Received: by mail-wm1-x329.google.com with SMTP id v7so1981308wmn.0 for ; Sat, 10 Dec 2022 07:55:18 -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=yrUqSoqcBKcPC/EIQSxB/g68+9dWnNAnr0RdD7MvGfE=; b=Mh3XIKg9gQlv3kGLBcQOwyrC/VYzC9TaWWyQadwmO6aQwTQ3Gkt7QI5DjQxgtIwrNB 7y2+Ld9RpU3MI2/pqCedvdA9AouhEmyZsUTuCoYg1Dr6loo5KPi4Ngmcn7vbz52nq/YQ WmT3dsXdvFNPPZyG2X8XIYfB6wbWBiD/VL9mzaCXt41qjZv6uYdZ2kAKRwlIRyXhG+Ba 8U6lJwPv91RtLoHlcg27AUGCJUZUpgHTFoKTkR3/j8hJHV7YW4y8tTg5RiFKGpxw0TK9 H2TC1qR+qabekSHUiXA6g6fmJys6/ouuwx6ZOhWrRKugsAetGdJS5AJl7/5JJkDYg+2W 7+vw== 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=yrUqSoqcBKcPC/EIQSxB/g68+9dWnNAnr0RdD7MvGfE=; b=zazAXxxU2p0v4bzY6QS8vDstdmpQAHS/wwS4IcuPhDsQxQKgdlbyGRbxkFT29aJpms WgFmgW2iIy+bQ+LwcKT9kegKYb4QwagRsPHRwz39ssMV4ctvaLQknXndd5s/pSGJr4Ok +Jl+pqwiMb8yiP0TnnCPW6hT5yXwHNkyttbZQ8z5fhWd/EXmrIy/IJPELBp45AaqcPPL 2/xYWSo1n2Xbuq1DCaEbYKDYGtW6Cczv0USqovp3IV0ajXAkvF7O4OGW/2b71g/Jx2iA lTfyYavy+jkw/QoLcqoOUx5WQd1uPUX0IYbbm/xcBUVFrddcQuqQbdz/OYc6ns2O7wAq lIFA== X-Gm-Message-State: ANoB5pmwlRZF0/5R3udHXGodbrktfgNBDDPKzQf0LfyQdgWOThPiVXdD k42thWo3ex3kAcBjfYf28h9aR0EfjwleMm2cbN0= X-Google-Smtp-Source: AA0mqf7TIT/Ie/basT+RM1Axzd4PGcFZUs9A40y/7aE/zrpMwVw9C0eb3aWa84Ec7hxHFuftpI+Ihg== X-Received: by 2002:a05:600c:3790:b0:3cf:8e70:f34e with SMTP id o16-20020a05600c379000b003cf8e70f34emr8079106wmr.14.1670687717085; Sat, 10 Dec 2022 07:55:17 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id n3-20020a7bc5c3000000b003cfd4e6400csm3192893wmk.19.2022.12.10.07.55.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 10 Dec 2022 07:55:16 -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 2/7] hw/mips/bootloader: Pass 32-bit immediate value to LUI opcode generator Date: Sat, 10 Dec 2022 16:54:57 +0100 Message-Id: <20221210155502.74609-3-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::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org While 32-bit wide instructions ISA restricts LUI to a 16-bit immediate value, some 16-bit ones allow up to 20-bit immediate (in particular nanoMIPS). Signed-off-by: Philippe Mathieu-Daudé --- hw/mips/bootloader.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/hw/mips/bootloader.c b/hw/mips/bootloader.c index fc14eb0894..3a4573118c 100644 --- a/hw/mips/bootloader.c +++ b/hw/mips/bootloader.c @@ -116,10 +116,11 @@ 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(void **p, bl_reg rt, uint16_t imm) +static void bl_gen_lui(void **p, bl_reg rt, uint32_t imm32) { /* R6: It's a alias of AUI with RS = 0 */ - bl_gen_i_type(p, 0x0f, 0, rt, imm); + 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) @@ -142,10 +143,10 @@ static void bl_gen_sd(void **p, bl_reg rt, uint8_t base, uint16_t offset) } /* Pseudo instructions */ -static void bl_gen_li(void **p, bl_reg rt, uint32_t imm) +static void bl_gen_li(void **p, bl_reg rt, uint32_t imm32) { - bl_gen_lui(p, rt, extract32(imm, 16, 16)); - bl_gen_ori(p, rt, rt, extract32(imm, 0, 16)); + bl_gen_lui(p, rt, imm32); + bl_gen_ori(p, rt, rt, extract32(imm32, 0, 16)); } static void bl_gen_dli(void **p, bl_reg rt, uint64_t imm) From patchwork Sat Dec 10 15:54:58 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: 13070366 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D499DC4708D for ; Sat, 10 Dec 2022 15:56:03 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p42CP-0003Vl-2H; Sat, 10 Dec 2022 10:55:37 -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 1p42CF-0003Q2-GJ for qemu-devel@nongnu.org; Sat, 10 Dec 2022 10:55:27 -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 1p42CC-0004MY-2f for qemu-devel@nongnu.org; Sat, 10 Dec 2022 10:55:26 -0500 Received: by mail-wm1-x335.google.com with SMTP id h8-20020a1c2108000000b003d1efd60b65so1889565wmh.0 for ; Sat, 10 Dec 2022 07:55:23 -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=rPsrEY4rtblWI0rx96iiEsOKP/PxGkNW2C7Zi9iNKyM=; b=cvgb+jTT3FrxLB3+OhGSyWxqMuJeO8bIlY/Mlnfo+ZjoS6zhlYyAuJlOpY6OuygkaS lSQ0S+rbIpZnog5gc4WcfKELUwiM0Ze891IYhl53KMmNZhNYnUoBBdzGQtzdVXJzQWjn 5OZ7xvkLJfZLwt3jk5cgOjJ8wqyep6kPnf4HfpLmmNBM68OQclmi28KimfpWQIVdblUn VjL/VEwxlCnKUwmQ9bn5Eb3XAwQVPtkA25J2mKDixfc6KuN/Ytv2b5mUbyDJZIuqbTt7 GpUvgG0ZdgxiISog3K7+Dj3MIvxpRD1OMNVQjFMugVh7Tu72mr7DLfur5DHa1BTEZvYt aGpQ== 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=rPsrEY4rtblWI0rx96iiEsOKP/PxGkNW2C7Zi9iNKyM=; b=l73AL2M9W7E6Esk1ts4ZZ+6DiPZ1qVlM84d+fFYRnI+w/mnBNDdpRR2WkteqFR2Lr0 XNLw8WZr+I3CAHz8Ea+YTt3H2UhCHpL8hD7XO62dSS19ikR7xgvrSd8v24IEorctfHJu 0kpv2SKz6uqEOJ8ienvBrXBf8GaYdWTjxaxpcBlBJ3Ibql8ShVt356wA09QesLnCX79S T3nRkNH8Jr4xdeRTPNQYiWhN4LVx5sQTT93H+Sup7kwBBatJ7pYC04+TmoFZfFnRy+QD FSPouQAmp7DS5lOFXfpkWy3ow+6Jf3dYT9GCMConCToqxdTkXe9QGlvSRGZ5AQ2SvwnM vymQ== X-Gm-Message-State: ANoB5plj3+/4OteOtk+dlYfJKn0L1lOaeFiLERfqYB9o+KzlVOe7RsN7 ecxgMYA2S7K7LRnN8xfdx7+m0rFn7LZWEmH3mHQ= X-Google-Smtp-Source: AA0mqf7G5VNuJde/fiFLjg1YX6rNtfLMR6Hxr5Krr8Fjs0lWXw6Ym5nzg2rJ4qAl+pN+1T5eMYypsg== X-Received: by 2002:a05:600c:a10:b0:3cf:ca4c:1e29 with SMTP id z16-20020a05600c0a1000b003cfca4c1e29mr7709916wmp.41.1670687722384; Sat, 10 Dec 2022 07:55:22 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id ay13-20020a05600c1e0d00b003c6bd91caa5sm3260782wmb.17.2022.12.10.07.55.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 10 Dec 2022 07:55:21 -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 3/7] hw/mips/bootloader: Implement nanoMIPS NOP opcode Date: Sat, 10 Dec 2022 16:54:58 +0100 Message-Id: <20221210155502.74609-4-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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- hw/mips/bootloader.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/mips/bootloader.c b/hw/mips/bootloader.c index 3a4573118c..7f7d938f2e 100644 --- a/hw/mips/bootloader.c +++ b/hw/mips/bootloader.c @@ -59,7 +59,11 @@ static void bl_gen_nop(void **ptr) { uint32_t *p = (uint32_t *)*ptr; - stl_p(p, 0); + if (bootcpu_supports_isa(ISA_NANOMIPS32)) { + stl_p(p, 0x8000c000); + } else { + stl_p(p, 0); + } p++; *ptr = p; } 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: 13070367 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 043F9C10F1B for ; Sat, 10 Dec 2022 15:56:03 +0000 (UTC) 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-Google-Smtp-Source: AA0mqf7i5fQgZs23xEjgpfJ3p/lKIl1LLFAekgDdslj5oWKKrNMC1iaaE2rPCrrbazo425pYA5mx2g== 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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) From patchwork Sat Dec 10 15:55:00 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: 13070364 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B1EFAC4167B for ; Sat, 10 Dec 2022 15:56:03 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p42CQ-0003YK-Mg; Sat, 10 Dec 2022 10:55:38 -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 1p42CO-0003Vk-OW for qemu-devel@nongnu.org; Sat, 10 Dec 2022 10:55:36 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p42CN-0004S5-76 for qemu-devel@nongnu.org; Sat, 10 Dec 2022 10:55:36 -0500 Received: by mail-wm1-x329.google.com with SMTP id n7so1943238wms.3 for ; Sat, 10 Dec 2022 07:55:34 -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=mSN/vxmvjzjZWG1Yzr7yo5qjrH7L/P4OnxN/YhyWvKE=; b=hL7pbh/woT31F3BVD6BSyogDelr+oUTeVcoPMl96aqzIWzxQ//hX6sjRAZMr188Uhx oPBjqz7zgFcXzm2x5Yndg2uxG4OPOxF6xwR8QpF5yLipE/1jG4EIw4w+frWV34u7orGq QgJMmTSaEogP1N8621KnpPi4mskq4wlEkEkQWH1C3ua6SVOcaKc3IoDnkf7ptqAjUj4r SaRiVrOuAZUYtnB8+HC2bEZh0HUbdcOyX0ZTVJjY+KTi2DNfSjiSxnzRqVurD9YUf8e4 dttbSCLciBB+k0h3aosAdRG/sSa8qKC/tcQU7axH0WIPWaxsHSFqHPmGx2TWYn/eemKI MNhA== 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=mSN/vxmvjzjZWG1Yzr7yo5qjrH7L/P4OnxN/YhyWvKE=; b=g4Nep87g5d79AUp2FHTiJcaaISXablCQ4adJrNQRVuQbOWOcunua272jvHH28rISL/ dFTHG2ZfzbCVFwUbxFKcNAwVe55BkDY9K4QnG+mPQ/vj5pR8evkySe7VKAkFNtyLEmlG EOtwYmQOIpe8mEZI+FiPa0z8WYOyMgnlJGK+bhvPRAu3LYRkhuz+yVkoHVIlPdbiE8a2 DQ0QQlWRMmrDVYWufKY/z30r8bvJCIB97Sa7v9iYb6AoahG2OglDpo9CNNSFeUPjow1T 2hwZETlXVpmmpkSFPO/UJSjWe41zFJKskkuhfON9DjO/Zw5nxkAkryH0mFvlA8Pi9otC G0yw== X-Gm-Message-State: ANoB5pmRSI0gBhOucunHpMZBTp3BbPskHl1iOjCWZ2oyX3SZ3O71gdA2 J0SA4IiWDvA2qgRa9IiTc3nxFyu0lJPdusQBnTM= X-Google-Smtp-Source: AA0mqf7MzyWtQauoGlTosMQEMp0vxLYqEtBgPMkMo1IygmMLmz25nsplyZA/lA5OML6hi46oBNBu0g== X-Received: by 2002:a05:600c:4fd0:b0:3d1:c0a1:4804 with SMTP id o16-20020a05600c4fd000b003d1c0a14804mr7958693wmq.17.1670687733567; Sat, 10 Dec 2022 07:55:33 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id d15-20020a5d538f000000b00242442c8ebdsm4137165wrv.111.2022.12.10.07.55.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 10 Dec 2022 07:55:33 -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 5/7] hw/mips/bootloader: Implement nanoMIPS SW opcode Date: Sat, 10 Dec 2022 16:55:00 +0100 Message-Id: <20221210155502.74609-6-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::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé --- hw/mips/bootloader.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/hw/mips/bootloader.c b/hw/mips/bootloader.c index 997e74ee52..cc3df385df 100644 --- a/hw/mips/bootloader.c +++ b/hw/mips/bootloader.c @@ -150,9 +150,31 @@ static void bl_gen_lui(void **p, bl_reg rt, uint32_t imm32) } } +static void bl_gen_ori_nm(void **ptr, bl_reg rt, bl_reg rs, uint16_t imm) +{ + uint16_t *p = (uint16_t *)*ptr; + uint32_t insn = 0; + + insn = deposit32(insn, 26, 6, 0b100000); + insn = deposit32(insn, 21, 5, rt); + insn = deposit32(insn, 16, 5, rs); + insn = deposit32(insn, 0, 12, imm); + + stw_p(p, insn >> 16); + p++; + stw_p(p, insn >> 0); + p++; + + *ptr = p; +} + static void bl_gen_ori(void **p, bl_reg rt, bl_reg rs, uint16_t imm) { - bl_gen_i_type(p, 0x0d, rs, rt, imm); + if (bootcpu_supports_isa(ISA_NANOMIPS32)) { + bl_gen_ori_nm(p, rt, rs, imm); + } else { + bl_gen_i_type(p, 0x0d, rs, rt, imm); + } } static void bl_gen_sw(void **p, bl_reg rt, uint8_t base, uint16_t offset) From patchwork Sat Dec 10 15:55:01 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: 13070371 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1986CC4332F for ; Sat, 10 Dec 2022 15:57:20 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p42CW-0003hh-5h; Sat, 10 Dec 2022 10:55:44 -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 1p42CU-0003ev-Ak for qemu-devel@nongnu.org; Sat, 10 Dec 2022 10:55:42 -0500 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p42CS-0004Tb-QJ for qemu-devel@nongnu.org; Sat, 10 Dec 2022 10:55:42 -0500 Received: by mail-wr1-x42c.google.com with SMTP id f18so8002767wrj.5 for ; Sat, 10 Dec 2022 07:55:40 -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=4QRrKPOgHC81ExTYEFHUZ5O6izEXVdgJCHiyrcpa6dc=; b=Wj4SZKrF4KwF28d17HNYAxQgnwyV3gcvJNe/Xzn8OlDN70bgx47YyfAhGOum4IlIVH LoG/ngrLblmgdMcetVhO9B8kptJumRToOTF2XxKV+K9NGpdzaN+iqHFx8b1qH5tvblQh u+eGpn1cHANIxdaZbjzeJop2ekX0+mJ/6bfOUQrvthPArGR0xOAhT1WiDOwEdERwbcYy XRnOvaThEl2em6Ai99/2Heh1xQCNiLI6ijuA9Mx8LFYJ/U/vaKH/CP2C8VgiOjgACa4Y QId0C6kQ3HNkeFBLRFuBAeH7wvje8ErAryMJiTgHr0UVNd+bVKeXEpo0an6A3UzkFE+g bTpA== 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=4QRrKPOgHC81ExTYEFHUZ5O6izEXVdgJCHiyrcpa6dc=; b=bTyEe2R138wJ6GIxVLVnLt234mVCn9g63yaQr3OWI/hyNFjAFwIjOHr3ZixLaDzZ+x tB32nGGep7v6hsFHM3xEDYhq2VpVn/fzy96sM9BsEPokQDqJDKQQ4aMhBREaHLUGbjHB PzAE+wDDBcklzXgK8AXMn/xSR1M9OktdujLmzMpnWIoylxZR1m4X8FjA+9RHuzXzfeys SnwXO1PJjuCXJfieietyitGrjRHoGSS/ElPeusLwM5lh67SFDk+YQboONLvS5vP7sPQy bZNHNnwsfUGajv3KwtObIpZ21FGaFOUxlcBnWNIfuWpEMlDbt8nUreLG3QhmMcjifnYc +yaA== X-Gm-Message-State: ANoB5plpAIuq0kly6Nt+Nt2rmAVJTc+iCqKejrDgw5ASGC6OYhX+PRrp dLGHKW1ZZJsLi2SqSddwOs2XslyXnj0n7CSeRuY= X-Google-Smtp-Source: AA0mqf4WsHB/rNrV2VbqdW05xYb9ymVABX0DjxuQOT6IcyU7RckfhlvljXYSaI8q2qMidV4iqRMybA== X-Received: by 2002:adf:e7c3:0:b0:242:eb5:254f with SMTP id e3-20020adfe7c3000000b002420eb5254fmr6967088wrn.48.1670687739261; Sat, 10 Dec 2022 07:55:39 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id o5-20020a5d58c5000000b00241da0e018dsm4111229wrf.29.2022.12.10.07.55.37 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 10 Dec 2022 07:55:38 -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 6/7] hw/mips/bootloader: Implement nanoMIPS SW opcode Date: Sat, 10 Dec 2022 16:55:01 +0100 Message-Id: <20221210155502.74609-7-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::42c; envelope-from=philmd@linaro.org; helo=mail-wr1-x42c.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé --- hw/mips/bootloader.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/hw/mips/bootloader.c b/hw/mips/bootloader.c index cc3df385df..541b59bf84 100644 --- a/hw/mips/bootloader.c +++ b/hw/mips/bootloader.c @@ -177,9 +177,32 @@ static void bl_gen_ori(void **p, bl_reg rt, bl_reg rs, uint16_t imm) } } +static void bl_gen_sw_nm(void **ptr, bl_reg rt, uint8_t rs, uint16_t offset) +{ + uint16_t *p = (uint16_t *)*ptr; + uint32_t insn = 0; + + insn = deposit32(insn, 26, 6, 0b100001); + insn = deposit32(insn, 21, 5, rt); + insn = deposit32(insn, 16, 5, rs); + insn = deposit32(insn, 12, 4, 0b1001); + insn = deposit32(insn, 0, 12, offset); + + stw_p(p, insn >> 16); + p++; + stw_p(p, insn >> 0); + p++; + + *ptr = p; +} + static void bl_gen_sw(void **p, bl_reg rt, uint8_t base, uint16_t offset) { - bl_gen_i_type(p, 0x2b, base, rt, offset); + if (bootcpu_supports_isa(ISA_NANOMIPS32)) { + bl_gen_sw_nm(p, rt, base, offset); + } else { + bl_gen_i_type(p, 0x2b, base, rt, offset); + } } static void bl_gen_sd(void **p, bl_reg rt, uint8_t base, uint16_t offset) From patchwork Sat Dec 10 15:55:02 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: 13070370 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 18AD4C4167B for ; Sat, 10 Dec 2022 15:56:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p42Cd-0003pU-4l; Sat, 10 Dec 2022 10:55:51 -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 1p42Cb-0003mm-M9 for qemu-devel@nongnu.org; Sat, 10 Dec 2022 10:55:49 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p42CY-0004Uc-Rh for qemu-devel@nongnu.org; Sat, 10 Dec 2022 10:55:48 -0500 Received: by mail-wr1-x42b.google.com with SMTP id h11so7978055wrw.13 for ; Sat, 10 Dec 2022 07:55:46 -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=XAIyeA7URHRc9R78H/YlOyhbX6NAYtvfVcML/GjO4L4=; b=bhjZzU3MTClQdCNmAaXU4SrNnUXhmvXa6/a2EPTQeZGi2NqGy6BFu0gZWWPAPFq+Tc vuryAXYcsjjBH5x6jERbU5Zlqak+OytLoRPYfdCdG6kfFjt27kfRCrZChxPOKPF72Njt ES2JEivvEP9ARskT9ccIeNGIq08xedqbD5eCyxbUFyVW/hKrOKnXZ80mIaR022Cs1Zo5 HcEaYCXqBzUr8NOiQA90okRuY+rxOveTNz8Vi9hZjzHTknRU3uZJlDWtUCa/42rrXauk G8Q4QPxaEUOHqZYRFzUnmsLQ+fluaxk+tIlEvZB1LAlHCJsn3HLygYcuQJHCB/hYzwI2 AjGQ== 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=XAIyeA7URHRc9R78H/YlOyhbX6NAYtvfVcML/GjO4L4=; b=HmG2PHqGUlDi/lFuFK3BK9Gmex9HIfDgvqmPe7EfiIM5NfSbDxaudxsMHw+t3w/Byn XHUXuW94KNpS94vRgYSfvHUG4qULX5/jJ5egG4dTA59YcBkEebre7p3TA9Un+UivQXEQ AIc6+82spUTdQdtEy9hM0olnKVHCGBDx6HNnQ5dK7Pv2+QWjcgt6ZqrizUOI8I3M1GQD mLF1/vw+YzNQ7YD6uuXSupexEF8HJ30x1ZJI7YEhXUnZ2cRPXF4dw4TdoVCF1g2G9KvP GxnB08fn5dcoYFLGb2E6tjY2WsL3v2fui6SKcGqmKLoxaufxg+eESTDGN5X67NHocQEn RCow== X-Gm-Message-State: ANoB5pnTrvQTCJKqeECCPJGcloFKpF4tSyMjHxl+jJsVxvwXuq/8Wel6 q5RZah6hZTwXdYN1AIUjoncBm+8Hi5ZVIHpQlMc= X-Google-Smtp-Source: AA0mqf6CQW2ywvR7uK/ygLG+pmvoIbdMJ2RuSzhp4huVtjGlIcv4eaEXV+HaEby4lTrHIo7h5PtjGA== X-Received: by 2002:a5d:4312:0:b0:241:997a:4f57 with SMTP id h18-20020a5d4312000000b00241997a4f57mr5985153wrq.39.1670687745326; Sat, 10 Dec 2022 07:55:45 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id w18-20020adfee52000000b00236883f2f5csm4180686wro.94.2022.12.10.07.55.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 10 Dec 2022 07:55:44 -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 7/7] hw/mips/malta: Use bootloader generator API for nanoMIPS CPUs Date: Sat, 10 Dec 2022 16:55:02 +0100 Message-Id: <20221210155502.74609-8-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::42b; envelope-from=philmd@linaro.org; helo=mail-wr1-x42b.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Similarly to how commit 0c8427baf0 ("hw/mips/malta: Use bootloader helper to set BAR registers") converted write_bootloader(), convert the equivalent write_bootloader_nanomips(), allowing us to modify the bootloader code more easily in the future. Signed-off-by: Philippe Mathieu-Daudé --- hw/mips/malta.c | 148 ++++++++++++------------------------------------ 1 file changed, 35 insertions(+), 113 deletions(-) diff --git a/hw/mips/malta.c b/hw/mips/malta.c index 944730af98..d0da0b71eb 100644 --- a/hw/mips/malta.c +++ b/hw/mips/malta.c @@ -614,6 +614,7 @@ static void write_bootloader_nanomips(uint8_t *base, uint64_t run_addr, uint64_t kernel_entry) { uint16_t *p; + void *v; /* Small bootloader */ p = (uint16_t *)base; @@ -682,123 +683,44 @@ static void write_bootloader_nanomips(uint8_t *base, uint64_t run_addr, stw_p(p++, 0x80e7); stw_p(p++, NM_LO(loaderparams.ram_low_size)); /* ori a3,a3,%lo(loaderparams.ram_low_size) */ - /* - * Load BAR registers as done by YAMON: - * - * - set up PCI0 I/O BARs from 0x18000000 to 0x181fffff - * - set up PCI0 MEM0 at 0x10000000, size 0x8000000 - * - set up PCI0 MEM1 at 0x18200000, size 0xbe00000 - * - */ - stw_p(p++, 0xe040); stw_p(p++, 0x0681); - /* lui t1, %hi(0xb4000000) */ - #if TARGET_BIG_ENDIAN - - stw_p(p++, 0xe020); stw_p(p++, 0x0be1); - /* lui t0, %hi(0xdf000000) */ - - /* 0x68 corresponds to GT_ISD (from hw/mips/gt64xxx_pci.c) */ - stw_p(p++, 0x8422); stw_p(p++, 0x9068); - /* sw t0, 0x68(t1) */ - - stw_p(p++, 0xe040); stw_p(p++, 0x077d); - /* lui t1, %hi(0xbbe00000) */ - - stw_p(p++, 0xe020); stw_p(p++, 0x0801); - /* lui t0, %hi(0xc0000000) */ - - /* 0x48 corresponds to GT_PCI0IOLD */ - stw_p(p++, 0x8422); stw_p(p++, 0x9048); - /* sw t0, 0x48(t1) */ - - stw_p(p++, 0xe020); stw_p(p++, 0x0800); - /* lui t0, %hi(0x40000000) */ - - /* 0x50 corresponds to GT_PCI0IOHD */ - stw_p(p++, 0x8422); stw_p(p++, 0x9050); - /* sw t0, 0x50(t1) */ - - stw_p(p++, 0xe020); stw_p(p++, 0x0001); - /* lui t0, %hi(0x80000000) */ - - /* 0x58 corresponds to GT_PCI0M0LD */ - stw_p(p++, 0x8422); stw_p(p++, 0x9058); - /* sw t0, 0x58(t1) */ - - stw_p(p++, 0xe020); stw_p(p++, 0x07e0); - /* lui t0, %hi(0x3f000000) */ - - /* 0x60 corresponds to GT_PCI0M0HD */ - stw_p(p++, 0x8422); stw_p(p++, 0x9060); - /* sw t0, 0x60(t1) */ - - stw_p(p++, 0xe020); stw_p(p++, 0x0821); - /* lui t0, %hi(0xc1000000) */ - - /* 0x80 corresponds to GT_PCI0M1LD */ - stw_p(p++, 0x8422); stw_p(p++, 0x9080); - /* sw t0, 0x80(t1) */ - - stw_p(p++, 0xe020); stw_p(p++, 0x0bc0); - /* lui t0, %hi(0x5e000000) */ - +#define cpu_to_gt32 cpu_to_le32 #else - - stw_p(p++, 0x0020); stw_p(p++, 0x00df); - /* addiu[32] t0, $0, 0xdf */ - - /* 0x68 corresponds to GT_ISD */ - stw_p(p++, 0x8422); stw_p(p++, 0x9068); - /* sw t0, 0x68(t1) */ - - /* Use kseg2 remapped address 0x1be00000 */ - stw_p(p++, 0xe040); stw_p(p++, 0x077d); - /* lui t1, %hi(0xbbe00000) */ - - stw_p(p++, 0x0020); stw_p(p++, 0x00c0); - /* addiu[32] t0, $0, 0xc0 */ - - /* 0x48 corresponds to GT_PCI0IOLD */ - stw_p(p++, 0x8422); stw_p(p++, 0x9048); - /* sw t0, 0x48(t1) */ - - stw_p(p++, 0x0020); stw_p(p++, 0x0040); - /* addiu[32] t0, $0, 0x40 */ - - /* 0x50 corresponds to GT_PCI0IOHD */ - stw_p(p++, 0x8422); stw_p(p++, 0x9050); - /* sw t0, 0x50(t1) */ - - stw_p(p++, 0x0020); stw_p(p++, 0x0080); - /* addiu[32] t0, $0, 0x80 */ - - /* 0x58 corresponds to GT_PCI0M0LD */ - stw_p(p++, 0x8422); stw_p(p++, 0x9058); - /* sw t0, 0x58(t1) */ - - stw_p(p++, 0x0020); stw_p(p++, 0x003f); - /* addiu[32] t0, $0, 0x3f */ - - /* 0x60 corresponds to GT_PCI0M0HD */ - stw_p(p++, 0x8422); stw_p(p++, 0x9060); - /* sw t0, 0x60(t1) */ - - stw_p(p++, 0x0020); stw_p(p++, 0x00c1); - /* addiu[32] t0, $0, 0xc1 */ - - /* 0x80 corresponds to GT_PCI0M1LD */ - stw_p(p++, 0x8422); stw_p(p++, 0x9080); - /* sw t0, 0x80(t1) */ - - stw_p(p++, 0x0020); stw_p(p++, 0x005e); - /* addiu[32] t0, $0, 0x5e */ - +#define cpu_to_gt32 cpu_to_be32 #endif + v = p; - /* 0x88 corresponds to GT_PCI0M1HD */ - stw_p(p++, 0x8422); stw_p(p++, 0x9088); - /* sw t0, 0x88(t1) */ + /* move GT64120 registers from 0x14000000 to 0x1be00000 */ + bl_gen_write_u32(&v, /* GT_ISD */ + cpu_mips_phys_to_kseg1(NULL, 0x14000000 + 0x68), + cpu_to_gt32(0x1be00000 << 3)); + + /* setup MEM-to-PCI0 mapping */ + /* setup PCI0 io window to 0x18000000-0x181fffff */ + bl_gen_write_u32(&v, /* GT_PCI0IOLD */ + cpu_mips_phys_to_kseg1(NULL, 0x1be00000 + 0x48), + cpu_to_gt32(0x18000000 << 3)); + bl_gen_write_u32(&v, /* GT_PCI0IOHD */ + cpu_mips_phys_to_kseg1(NULL, 0x1be00000 + 0x50), + cpu_to_gt32(0x08000000 << 3)); + /* setup PCI0 mem windows */ + bl_gen_write_u32(&v, /* GT_PCI0M0LD */ + cpu_mips_phys_to_kseg1(NULL, 0x1be00000 + 0x58), + cpu_to_gt32(0x10000000 << 3)); + bl_gen_write_u32(&v, /* GT_PCI0M0HD */ + cpu_mips_phys_to_kseg1(NULL, 0x1be00000 + 0x60), + cpu_to_gt32(0x07e00000 << 3)); + + bl_gen_write_u32(&v, /* GT_PCI0M1LD */ + cpu_mips_phys_to_kseg1(NULL, 0x1be00000 + 0x80), + cpu_to_gt32(0x18200000 << 3)); + bl_gen_write_u32(&v, /* GT_PCI0M1HD */ + cpu_mips_phys_to_kseg1(NULL, 0x1be00000 + 0x88), + cpu_to_gt32(0x0bc00000 << 3)); + + p = (uint16_t *)v; + +#undef cpu_to_gt32 stw_p(p++, 0xe320 | NM_HI1(kernel_entry));