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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 94A0DC77B7D for ; Fri, 5 May 2023 08:02:37 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 56CE5846A4; Fri, 5 May 2023 10:02:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=quarantine dis=none) header.from=sifive.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 88591846A1; Fri, 5 May 2023 10:02:21 +0200 (CEST) Received: from imap5.colo.codethink.co.uk (imap5.colo.codethink.co.uk [78.40.148.171]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id BBCC1846A0 for ; Fri, 5 May 2023 10:02:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=quarantine dis=none) header.from=sifive.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ben@codethink.co.uk Received: from [167.98.27.226] (helo=rainbowdash) by imap5.colo.codethink.co.uk with esmtpsa (Exim 4.94.2 #2 (Debian)) id 1puqOH-00114H-5V; Fri, 05 May 2023 09:02:09 +0100 Received: from ben by rainbowdash with local (Exim 4.96) (envelope-from ) id 1puqOH-00036S-05; Fri, 05 May 2023 09:02:09 +0100 From: Ben Dooks To: u-boot@lists.denx.de Cc: Rick Chen , Leo , Ben Dooks Subject: [PATCH 2/3] riscv: implement local_irq_{save,restore} macros Date: Fri, 5 May 2023 09:02:06 +0100 Message-Id: <20230505080207.11902-3-ben.dooks@sifive.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230505080207.11902-1-ben.dooks@sifive.com> References: <20230505080207.11902-1-ben.dooks@sifive.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.8 at phobos.denx.de X-Virus-Status: Clean Add implementations of the local_irq_{save,restore} macros so that can be used with riscv. Signed-off-by: Ben Dooks --- arch/riscv/include/asm/system.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/arch/riscv/include/asm/system.h b/arch/riscv/include/asm/system.h index 9d8e43e394..78093681e5 100644 --- a/arch/riscv/include/asm/system.h +++ b/arch/riscv/include/asm/system.h @@ -7,15 +7,22 @@ #ifndef __ASM_RISCV_SYSTEM_H #define __ASM_RISCV_SYSTEM_H +#include + struct event; /* - * Interrupt configuring macros. - * - * TODO - * + * Interupt configuration macros */ +#define local_irq_save(__flags) do { \ + __flags = csr_read_clear(CSR_SSTATUS, SR_SIE) & SR_SIE; \ + } while (0) + +#define local_irq_restore(__flags) do { \ + csr_set(CSR_SSTATUS, __flags & SR_SIE); \ + } while(0) + /* Hook to set up the CPU (called from SPL too) */ int riscv_cpu_setup(void *ctx, struct event *event); -- 2.39.2