mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-11-28 16:36:00 +00:00
hv: host_pm: Move two common APIs to common scope
Move shutdown_system to common (and rename to shutdown_host) Move reset_host to common Tracked-On: #8830 Signed-off-by: Yifan Liu <yifan1.liu@intel.com> Reviewed-by: Fei Li <fei1.li@intel.com> Acked-by: Wang Yu1 <yu1.wang@intel.com>
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include <vm.h>
|
#include <vm.h>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <asm/host_pm.h>
|
#include <host_pm.h>
|
||||||
#include <logmsg.h>
|
#include <logmsg.h>
|
||||||
#include <per_cpu.h>
|
#include <per_cpu.h>
|
||||||
#include <asm/guest/vm_reset.h>
|
#include <asm/guest/vm_reset.h>
|
||||||
@@ -49,7 +49,7 @@ void triple_fault_shutdown_vm(struct acrn_vcpu *vcpu)
|
|||||||
pause_vm(pl_vm);
|
pause_vm(pl_vm);
|
||||||
(void)destroy_vm(pl_vm);
|
(void)destroy_vm(pl_vm);
|
||||||
if (is_ready_for_system_shutdown()) {
|
if (is_ready_for_system_shutdown()) {
|
||||||
shutdown_system();
|
shutdown_host();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
put_vm_lock(pl_vm);
|
put_vm_lock(pl_vm);
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ void save_s5_reg_val(uint32_t pm1a_cnt_val, uint32_t pm1b_cnt_val)
|
|||||||
system_pm1b_cnt_val = pm1b_cnt_val;
|
system_pm1b_cnt_val = pm1b_cnt_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void shutdown_system(void)
|
void arch_shutdown_host(void)
|
||||||
{
|
{
|
||||||
struct pm_s_state_data *sx_data = get_host_sstate_data();
|
struct pm_s_state_data *sx_data = get_host_sstate_data();
|
||||||
do_acpi_sx(sx_data, system_pm1a_cnt_val, system_pm1b_cnt_val);
|
do_acpi_sx(sx_data, system_pm1a_cnt_val, system_pm1b_cnt_val);
|
||||||
@@ -245,7 +245,7 @@ void host_enter_s3(const struct pm_s_state_data *sstate_data, uint32_t pm1a_cnt_
|
|||||||
resume_console();
|
resume_console();
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset_host(bool warm)
|
void arch_reset_host(bool warm)
|
||||||
{
|
{
|
||||||
struct acrn_acpi_generic_address *gas = &(host_reset_reg.reg);
|
struct acrn_acpi_generic_address *gas = &(host_reset_reg.reg);
|
||||||
uint8_t reboot_code = warm ? CF9_RESET_WARM : CF9_RESET_COLD;
|
uint8_t reboot_code = warm ? CF9_RESET_WARM : CF9_RESET_COLD;
|
||||||
|
|||||||
@@ -7,11 +7,12 @@
|
|||||||
#include <per_cpu.h>
|
#include <per_cpu.h>
|
||||||
#include <vcpu.h>
|
#include <vcpu.h>
|
||||||
#include <vm.h>
|
#include <vm.h>
|
||||||
|
#include <types.h>
|
||||||
#include <logmsg.h>
|
#include <logmsg.h>
|
||||||
#include <sbuf.h>
|
#include <sbuf.h>
|
||||||
#include <sprintf.h>
|
#include <sprintf.h>
|
||||||
#include <asm/notify.h>
|
#include <asm/notify.h>
|
||||||
#include <asm/host_pm.h>
|
#include <host_pm.h>
|
||||||
|
|
||||||
static struct acrn_vm vm_array[CONFIG_MAX_VM_NUM] __aligned(PAGE_SIZE);
|
static struct acrn_vm vm_array[CONFIG_MAX_VM_NUM] __aligned(PAGE_SIZE);
|
||||||
|
|
||||||
@@ -341,7 +342,6 @@ int32_t destroy_vm(struct acrn_vm *vm)
|
|||||||
memset(vm_config->name, 0U, MAX_VM_NAME_LEN);
|
memset(vm_config->name, 0U, MAX_VM_NAME_LEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return status to caller */
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -457,7 +457,7 @@ void shutdown_vm_from_idle(uint16_t pcpu_id)
|
|||||||
if (is_paused_vm(vm)) {
|
if (is_paused_vm(vm)) {
|
||||||
(void)destroy_vm(vm);
|
(void)destroy_vm(vm);
|
||||||
if (is_ready_for_system_shutdown()) {
|
if (is_ready_for_system_shutdown()) {
|
||||||
shutdown_system();
|
shutdown_host();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
put_vm_lock(vm);
|
put_vm_lock(vm);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
#include <logmsg.h>
|
#include <logmsg.h>
|
||||||
#include <version.h>
|
#include <version.h>
|
||||||
#include <asm/guest/vmcs.h>
|
#include <asm/guest/vmcs.h>
|
||||||
#include <asm/host_pm.h>
|
#include <host_pm.h>
|
||||||
#include <cpu.h>
|
#include <cpu.h>
|
||||||
#include "debug/shell_priv.h"
|
#include "debug/shell_priv.h"
|
||||||
|
|
||||||
|
|||||||
@@ -18,11 +18,4 @@ struct vm_arch {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* FIXME: riscv dummy function */
|
|
||||||
static inline bool need_shutdown_vm(uint16_t pcpu_id)
|
|
||||||
{
|
|
||||||
(void)pcpu_id;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* RISCV_VM_H_ */
|
#endif /* RISCV_VM_H_ */
|
||||||
|
|||||||
14
hypervisor/include/arch/riscv/asm/host_pm.h
Normal file
14
hypervisor/include/arch/riscv/asm/host_pm.h
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018-2025 Intel Corporation.
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef RISCV_HOST_PM_H
|
||||||
|
#define RISCV_HOST_PM_H
|
||||||
|
|
||||||
|
/* FIXME: To be implemented */
|
||||||
|
static inline void arch_shutdown_host(void) { }
|
||||||
|
/* FIXME: To be implemented */
|
||||||
|
static inline void arch_reset_host(bool warm) { (void)warm; }
|
||||||
|
|
||||||
|
#endif /* RISCV_HOST_PM_H */
|
||||||
@@ -3,8 +3,8 @@
|
|||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef HOST_PM_H
|
#ifndef X86_HOST_PM_H
|
||||||
#define HOST_PM_H
|
#define X86_HOST_PM_H
|
||||||
|
|
||||||
#include <acrn_common.h>
|
#include <acrn_common.h>
|
||||||
|
|
||||||
@@ -34,15 +34,13 @@ struct acpi_reset_reg {
|
|||||||
|
|
||||||
struct pm_s_state_data *get_host_sstate_data(void);
|
struct pm_s_state_data *get_host_sstate_data(void);
|
||||||
void host_enter_s3(const struct pm_s_state_data *sstate_data, uint32_t pm1a_cnt_val, uint32_t pm1b_cnt_val);
|
void host_enter_s3(const struct pm_s_state_data *sstate_data, uint32_t pm1a_cnt_val, uint32_t pm1b_cnt_val);
|
||||||
void shutdown_system(void);
|
|
||||||
void save_s5_reg_val(uint32_t pm1a_cnt_val, uint32_t pm1b_cnt_val);
|
void save_s5_reg_val(uint32_t pm1a_cnt_val, uint32_t pm1b_cnt_val);
|
||||||
void do_acpi_sx(const struct pm_s_state_data *sstate_data, uint32_t pm1a_cnt_val, uint32_t pm1b_cnt_val);
|
void do_acpi_sx(const struct pm_s_state_data *sstate_data, uint32_t pm1a_cnt_val, uint32_t pm1b_cnt_val);
|
||||||
extern void asm_enter_s3(const struct pm_s_state_data *sstate_data, uint32_t pm1a_cnt_val, uint32_t pm1b_cnt_val);
|
extern void asm_enter_s3(const struct pm_s_state_data *sstate_data, uint32_t pm1a_cnt_val, uint32_t pm1b_cnt_val);
|
||||||
extern void restore_s3_context(void);
|
extern void restore_s3_context(void);
|
||||||
struct cpu_state_info *get_cpu_pm_state_info(void);
|
struct cpu_state_info *get_cpu_pm_state_info(void);
|
||||||
struct acpi_reset_reg *get_host_reset_reg_data(void);
|
struct acpi_reset_reg *get_host_reset_reg_data(void);
|
||||||
void reset_host(bool warm);
|
|
||||||
void init_frequency_policy(void);
|
void init_frequency_policy(void);
|
||||||
void apply_frequency_policy(void);
|
void apply_frequency_policy(void);
|
||||||
|
|
||||||
#endif /* HOST_PM_H */
|
#endif /* X86_HOST_PM_H */
|
||||||
|
|||||||
25
hypervisor/include/common/host_pm.h
Normal file
25
hypervisor/include/common/host_pm.h
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018-2025 Intel Corporation.
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HOST_PM_H
|
||||||
|
#define HOST_PM_H
|
||||||
|
|
||||||
|
#include <asm/host_pm.h>
|
||||||
|
#include <logmsg.h>
|
||||||
|
|
||||||
|
void arch_shutdown_host(void);
|
||||||
|
void arch_reset_host(bool warm);
|
||||||
|
|
||||||
|
static inline void shutdown_host(void) {
|
||||||
|
pr_info("Shutting down ACRN");
|
||||||
|
arch_shutdown_host();
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void reset_host(bool warm) {
|
||||||
|
pr_info("%s resetting ACRN", warm ? "Warm" : "Cold");
|
||||||
|
arch_reset_host(warm);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* HOST_PM_H */
|
||||||
Reference in New Issue
Block a user