Skip to content

Instantly share code, notes, and snippets.

@heatd
Created January 29, 2022 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heatd/59fc0131bdbcd2e299f296add28557ef to your computer and use it in GitHub Desktop.
Save heatd/59fc0131bdbcd2e299f296add28557ef to your computer and use it in GitHub Desktop.
lla t0, boot_page_tables
mv t1, t0
li t3, 4096
add t0, t0, t3
mv t2, t0
add t0, t0, t3
mv t6, t0
ori t0, t2, 1
addi a1, t1, 2044
sd t0, 2044(a1)
ori t0, t6, 1
sd t0, 0(t1)
# Map the first 2GB of DRAM on 0xffffffff80000000 such that we end up executing on -2GB
li t4, 0x80000000
ori t4, t4, 0xf # 0xf = valid, readable, writeable and executable
addi a1, t2, 2044
sd t4, 2036(a1)
sd t4, 16(t6)
li t4, 0x90000000
ori t4, t4, 0xf
addi a1, t2, 2044
sd t4, 2044(a1)
sd t4, 24(t6)
srli t1, t1, 12
li t5, 9 << 60
or t1, t1, t5
csrw satp, t1
li t0, (1 << 11)
csrw mstatus, t0
la t1, 1f
csrw mepc, t1
mret
1:
j .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment