• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 Huawei Technologies Co., Ltd.
3  * Licensed under the Mulan PSL v2.
4  * You can use this software according to the terms and conditions of the Mulan PSL v2.
5  * You may obtain a copy of Mulan PSL v2 at:
6  *     http://license.coscl.org.cn/MulanPSL2
7  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
8  * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
9  * PURPOSE.
10  * See the Mulan PSL v2 for more details.
11  */
12 
13 #include <teed_private.h>
14 
15 /* Array to keep track of per-cpu Secure Payload state */
16 tee_context_t g_teed_sp_context[TEED_CORE_COUNT];
17 tee_context_t g_teed_sp_init_context;
18 int64_t g_tee_init_context_saved;
19 
20 #define PRIMARY_CPU_DEFAULT 0xff
21 
22 /* primary_cpu: which core bring up the teeos */
23 uint64_t g_primary_cpu_mpidr = PRIMARY_CPU_DEFAULT;
24 
25 tee_vectors_t *g_tee_vectors = NULL;
26 
get_teed_sp_context(const uint32_t linear_id)27 tee_context_t *get_teed_sp_context(const uint32_t linear_id)
28 {
29     if (linear_id >= TEED_CORE_COUNT)
30         return NULL;
31 
32     return &g_teed_sp_context[linear_id];
33 }
34 
get_teed_sp_context_size(void)35 uint64_t get_teed_sp_context_size(void)
36 {
37     return sizeof(g_teed_sp_context);
38 }
39 
get_teed_sp_context_ptr(void)40 tee_context_t *get_teed_sp_context_ptr(void)
41 {
42     return g_teed_sp_context;
43 }
44 
get_teed_sp_init_context(void)45 tee_context_t *get_teed_sp_init_context(void)
46 {
47     return &g_teed_sp_init_context;
48 }
49 
get_tee_init_context_saved(void)50 int64_t get_tee_init_context_saved(void)
51 {
52     return g_tee_init_context_saved;
53 }
54 
set_tee_init_context_saved(const int64_t tee_init_context_saved)55 void set_tee_init_context_saved(const int64_t tee_init_context_saved)
56 {
57     g_tee_init_context_saved = tee_init_context_saved;
58 }
59 
get_primary_cpu_mpidr(void)60 uint64_t get_primary_cpu_mpidr(void)
61 {
62     return g_primary_cpu_mpidr;
63 }
64 
set_primary_cpu_mpidr(const uint64_t primary_cpu_mpidr_in)65 void set_primary_cpu_mpidr(const uint64_t primary_cpu_mpidr_in)
66 {
67     g_primary_cpu_mpidr = primary_cpu_mpidr_in;
68 }
69 
get_tee_vectors_t(void)70 tee_vectors_t *get_tee_vectors_t(void)
71 {
72     return g_tee_vectors;
73 }
74 
set_tee_vectors_t(tee_vectors_t * const tee_vectors_tmp)75 void set_tee_vectors_t(tee_vectors_t *const tee_vectors_tmp)
76 {
77     g_tee_vectors = tee_vectors_tmp;
78 }
79