blob: 66873e276ac508035ac035b69976a1184f222bcc [file] [log] [blame]
Dan Handleye2c27f52014-08-01 17:58:27 +01001/*
Achin Gupta6b4ec242021-10-04 20:13:36 +01002 * Copyright (c) 2014-2022, ARM Limited and Contributors. All rights reserved.
Dan Handleye2c27f52014-08-01 17:58:27 +01003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Dan Handleye2c27f52014-08-01 17:58:27 +01005 */
6
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +00007#ifndef TSP_PRIVATE_H
8#define TSP_PRIVATE_H
Dan Handleye2c27f52014-08-01 17:58:27 +01009
Achin Gupta6b4ec242021-10-04 20:13:36 +010010/*******************************************************************************
11 * The TSP memory footprint starts at address BL32_BASE and ends with the
12 * linker symbol __BL32_END__. Use these addresses to compute the TSP image
13 * size.
14 ******************************************************************************/
15#define BL32_TOTAL_LIMIT BL32_END
16#define BL32_TOTAL_SIZE (BL32_TOTAL_LIMIT - (unsigned long) BL32_BASE)
Dan Handleye2c27f52014-08-01 17:58:27 +010017
Julius Werner53456fc2019-07-09 13:49:11 -070018#ifndef __ASSEMBLER__
Dan Handleye2c27f52014-08-01 17:58:27 +010019
Dan Handleye2c27f52014-08-01 17:58:27 +010020#include <stdint.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000021
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000022#include <bl32/tsp/tsp.h>
23#include <lib/cassert.h>
24#include <lib/spinlock.h>
Achin Gupta6b4ec242021-10-04 20:13:36 +010025#include <smccc_helpers.h>
Dan Handleye2c27f52014-08-01 17:58:27 +010026
27typedef struct work_statistics {
Soby Mathewbec98512015-09-03 18:29:38 +010028 /* Number of s-el1 interrupts on this cpu */
29 uint32_t sel1_intr_count;
Soby Mathewbc912822015-09-22 12:01:18 +010030 /* Number of non s-el1 interrupts on this cpu which preempted TSP */
31 uint32_t preempt_intr_count;
Soby Mathewbec98512015-09-03 18:29:38 +010032 /* Number of sync s-el1 interrupts on this cpu */
33 uint32_t sync_sel1_intr_count;
34 /* Number of s-el1 interrupts returns on this cpu */
35 uint32_t sync_sel1_intr_ret_count;
Dan Handleye2c27f52014-08-01 17:58:27 +010036 uint32_t smc_count; /* Number of returns on this cpu */
37 uint32_t eret_count; /* Number of entries on this cpu */
38 uint32_t cpu_on_count; /* Number of cpu on requests */
39 uint32_t cpu_off_count; /* Number of cpu off requests */
40 uint32_t cpu_suspend_count; /* Number of cpu suspend requests */
41 uint32_t cpu_resume_count; /* Number of cpu resume requests */
42} __aligned(CACHE_WRITEBACK_GRANULE) work_statistics_t;
43
Dan Handleye2c27f52014-08-01 17:58:27 +010044/* Macros to access members of the above structure using their offsets */
45#define read_sp_arg(args, offset) ((args)->_regs[offset >> 3])
46#define write_sp_arg(args, offset, val) (((args)->_regs[offset >> 3]) \
47 = val)
Dan Handleye2c27f52014-08-01 17:58:27 +010048
Alexei Fedorov7d616ee2020-11-13 12:36:49 +000049uint128_t tsp_get_magic(void);
Dan Handleye2c27f52014-08-01 17:58:27 +010050
Achin Gupta6b4ec242021-10-04 20:13:36 +010051smc_args_t *set_smc_args(uint64_t arg0,
52 uint64_t arg1,
53 uint64_t arg2,
54 uint64_t arg3,
55 uint64_t arg4,
56 uint64_t arg5,
57 uint64_t arg6,
58 uint64_t arg7);
59smc_args_t *tsp_cpu_resume_main(uint64_t max_off_pwrlvl,
Dan Handleye2c27f52014-08-01 17:58:27 +010060 uint64_t arg1,
61 uint64_t arg2,
62 uint64_t arg3,
63 uint64_t arg4,
64 uint64_t arg5,
65 uint64_t arg6,
66 uint64_t arg7);
Achin Gupta6b4ec242021-10-04 20:13:36 +010067smc_args_t *tsp_cpu_suspend_main(uint64_t arg0,
Dan Handleye2c27f52014-08-01 17:58:27 +010068 uint64_t arg1,
69 uint64_t arg2,
70 uint64_t arg3,
71 uint64_t arg4,
72 uint64_t arg5,
73 uint64_t arg6,
74 uint64_t arg7);
Achin Gupta6b4ec242021-10-04 20:13:36 +010075smc_args_t *tsp_cpu_on_main(void);
76smc_args_t *tsp_cpu_off_main(uint64_t arg0,
Dan Handleye2c27f52014-08-01 17:58:27 +010077 uint64_t arg1,
78 uint64_t arg2,
79 uint64_t arg3,
80 uint64_t arg4,
81 uint64_t arg5,
82 uint64_t arg6,
83 uint64_t arg7);
84
85/* Generic Timer functions */
86void tsp_generic_timer_start(void);
87void tsp_generic_timer_handler(void);
88void tsp_generic_timer_stop(void);
89void tsp_generic_timer_save(void);
90void tsp_generic_timer_restore(void);
91
Soby Mathewbec98512015-09-03 18:29:38 +010092/* S-EL1 interrupt management functions */
93void tsp_update_sync_sel1_intr_stats(uint32_t type, uint64_t elr_el3);
Dan Handleye2c27f52014-08-01 17:58:27 +010094
95
96/* Data structure to keep track of TSP statistics */
Dan Handleye2c27f52014-08-01 17:58:27 +010097extern work_statistics_t tsp_stats[PLATFORM_CORE_COUNT];
98
99/* Vector table of jumps */
100extern tsp_vectors_t tsp_vector_table;
101
Roberto Vargasd4b35e12018-02-12 12:36:17 +0000102/* functions */
103int32_t tsp_common_int_handler(void);
104int32_t tsp_handle_preemption(void);
105
Achin Gupta6b4ec242021-10-04 20:13:36 +0100106smc_args_t *tsp_abort_smc_handler(uint64_t func,
Roberto Vargasd4b35e12018-02-12 12:36:17 +0000107 uint64_t arg1,
108 uint64_t arg2,
109 uint64_t arg3,
110 uint64_t arg4,
111 uint64_t arg5,
112 uint64_t arg6,
113 uint64_t arg7);
114
Achin Gupta6b4ec242021-10-04 20:13:36 +0100115smc_args_t *tsp_smc_handler(uint64_t func,
116 uint64_t arg1,
117 uint64_t arg2,
118 uint64_t arg3,
119 uint64_t arg4,
120 uint64_t arg5,
121 uint64_t arg6,
122 uint64_t arg7);
Roberto Vargasd4b35e12018-02-12 12:36:17 +0000123
Achin Gupta6b4ec242021-10-04 20:13:36 +0100124smc_args_t *tsp_system_reset_main(uint64_t arg0,
125 uint64_t arg1,
126 uint64_t arg2,
127 uint64_t arg3,
128 uint64_t arg4,
129 uint64_t arg5,
130 uint64_t arg6,
131 uint64_t arg7);
Roberto Vargasd4b35e12018-02-12 12:36:17 +0000132
Achin Gupta6b4ec242021-10-04 20:13:36 +0100133smc_args_t *tsp_system_off_main(uint64_t arg0,
Roberto Vargasd4b35e12018-02-12 12:36:17 +0000134 uint64_t arg1,
135 uint64_t arg2,
136 uint64_t arg3,
137 uint64_t arg4,
138 uint64_t arg5,
139 uint64_t arg6,
140 uint64_t arg7);
Dan Handleye2c27f52014-08-01 17:58:27 +0100141
Roberto Vargasd4b35e12018-02-12 12:36:17 +0000142uint64_t tsp_main(void);
Julius Werner53456fc2019-07-09 13:49:11 -0700143#endif /* __ASSEMBLER__ */
Dan Handleye2c27f52014-08-01 17:58:27 +0100144
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +0000145#endif /* TSP_PRIVATE_H */