15a06bb7eSDan Handley /* 2*32d9e8ecSHarrison Mutai * Copyright (c) 2013-2025, 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 444d482156SDaniel Boulby #define TSP_CHECK_DIT 0x2005 457623e085SJayanth Dodderi Chidanand #define TSP_MODIFY_EL1_CTX 0x2006 465a06bb7eSDan Handley 475a06bb7eSDan Handley /* 485a06bb7eSDan Handley * Identify a TSP service from function ID filtering the last 16 bits from the 495a06bb7eSDan Handley * SMC function ID 505a06bb7eSDan Handley */ 515a06bb7eSDan Handley #define TSP_BARE_FID(fid) ((fid) & 0xffff) 525a06bb7eSDan Handley 535a06bb7eSDan Handley /* 545388a584SDouglas Raillard * Generate function IDs for TSP services to be used in SMC calls, by 5516292f54SDavid Cunado * appropriately setting bit 31 to differentiate yielding and fast SMC calls 565388a584SDouglas Raillard */ 5716292f54SDavid Cunado #define TSP_YIELD_FID(fid) ((TSP_BARE_FID(fid) | 0x72000000)) 585388a584SDouglas Raillard #define TSP_FAST_FID(fid) ((TSP_BARE_FID(fid) | 0x72000000) | (1u << 31)) 595388a584SDouglas Raillard 6016292f54SDavid Cunado /* SMC function ID to request a previously preempted yielding smc */ 6116292f54SDavid Cunado #define TSP_FID_RESUME TSP_YIELD_FID(0x3000) 625388a584SDouglas Raillard /* 6316292f54SDavid Cunado * SMC function ID to request abortion of a previously preempted yielding SMC. A 643df6012aSDouglas Raillard * fast SMC is used so that the TSP abort handler does not have to be 653df6012aSDouglas Raillard * reentrant. 663df6012aSDouglas Raillard */ 673df6012aSDouglas Raillard #define TSP_FID_ABORT TSP_FAST_FID(0x3001) 683df6012aSDouglas Raillard 693df6012aSDouglas Raillard /* 705a06bb7eSDan Handley * Total number of function IDs implemented for services offered to NS clients. 715a06bb7eSDan Handley * The function IDs are defined above 725a06bb7eSDan Handley */ 733df6012aSDouglas Raillard #define TSP_NUM_FID 0x5 745a06bb7eSDan Handley 755a06bb7eSDan Handley /* TSP implementation version numbers */ 765a06bb7eSDan Handley #define TSP_VERSION_MAJOR 0x0 /* Major version */ 775a06bb7eSDan Handley #define TSP_VERSION_MINOR 0x1 /* Minor version */ 785a06bb7eSDan Handley 795a06bb7eSDan Handley /* 805a06bb7eSDan Handley * Standard Trusted OS Function IDs that fall under Trusted OS call range 815a06bb7eSDan Handley * according to SMC calling convention 825a06bb7eSDan Handley */ 835a06bb7eSDan Handley #define TOS_CALL_COUNT 0xbf00ff00 /* Number of calls implemented */ 845a06bb7eSDan Handley #define TOS_UID 0xbf00ff01 /* Implementation UID */ 855a06bb7eSDan Handley /* 0xbf00ff02 is reserved */ 865a06bb7eSDan Handley #define TOS_CALL_VERSION 0xbf00ff03 /* Trusted OS Call Version */ 875a06bb7eSDan Handley 885a06bb7eSDan Handley 89d5dfdeb6SJulius Werner #ifndef __ASSEMBLER__ 905a06bb7eSDan Handley 915a06bb7eSDan Handley #include <stdint.h> 925a06bb7eSDan Handley 935a06bb7eSDan Handley 945a06bb7eSDan Handley typedef uint32_t tsp_vector_isn_t; 955a06bb7eSDan Handley 965a06bb7eSDan Handley typedef struct tsp_vectors { 9716292f54SDavid Cunado tsp_vector_isn_t yield_smc_entry; 985a06bb7eSDan Handley tsp_vector_isn_t fast_smc_entry; 995a06bb7eSDan Handley tsp_vector_isn_t cpu_on_entry; 1005a06bb7eSDan Handley tsp_vector_isn_t cpu_off_entry; 1015a06bb7eSDan Handley tsp_vector_isn_t cpu_resume_entry; 1025a06bb7eSDan Handley tsp_vector_isn_t cpu_suspend_entry; 10302446137SSoby Mathew tsp_vector_isn_t sel1_intr_entry; 104d5f13093SJuan Castillo tsp_vector_isn_t system_off_entry; 105d5f13093SJuan Castillo tsp_vector_isn_t system_reset_entry; 10616292f54SDavid Cunado tsp_vector_isn_t abort_yield_smc_entry; 1075a06bb7eSDan Handley } tsp_vectors_t; 1085a06bb7eSDan Handley 109*32d9e8ecSHarrison Mutai void tsp_setup(u_register_t arg0, u_register_t arg1, u_register_t arg2, 110*32d9e8ecSHarrison Mutai u_register_t arg3); 1115a06bb7eSDan Handley 112d5dfdeb6SJulius Werner #endif /* __ASSEMBLER__ */ 1135a06bb7eSDan Handley 114c3cf06f1SAntonio Nino Diaz #endif /* TSP_H */ 115