mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-07-27 08:50:58 +00:00
To support shutting down or resetting host. Tracked-On: #8841 Signed-off-by: Yifan Liu <yifan1.liu@intel.com> Acked-by: Wang Yu1 <yu1.wang@intel.com>
37 lines
770 B
C
37 lines
770 B
C
/*
|
|
* Copyright (C) 2025 Intel Corporation.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
#include <types.h>
|
|
#include <host_pm.h>
|
|
#include <asm/sbi.h>
|
|
|
|
static const char *reset_mode_str[] = {
|
|
"shutdown",
|
|
"cold reboot",
|
|
"warm reboot",
|
|
};
|
|
|
|
static void sbi_system_reset(uint32_t rst_type, uint32_t rst_reason)
|
|
{
|
|
sbiret ret;
|
|
|
|
ret = sbi_ecall(rst_type, rst_reason, 0, 0, 0, 0, SBI_EXT_SRST_RESET, SBI_EID_SRST);
|
|
|
|
/* above sbi call will not return if succeeded */
|
|
panic("Failed to %s system, ret 0x%x", reset_mode_str[rst_type], ret.error);
|
|
}
|
|
|
|
void arch_shutdown_host()
|
|
{
|
|
sbi_system_reset(SBI_SRST_RESET_TYPE_SHUTDOWN, 0U);
|
|
}
|
|
|
|
void arch_reset_host(bool warm)
|
|
{
|
|
sbi_system_reset(warm ? SBI_SRST_RESET_TYPE_WARM_REBOOT \
|
|
: SBI_SRST_RESET_TYPE_COLD_REBOOT, 0U);
|
|
}
|