1. Aug 01, 2022
  2. Jul 31, 2022
  3. Jul 16, 2022
    • bors[bot]'s avatar
      Merge #104 · d50928b6
      bors[bot] authored
      
      
      104: Fix asm::delay not clobbering count register r=dkhayes117 a=adamgreig
      
      I noticed that a small example using two `asm::delay()` calls worked fine in debug mode but not in release mode. Eventually `@jamesmunns` spotted that the count register wasn't being reloaded between calls:
      
      ```
          # loads a2 with real_cyc
          400001ce:	02faf637          lui	a2,0x2faf
          400001d2:	0816061b          addiw	a2,a2,129
          # turn on led
          400001d6:	c10c              sw	a1,0(a0)
          # count down (delay impl)
          400001d8:	167d              addi	a2,a2,-1
          400001da:	fe7d              bnez	a2,400001d8 <.LBB0_8+0x30>
          # turn off led
          400001dc:	00052023          sw	zero,0(a0) # 2000000 <.Lline_table_start0+0x1fff7a4>
          # count down again (delay impl, note a2 not reloaded)
          400001e0:	167d              addi	a2,a2,-1
          400001e2:	fe7d              bnez	a2,400001e0 <.LBB0_8+0x38>
          # loop back to start
          400001e4:	bfcd              j	400001d6 <.LBB0_8+0x2e>
      ```
      
      By changing the register spec to `inout`, Rust knows the register is modified and reloads it next time. I added the nomem and nostack options too since the instructions don't touch memory or stack, to match the cortex-m impl. This change fixes codegen for my example:
      
      
      ```
          400001ce:	02faf637          lui	a2,0x2faf
          400001d2:	0816061b          addiw	a2,a2,129
          400001d6:	c10c              sw	a1,0(a0)
          400001d8:	86b2              mv	a3,a2
          400001da:	16fd              addi	a3,a3,-1
          400001dc:	fefd              bnez	a3,400001da <.LBB0_8+0x32>
          400001de:	00052023          sw	zero,0(a0) # 2000000 <.Lline_table_start0+0x1fff779>
          400001e2:	86b2              mv	a3,a2
          400001e4:	16fd              addi	a3,a3,-1
          400001e6:	fefd              bnez	a3,400001e4 <.LBB0_8+0x3c>
          400001e8:	b7fd              j	400001d6 <.LBB0_8+0x2e>
      
      ```
      
      Co-authored-by: default avatarAdam Greig <adam@adamgreig.com>
      d50928b6
    • Adam Greig's avatar
      Fix asm::delay not clobbering count register · cdd70bb4
      Adam Greig authored
      cdd70bb4
  4. Apr 21, 2022
  5. Mar 19, 2022
  6. Feb 09, 2022
  7. Jan 27, 2022
  8. Jan 09, 2022
  9. Jan 07, 2022
  10. Dec 04, 2021
    • bors[bot]'s avatar
      Merge #88 · 418c1053
      bors[bot] authored
      88: Bug fix: sfence.vma - incorrect operand order r=Disasm a=DeathWish5
      
      There is a bug about the operand order of `riscv::asm::sfence_vma(asid: usize, addr: usize)`. According to [riscv-isa-manual](https://github.com/riscv/riscv-isa-manual/blob/master/src/supervisor.tex#L1198
      
      ), the first operand should be `vaddr`, and the second be `asid`. But `riscv::asm::sfence_vma` generates assembly code in the reverse order. In fact, our rust-OS which using this instruction to flush TLB have been running into an error until we reverse the parameter order.
      I propose a simple solution which leave the function parameter order unchanged. Maybe you guys will change it to be more consistent with the specification. Anyway, let's fix this bug.
      
      
      
      Co-authored-by: default avatarDeathWish5 <zyr_ms@outlook.com>
      418c1053
  11. Dec 03, 2021