15a06bb7eSDan Handley /* 2*16292f54SDavid Cunado * Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved. 35a06bb7eSDan Handley * 45a06bb7eSDan Handley * Redistribution and use in source and binary forms, with or without 55a06bb7eSDan Handley * modification, are permitted provided that the following conditions are met: 65a06bb7eSDan Handley * 75a06bb7eSDan Handley * Redistributions of source code must retain the above copyright notice, this 85a06bb7eSDan Handley * list of conditions and the following disclaimer. 95a06bb7eSDan Handley * 105a06bb7eSDan Handley * Redistributions in binary form must reproduce the above copyright notice, 115a06bb7eSDan Handley * this list of conditions and the following disclaimer in the documentation 125a06bb7eSDan Handley * and/or other materials provided with the distribution. 135a06bb7eSDan Handley * 145a06bb7eSDan Handley * Neither the name of ARM nor the names of its contributors may be used 155a06bb7eSDan Handley * to endorse or promote products derived from this software without specific 165a06bb7eSDan Handley * prior written permission. 175a06bb7eSDan Handley * 185a06bb7eSDan Handley * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 195a06bb7eSDan Handley * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 205a06bb7eSDan Handley * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 215a06bb7eSDan Handley * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 225a06bb7eSDan Handley * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 235a06bb7eSDan Handley * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 245a06bb7eSDan Handley * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 255a06bb7eSDan Handley * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 265a06bb7eSDan Handley * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 275a06bb7eSDan Handley * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 285a06bb7eSDan Handley * POSSIBILITY OF SUCH DAMAGE. 295a06bb7eSDan Handley */ 305a06bb7eSDan Handley 315a06bb7eSDan Handley #ifndef __TSP_H__ 325a06bb7eSDan Handley #define __TSP_H__ 335a06bb7eSDan Handley 345a06bb7eSDan Handley /* 355a06bb7eSDan Handley * SMC function IDs that TSP uses to signal various forms of completions 365a06bb7eSDan Handley * to the secure payload dispatcher. 375a06bb7eSDan Handley */ 385a06bb7eSDan Handley #define TSP_ENTRY_DONE 0xf2000000 395a06bb7eSDan Handley #define TSP_ON_DONE 0xf2000001 405a06bb7eSDan Handley #define TSP_OFF_DONE 0xf2000002 415a06bb7eSDan Handley #define TSP_SUSPEND_DONE 0xf2000003 425a06bb7eSDan Handley #define TSP_RESUME_DONE 0xf2000004 435a06bb7eSDan Handley #define TSP_PREEMPTED 0xf2000005 443df6012aSDouglas Raillard #define TSP_ABORT_DONE 0xf2000007 45d5f13093SJuan Castillo #define TSP_SYSTEM_OFF_DONE 0xf2000008 46d5f13093SJuan Castillo #define TSP_SYSTEM_RESET_DONE 0xf2000009 475a06bb7eSDan Handley 485a06bb7eSDan Handley /* 49*16292f54SDavid Cunado * Function identifiers to handle S-EL1 interrupt through the synchronous 5002446137SSoby Mathew * handling model. If the TSP was previously interrupted then control has to 5102446137SSoby Mathew * be returned to the TSPD after handling the interrupt else execution can 5202446137SSoby Mathew * remain in the TSP. 535a06bb7eSDan Handley */ 5402446137SSoby Mathew #define TSP_HANDLED_S_EL1_INTR 0xf2000006 555a06bb7eSDan Handley 565a06bb7eSDan Handley /* SMC function ID that TSP uses to request service from secure monitor */ 575a06bb7eSDan Handley #define TSP_GET_ARGS 0xf2001000 585a06bb7eSDan Handley 595a06bb7eSDan Handley /* 605a06bb7eSDan Handley * Identifiers for various TSP services. Corresponding function IDs (whether 61*16292f54SDavid Cunado * fast or yielding) are generated by macros defined below 625a06bb7eSDan Handley */ 635a06bb7eSDan Handley #define TSP_ADD 0x2000 645a06bb7eSDan Handley #define TSP_SUB 0x2001 655a06bb7eSDan Handley #define TSP_MUL 0x2002 665a06bb7eSDan Handley #define TSP_DIV 0x2003 6702446137SSoby Mathew #define TSP_HANDLE_SEL1_INTR_AND_RETURN 0x2004 685a06bb7eSDan Handley 695a06bb7eSDan Handley /* 705a06bb7eSDan Handley * Identify a TSP service from function ID filtering the last 16 bits from the 715a06bb7eSDan Handley * SMC function ID 725a06bb7eSDan Handley */ 735a06bb7eSDan Handley #define TSP_BARE_FID(fid) ((fid) & 0xffff) 745a06bb7eSDan Handley 755a06bb7eSDan Handley /* 765388a584SDouglas Raillard * Generate function IDs for TSP services to be used in SMC calls, by 77*16292f54SDavid Cunado * appropriately setting bit 31 to differentiate yielding and fast SMC calls 785388a584SDouglas Raillard */ 79*16292f54SDavid Cunado #define TSP_YIELD_FID(fid) ((TSP_BARE_FID(fid) | 0x72000000)) 805388a584SDouglas Raillard #define TSP_FAST_FID(fid) ((TSP_BARE_FID(fid) | 0x72000000) | (1u << 31)) 815388a584SDouglas Raillard 82*16292f54SDavid Cunado /* SMC function ID to request a previously preempted yielding smc */ 83*16292f54SDavid Cunado #define TSP_FID_RESUME TSP_YIELD_FID(0x3000) 845388a584SDouglas Raillard /* 85*16292f54SDavid Cunado * SMC function ID to request abortion of a previously preempted yielding SMC. A 863df6012aSDouglas Raillard * fast SMC is used so that the TSP abort handler does not have to be 873df6012aSDouglas Raillard * reentrant. 883df6012aSDouglas Raillard */ 893df6012aSDouglas Raillard #define TSP_FID_ABORT TSP_FAST_FID(0x3001) 903df6012aSDouglas Raillard 913df6012aSDouglas Raillard /* 925a06bb7eSDan Handley * Total number of function IDs implemented for services offered to NS clients. 935a06bb7eSDan Handley * The function IDs are defined above 945a06bb7eSDan Handley */ 953df6012aSDouglas Raillard #define TSP_NUM_FID 0x5 965a06bb7eSDan Handley 975a06bb7eSDan Handley /* TSP implementation version numbers */ 985a06bb7eSDan Handley #define TSP_VERSION_MAJOR 0x0 /* Major version */ 995a06bb7eSDan Handley #define TSP_VERSION_MINOR 0x1 /* Minor version */ 1005a06bb7eSDan Handley 1015a06bb7eSDan Handley /* 1025a06bb7eSDan Handley * Standard Trusted OS Function IDs that fall under Trusted OS call range 1035a06bb7eSDan Handley * according to SMC calling convention 1045a06bb7eSDan Handley */ 1055a06bb7eSDan Handley #define TOS_CALL_COUNT 0xbf00ff00 /* Number of calls implemented */ 1065a06bb7eSDan Handley #define TOS_UID 0xbf00ff01 /* Implementation UID */ 1075a06bb7eSDan Handley /* 0xbf00ff02 is reserved */ 1085a06bb7eSDan Handley #define TOS_CALL_VERSION 0xbf00ff03 /* Trusted OS Call Version */ 1095a06bb7eSDan Handley 1105a06bb7eSDan Handley 1115a06bb7eSDan Handley #ifndef __ASSEMBLY__ 1125a06bb7eSDan Handley 1135a06bb7eSDan Handley #include <stdint.h> 1145a06bb7eSDan Handley 1155a06bb7eSDan Handley 1165a06bb7eSDan Handley typedef uint32_t tsp_vector_isn_t; 1175a06bb7eSDan Handley 1185a06bb7eSDan Handley typedef struct tsp_vectors { 119*16292f54SDavid Cunado tsp_vector_isn_t yield_smc_entry; 1205a06bb7eSDan Handley tsp_vector_isn_t fast_smc_entry; 1215a06bb7eSDan Handley tsp_vector_isn_t cpu_on_entry; 1225a06bb7eSDan Handley tsp_vector_isn_t cpu_off_entry; 1235a06bb7eSDan Handley tsp_vector_isn_t cpu_resume_entry; 1245a06bb7eSDan Handley tsp_vector_isn_t cpu_suspend_entry; 12502446137SSoby Mathew tsp_vector_isn_t sel1_intr_entry; 126d5f13093SJuan Castillo tsp_vector_isn_t system_off_entry; 127d5f13093SJuan Castillo tsp_vector_isn_t system_reset_entry; 128*16292f54SDavid Cunado tsp_vector_isn_t abort_yield_smc_entry; 1295a06bb7eSDan Handley } tsp_vectors_t; 1305a06bb7eSDan Handley 1315a06bb7eSDan Handley 1325a06bb7eSDan Handley #endif /* __ASSEMBLY__ */ 1335a06bb7eSDan Handley 1345a06bb7eSDan Handley #endif /* __TSP_H__ */ 135