xref: /rk3399_ARM-atf/include/bl32/tsp/tsp.h (revision 4d4821569d15c3411a6fe5dcfc791d6b28c6d6a9)
15a06bb7eSDan Handley /*
2*4d482156SDaniel Boulby  * Copyright (c) 2013-2022, ARM Limited and Contributors. All rights reserved.
35a06bb7eSDan Handley  *
482cb2c1aSdp-arm  * SPDX-License-Identifier: BSD-3-Clause
55a06bb7eSDan Handley  */
65a06bb7eSDan Handley 
7c3cf06f1SAntonio Nino Diaz #ifndef TSP_H
8c3cf06f1SAntonio Nino Diaz #define TSP_H
95a06bb7eSDan Handley 
105a06bb7eSDan Handley /*
115a06bb7eSDan Handley  * SMC function IDs that TSP uses to signal various forms of completions
125a06bb7eSDan Handley  * to the secure payload dispatcher.
135a06bb7eSDan Handley  */
145a06bb7eSDan Handley #define TSP_ENTRY_DONE		0xf2000000
155a06bb7eSDan Handley #define TSP_ON_DONE		0xf2000001
165a06bb7eSDan Handley #define TSP_OFF_DONE		0xf2000002
175a06bb7eSDan Handley #define TSP_SUSPEND_DONE	0xf2000003
185a06bb7eSDan Handley #define TSP_RESUME_DONE		0xf2000004
195a06bb7eSDan Handley #define TSP_PREEMPTED		0xf2000005
203df6012aSDouglas Raillard #define TSP_ABORT_DONE		0xf2000007
21d5f13093SJuan Castillo #define TSP_SYSTEM_OFF_DONE	0xf2000008
22d5f13093SJuan Castillo #define TSP_SYSTEM_RESET_DONE	0xf2000009
235a06bb7eSDan Handley 
245a06bb7eSDan Handley /*
2516292f54SDavid Cunado  * Function identifiers to handle S-EL1 interrupt through the synchronous
2602446137SSoby Mathew  * handling model. If the TSP was previously interrupted then control has to
2702446137SSoby Mathew  * be returned to the TSPD after handling the interrupt else execution can
2802446137SSoby Mathew  * remain in the TSP.
295a06bb7eSDan Handley  */
3002446137SSoby Mathew #define TSP_HANDLED_S_EL1_INTR		0xf2000006
315a06bb7eSDan Handley 
325a06bb7eSDan Handley /* SMC function ID that TSP uses to request service from secure monitor */
335a06bb7eSDan Handley #define TSP_GET_ARGS		0xf2001000
345a06bb7eSDan Handley 
355a06bb7eSDan Handley /*
365a06bb7eSDan Handley  * Identifiers for various TSP services. Corresponding function IDs (whether
3716292f54SDavid Cunado  * fast or yielding) are generated by macros defined below
385a06bb7eSDan Handley  */
395a06bb7eSDan Handley #define TSP_ADD		0x2000
405a06bb7eSDan Handley #define TSP_SUB		0x2001
415a06bb7eSDan Handley #define TSP_MUL		0x2002
425a06bb7eSDan Handley #define TSP_DIV		0x2003
4302446137SSoby Mathew #define TSP_HANDLE_SEL1_INTR_AND_RETURN	0x2004
44*4d482156SDaniel Boulby #define TSP_CHECK_DIT	0x2005
455a06bb7eSDan Handley 
465a06bb7eSDan Handley /*
475a06bb7eSDan Handley  * Identify a TSP service from function ID filtering the last 16 bits from the
485a06bb7eSDan Handley  * SMC function ID
495a06bb7eSDan Handley  */
505a06bb7eSDan Handley #define TSP_BARE_FID(fid)	((fid) & 0xffff)
515a06bb7eSDan Handley 
525a06bb7eSDan Handley /*
535388a584SDouglas Raillard  * Generate function IDs for TSP services to be used in SMC calls, by
5416292f54SDavid Cunado  * appropriately setting bit 31 to differentiate yielding and fast SMC calls
555388a584SDouglas Raillard  */
5616292f54SDavid Cunado #define TSP_YIELD_FID(fid)	((TSP_BARE_FID(fid) | 0x72000000))
575388a584SDouglas Raillard #define TSP_FAST_FID(fid)	((TSP_BARE_FID(fid) | 0x72000000) | (1u << 31))
585388a584SDouglas Raillard 
5916292f54SDavid Cunado /* SMC function ID to request a previously preempted yielding smc */
6016292f54SDavid Cunado #define TSP_FID_RESUME		TSP_YIELD_FID(0x3000)
615388a584SDouglas Raillard /*
6216292f54SDavid Cunado  * SMC function ID to request abortion of a previously preempted yielding SMC. A
633df6012aSDouglas Raillard  * fast SMC is used so that the TSP abort handler does not have to be
643df6012aSDouglas Raillard  * reentrant.
653df6012aSDouglas Raillard  */
663df6012aSDouglas Raillard #define TSP_FID_ABORT		TSP_FAST_FID(0x3001)
673df6012aSDouglas Raillard 
683df6012aSDouglas Raillard /*
695a06bb7eSDan Handley  * Total number of function IDs implemented for services offered to NS clients.
705a06bb7eSDan Handley  * The function IDs are defined above
715a06bb7eSDan Handley  */
723df6012aSDouglas Raillard #define TSP_NUM_FID		0x5
735a06bb7eSDan Handley 
745a06bb7eSDan Handley /* TSP implementation version numbers */
755a06bb7eSDan Handley #define TSP_VERSION_MAJOR	0x0 /* Major version */
765a06bb7eSDan Handley #define TSP_VERSION_MINOR	0x1 /* Minor version */
775a06bb7eSDan Handley 
785a06bb7eSDan Handley /*
795a06bb7eSDan Handley  * Standard Trusted OS Function IDs that fall under Trusted OS call range
805a06bb7eSDan Handley  * according to SMC calling convention
815a06bb7eSDan Handley  */
825a06bb7eSDan Handley #define TOS_CALL_COUNT		0xbf00ff00 /* Number of calls implemented */
835a06bb7eSDan Handley #define TOS_UID			0xbf00ff01 /* Implementation UID */
845a06bb7eSDan Handley /*				0xbf00ff02 is reserved */
855a06bb7eSDan Handley #define TOS_CALL_VERSION	0xbf00ff03 /* Trusted OS Call Version */
865a06bb7eSDan Handley 
875a06bb7eSDan Handley 
88d5dfdeb6SJulius Werner #ifndef __ASSEMBLER__
895a06bb7eSDan Handley 
905a06bb7eSDan Handley #include <stdint.h>
915a06bb7eSDan Handley 
925a06bb7eSDan Handley 
935a06bb7eSDan Handley typedef uint32_t tsp_vector_isn_t;
945a06bb7eSDan Handley 
955a06bb7eSDan Handley typedef struct tsp_vectors {
9616292f54SDavid Cunado 	tsp_vector_isn_t yield_smc_entry;
975a06bb7eSDan Handley 	tsp_vector_isn_t fast_smc_entry;
985a06bb7eSDan Handley 	tsp_vector_isn_t cpu_on_entry;
995a06bb7eSDan Handley 	tsp_vector_isn_t cpu_off_entry;
1005a06bb7eSDan Handley 	tsp_vector_isn_t cpu_resume_entry;
1015a06bb7eSDan Handley 	tsp_vector_isn_t cpu_suspend_entry;
10202446137SSoby Mathew 	tsp_vector_isn_t sel1_intr_entry;
103d5f13093SJuan Castillo 	tsp_vector_isn_t system_off_entry;
104d5f13093SJuan Castillo 	tsp_vector_isn_t system_reset_entry;
10516292f54SDavid Cunado 	tsp_vector_isn_t abort_yield_smc_entry;
1065a06bb7eSDan Handley } tsp_vectors_t;
1075a06bb7eSDan Handley 
10867b6ff9fSAntonio Nino Diaz void tsp_setup(void);
1095a06bb7eSDan Handley 
110d5dfdeb6SJulius Werner #endif /* __ASSEMBLER__ */
1115a06bb7eSDan Handley 
112c3cf06f1SAntonio Nino Diaz #endif /* TSP_H */
113