compiler/
kernel/
lib/
scripts/
seed/
sublime/
test/
acceptance/
boot/
bootstrap/
cycles/
dispatch/
loader/
mmio/
native/
packages/
pages/
runtime/
scheduling/
shared/
slots/
smp/
support/
sync/
termination/
tests/
trap/
machine.ras
6.2 KiB
reservations.ras
2.0 KiB
run
633 B
package-golden
1.6 KiB
run
3.1 KiB
runner.rad
10.5 KiB
vim/
.gitignore
336 B
.gitsigners
112 B
CONTRIBUTING
2.1 KiB
LICENSE
1.1 KiB
Makefile
9.2 KiB
README
2.5 KiB
STYLE
2.5 KiB
std.lib
1.5 KiB
std.lib.test
662 B
test/trap/machine.ras
raw
| 1 | //! Machine and user trap entry with a nested machine timer interrupt. |
| 2 | .text; |
| 3 | li %s0 1073807360; |
| 4 | slli %s0 %s0 1; |
| 5 | sd %sp 0(%s0); |
| 6 | li %t0 4096; |
| 7 | sub %t0 %sp %t0; |
| 8 | sd %t0 8(%s0); |
| 9 | li %t0 0x12345678; |
| 10 | sd %t0 16(%s0); |
| 11 | la %t0 @handler; |
| 12 | sd %t0 24(%s0); |
| 13 | mv %a0 %s0; |
| 14 | call @kernel::trap::install; |
| 15 | li %ra 17; |
| 16 | li %gp 51; |
| 17 | li %tp 68; |
| 18 | li %t0 85; |
| 19 | li %t1 102; |
| 20 | li %t2 119; |
| 21 | li %s1 153; |
| 22 | li %a0 170; |
| 23 | li %a1 187; |
| 24 | li %a2 204; |
| 25 | li %a3 221; |
| 26 | li %a4 238; |
| 27 | li %a5 255; |
| 28 | li %a6 272; |
| 29 | li %a7 289; |
| 30 | li %s2 306; |
| 31 | li %s3 323; |
| 32 | li %s4 340; |
| 33 | li %s5 357; |
| 34 | li %s6 374; |
| 35 | li %s7 391; |
| 36 | li %s8 408; |
| 37 | li %s9 425; |
| 38 | li %s10 442; |
| 39 | li %s11 459; |
| 40 | li %t3 476; |
| 41 | li %t4 493; |
| 42 | li %t5 510; |
| 43 | li %t6 527; |
| 44 | ecall; |
| 45 | addi %t0 %t0 -85; |
| 46 | bnez %t0 @fail; |
| 47 | li %t0 17; |
| 48 | bne %ra %t0 @fail; |
| 49 | li %t0 51; |
| 50 | bne %gp %t0 @fail; |
| 51 | li %t0 68; |
| 52 | bne %tp %t0 @fail; |
| 53 | li %t0 102; |
| 54 | bne %t1 %t0 @fail; |
| 55 | li %t0 119; |
| 56 | bne %t2 %t0 @fail; |
| 57 | li %t0 153; |
| 58 | bne %s1 %t0 @fail; |
| 59 | li %t0 170; |
| 60 | bne %a0 %t0 @fail; |
| 61 | li %t0 187; |
| 62 | bne %a1 %t0 @fail; |
| 63 | li %t0 204; |
| 64 | bne %a2 %t0 @fail; |
| 65 | li %t0 221; |
| 66 | bne %a3 %t0 @fail; |
| 67 | li %t0 238; |
| 68 | bne %a4 %t0 @fail; |
| 69 | li %t0 255; |
| 70 | bne %a5 %t0 @fail; |
| 71 | li %t0 272; |
| 72 | bne %a6 %t0 @fail; |
| 73 | li %t0 289; |
| 74 | bne %a7 %t0 @fail; |
| 75 | li %t0 306; |
| 76 | bne %s2 %t0 @fail; |
| 77 | li %t0 323; |
| 78 | bne %s3 %t0 @fail; |
| 79 | li %t0 340; |
| 80 | bne %s4 %t0 @fail; |
| 81 | li %t0 357; |
| 82 | bne %s5 %t0 @fail; |
| 83 | li %t0 374; |
| 84 | bne %s6 %t0 @fail; |
| 85 | li %t0 391; |
| 86 | bne %s7 %t0 @fail; |
| 87 | li %t0 408; |
| 88 | bne %s8 %t0 @fail; |
| 89 | li %t0 425; |
| 90 | bne %s9 %t0 @fail; |
| 91 | li %t0 442; |
| 92 | bne %s10 %t0 @fail; |
| 93 | li %t0 459; |
| 94 | bne %s11 %t0 @fail; |
| 95 | li %t0 476; |
| 96 | bne %t3 %t0 @fail; |
| 97 | li %t0 493; |
| 98 | bne %t4 %t0 @fail; |
| 99 | li %t0 510; |
| 100 | bne %t5 %t0 @fail; |
| 101 | li %t0 527; |
| 102 | bne %t6 %t0 @fail; |
| 103 | li %t0 1073807360; |
| 104 | slli %t0 %t0 1; |
| 105 | bne %s0 %t0 @fail; |
| 106 | ld %t0 0(%s0); |
| 107 | bne %sp %t0 @fail; |
| 108 | ld %t0 64(%s0); |
| 109 | li %t1 2; |
| 110 | bne %t0 %t1 @fail; |
| 111 | la %t0 @user; |
| 112 | csrw mepc %t0; |
| 113 | csrw mstatus %zero; |
| 114 | li %sp 1073809400; |
| 115 | slli %sp %sp 1; |
| 116 | mret; |
| 117 | @user |
| 118 | li %ra 17; |
| 119 | li %gp 51; |
| 120 | li %tp 68; |
| 121 | li %t0 85; |
| 122 | li %t1 102; |
| 123 | li %t2 119; |
| 124 | li %s1 153; |
| 125 | li %a0 170; |
| 126 | li %a1 187; |
| 127 | li %a2 204; |
| 128 | li %a3 221; |
| 129 | li %a4 238; |
| 130 | li %a5 255; |
| 131 | li %a6 272; |
| 132 | li %a7 289; |
| 133 | li %s2 306; |
| 134 | li %s3 323; |
| 135 | li %s4 340; |
| 136 | li %s5 357; |
| 137 | li %s6 374; |
| 138 | li %s7 391; |
| 139 | li %s8 408; |
| 140 | li %s9 425; |
| 141 | li %s10 442; |
| 142 | li %s11 459; |
| 143 | li %t3 476; |
| 144 | li %t4 493; |
| 145 | li %t5 510; |
| 146 | li %t6 527; |
| 147 | ecall; |
| 148 | addi %t0 %t0 -85; |
| 149 | bnez %t0 @fail; |
| 150 | li %t0 17; |
| 151 | bne %ra %t0 @fail; |
| 152 | li %t0 51; |
| 153 | bne %gp %t0 @fail; |
| 154 | li %t0 68; |
| 155 | bne %tp %t0 @fail; |
| 156 | li %t0 102; |
| 157 | bne %t1 %t0 @fail; |
| 158 | li %t0 119; |
| 159 | bne %t2 %t0 @fail; |
| 160 | li %t0 153; |
| 161 | bne %s1 %t0 @fail; |
| 162 | li %t0 170; |
| 163 | bne %a0 %t0 @fail; |
| 164 | li %t0 187; |
| 165 | bne %a1 %t0 @fail; |
| 166 | li %t0 204; |
| 167 | bne %a2 %t0 @fail; |
| 168 | li %t0 221; |
| 169 | bne %a3 %t0 @fail; |
| 170 | li %t0 238; |
| 171 | bne %a4 %t0 @fail; |
| 172 | li %t0 255; |
| 173 | bne %a5 %t0 @fail; |
| 174 | li %t0 272; |
| 175 | bne %a6 %t0 @fail; |
| 176 | li %t0 289; |
| 177 | bne %a7 %t0 @fail; |
| 178 | li %t0 306; |
| 179 | bne %s2 %t0 @fail; |
| 180 | li %t0 323; |
| 181 | bne %s3 %t0 @fail; |
| 182 | li %t0 340; |
| 183 | bne %s4 %t0 @fail; |
| 184 | li %t0 357; |
| 185 | bne %s5 %t0 @fail; |
| 186 | li %t0 374; |
| 187 | bne %s6 %t0 @fail; |
| 188 | li %t0 391; |
| 189 | bne %s7 %t0 @fail; |
| 190 | li %t0 408; |
| 191 | bne %s8 %t0 @fail; |
| 192 | li %t0 425; |
| 193 | bne %s9 %t0 @fail; |
| 194 | li %t0 442; |
| 195 | bne %s10 %t0 @fail; |
| 196 | li %t0 459; |
| 197 | bne %s11 %t0 @fail; |
| 198 | li %t0 476; |
| 199 | bne %t3 %t0 @fail; |
| 200 | li %t0 493; |
| 201 | bne %t4 %t0 @fail; |
| 202 | li %t0 510; |
| 203 | bne %t5 %t0 @fail; |
| 204 | li %t0 527; |
| 205 | bne %t6 %t0 @fail; |
| 206 | li %t0 1073807360; |
| 207 | slli %t0 %t0 1; |
| 208 | bne %s0 %t0 @fail; |
| 209 | li %t0 1073809400; |
| 210 | slli %t0 %t0 1; |
| 211 | bne %sp %t0 @fail; |
| 212 | li %t0 85; |
| 213 | @illegalInstruction |
| 214 | csrr %t0 mhartid; |
| 215 | addi %t0 %t0 -85; |
| 216 | bnez %t0 @fail; |
| 217 | li %a7 1234; |
| 218 | ecall; |
| 219 | j @fail; |
| 220 | @success |
| 221 | li %t0 0x10001000; |
| 222 | li %t1 0x5555; |
| 223 | sw %t1 0(%t0); |
| 224 | @fail |
| 225 | li %t0 0x10001000; |
| 226 | li %t1 0x13333; |
| 227 | sw %t1 0(%t0); |
| 228 | @park |
| 229 | wfi; |
| 230 | j @park; |
| 231 | |
| 232 | // Validate stack/base switching before enabling a nested timer interrupt. |
| 233 | @handler |
| 234 | li %t0 0x12345678; |
| 235 | bne %gp %t0 @fail; |
| 236 | li %t0 1073807360; |
| 237 | slli %t0 %t0 1; |
| 238 | bne %tp %t0 @fail; |
| 239 | bne %a1 %tp @fail; |
| 240 | bne %a0 %sp @fail; |
| 241 | ld %t0 272(%a0); |
| 242 | li %t1 1; |
| 243 | slli %t1 %t1 63; |
| 244 | ori %t1 %t1 7; |
| 245 | beq %t0 %t1 @timer; |
| 246 | li %t1 8; |
| 247 | beq %t0 %t1 @userCall; |
| 248 | li %t1 2; |
| 249 | beq %t0 %t1 @illegal; |
| 250 | li %t1 11; |
| 251 | bne %t0 %t1 @fail; |
| 252 | ld %t0 64(%tp); |
| 253 | bnez %t0 @fail; |
| 254 | li %t0 1; |
| 255 | sd %t0 64(%tp); |
| 256 | addi %sp %sp -16; |
| 257 | sd %ra 0(%sp); |
| 258 | sd %a0 8(%sp); |
| 259 | li %t0 0x02004000; |
| 260 | sd %zero 0(%t0); |
| 261 | li %t0 128; |
| 262 | csrw mie %t0; |
| 263 | li %s10 0; |
| 264 | csrr %t0 mstatus; |
| 265 | ori %t0 %t0 8; |
| 266 | csrw mstatus %t0; |
| 267 | @awaitTimer |
| 268 | addi %s10 %s10 1; |
| 269 | ld %t0 64(%tp); |
| 270 | li %t1 2; |
| 271 | bne %t0 %t1 @awaitTimer; |
| 272 | li %t0 1; |
| 273 | bne %s10 %t0 @fail; |
| 274 | csrr %t0 mstatus; |
| 275 | andi %t0 %t0 8; |
| 276 | beqz %t0 @fail; |
| 277 | csrr %t0 mstatus; |
| 278 | andi %t0 %t0 -9; |
| 279 | csrw mstatus %t0; |
| 280 | csrw mie %zero; |
| 281 | ld %ra 0(%sp); |
| 282 | ld %a0 8(%sp); |
| 283 | addi %sp %sp 16; |
| 284 | j @advance; |
| 285 | @timer |
| 286 | ld %t0 256(%a0); |
| 287 | la %t1 @awaitTimer; |
| 288 | bne %t0 %t1 @fail; |
| 289 | ld %t0 264(%a0); |
| 290 | li %t1 0x1800; |
| 291 | and %t0 %t0 %t1; |
| 292 | bne %t0 %t1 @fail; |
| 293 | ld %t0 16(%a0); |
| 294 | addi %t1 %a0 288; |
| 295 | bne %t0 %t1 @fail; |
| 296 | li %t0 0x02004000; |
| 297 | li %t1 -1; |
| 298 | sd %t1 0(%t0); |
| 299 | li %t0 2; |
| 300 | sd %t0 64(%tp); |
| 301 | ret; |
| 302 | @illegal |
| 303 | ld %t0 256(%a0); |
| 304 | la %t1 @illegalInstruction; |
| 305 | bne %t0 %t1 @fail; |
| 306 | ld %t0 280(%a0); |
| 307 | li %t1 2023756153; |
| 308 | slli %t1 %t1 1; |
| 309 | addi %t1 %t1 1; |
| 310 | bne %t0 %t1 @fail; |
| 311 | li %t0 1; |
| 312 | sd %t0 72(%tp); |
| 313 | j @advance; |
| 314 | @userCall |
| 315 | ld %t0 136(%a0); |
| 316 | li %t1 1234; |
| 317 | bne %t0 %t1 @checkUserFrame; |
| 318 | ld %t0 72(%tp); |
| 319 | li %t1 1; |
| 320 | bne %t0 %t1 @fail; |
| 321 | j @success; |
| 322 | @checkUserFrame |
| 323 | ld %t0 264(%a0); |
| 324 | li %t1 0x1800; |
| 325 | and %t0 %t0 %t1; |
| 326 | bnez %t0 @fail; |
| 327 | ld %t0 0(%tp); |
| 328 | addi %t0 %t0 -288; |
| 329 | bne %a0 %t0 @fail; |
| 330 | @advance |
| 331 | ld %t0 256(%a0); |
| 332 | addi %t0 %t0 4; |
| 333 | sd %t0 256(%a0); |
| 334 | ret; |