diff --git a/src/main/scala/vexriscv/demo/GenZephyr.scala b/src/main/scala/vexriscv/demo/GenZephyr.scala index b9d0c7a..4666ec4 100644 --- a/src/main/scala/vexriscv/demo/GenZephyr.scala +++ b/src/main/scala/vexriscv/demo/GenZephyr.scala @@ -5,11 +5,12 @@ import vexriscv.ip.{DataCacheConfig, InstructionCacheConfig} import vexriscv.{plugin, VexRiscv, VexRiscvConfig} import spinal.core._ -object GenZephyr extends App{ +object GenZephyr extends App { def cpu() = new VexRiscv( config = VexRiscvConfig( plugins = List( new IBusCachedPlugin( + resetVector = 0x80000000l, prediction = STATIC, config = InstructionCacheConfig( cacheSize = 4096, diff --git a/src/main/scala/vexriscv/plugin/PmpPlugin.scala b/src/main/scala/vexriscv/plugin/PmpPlugin.scala index 96599e0..2d727fd 100644 --- a/src/main/scala/vexriscv/plugin/PmpPlugin.scala +++ b/src/main/scala/vexriscv/plugin/PmpPlugin.scala @@ -153,8 +153,8 @@ class PmpPlugin(regions : Int, ioRange : UInt => Bool) extends Plugin[VexRiscv] pmps += PmpRegister() csrService.rw(0x3b0 + i, pmps(i).csr.addr) csrService.onWrite(0x3b0 + i) { - execute.arbitration.flushNext := True - redoInterface.valid := True + //execute.arbitration.flushNext := True + //redoInterface.valid := True } } @@ -173,8 +173,8 @@ class PmpPlugin(regions : Int, ioRange : UInt => Bool) extends Plugin[VexRiscv] 1 -> pmps((i * 4) ).csr.w, 0 -> pmps((i * 4) ).csr.r ) csrService.onWrite(0x3a0 + i) { - execute.arbitration.flushNext := True - redoInterface.valid := True + //execute.arbitration.flushNext := True + //redoInterface.valid := True } } diff --git a/src/test/cpp/raw/pmp/.gdbinit b/src/test/cpp/raw/pmp/.gdbinit new file mode 100644 index 0000000..45fceb2 --- /dev/null +++ b/src/test/cpp/raw/pmp/.gdbinit @@ -0,0 +1,3 @@ +target remote localhost:3333 +monitor reset halt +load diff --git a/src/test/cpp/raw/pmp/build/pmp.asm b/src/test/cpp/raw/pmp/build/pmp.asm index 9d5dddf..d625d87 100644 --- a/src/test/cpp/raw/pmp/build/pmp.asm +++ b/src/test/cpp/raw/pmp/build/pmp.asm @@ -8,163 +8,159 @@ Disassembly of section .crt_section: 80000000: 00000097 auipc ra,0x0 80000004: 01008093 addi ra,ra,16 # 80000010 80000008: 30509073 csrw mtvec,ra -8000000c: 0240006f j 80000030 +8000000c: 00c0006f j 80000018 80000010 : 80000010: 341f1073 csrw mepc,t5 80000014: 30200073 mret -80000018 : -80000018: 00014137 lui sp,0x14 -8000001c: 30013073 csrc mstatus,sp -80000020: 20000113 li sp,512 -80000024: 30012073 csrs mstatus,sp -80000028: 341e9073 csrw mepc,t4 -8000002c: 30200073 mret - -80000030 : -80000030: 00000e13 li t3,0 -80000034: 00000f17 auipc t5,0x0 -80000038: 1f0f0f13 addi t5,t5,496 # 80000224 -8000003c: 800000b7 lui ra,0x80000 -80000040: 80008237 lui tp,0x80008 -80000044: deadc137 lui sp,0xdeadc -80000048: eef10113 addi sp,sp,-273 # deadbeef -8000004c: 0020a023 sw sp,0(ra) # 80000000 -80000050: 00222023 sw sp,0(tp) # 80008000 -80000054: 0000a183 lw gp,0(ra) -80000058: 1c311663 bne sp,gp,80000224 -8000005c: 00022183 lw gp,0(tp) # 0 <_start-0x80000000> -80000060: 1c311263 bne sp,gp,80000224 -80000064: 071a12b7 lui t0,0x71a1 -80000068: 80828293 addi t0,t0,-2040 # 71a0808 <_start-0x78e5f7f8> -8000006c: 3a029073 csrw pmpcfg0,t0 -80000070: 191c02b7 lui t0,0x191c0 -80000074: 50428293 addi t0,t0,1284 # 191c0504 <_start-0x66e3fafc> -80000078: 3a129073 csrw pmpcfg1,t0 -8000007c: 01800293 li t0,24 -80000080: 3a229073 csrw pmpcfg2,t0 -80000084: 0f1e22b7 lui t0,0xf1e2 -80000088: 90028293 addi t0,t0,-1792 # f1e1900 <_start-0x70e1e700> -8000008c: 3a329073 csrw pmpcfg3,t0 -80000090: 200002b7 lui t0,0x20000 -80000094: 3b029073 csrw pmpaddr0,t0 -80000098: fff00293 li t0,-1 -8000009c: 3b129073 csrw pmpaddr1,t0 -800000a0: 200022b7 lui t0,0x20002 -800000a4: 3b229073 csrw pmpaddr2,t0 +80000018 : +80000018: 00000e13 li t3,0 +8000001c: 00000f17 auipc t5,0x0 +80000020: 1f4f0f13 addi t5,t5,500 # 80000210 +80000024: 800000b7 lui ra,0x80000 +80000028: 80008237 lui tp,0x80008 +8000002c: deadc137 lui sp,0xdeadc +80000030: eef10113 addi sp,sp,-273 # deadbeef +80000034: 0020a023 sw sp,0(ra) # 80000000 +80000038: 00222023 sw sp,0(tp) # 80008000 +8000003c: 0000a183 lw gp,0(ra) +80000040: 1c311863 bne sp,gp,80000210 +80000044: 00022183 lw gp,0(tp) # 0 <_start-0x80000000> +80000048: 1c311463 bne sp,gp,80000210 +8000004c: 071212b7 lui t0,0x7121 +80000050: 80828293 addi t0,t0,-2040 # 7120808 <_start-0x78edf7f8> +80000054: 3a029073 csrw pmpcfg0,t0 +80000058: 191f02b7 lui t0,0x191f0 +8000005c: 30428293 addi t0,t0,772 # 191f0304 <_start-0x66e0fcfc> +80000060: 3a129073 csrw pmpcfg1,t0 +80000064: 01800293 li t0,24 +80000068: 3a229073 csrw pmpcfg2,t0 +8000006c: 0f1e22b7 lui t0,0xf1e2 +80000070: 90028293 addi t0,t0,-1792 # f1e1900 <_start-0x70e1e700> +80000074: 3a329073 csrw pmpcfg3,t0 +80000078: 200002b7 lui t0,0x20000 +8000007c: 3b029073 csrw pmpaddr0,t0 +80000080: fff00293 li t0,-1 +80000084: 3b129073 csrw pmpaddr1,t0 +80000088: 200022b7 lui t0,0x20002 +8000008c: 3b229073 csrw pmpaddr2,t0 +80000090: 200042b7 lui t0,0x20004 +80000094: fff28293 addi t0,t0,-1 # 20003fff <_start-0x5fffc001> +80000098: 3b329073 csrw pmpaddr3,t0 +8000009c: 200042b7 lui t0,0x20004 +800000a0: fff28293 addi t0,t0,-1 # 20003fff <_start-0x5fffc001> +800000a4: 3b429073 csrw pmpaddr4,t0 800000a8: 200042b7 lui t0,0x20004 800000ac: fff28293 addi t0,t0,-1 # 20003fff <_start-0x5fffc001> -800000b0: 3b329073 csrw pmpaddr3,t0 -800000b4: 200042b7 lui t0,0x20004 -800000b8: fff28293 addi t0,t0,-1 # 20003fff <_start-0x5fffc001> -800000bc: 3b429073 csrw pmpaddr4,t0 +800000b0: 3b529073 csrw pmpaddr5,t0 +800000b4: 200022b7 lui t0,0x20002 +800000b8: fff28293 addi t0,t0,-1 # 20001fff <_start-0x5fffe001> +800000bc: 3b629073 csrw pmpaddr6,t0 800000c0: 200042b7 lui t0,0x20004 800000c4: fff28293 addi t0,t0,-1 # 20003fff <_start-0x5fffc001> -800000c8: 3b529073 csrw pmpaddr5,t0 -800000cc: 200022b7 lui t0,0x20002 -800000d0: fff28293 addi t0,t0,-1 # 20001fff <_start-0x5fffe001> -800000d4: 3b629073 csrw pmpaddr6,t0 -800000d8: 200042b7 lui t0,0x20004 -800000dc: fff28293 addi t0,t0,-1 # 20003fff <_start-0x5fffc001> -800000e0: 3b729073 csrw pmpaddr7,t0 -800000e4: 200042b7 lui t0,0x20004 -800000e8: fff28293 addi t0,t0,-1 # 20003fff <_start-0x5fffc001> -800000ec: 3b829073 csrw pmpaddr8,t0 +800000c8: 3b729073 csrw pmpaddr7,t0 +800000cc: 200042b7 lui t0,0x20004 +800000d0: fff28293 addi t0,t0,-1 # 20003fff <_start-0x5fffc001> +800000d4: 3b829073 csrw pmpaddr8,t0 +800000d8: 00000293 li t0,0 +800000dc: 3b929073 csrw pmpaddr9,t0 +800000e0: 00000293 li t0,0 +800000e4: 3ba29073 csrw pmpaddr10,t0 +800000e8: 00000293 li t0,0 +800000ec: 3bb29073 csrw pmpaddr11,t0 800000f0: 00000293 li t0,0 -800000f4: 3b929073 csrw pmpaddr9,t0 +800000f4: 3bc29073 csrw pmpaddr12,t0 800000f8: 00000293 li t0,0 -800000fc: 3ba29073 csrw pmpaddr10,t0 +800000fc: 3bd29073 csrw pmpaddr13,t0 80000100: 00000293 li t0,0 -80000104: 3bb29073 csrw pmpaddr11,t0 +80000104: 3be29073 csrw pmpaddr14,t0 80000108: 00000293 li t0,0 -8000010c: 3bc29073 csrw pmpaddr12,t0 -80000110: 00000293 li t0,0 -80000114: 3bd29073 csrw pmpaddr13,t0 -80000118: 00000293 li t0,0 -8000011c: 3be29073 csrw pmpaddr14,t0 -80000120: 00000293 li t0,0 -80000124: 3bf29073 csrw pmpaddr15,t0 -80000128: 00c10137 lui sp,0xc10 -8000012c: fee10113 addi sp,sp,-18 # c0ffee <_start-0x7f3f0012> -80000130: 0020a023 sw sp,0(ra) -80000134: 00222023 sw sp,0(tp) # 0 <_start-0x80000000> -80000138: 0000a183 lw gp,0(ra) -8000013c: 0e311463 bne sp,gp,80000224 -80000140: 00022183 lw gp,0(tp) # 0 <_start-0x80000000> -80000144: 0e311063 bne sp,gp,80000224 +8000010c: 3bf29073 csrw pmpaddr15,t0 +80000110: 00c10137 lui sp,0xc10 +80000114: fee10113 addi sp,sp,-18 # c0ffee <_start-0x7f3f0012> +80000118: 0020a023 sw sp,0(ra) +8000011c: 00222023 sw sp,0(tp) # 0 <_start-0x80000000> +80000120: 0000a183 lw gp,0(ra) +80000124: 0e311663 bne sp,gp,80000210 +80000128: 00000193 li gp,0 +8000012c: 00022183 lw gp,0(tp) # 0 <_start-0x80000000> +80000130: 0e311063 bne sp,gp,80000210 -80000148 : -80000148: 00100e13 li t3,1 -8000014c: 00000f17 auipc t5,0x0 -80000150: 0d8f0f13 addi t5,t5,216 # 80000224 -80000154: 079a12b7 lui t0,0x79a1 -80000158: 80828293 addi t0,t0,-2040 # 79a0808 <_start-0x7865f7f8> -8000015c: 3a029073 csrw pmpcfg0,t0 -80000160: deadc137 lui sp,0xdeadc -80000164: eef10113 addi sp,sp,-273 # deadbeef -80000168: 00222023 sw sp,0(tp) # 0 <_start-0x80000000> +80000134 : +80000134: 00100e13 li t3,1 +80000138: 00000f17 auipc t5,0x0 +8000013c: 0d8f0f13 addi t5,t5,216 # 80000210 +80000140: 079212b7 lui t0,0x7921 +80000144: 80828293 addi t0,t0,-2040 # 7920808 <_start-0x786df7f8> +80000148: 3a029073 csrw pmpcfg0,t0 +8000014c: deadc137 lui sp,0xdeadc +80000150: eef10113 addi sp,sp,-273 # deadbeef +80000154: 00222023 sw sp,0(tp) # 0 <_start-0x80000000> +80000158: 00000f17 auipc t5,0x0 +8000015c: 010f0f13 addi t5,t5,16 # 80000168 +80000160: 00022183 lw gp,0(tp) # 0 <_start-0x80000000> +80000164: 0ac0006f j 80000210 + +80000168 : +80000168: 00200e13 li t3,2 8000016c: 00000f17 auipc t5,0x0 -80000170: 010f0f13 addi t5,t5,16 # 8000017c -80000174: 00022183 lw gp,0(tp) # 0 <_start-0x80000000> -80000178: 0ac0006f j 80000224 +80000170: 0a4f0f13 addi t5,t5,164 # 80000210 +80000174: 071212b7 lui t0,0x7121 +80000178: 80828293 addi t0,t0,-2040 # 7120808 <_start-0x78edf7f8> +8000017c: 3a029073 csrw pmpcfg0,t0 +80000180: deadc137 lui sp,0xdeadc +80000184: eef10113 addi sp,sp,-273 # deadbeef +80000188: 00222023 sw sp,0(tp) # 0 <_start-0x80000000> +8000018c: 00000f17 auipc t5,0x0 +80000190: 010f0f13 addi t5,t5,16 # 8000019c +80000194: 00022183 lw gp,0(tp) # 0 <_start-0x80000000> +80000198: 0780006f j 80000210 -8000017c : -8000017c: 00200e13 li t3,2 -80000180: 00000f17 auipc t5,0x0 -80000184: 0a4f0f13 addi t5,t5,164 # 80000224 -80000188: 071a12b7 lui t0,0x71a1 -8000018c: 80828293 addi t0,t0,-2040 # 71a0808 <_start-0x78e5f7f8> -80000190: 3a029073 csrw pmpcfg0,t0 -80000194: deadc137 lui sp,0xdeadc -80000198: eef10113 addi sp,sp,-273 # deadbeef -8000019c: 00222023 sw sp,0(tp) # 0 <_start-0x80000000> +8000019c : +8000019c: 00300e13 li t3,3 800001a0: 00000f17 auipc t5,0x0 -800001a4: 010f0f13 addi t5,t5,16 # 800001b0 -800001a8: 00022183 lw gp,0(tp) # 0 <_start-0x80000000> -800001ac: 0780006f j 80000224 +800001a4: 070f0f13 addi t5,t5,112 # 80000210 +800001a8: 00000117 auipc sp,0x0 +800001ac: 01010113 addi sp,sp,16 # 800001b8 +800001b0: 34111073 csrw mepc,sp +800001b4: 30200073 mret -800001b0 : -800001b0: 00300e13 li t3,3 -800001b4: 00000f17 auipc t5,0x0 -800001b8: 070f0f13 addi t5,t5,112 # 80000224 -800001bc: 00000e97 auipc t4,0x0 -800001c0: 00ce8e93 addi t4,t4,12 # 800001c8 -800001c4: e55ff06f j 80000018 +800001b8 : +800001b8: 00400e13 li t3,4 +800001bc: 00000f17 auipc t5,0x0 +800001c0: 054f0f13 addi t5,t5,84 # 80000210 +800001c4: deadc137 lui sp,0xdeadc +800001c8: eef10113 addi sp,sp,-273 # deadbeef +800001cc: 00222023 sw sp,0(tp) # 0 <_start-0x80000000> +800001d0: 00000f17 auipc t5,0x0 +800001d4: 010f0f13 addi t5,t5,16 # 800001e0 +800001d8: 00022183 lw gp,0(tp) # 0 <_start-0x80000000> +800001dc: 0340006f j 80000210 -800001c8 : -800001c8: 00400e13 li t3,4 -800001cc: 00000f17 auipc t5,0x0 -800001d0: 058f0f13 addi t5,t5,88 # 80000224 -800001d4: deadc137 lui sp,0xdeadc -800001d8: eef10113 addi sp,sp,-273 # deadbeef -800001dc: 00222023 sw sp,0(tp) # 0 <_start-0x80000000> -800001e0: 00000f17 auipc t5,0x0 -800001e4: 010f0f13 addi t5,t5,16 # 800001f0 -800001e8: 00022183 lw gp,0(tp) # 0 <_start-0x80000000> -800001ec: 0380006f j 80000224 +800001e0 : +800001e0: 00500e13 li t3,5 +800001e4: deadc137 lui sp,0xdeadc +800001e8: eef10113 addi sp,sp,-273 # deadbeef +800001ec: 0020a023 sw sp,0(ra) +800001f0: 0000a183 lw gp,0(ra) +800001f4: 00311e63 bne sp,gp,80000210 -800001f0 : -800001f0: 00500e13 li t3,5 -800001f4: 00000f17 auipc t5,0x0 -800001f8: 03cf0f13 addi t5,t5,60 # 80000230 +800001f8 : +800001f8: 00600e13 li t3,6 800001fc: 80010237 lui tp,0x80010 -80000200: deadc137 lui sp,0xdeadc -80000204: eef10113 addi sp,sp,-273 # deadbeef -80000208: 0020a023 sw sp,0(ra) -8000020c: 0000a183 lw gp,0(ra) -80000210: 00311a63 bne sp,gp,80000224 -80000214: 00022183 lw gp,0(tp) # 80010000 -80000218: 00000f17 auipc t5,0x0 -8000021c: 018f0f13 addi t5,t5,24 # 80000230 -80000220: 00322023 sw gp,0(tp) # 0 <_start-0x80000000> +80000200: 00022183 lw gp,0(tp) # 80010000 +80000204: 00000f17 auipc t5,0x0 +80000208: 018f0f13 addi t5,t5,24 # 8000021c +8000020c: 00322023 sw gp,0(tp) # 0 <_start-0x80000000> -80000224 : -80000224: f0100137 lui sp,0xf0100 -80000228: f2410113 addi sp,sp,-220 # f00fff24 -8000022c: 01c12023 sw t3,0(sp) +80000210 : +80000210: f0100137 lui sp,0xf0100 +80000214: f2410113 addi sp,sp,-220 # f00fff24 +80000218: 01c12023 sw t3,0(sp) -80000230 : -80000230: f0100137 lui sp,0xf0100 -80000234: f2010113 addi sp,sp,-224 # f00fff20 -80000238: 00012023 sw zero,0(sp) +8000021c : +8000021c: 29a00e13 li t3,666 +80000220: f0100137 lui sp,0xf0100 +80000224: f2010113 addi sp,sp,-224 # f00fff20 +80000228: 00012023 sw zero,0(sp) diff --git a/src/test/cpp/raw/pmp/build/pmp.elf b/src/test/cpp/raw/pmp/build/pmp.elf index 381eec7..e5e89ac 100755 Binary files a/src/test/cpp/raw/pmp/build/pmp.elf and b/src/test/cpp/raw/pmp/build/pmp.elf differ diff --git a/src/test/cpp/raw/pmp/build/pmp.hex b/src/test/cpp/raw/pmp/build/pmp.hex index 840a560..c87e1d4 100644 --- a/src/test/cpp/raw/pmp/build/pmp.hex +++ b/src/test/cpp/raw/pmp/build/pmp.hex @@ -1,39 +1,38 @@ :0200000480007A -:100000009700000093800001739050306F00400211 -:1000100073101F34730020303741010073300130FA -:10002000130100207320013073901E3473002030C0 -:10003000130E0000170F0000130F0F1FB7000080F2 -:100040003782008037C1ADDE1301F1EE23A020001E -:100050002320220083A100006316311C83210200AB -:100060006312311CB7121A07938282807390023A8E -:10007000B7021C19938242507390123A9302800186 -:100080007390223AB7221E0F938202907390323AF5 -:10009000B70200207390023B9302F0FF7390123B73 -:1000A000B72200207390223BB74200209382F2FFD8 -:1000B0007390323BB74200209382F2FF7390423B31 -:1000C000B74200209382F2FF7390523BB722002088 -:1000D0009382F2FF7390623BB74200209382F2FF5B -:1000E0007390723BB74200209382F2FF7390823B81 -:1000F000930200007390923B930200007390A23B26 -:10010000930200007390B23B930200007390C23BD5 -:10011000930200007390D23B930200007390E23B85 -:10012000930200007390F23B3701C1001301E1FE1E -:1001300023A020002320220083A100006314310E9D -:10014000832102006310310E130E1000170F000000 -:10015000130F8F0DB7129A07938282807390023A21 -:1001600037C1ADDE1301F1EE23202200170F00008E -:10017000130F0F01832102006F00C00A130E20002D -:10018000170F0000130F4F0AB7121A0793828280CD -:100190007390023A37C1ADDE1301F1EE2320220045 -:1001A000170F0000130F0F01832102006F0080075B -:1001B000130E3000170F0000130F0F07970E0000EB -:1001C000938ECE006FF05FE5130E4000170F000016 -:1001D000130F8F0537C1ADDE1301F1EE232022008E -:1001E000170F0000130F0F01832102006F0080031F -:1001F000130E5000170F0000130FCF0337020180BA -:1002000037C1ADDE1301F1EE23A0200083A1000071 -:10021000631A310083210200170F0000130F8F01B2 -:1002200023203200370110F0130141F22320C101D5 -:0C023000370110F0130101F2232001003F +:100000009700000093800001739050306F00C00093 +:1000100073101F3473002030130E0000170F000000 +:10002000130F4F1FB70000803782008037C1ADDE4D +:100030001301F1EE23A020002320220083A1000061 +:100040006318311C832102006314311CB71212079C +:10005000938282807390023AB7021F1993824230D2 +:100060007390123A930280017390223AB7221E0FC6 +:10007000938202907390323AB70200207390023B51 +:100080009302F0FF7390123BB72200207390223B43 +:10009000B74200209382F2FF7390323BB7420020B8 +:1000A0009382F2FF7390423BB74200209382F2FFAB +:1000B0007390523BB72200209382F2FF7390623B11 +:1000C000B74200209382F2FF7390723BB742002048 +:1000D0009382F2FF7390823B930200007390923BF5 +:1000E000930200007390A23B930200007390B23B16 +:1000F000930200007390C23B930200007390D23BC6 +:10010000930200007390E23B930200007390F23B75 +:100110003701C1001301E1FE23A0200023202200AB +:1001200083A100006316310E9301000083210200B9 +:100130006310310E130E1000170F0000130F8F0DF8 +:10014000B7129207938282807390023A37C1ADDE74 +:100150001301F1EE23202200170F0000130F0F01EF +:10016000832102006F00C00A130E2000170F000049 +:10017000130F4F0AB7121207938282807390023ACC +:1001800037C1ADDE1301F1EE23202200170F00006E +:10019000130F0F01832102006F008007130E300040 +:1001A000170F0000130F0F071701000013010101C3 +:1001B0007310113473002030130E4000170F00002D +:1001C000130F4F0537C1ADDE1301F1EE23202200DE +:1001D000170F0000130F0F01832102006F0040036F +:1001E000130E500037C1ADDE1301F1EE23A0200045 +:1001F00083A10000631E3100130E600037020180EE +:1002000083210200170F0000130F8F0123203200FB +:10021000370110F0130141F22320C101130EA02970 +:0C022000370110F0130101F2232001004F :040000058000000077 :00000001FF diff --git a/src/test/cpp/raw/pmp/build/pmp.map b/src/test/cpp/raw/pmp/build/pmp.map index ede4c4b..f49f55e 100644 --- a/src/test/cpp/raw/pmp/build/pmp.map +++ b/src/test/cpp/raw/pmp/build/pmp.map @@ -15,20 +15,19 @@ LOAD /opt/riscv/lib/gcc/riscv64-unknown-elf/10.2.0/../../../../riscv64-unknown-e END GROUP LOAD /opt/riscv/lib/gcc/riscv64-unknown-elf/10.2.0/libgcc.a -.crt_section 0x0000000080000000 0x23c +.crt_section 0x0000000080000000 0x22c 0x0000000080000000 . = ALIGN (0x4) *crt.o(.text) - .text 0x0000000080000000 0x23c build/src/crt.o + .text 0x0000000080000000 0x22c build/src/crt.o 0x0000000080000000 _start 0x0000000080000010 trap - 0x0000000080000018 to_user OUTPUT(build/pmp.elf elf32-littleriscv) -.data 0x000000008000023c 0x0 - .data 0x000000008000023c 0x0 build/src/crt.o +.data 0x000000008000022c 0x0 + .data 0x000000008000022c 0x0 build/src/crt.o -.bss 0x000000008000023c 0x0 - .bss 0x000000008000023c 0x0 build/src/crt.o +.bss 0x000000008000022c 0x0 + .bss 0x000000008000022c 0x0 build/src/crt.o .riscv.attributes 0x0000000000000000 0x1e diff --git a/src/test/cpp/raw/pmp/src/crt.S b/src/test/cpp/raw/pmp/src/crt.S index 6eacc08..d7881ae 100644 --- a/src/test/cpp/raw/pmp/src/crt.S +++ b/src/test/cpp/raw/pmp/src/crt.S @@ -5,12 +5,11 @@ */ #define TEST_ID x28 -#define USER_RA x29 #define TRAP_RA x30 -#define PMPCFG0 0x071a0808 -#define PMPCFG0_ 0x079a0808 // lock region 2 -#define PMPCFG1 0x191c0504 +#define PMPCFG0 0x07120808 +#define PMPCFG0_ 0x07920808 // lock region 2 +#define PMPCFG1 0x191f0304 #define PMPCFG2 0x00000018 #define PMPCFG3 0x0f1e1900 @@ -42,15 +41,6 @@ trap: csrw mepc, TRAP_RA mret -.global to_user -to_user: - li x2, 0x14000 - csrc mstatus, x2 - li x2, 0x200 - csrs mstatus, x2 - csrw mepc, USER_RA - mret - // configure PMP, attempt read/write from machine mode test0: li TEST_ID, 0 @@ -112,6 +102,7 @@ test0: sw x2, 0x0(x4) lw x3, 0x0(x1) bne x2, x3, fail + li x3, 0x0 lw x3, 0x0(x4) bne x2, x3, fail @@ -143,8 +134,9 @@ test2: test3: li TEST_ID, 3 la TRAP_RA, fail - la USER_RA, test4 - j to_user + la x2, test4 + csrw mepc, x2 + mret // attempt to read/write region 2 from user mode test4: @@ -159,12 +151,14 @@ test4: // attempt to read/write other regions from user mode test5: li TEST_ID, 5 - la TRAP_RA, pass - li x4, 0x80010000 li x2, 0xdeadbeef sw x2, 0x0(x1) lw x3, 0x0(x1) - bne x2, x3, fail // should be OK + bne x2, x3, fail // should be OK (read/write 0x80000000) + +test6: + li TEST_ID, 6 + li x4, 0x80010000 lw x3, 0x0(x4) // should be OK (read 0x80010000) la TRAP_RA, pass sw x3, 0x0(x4) // should fault (write 0x80010000) @@ -174,5 +168,6 @@ fail: sw TEST_ID, 0(x2) pass: + li TEST_ID, 666 li x2, 0xf00fff20 sw x0, 0(x2) diff --git a/src/test/cpp/regression/main.cpp b/src/test/cpp/regression/main.cpp index acc7793..81eae4c 100644 --- a/src/test/cpp/regression/main.cpp +++ b/src/test/cpp/regression/main.cpp @@ -4054,7 +4054,7 @@ int main(int argc, char **argv, char **env) { #endif #ifdef PMP - redo(REDO,WorkspaceRegression("pmp").withRiscvRef()->loadHex(string(REGRESSION_PATH) + "../raw/pmp/build/pmp.hex")->bootAt(0x00000000u)->run(10e3);); + redo(REDO,WorkspaceRegression("pmp").loadHex(string(REGRESSION_PATH) + "../raw/pmp/build/pmp.hex")->bootAt(0x00000000u)->run(10e3);); #endif #ifdef AMO