* [PATCH v2] RISC-V: Initialize the jvt CSR
@ 2024-01-05 7:06 Hau Hsu
2024-01-05 7:09 ` Kito Cheng
2024-01-08 12:12 ` Corinna Vinschen
0 siblings, 2 replies; 3+ messages in thread
From: Hau Hsu @ 2024-01-05 7:06 UTC (permalink / raw)
To: hau.hsu, newlib, kito.cheng
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] RISC-V: Initialize the jvt CSR
2024-01-05 7:06 [PATCH v2] RISC-V: Initialize the jvt CSR Hau Hsu
@ 2024-01-05 7:09 ` Kito Cheng
2024-01-08 12:12 ` Corinna Vinschen
1 sibling, 0 replies; 3+ messages in thread
From: Kito Cheng @ 2024-01-05 7:09 UTC (permalink / raw)
To: Hau Hsu; +Cc: newlib
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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] RISC-V: Initialize the jvt CSR
2024-01-05 7:06 [PATCH v2] RISC-V: Initialize the jvt CSR Hau Hsu
2024-01-05 7:09 ` Kito Cheng
@ 2024-01-08 12:12 ` Corinna Vinschen
1 sibling, 0 replies; 3+ messages in thread
From: Corinna Vinschen @ 2024-01-08 12:12 UTC (permalink / raw)
To: Hau Hsu; +Cc: newlib, kito.cheng
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-01-08 12:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-05 7:06 [PATCH v2] RISC-V: Initialize the jvt CSR Hau Hsu
2024-01-05 7:09 ` Kito Cheng
2024-01-08 12:12 ` Corinna Vinschen
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).