1 // © 2023 Qualcomm Innovation Center, Inc. All rights reserved.
2 //
3 // SPDX-License-Identifier: BSD-3-Clause
4 
5 #include <hyptypes.h>
6 
7 #include <globals.h>
8 #include <spinlock.h>
9 
10 #include "event_handlers.h"
11 
12 static global_options_t global_options;
13 static spinlock_t	global_options_lock;
14 
15 void
globals_handle_boot_cold_init(void)16 globals_handle_boot_cold_init(void)
17 {
18 	spinlock_init(&global_options_lock);
19 }
20 
21 const global_options_t *
globals_get_options(void)22 globals_get_options(void)
23 {
24 	return &global_options;
25 }
26 
27 void
globals_set_options(global_options_t set)28 globals_set_options(global_options_t set)
29 {
30 	spinlock_acquire(&global_options_lock);
31 	global_options = global_options_union(global_options, set);
32 	spinlock_release(&global_options_lock);
33 }
34 
35 void
globals_clear_options(global_options_t clear)36 globals_clear_options(global_options_t clear)
37 {
38 	spinlock_acquire(&global_options_lock);
39 	global_options = global_options_difference(global_options, clear);
40 	spinlock_release(&global_options_lock);
41 }
42