Heinrich Schuchardt | 309c775 | 2024-02-12 17:18:37 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 2 | |
| 3 | #include <efi_loader.h> |
| 4 | #include <asm/sbi.h> |
| 5 | |
| 6 | void __efi_runtime EFIAPI efi_reset_system(enum efi_reset_type reset_type, |
| 7 | efi_status_t reset_status, |
| 8 | unsigned long data_size, |
| 9 | void *reset_data) |
| 10 | { |
| 11 | register unsigned long eid asm("a7") = SBI_EXT_SRST; |
| 12 | register unsigned long fid asm("a6") = SBI_EXT_SRST_RESET; |
| 13 | register unsigned long type asm("a0"); |
| 14 | register unsigned long reason asm("a1") = SBI_SRST_RESET_REASON_NONE; |
| 15 | |
| 16 | switch (reset_type) { |
| 17 | case EFI_RESET_WARM: |
| 18 | type = SBI_SRST_RESET_TYPE_WARM_REBOOT; |
| 19 | break; |
| 20 | case EFI_RESET_SHUTDOWN: |
| 21 | type = SBI_SRST_RESET_TYPE_SHUTDOWN; |
| 22 | break; |
| 23 | default: |
| 24 | type = SBI_SRST_RESET_TYPE_COLD_REBOOT; |
| 25 | break; |
| 26 | } |
| 27 | asm volatile ("ecall\n" |
| 28 | : : "r" (eid), "r" (fid), "r" (type), "r" (reason)); |
| 29 | } |