Skip to content

Instantly share code, notes, and snippets.

@heatd
Created January 29, 2022 16:46
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/199cc2f7441a85dab05adf82b0b902b2 to your computer and use it in GitHub Desktop.
Save heatd/199cc2f7441a85dab05adf82b0b902b2 to your computer and use it in GitHub Desktop.
lla t0, boot_page_tables
mv t1, t0
lui t3, 4096
add t0, t0, t3
mv t2, t0
ori t2, t2, 1
sd t2, 511(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
sd t4, 510(t2)
li t4, 0x90000000
ori t4, t4, 0xf
sd t4, 511(t2)
srli t1, t1, 12
li t5, 9 << 60
or t1, t1, t5
csrw satp, t1
li t0, (1 << 11)
csrw mstatus, t0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment