Message ID | 20240105070639.404903-1-hau.hsu@sifive.com |
---|---|
State | New |
Headers |
Return-Path: <newlib-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F0BF738582AD for <patchwork@sourceware.org>; Fri, 5 Jan 2024 07:07:04 +0000 (GMT) X-Original-To: newlib@sourceware.org Delivered-To: newlib@sourceware.org Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by sourceware.org (Postfix) with ESMTPS id 3CB4938582AD for <newlib@sourceware.org>; Fri, 5 Jan 2024 07:06:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3CB4938582AD Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=sifive.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3CB4938582AD Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::102e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704438409; cv=none; b=apaCywxuxfrcveVVSEA4CDD5RXrcM3Wi9lkZf+Vx/6Ezudj5KtDiaYK+LtVZvvjSCt+DeK7CRDKKGPCRolzESshF9DERtVp+tmPWXwpHV7Tdx339wjQNQ2gYGhmu46n1WPebWVbNvljv6RoMqKhbVhvLkwMi4agYhaPBsWeFu6o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704438409; c=relaxed/simple; bh=bFL+3sPpksEQTJAFTPK9X77+7pIRRjU48cGJ+4ThS7E=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=rSSXu3bTNZtIJpaafkR8O/JjRQVlp9dVsNgT/hZnw2PAMIf37JSVHOXWNl5kLlDRQ+uqytah5ry6JMHOr7z97layW101YCQB8mukJNAo/DGO3cZSmQBAouemERLNBzijxj+l54xfi3n7m5g0YhxkvVHW7giCN+V+k+6XNP7Ajjw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-28c9d424cceso217667a91.0 for <newlib@sourceware.org>; Thu, 04 Jan 2024 23:06:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1704438406; x=1705043206; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=h79YF9e2IDlPVNrSErUAMzp5zK+ot9T7kpsoG/4UUZs=; b=cM0hYhOQf7NkbJHOsAN1emq89fHYZZuuAw6zgy89g5EQbWOha7yXODVuvkwjehN+Uu 4LMvVjxPPChFxHpBlwNDPVY/c0GIutqwD2p4IAYVNbogXK/dPakS8/Yk+eqy1mQrdSVf g4vgf6m7juAcjsldArXiHSEOJQOqfKLGYSHwjTY57Cs3pCGY1kdyHu8QqKUdk+pOQSv0 llyIxOTM8yzHCOqgVU7WasqV2Br0aoC+p5PQ8NJR1UvW+HrQqMoqSZtbKxvbTksPmyKn rsQs4jns69q62DodXoyoG0NMWFHJAhhJPLAwSru09SN00DMePRlWVtkkwxN0I5D41ACq /Cgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704438406; x=1705043206; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=h79YF9e2IDlPVNrSErUAMzp5zK+ot9T7kpsoG/4UUZs=; b=AkTGkI5fPw1af80FgC+2OgiY34srsINEfWSFXmTK9Xdv1zUVnFY13hlyrU40gu+m4Z FaEED/iMtLoaXtpBo2KJEpHSaemz9yOwGtNd432BoXZFgS4rdGvj52reo267W8AzyMXZ HFeRcm1YsddPxNq14qmUl4Ig0cR4BgtXr/2E+LXDaF4T/Vfe7akbMqasK+RpjoO8Q8eS Airg0OUViudeOT5MzPY2CxNs9zko3A3KDfj2mjsuYvERk8xFX8hufnXidoFNAGY9ryum LASYrFTyJkzE9igVtY2ClWS0mtnAnLRbqsP5CCRkO2jG9NjOGJOmS6E+5GsrhlZ9IhIY 58cQ== X-Gm-Message-State: AOJu0YzoqZMHFU3Ae1xc41tXGdq/lk+RER6qBYG5f5YWwTKSDkarFeia o9iGZHR7AwlIzcEtUt3GWT15k1eAOecmrU932S+9A68lZTEJ3w== X-Google-Smtp-Source: AGHT+IFO17u1w0jKFOEYzCVO7Dws6dxKPH7Bt+9jDEubvuTEu4Kvs407TvnCPO7ru5wcV3eqmB256w== X-Received: by 2002:a17:90a:4a8b:b0:28c:8d6b:2efb with SMTP id f11-20020a17090a4a8b00b0028c8d6b2efbmr2024396pjh.30.1704438406136; Thu, 04 Jan 2024 23:06:46 -0800 (PST) Received: from sw05.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id rr7-20020a17090b2b4700b0028b2262e0cdsm480272pjb.56.2024.01.04.23.06.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 23:06:43 -0800 (PST) From: Hau Hsu <hau.hsu@sifive.com> To: hau.hsu@sifive.com, newlib@sourceware.org, kito.cheng@gmail.com Subject: [PATCH v2] RISC-V: Initialize the jvt CSR Date: Fri, 5 Jan 2024 15:06:39 +0800 Message-Id: <20240105070639.404903-1-hau.hsu@sifive.com> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Newlib mailing list <newlib.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/newlib>, <mailto:newlib-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/newlib/> List-Post: <mailto:newlib@sourceware.org> List-Help: <mailto:newlib-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/newlib>, <mailto:newlib-request@sourceware.org?subject=subscribe> Errors-To: newlib-bounces+patchwork=sourceware.org@sourceware.org |
Series |
[v2] RISC-V: Initialize the jvt CSR
|
|
Commit Message
Hau Hsu
Jan. 5, 2024, 7:06 a.m. UTC
Set symbol '__jvt_base$' as weak. So if the symbol is not set in the linker script, the address would be 0. We initialize jvt CSR only if the address is not 0. Also use csr number directly instead of using symbolic name to prevent the backward incompatible issue. psabi reference: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/2d770815dc9a8b11e61ea1abd487cb25ee56ad5e/riscv-elf.adoc#table-jump-relaxation --- libgloss/riscv/crt0.S | 11 +++++++++++ 1 file changed, 11 insertions(+)
Comments
LGTM On Fri, Jan 5, 2024 at 3:07 PM Hau Hsu <hau.hsu@sifive.com> wrote: > > Set symbol '__jvt_base$' as weak. So if the symbol is not set in the > linker script, the address would be 0. We initialize jvt CSR only if > the address is not 0. > > Also use csr number directly instead of using symbolic name to prevent the > backward incompatible issue. > > psabi reference: > https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/2d770815dc9a8b11e61ea1abd487cb25ee56ad5e/riscv-elf.adoc#table-jump-relaxation > --- > libgloss/riscv/crt0.S | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/libgloss/riscv/crt0.S b/libgloss/riscv/crt0.S > index 7a4e4e32c..f1c5419a5 100644 > --- a/libgloss/riscv/crt0.S > +++ b/libgloss/riscv/crt0.S > @@ -26,6 +26,17 @@ _start: > addi gp, gp, %pcrel_lo(1b) > .option pop > > + /* Initialize jvt CSR (reg addr: 0x0017) */ > + .weak __jvt_base$ > + lla a0, __jvt_base$ > + beqz a0, .Ljvt_init_end > +.option push > +.option norelax > +.option arch, +zicsr > + csrw 0x17, a0 > +.option pop > +.Ljvt_init_end: > + > # Clear the bss segment > la a0, __bss_start > la a2, _end > -- > 2.37.1 >
On Jan 5 15:06, Hau Hsu wrote: > Set symbol '__jvt_base$' as weak. So if the symbol is not set in the > linker script, the address would be 0. We initialize jvt CSR only if > the address is not 0. > > Also use csr number directly instead of using symbolic name to prevent the > backward incompatible issue. > > psabi reference: > https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/2d770815dc9a8b11e61ea1abd487cb25ee56ad5e/riscv-elf.adoc#table-jump-relaxation > --- > libgloss/riscv/crt0.S | 11 +++++++++++ > 1 file changed, 11 insertions(+) Pushed. Thanks, Corinna
diff --git a/libgloss/riscv/crt0.S b/libgloss/riscv/crt0.S index 7a4e4e32c..f1c5419a5 100644 --- a/libgloss/riscv/crt0.S +++ b/libgloss/riscv/crt0.S @@ -26,6 +26,17 @@ _start: addi gp, gp, %pcrel_lo(1b) .option pop + /* Initialize jvt CSR (reg addr: 0x0017) */ + .weak __jvt_base$ + lla a0, __jvt_base$ + beqz a0, .Ljvt_init_end +.option push +.option norelax +.option arch, +zicsr + csrw 0x17, a0 +.option pop +.Ljvt_init_end: + # Clear the bss segment la a0, __bss_start la a2, _end