From patchwork Wed Jan 27 06:54:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 12049075 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B5A3C433DB for ; Wed, 27 Jan 2021 06:59:11 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E74052072C for ; Wed, 27 Jan 2021 06:59:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E74052072C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=flygoat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:52862 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l4enF-0007mI-Qn for qemu-devel@archiver.kernel.org; Wed, 27 Jan 2021 01:59:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51126) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l4ej0-00047g-8A for qemu-devel@nongnu.org; Wed, 27 Jan 2021 01:54:46 -0500 Received: from new2-smtp.messagingengine.com ([66.111.4.224]:48207) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l4eiy-0000wP-FJ for qemu-devel@nongnu.org; Wed, 27 Jan 2021 01:54:46 -0500 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.nyi.internal (Postfix) with ESMTP id E98965807FE; Wed, 27 Jan 2021 01:54:43 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Wed, 27 Jan 2021 01:54:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=QtatUkRBvp19n 21lJT7urCwMg1o5Ctr05LfED+qicRw=; b=jGaUTUSRCDs953I2kBIdIeszNMkIT r8Y4rIWDuSclgFQQGtm8+IzftcJZU34MeeHpRx9+dWZjbmlyxFNByVodsDToS4mp F2tLMgB7sDVzL2SAh12UZhPCwNz5iYkwjbV7stPvFTJruO3LpeHI8WODGZe/IiWo Q+/j4TJcXvDQvPvMr4DbDw9cuG9YemnBEFAU05Yw69s7xeGGAaAAsdNFtYoZwcBV ERxLteBUs5DuYKYYRrDNDoTbuT8yrnoWbAe6dg2PXa0KJy4RpI3V9FoC8l15KCDV jIu/4e52SOiu253PvrxV3c4lnIz77pQVOa94Ax83pN0Zcr6W9uMzUn7bw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=QtatUkRBvp19n21lJT7urCwMg1o5Ctr05LfED+qicRw=; b=gGjEt2cF hRd9yutB7SUO3W7ySBK/LnfkMzQ5YjHx579Ctzl7oQY+2SGcnQiWlSTLwZMbnOn/ 3BfWbvUzDDOk4MsscWto1ZVv6dZMdbHVLARlQQVGcrivLYFnjoxjmIKUB7wj685U GY3Cls3xcAiPIqRiFtIvgVjbLAQnZk5R0zWPHoHwK4/RWPHC+vsKdgBwbBVD+8DD k6dl8NlkXT4RmkDvkVuRXthKbkwevyvqBcqmTJk3Jp+q8V7G3LJTkYQMz5gLSyZy FhN7PISJG7GJ9lADAq59NFgqqf2GPQTep7K5jZFfgXSSFVYqQG5+IWpb9HDQxe9q ZPajeqjR8NQtHQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdejgddutdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeflihgrgihu nhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomheqnecugg ftrfgrthhtvghrnhepjeeihffgteelkeelffdukedtheevudejvdegkeekjeefhffhhfet udetgfdtffeunecukfhppeduudehrdduleejrddvvdegrddvvdefnecuvehluhhsthgvrh fuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghes fhhlhihgohgrthdrtghomh X-ME-Proxy: Received: from strike.202.net.flygoat.com (unknown [115.197.224.223]) by mail.messagingengine.com (Postfix) with ESMTPA id 2B29D240064; Wed, 27 Jan 2021 01:54:39 -0500 (EST) From: Jiaxun Yang To: qemu-devel@nongnu.org Subject: [PATCH v3 3/4] hw/mips/malta: Use bootloader helper to set BAR resgiters Date: Wed, 27 Jan 2021 14:54:23 +0800 Message-Id: <20210127065424.114125-4-jiaxun.yang@flygoat.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210127065424.114125-1-jiaxun.yang@flygoat.com> References: <20210127065424.114125-1-jiaxun.yang@flygoat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=66.111.4.224; envelope-from=jiaxun.yang@flygoat.com; helo=new2-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Aleksandar Rikalo , Paul Burton , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Aurelien Jarno Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Translate embedded assembly into IO writes which is more readable. Signed-off-by: Jiaxun Yang --- hw/mips/malta.c | 68 ++++++++++++++++--------------------------------- 1 file changed, 22 insertions(+), 46 deletions(-) diff --git a/hw/mips/malta.c b/hw/mips/malta.c index ffd67b8293..9466fd1058 100644 --- a/hw/mips/malta.c +++ b/hw/mips/malta.c @@ -875,55 +875,31 @@ static void write_bootloader(uint8_t *base, uint64_t run_addr, p = (uint32_t *) (base + 0x580); /* Load BAR registers as done by YAMON */ - stl_p(p++, 0x3c09b400); /* lui t1, 0xb400 */ - -#ifdef TARGET_WORDS_BIGENDIAN - stl_p(p++, 0x3c08df00); /* lui t0, 0xdf00 */ -#else - stl_p(p++, 0x340800df); /* ori t0, r0, 0x00df */ -#endif - stl_p(p++, 0xad280068); /* sw t0, 0x0068(t1) */ - - stl_p(p++, 0x3c09bbe0); /* lui t1, 0xbbe0 */ - -#ifdef TARGET_WORDS_BIGENDIAN - stl_p(p++, 0x3c08c000); /* lui t0, 0xc000 */ -#else - stl_p(p++, 0x340800c0); /* ori t0, r0, 0x00c0 */ -#endif - stl_p(p++, 0xad280048); /* sw t0, 0x0048(t1) */ -#ifdef TARGET_WORDS_BIGENDIAN - stl_p(p++, 0x3c084000); /* lui t0, 0x4000 */ -#else - stl_p(p++, 0x34080040); /* ori t0, r0, 0x0040 */ -#endif - stl_p(p++, 0xad280050); /* sw t0, 0x0050(t1) */ - -#ifdef TARGET_WORDS_BIGENDIAN - stl_p(p++, 0x3c088000); /* lui t0, 0x8000 */ -#else - stl_p(p++, 0x34080080); /* ori t0, r0, 0x0080 */ -#endif - stl_p(p++, 0xad280058); /* sw t0, 0x0058(t1) */ -#ifdef TARGET_WORDS_BIGENDIAN - stl_p(p++, 0x3c083f00); /* lui t0, 0x3f00 */ -#else - stl_p(p++, 0x3408003f); /* ori t0, r0, 0x003f */ -#endif - stl_p(p++, 0xad280060); /* sw t0, 0x0060(t1) */ - -#ifdef TARGET_WORDS_BIGENDIAN - stl_p(p++, 0x3c08c100); /* lui t0, 0xc100 */ -#else - stl_p(p++, 0x340800c1); /* ori t0, r0, 0x00c1 */ -#endif - stl_p(p++, 0xad280080); /* sw t0, 0x0080(t1) */ + /* Bus endianess is always reversed */ #ifdef TARGET_WORDS_BIGENDIAN - stl_p(p++, 0x3c085e00); /* lui t0, 0x5e00 */ +#define cpu_to_gt32 cpu_to_le32 #else - stl_p(p++, 0x3408005e); /* ori t0, r0, 0x005e */ +#define cpu_to_gt32 cpu_to_be32 #endif - stl_p(p++, 0xad280088); /* sw t0, 0x0088(t1) */ + /* move GT64120 registers from 0x14000000 to 0x1be00000 */ + bl_gen_write_u32(&p, cpu_to_gt32(0xdf000000), + cpu_mips_phys_to_kseg1(NULL, 0x14000068)); + /* setup MEM-to-PCI0 mapping */ + /* setup PCI0 io window to 0x18000000-0x181fffff */ + bl_gen_write_u32(&p, cpu_to_gt32(0xc0000000), + cpu_mips_phys_to_kseg1(NULL, 0x1be00048)); + bl_gen_write_u32(&p, cpu_to_gt32(0x40000000), + cpu_mips_phys_to_kseg1(NULL, 0x1be00050)); + /* setup PCI0 mem windows */ + bl_gen_write_u32(&p, cpu_to_gt32(0x80000000), + cpu_mips_phys_to_kseg1(NULL, 0x1be00058)); + bl_gen_write_u32(&p, cpu_to_gt32(0x3f000000), + cpu_mips_phys_to_kseg1(NULL, 0x1be00060)); + bl_gen_write_u32(&p, cpu_to_gt32(0xc1000000), + cpu_mips_phys_to_kseg1(NULL, 0x1be00080)); + bl_gen_write_u32(&p, cpu_to_gt32(0x5e000000), + cpu_mips_phys_to_kseg1(NULL, 0x1be00088)); +#undef cpu_to_gt32 if (semihosting_get_argc()) { a0 = 0;