public inbox for
 help / color / mirror / Atom feed
From: Hau Hsu <>
Subject: [PATCH] RISC-V: Initialize the jvt CSR
Date: Fri,  5 Jan 2024 11:07:09 +0800	[thread overview]
Message-ID: <> (raw)

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:
 libgloss/riscv/crt0.S | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/libgloss/riscv/crt0.S b/libgloss/riscv/crt0.S
index 7a4e4e32c..187ca4a56 100644
--- a/libgloss/riscv/crt0.S
+++ b/libgloss/riscv/crt0.S
@@ -26,6 +26,19 @@ _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
+  /* Enable zicsr to set jvt.
+     Also need to exclude conflict extensions.  */
+.option push
+.option norelax
+.option arch, +zicsr
+  csrw 0x17, a0
+.option pop
   # Clear the bss segment
   la      a0, __bss_start
   la      a2, _end

             reply	other threads:[~2024-01-05  3:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-05  3:07 Hau Hsu [this message]
2024-01-05  6:49 ` Kito Cheng
  -- strict thread matches above, loose matches on Subject: below --
2023-09-25  5:36 Hau Hsu
2023-09-25  6:17 ` Kito Cheng
2023-09-27  1:17   ` Hau Hsu
2023-09-29  2:26 ` Kito Cheng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).