|
40 | 40 | #define SBI_REMOTE_HFENCE_VVMA_FID (5) |
41 | 41 | #define SBI_REMOTE_HFENCE_VVMA_ASID_FID (6) |
42 | 42 |
|
| 43 | +#define SBI_EXTID_SRST (0x53525354) |
| 44 | +#define SBI_SYSTEM_RESET_FID (0) |
| 45 | +#define SBI_RST_TYPE_COLD_REBOOT (0x00000001) |
| 46 | + |
43 | 47 | /** |
44 | 48 | * For now we're defining bao specific ecalls, ie, hypercall, under the experimental extension id |
45 | 49 | * space. |
@@ -166,7 +170,7 @@ struct sbiret sbi_hart_status(unsigned long hartid) |
166 | 170 | } |
167 | 171 |
|
168 | 172 | static unsigned long ext_table[] = { SBI_EXTID_BASE, SBI_EXTID_TIME, SBI_EXTID_IPI, SBI_EXTID_RFNC, |
169 | | - SBI_EXTID_HSM }; |
| 173 | + SBI_EXTID_HSM, SBI_EXTID_SRST }; |
170 | 174 |
|
171 | 175 | static const size_t NUM_EXT = sizeof(ext_table) / sizeof(unsigned long); |
172 | 176 |
|
@@ -256,7 +260,7 @@ static struct sbiret sbi_base_handler(unsigned long fid) |
256 | 260 |
|
257 | 261 | switch (fid) { |
258 | 262 | case SBI_GET_SBI_SPEC_VERSION_FID: |
259 | | - ret.value = 2; |
| 263 | + ret.value = 3; |
260 | 264 | break; |
261 | 265 | case SBI_PROBE_EXTENSION_FID: |
262 | 266 | ret.value = 0; |
@@ -391,6 +395,32 @@ static struct sbiret sbi_hsm_handler(unsigned long fid) |
391 | 395 | return ret; |
392 | 396 | } |
393 | 397 |
|
| 398 | +static struct sbiret sbi_srst_handler(unsigned long fid) |
| 399 | +{ |
| 400 | + struct sbiret ret; |
| 401 | + |
| 402 | + uint32_t reset_type = (uint32_t)vcpu_readreg(cpu()->vcpu, REG_A0); |
| 403 | + |
| 404 | + switch (fid) { |
| 405 | + case SBI_SYSTEM_RESET_FID: |
| 406 | + if (reset_type == SBI_RST_TYPE_COLD_REBOOT) { |
| 407 | + if (vm_reset(cpu()->vcpu->vm)) { |
| 408 | + ret.error = SBI_SUCCESS; |
| 409 | + } else { |
| 410 | + ret.error = SBI_ERR_FAILURE; |
| 411 | + } |
| 412 | + } else { |
| 413 | + ret.error = SBI_ERR_INVALID_PARAM; |
| 414 | + } |
| 415 | + break; |
| 416 | + default: |
| 417 | + ret.error = SBI_ERR_NOT_SUPPORTED; |
| 418 | + break; |
| 419 | + } |
| 420 | + |
| 421 | + return ret; |
| 422 | +} |
| 423 | + |
394 | 424 | static struct sbiret sbi_bao_handler(unsigned long fid) |
395 | 425 | { |
396 | 426 | struct sbiret ret; |
@@ -422,6 +452,9 @@ size_t sbi_vs_handler() |
422 | 452 | case SBI_EXTID_HSM: |
423 | 453 | ret = sbi_hsm_handler(fid); |
424 | 454 | break; |
| 455 | + case SBI_EXTID_SRST: |
| 456 | + ret = sbi_srst_handler(fid); |
| 457 | + break; |
425 | 458 | case SBI_EXTID_BAO: |
426 | 459 | ret = sbi_bao_handler(fid); |
427 | 460 | break; |
|
0 commit comments