Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

riscv-rt: Assembly algorithm for RAM init incompatible with upcoming RVE extension (future proofing) #189

Open
hegza opened this issue Feb 23, 2024 · 1 comment
Milestone

Comments

@hegza
Copy link

hegza commented Feb 23, 2024

The RAM init function is incompatible with (as of yet, unratified) RV32E base ISA.

riscv/riscv-rt/src/asm.rs

Lines 147 to 158 in f5a2da9

// Copy .data from flash to RAM
la t0, _sdata
la t2, _edata
la t1, _sidata
bgeu t0, t2, 2f
1: ",
#[cfg(target_arch = "riscv32")]
"lw t3, 0(t1)
addi t1, t1, 4
sw t3, 0(t0)
addi t0, t0, 4
bltu t0, t2, 1b",

The algorithm uses temporaries t0--t3 to copy data from from flash to RAM. However, the RV32E removes registers x16--x31, which includes t3 / x28, therefore making this algorithm unavailable on RVE.

Proposals for a solution

  1. We could pick another register in range x0--x16 in place of t3 to make the code compatible between RVI and RVE
  2. We could #[cfg(riscve)] the algorithm to use another register on RV32E.
@romancardenas
Copy link
Contributor

I personally prefer using another register that fits all the specifications

@hegza hegza changed the title Assembly algorithm for RAM init incompatible with upcoming RVE extension (future proofing) riscv-rt: Assembly algorithm for RAM init incompatible with upcoming RVE extension (future proofing) Feb 25, 2024
@romancardenas romancardenas added this to the riscv 0.13.0 milestone Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants