Achin Gupta | 7c88f3f | 2014-02-18 18:09:12 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions are met: |
| 6 | * |
| 7 | * Redistributions of source code must retain the above copyright notice, this |
| 8 | * list of conditions and the following disclaimer. |
| 9 | * |
| 10 | * Redistributions in binary form must reproduce the above copyright notice, |
| 11 | * this list of conditions and the following disclaimer in the documentation |
| 12 | * and/or other materials provided with the distribution. |
| 13 | * |
| 14 | * Neither the name of ARM nor the names of its contributors may be used |
| 15 | * to endorse or promote products derived from this software without specific |
| 16 | * prior written permission. |
| 17 | * |
| 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 22 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 23 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 24 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 26 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 28 | * POSSIBILITY OF SUCH DAMAGE. |
| 29 | */ |
| 30 | |
| 31 | #ifndef __TSP_H__ |
| 32 | #define __TSP_H__ |
| 33 | |
Achin Gupta | 7c88f3f | 2014-02-18 18:09:12 +0000 | [diff] [blame] | 34 | #include <platform.h> |
Dan Handley | bdbfc3c | 2014-04-17 17:29:58 +0100 | [diff] [blame] | 35 | #include <cassert.h> |
Achin Gupta | 7c88f3f | 2014-02-18 18:09:12 +0000 | [diff] [blame] | 36 | |
| 37 | /* |
| 38 | * SMC function IDs that TSP uses to signal various forms of completions |
| 39 | * to the secure payload dispatcher. |
| 40 | */ |
| 41 | #define TSP_ENTRY_DONE 0xf2000000 |
| 42 | #define TSP_ON_DONE 0xf2000001 |
| 43 | #define TSP_OFF_DONE 0xf2000002 |
| 44 | #define TSP_SUSPEND_DONE 0xf2000003 |
| 45 | #define TSP_RESUME_DONE 0xf2000004 |
| 46 | #define TSP_WORK_DONE 0xf2000005 |
| 47 | |
| 48 | /* SMC function ID that TSP uses to request service from secure montior */ |
| 49 | #define TSP_GET_ARGS 0xf2001000 |
| 50 | |
| 51 | /* Function IDs for various TSP services */ |
| 52 | #define TSP_FID_ADD 0xf2002000 |
| 53 | #define TSP_FID_SUB 0xf2002001 |
| 54 | #define TSP_FID_MUL 0xf2002002 |
| 55 | #define TSP_FID_DIV 0xf2002003 |
| 56 | |
Jeenu Viswambharan | 52538b9 | 2014-02-28 11:23:35 +0000 | [diff] [blame] | 57 | /* |
| 58 | * Total number of function IDs implemented for services offered to NS clients. |
| 59 | * The function IDs are defined above |
| 60 | */ |
| 61 | #define TSP_NUM_FID 0x4 |
| 62 | |
| 63 | /* TSP implementation version numbers */ |
| 64 | #define TSP_VERSION_MAJOR 0x0 /* Major version */ |
| 65 | #define TSP_VERSION_MINOR 0x1 /* Minor version */ |
| 66 | |
| 67 | /* |
| 68 | * Standard Trusted OS Function IDs that fall under Trusted OS call range |
| 69 | * according to SMC calling convention |
| 70 | */ |
| 71 | #define TOS_CALL_COUNT 0xbf00ff00 /* Number of calls implemented */ |
| 72 | #define TOS_UID 0xbf00ff01 /* Implementation UID */ |
| 73 | /* 0xbf00ff02 is reserved */ |
| 74 | #define TOS_CALL_VERSION 0xbf00ff03 /* Trusted OS Call Version */ |
| 75 | |
Achin Gupta | 7c88f3f | 2014-02-18 18:09:12 +0000 | [diff] [blame] | 76 | /* Definitions to help the assembler access the SMC/ERET args structure */ |
| 77 | #define TSP_ARGS_SIZE 0x40 |
| 78 | #define TSP_ARG0 0x0 |
| 79 | #define TSP_ARG1 0x8 |
| 80 | #define TSP_ARG2 0x10 |
| 81 | #define TSP_ARG3 0x18 |
| 82 | #define TSP_ARG4 0x20 |
| 83 | #define TSP_ARG5 0x28 |
| 84 | #define TSP_ARG6 0x30 |
| 85 | #define TSP_ARG7 0x38 |
| 86 | #define TSP_ARGS_END 0x40 |
| 87 | |
| 88 | #ifndef __ASSEMBLY__ |
| 89 | #include <stdint.h> |
| 90 | |
Dan Handley | fb037bf | 2014-04-10 15:37:22 +0100 | [diff] [blame^] | 91 | typedef void (*tsp_generic_fptr_t)(uint64_t arg0, |
Achin Gupta | 7c88f3f | 2014-02-18 18:09:12 +0000 | [diff] [blame] | 92 | uint64_t arg1, |
| 93 | uint64_t arg2, |
| 94 | uint64_t arg3, |
| 95 | uint64_t arg4, |
| 96 | uint64_t arg5, |
| 97 | uint64_t arg6, |
| 98 | uint64_t arg7); |
| 99 | |
Dan Handley | fb037bf | 2014-04-10 15:37:22 +0100 | [diff] [blame^] | 100 | typedef struct entry_info { |
| 101 | tsp_generic_fptr_t fast_smc_entry; |
| 102 | tsp_generic_fptr_t cpu_on_entry; |
| 103 | tsp_generic_fptr_t cpu_off_entry; |
| 104 | tsp_generic_fptr_t cpu_resume_entry; |
| 105 | tsp_generic_fptr_t cpu_suspend_entry; |
| 106 | } entry_info_t; |
Achin Gupta | 7c88f3f | 2014-02-18 18:09:12 +0000 | [diff] [blame] | 107 | |
Dan Handley | fb037bf | 2014-04-10 15:37:22 +0100 | [diff] [blame^] | 108 | typedef struct work_statistics { |
Achin Gupta | 7c88f3f | 2014-02-18 18:09:12 +0000 | [diff] [blame] | 109 | uint32_t smc_count; /* Number of returns on this cpu */ |
| 110 | uint32_t eret_count; /* Number of entries on this cpu */ |
| 111 | uint32_t cpu_on_count; /* Number of cpu on requests */ |
| 112 | uint32_t cpu_off_count; /* Number of cpu off requests */ |
| 113 | uint32_t cpu_suspend_count; /* Number of cpu suspend requests */ |
| 114 | uint32_t cpu_resume_count; /* Number of cpu resume requests */ |
Dan Handley | fb037bf | 2014-04-10 15:37:22 +0100 | [diff] [blame^] | 115 | } __aligned(CACHE_WRITEBACK_GRANULE) work_statistics_t; |
Achin Gupta | 7c88f3f | 2014-02-18 18:09:12 +0000 | [diff] [blame] | 116 | |
Dan Handley | fb037bf | 2014-04-10 15:37:22 +0100 | [diff] [blame^] | 117 | typedef struct tsp_args { |
Achin Gupta | 7c88f3f | 2014-02-18 18:09:12 +0000 | [diff] [blame] | 118 | uint64_t _regs[TSP_ARGS_END >> 3]; |
Dan Handley | fb037bf | 2014-04-10 15:37:22 +0100 | [diff] [blame^] | 119 | } __aligned(CACHE_WRITEBACK_GRANULE) tsp_args_t; |
Achin Gupta | 7c88f3f | 2014-02-18 18:09:12 +0000 | [diff] [blame] | 120 | |
| 121 | /* Macros to access members of the above structure using their offsets */ |
| 122 | #define read_sp_arg(args, offset) ((args)->_regs[offset >> 3]) |
| 123 | #define write_sp_arg(args, offset, val)(((args)->_regs[offset >> 3]) \ |
| 124 | = val) |
| 125 | |
| 126 | /* |
| 127 | * Ensure that the assembler's view of the size of the tsp_args is the |
| 128 | * same as the compilers |
| 129 | */ |
Dan Handley | fb037bf | 2014-04-10 15:37:22 +0100 | [diff] [blame^] | 130 | CASSERT(TSP_ARGS_SIZE == sizeof(tsp_args_t), assert_sp_args_size_mismatch); |
Achin Gupta | 7c88f3f | 2014-02-18 18:09:12 +0000 | [diff] [blame] | 131 | |
| 132 | extern void tsp_get_magic(uint64_t args[4]); |
| 133 | |
| 134 | extern void tsp_fast_smc_entry(uint64_t arg0, |
| 135 | uint64_t arg1, |
| 136 | uint64_t arg2, |
| 137 | uint64_t arg3, |
| 138 | uint64_t arg4, |
| 139 | uint64_t arg5, |
| 140 | uint64_t arg6, |
| 141 | uint64_t arg7); |
| 142 | extern void tsp_cpu_resume_entry(uint64_t arg0, |
| 143 | uint64_t arg1, |
| 144 | uint64_t arg2, |
| 145 | uint64_t arg3, |
| 146 | uint64_t arg4, |
| 147 | uint64_t arg5, |
| 148 | uint64_t arg6, |
| 149 | uint64_t arg7); |
Dan Handley | fb037bf | 2014-04-10 15:37:22 +0100 | [diff] [blame^] | 150 | extern tsp_args_t *tsp_cpu_resume_main(uint64_t arg0, |
Achin Gupta | 7c88f3f | 2014-02-18 18:09:12 +0000 | [diff] [blame] | 151 | uint64_t arg1, |
| 152 | uint64_t arg2, |
| 153 | uint64_t arg3, |
| 154 | uint64_t arg4, |
| 155 | uint64_t arg5, |
| 156 | uint64_t arg6, |
| 157 | uint64_t arg7); |
| 158 | extern void tsp_cpu_suspend_entry(uint64_t arg0, |
| 159 | uint64_t arg1, |
| 160 | uint64_t arg2, |
| 161 | uint64_t arg3, |
| 162 | uint64_t arg4, |
| 163 | uint64_t arg5, |
| 164 | uint64_t arg6, |
| 165 | uint64_t arg7); |
Dan Handley | fb037bf | 2014-04-10 15:37:22 +0100 | [diff] [blame^] | 166 | extern tsp_args_t *tsp_cpu_suspend_main(uint64_t arg0, |
Achin Gupta | 7c88f3f | 2014-02-18 18:09:12 +0000 | [diff] [blame] | 167 | uint64_t arg1, |
| 168 | uint64_t arg2, |
| 169 | uint64_t arg3, |
| 170 | uint64_t arg4, |
| 171 | uint64_t arg5, |
| 172 | uint64_t arg6, |
| 173 | uint64_t arg7); |
| 174 | extern void tsp_cpu_on_entry(uint64_t arg0, |
| 175 | uint64_t arg1, |
| 176 | uint64_t arg2, |
| 177 | uint64_t arg3, |
| 178 | uint64_t arg4, |
| 179 | uint64_t arg5, |
| 180 | uint64_t arg6, |
| 181 | uint64_t arg7); |
Dan Handley | fb037bf | 2014-04-10 15:37:22 +0100 | [diff] [blame^] | 182 | extern tsp_args_t *tsp_cpu_on_main(void); |
Achin Gupta | 7c88f3f | 2014-02-18 18:09:12 +0000 | [diff] [blame] | 183 | extern void tsp_cpu_off_entry(uint64_t arg0, |
| 184 | uint64_t arg1, |
| 185 | uint64_t arg2, |
| 186 | uint64_t arg3, |
| 187 | uint64_t arg4, |
| 188 | uint64_t arg5, |
| 189 | uint64_t arg6, |
| 190 | uint64_t arg7); |
Dan Handley | fb037bf | 2014-04-10 15:37:22 +0100 | [diff] [blame^] | 191 | extern tsp_args_t *tsp_cpu_off_main(uint64_t arg0, |
Achin Gupta | 7c88f3f | 2014-02-18 18:09:12 +0000 | [diff] [blame] | 192 | uint64_t arg1, |
| 193 | uint64_t arg2, |
| 194 | uint64_t arg3, |
| 195 | uint64_t arg4, |
| 196 | uint64_t arg5, |
| 197 | uint64_t arg6, |
| 198 | uint64_t arg7); |
| 199 | #endif /* __ASSEMBLY__ */ |
| 200 | |
| 201 | #endif /* __BL2_H__ */ |