From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 04582385842D; Mon, 8 Jan 2024 12:12:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 04582385842D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1704715948; bh=yFU/yGMgXtfIStNkvf/GEZYF5qZOR9pYeypMITQpfF4=; h=From:To:Subject:Date:From; b=JGKhSrXvq2hIhxhf4q7VqeA1DzWGkNtUJW5R9P+qMsTKJp7mhlbSpUOpvNq32eZsD ZITgZvMWv/3SfV9xjP76ed58rQaYXGebBGGNk5Ywe3U6rpXuuz7XH3Nfb7udKGlC6p +1imrDRBd2JbCndN2oonStqE37UHtjvOiXIMRylw= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: newlib-cvs@sourceware.org Subject: [newlib-cygwin/main] RISC-V: Initialize the jvt CSR X-Act-Checkin: newlib-cygwin X-Git-Author: Hau Hsu X-Git-Refname: refs/heads/main X-Git-Oldrev: 94d871eeac43657090138653ececd49dc97ee631 X-Git-Newrev: 573458e7fc4f5247874b139a17e7e54827c92440 Message-Id: <20240108121228.04582385842D@sourceware.org> Date: Mon, 8 Jan 2024 12:12:27 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D573458e7fc4= f5247874b139a17e7e54827c92440 commit 573458e7fc4f5247874b139a17e7e54827c92440 Author: Hau Hsu AuthorDate: Fri Jan 5 15:06:39 2024 +0800 Commit: Corinna Vinschen CommitDate: Mon Jan 8 13:12:06 2024 +0100 RISC-V: Initialize the jvt CSR =20 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. =20 Also use csr number directly instead of using symbolic name to prevent = the backward incompatible issue. =20 psabi reference: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/2d770815dc9a8= b11e61ea1abd487cb25ee56ad5e/riscv-elf.adoc#table-jump-relaxation Diff: --- libgloss/riscv/crt0.S | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libgloss/riscv/crt0.S b/libgloss/riscv/crt0.S index 7a4e4e32c146..f1c5419a5eb4 100644 --- a/libgloss/riscv/crt0.S +++ b/libgloss/riscv/crt0.S @@ -26,6 +26,17 @@ _start: addi gp, gp, %pcrel_lo(1b) .option pop =20 + /* 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