1 /*
2  * Copyright (C) 2023 Intel Corporation.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <types.h>
8 #include <softirq.h>
9 #include <trace.h>
10 #include <asm/guest/virq.h>
11 #include <hw/hw_thermal.h>
12 
thermal_softirq(uint16_t pcpu_id)13 static void thermal_softirq(uint16_t pcpu_id)
14 {
15 	struct acrn_vcpu *vcpu;
16 	uint32_t idx;
17 
18 	for (idx = 0; idx < CONFIG_MAX_VM_NUM; idx++) {
19 		vcpu = per_cpu(vcpu_array, pcpu_id)[idx];
20 		if (vcpu != NULL) {
21 			vcpu_inject_thermal_interrupt(vcpu);
22 		}
23 	}
24 }
25 
thermal_init(void)26 void thermal_init(void)
27 {
28 	uint16_t pcpu_id = get_pcpu_id();
29 
30 	if (pcpu_id == BSP_CPU_ID) {
31 		register_softirq(SOFTIRQ_THERMAL, thermal_softirq);
32 	}
33 
34 	init_hw_thermal();
35 }
36