1 // © 2021 Qualcomm Innovation Center, Inc. All rights reserved.
2 //
3 // SPDX-License-Identifier: BSD-3-Clause
4 
5 #include <assert.h>
6 #include <hyptypes.h>
7 
8 #include <hypregisters.h>
9 
10 #include <irq.h>
11 #include <timer_queue.h>
12 #include <vic.h>
13 #include <virq.h>
14 
15 #include <asm/barrier.h>
16 
17 #include "arm_vm_pmu.h"
18 #include "event_handlers.h"
19 
20 error_t
arm_vm_pmu_handle_object_activate_thread(thread_t * thread)21 arm_vm_pmu_handle_object_activate_thread(thread_t *thread)
22 {
23 	error_t ret = OK;
24 
25 	if (thread->kind == THREAD_KIND_VCPU) {
26 		ret = vic_bind_private_vcpu(&thread->pmu.pmu_virq_src, thread,
27 					    PLATFORM_VM_PMU_IRQ,
28 					    VIRQ_TRIGGER_PMU);
29 	}
30 
31 	return ret;
32 }
33 
34 void
arm_vm_pmu_handle_object_deactivate_thread(thread_t * thread)35 arm_vm_pmu_handle_object_deactivate_thread(thread_t *thread)
36 {
37 	if (thread->kind == THREAD_KIND_VCPU) {
38 		vic_unbind(&thread->pmu.pmu_virq_src);
39 	}
40 }
41