From patchwork Mon Sep 19 11:49:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kautuk Consul X-Patchwork-Id: 1679378 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=dz7dJj6W; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MWNJ91CnNz1yp7 for ; Mon, 19 Sep 2022 21:49:29 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CE44B84C20; Mon, 19 Sep 2022 13:49:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="dz7dJj6W"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 90F1D84C25; Mon, 19 Sep 2022 13:49:23 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E735584A8E for ; Mon, 19 Sep 2022 13:49:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=kconsul@ventanamicro.com Received: by mail-pj1-x1033.google.com with SMTP id d64-20020a17090a6f4600b00202ce056566so6832369pjk.4 for ; Mon, 19 Sep 2022 04:49:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=2dKDYWKfFY0DxfLMnKzDyzKlxbDlz5GW5w7N+hCYmtU=; b=dz7dJj6WroeWsDkCm3pxlEJFAnxohe23VkjWLpFS4Y7NS22MUxi7as75SzXXWnFAN2 wLuYigzAQETUVS9Hp1rV0rdaqBMJ4pZjES+fEWcYuF+tl2JxS5PBwkS2Q2x5azhDOKTi 0I4dYjzvvO21bbgZUg8DLc4+evIAsny0QcjOZse1eX7IDUKSEKnaAPs0ewTak4gN5llG 8HXrk6d6dJxHAGmxajHzPdwEG1ZICBTS2TIeF78Rk6900dgHiL/6dxLwWJKJuGD8Tak7 lS9VeCzE/tANoWicwfg21NAV1F4MMiyrLfDPUCueQ2VpNxsgo/ssGa+SBBcYWfSYkVia Swzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=2dKDYWKfFY0DxfLMnKzDyzKlxbDlz5GW5w7N+hCYmtU=; b=f/hIWLGMndi1BmJg1x8CbdjmUXwAOOVlHuRcds3yK1Z+duYsmQL5FXEIrNc2gL6OJK 0Mh7HR9DXMH0Lgx9m+2NM5QhcZhgNLZNl60RZCkG5UxvFoBKCDYGS1wEl0I3PD3JP7wc fT/KDInATWsf4X+ZkCab9zcPia8gcCDJ//VDRNrlGiSw3MEqPtJxQ0I7jBZls0TL06du aSZ8NRQyxmJa+YufFsoNLwEKjQZ6bT2Rxa7uBECVIBcMw/5G0H7YYwA8L0zMyZ1uDF8Z TOAArAtGXHS8dcxfc/Dl4Gz3MRnI0U1uCB/mgz4ESpWQrypjwNT6yy7P2eXhbGuTU9O2 zZRg== X-Gm-Message-State: ACrzQf173EJnlyXUFA/wVjZ+hO/PEecwI/SdDhou6N1X0i6OtGMb3jCH 6w2too8l9z63QvZ0Zz8+y5byMg== X-Google-Smtp-Source: AMsMyM6HCNCIWO9YJLfE9XHWm1wl9VK7Uqr+Xm/KCQqrA7vV0vA+IYDLzCg6X+uRIRlEiwnoJLIRJQ== X-Received: by 2002:a17:902:c3c5:b0:178:7c2a:72af with SMTP id j5-20020a170902c3c500b001787c2a72afmr12525444plj.157.1663588159246; Mon, 19 Sep 2022 04:49:19 -0700 (PDT) Received: from performance-PowerEdge-T440.. ([103.97.165.210]) by smtp.googlemail.com with ESMTPSA id x7-20020a17090a8a8700b001fd77933fb3sm6650803pjn.17.2022.09.19.04.49.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 04:49:18 -0700 (PDT) From: Kautuk Consul To: Rayagonda Kokatanur , Sean Anderson , Rick Chen , Leo , Simon Glass , Heinrich Schuchardt , Ilias Apalodimas , Alexandru Gagniuc , Philippe Reynes , Rasmus Villemoes , Stefan Roese , Loic Poulain , Bin Meng Cc: u-boot@lists.denx.de, Kautuk Consul Subject: [PATCH v4 0/3] Add riscv semihosting support in u-boot Date: Mon, 19 Sep 2022 17:19:05 +0530 Message-Id: <20220919114908.2780149-1-kconsul@ventanamicro.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Semihosting is a mechanism that enables code running on a target to communicate and use the Input/Output facilities on a host computer that is running a debugger. This patchset adds support for semihosting in u-boot for RISCV64 targets. CHANGES since v2 and v3: - v2: Move the arch/arm/Kconfig common *SEMIHOSTING* config options from arch/arm/Kconfig to lib/Kconfig. - v2: Improve the *SEMIHOSTING_FALLBACK config options in lib/Kconfig to depend on RISCV or ARM64. - v2: Remove the arch/riscv/include/asm/semhosting.h file. - v2: Improve the arch/riscv/lib/semihosting.c by removing the jump statement and moving the .align 4 to before the 2 .option directives. - v3: Additionally check for the RISCV config option in the "depends" of the SPL_SEMIHOSTING_FALLBACK config option in lib/Kconfig. Compilation and test commands for SPL and S-mode configurations ================================================================= U-Boot S-mode on QEMU virt ---------------------------- // Compilation of S-mode u-boot ARCH=riscv CROSS_COMPILE=riscv64-unknown-linux-gnu- make qemu-riscv64_smode_defconfig make // Run riscv 64-bit u-boot with opensbi on qemu qemu-system-riscv64 -M virt -m 256M -display none -serial stdio -bios\ opensbi/build/platform/generic/firmware/fw_jump.bin -kernel\ u-boot/u-boot.bin U-Boot SPL on QEMU virt ------------------------ // Compilation of u-boot-spl ARCH=riscv CROSS_COMPILE=riscv64-unknown-linux-gnu- make qemu-riscv64_spl_defconfig make OPENSBI=opensbi/build/platform/generic/firmware/fw_dynamic.bin // Run 64-bit u-boot-spl in qemu qemu-system-riscv64 -M virt -m 256M -display none -serial stdio -bios\ u-boot/spl/u-boot-spl.bin -device\ loader,file=u-boot/u-boot.itb,addr=0x80200000 Kautuk Consul (3): lib: Add common semihosting library arch/riscv: add semihosting support for RISC-V board: qemu-riscv: enable semihosting arch/arm/Kconfig | 46 ------- arch/arm/lib/semihosting.c | 181 +------------------------- arch/riscv/include/asm/spl.h | 1 + arch/riscv/lib/Makefile | 2 + arch/riscv/lib/interrupts.c | 11 ++ arch/riscv/lib/semihosting.c | 24 ++++ configs/qemu-riscv32_defconfig | 4 + configs/qemu-riscv32_smode_defconfig | 4 + configs/qemu-riscv32_spl_defconfig | 7 + configs/qemu-riscv64_defconfig | 4 + configs/qemu-riscv64_smode_defconfig | 4 + configs/qemu-riscv64_spl_defconfig | 7 + include/semihosting.h | 11 ++ lib/Kconfig | 46 +++++++ lib/Makefile | 2 + lib/semihosting.c | 186 +++++++++++++++++++++++++++ 16 files changed, 314 insertions(+), 226 deletions(-) create mode 100644 arch/riscv/lib/semihosting.c create mode 100644 lib/semihosting.c