使用板子是全志d1,实现一个riscv64的操作系统,在mmu这一部分实现时遇到一个问题,通过opensbi启动之后,系统进入s模式,然后尝试更改satp的mode字段为8,既实现SV39模式,但尝试多次无法更改satp.mode,只能保持默认的0,但是satp的其他字段是可以更改的,使用代码如下
# set MODE to SV39 (8)
li t0, 8
slli t0, t0, 60
# Right shift the address in the t1 register by 12 bits to get the PFN
li t1, 0x80000000
srli t1, t1, 12
# Combine MODE and PFN
or t1, t1, t0
# Set the satp register to SV39 mode, and set the page table base address at the same time
csrw satp, t1
# Execute the sfence.vma instruction to flush the TLB
sfence.vma x0, x0