1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /* 3 * Copyright (C) 2023, STMicroelectronics 4 */ 5 6 #ifndef __REMOTEPROC_PTA_H 7 #define __REMOTEPROC_PTA_H 8 9 #include <stdint.h> 10 #include <util.h> 11 12 /* 13 * Interface to the pseudo TA which provides platform implementation 14 * of the remote processor management 15 */ 16 17 #define PTA_RPROC_UUID { 0x54af4a68, 0x19be, 0x40d7, \ 18 { 0xbb, 0xe6, 0x89, 0x50, 0x35, 0x0a, 0x87, 0x44 } } 19 20 /* Hardware capability: firmware format */ 21 #define PTA_RPROC_HWCAP_FMT_ELF BIT32(0) 22 23 /* Hardware capability: image protection method */ 24 /* The platform supports load of segment with hash protection */ 25 #define PTA_RPROC_HWCAP_PROT_HASH_TABLE BIT32(0) 26 27 /** 28 * struct rproc_pta_key_info - public key information 29 * @algo: Algorithm, defined by public key algorithms TEE_ALG_* 30 * @info_size: Byte size of @info 31 * @info: Append key information data 32 */ 33 struct rproc_pta_key_info { 34 uint32_t algo; 35 uint32_t info_size; 36 uint8_t info[]; 37 }; 38 39 static inline size_t rproc_pta_keyinfo_size(struct rproc_pta_key_info *keyinf) 40 { 41 size_t s = 0; 42 43 if (!keyinf || ADD_OVERFLOW(sizeof(*keyinf), keyinf->info_size, &s)) 44 return 0; 45 46 return s; 47 } 48 49 /* 50 * Platform capabilities. 51 * 52 * Get Platform firmware loader service capabilities. 53 * 54 * [in] params[0].value.a: Unique 32bit remote processor identifier 55 * [out] params[1].value.a: Firmware format (PTA_RPROC_HWCAP_FMT_*) 56 * [out] params[2].value.a: Image protection method (PTA_RPROC_HWCAP_PROT_*) 57 */ 58 #define PTA_RPROC_HW_CAPABILITIES 1 59 60 /* 61 * Firmware loading. 62 * 63 * Optional service to implement only in case of proprietary format. 64 * 65 * [in] params[0].value.a: Unique 32bit remote processor identifier 66 * [in] params[1].memref: Loadable firmware image 67 */ 68 #define PTA_RPROC_FIRMWARE_LOAD 2 69 70 /* 71 * Load a segment with a SHA256 hash. 72 * 73 * This command is used when the platform secure memory is too constrained to 74 * save the whole firmware image. Upon segment load, a successful completion 75 * ensures the loaded image complies with the provided hash. 76 * 77 * [in] params[0].value.a: Unique 32bit remote processor identifier 78 * [in] params[1].memref: Section data to load 79 * [in] params[2].value.a: 32bit LSB load device segment address 80 * [in] params[2].value.b: 32bit MSB load device segment address 81 * [in] params[3].memref: Expected hash (SHA256) of the payload 82 */ 83 #define PTA_RPROC_LOAD_SEGMENT_SHA256 3 84 85 /* 86 * Memory set. 87 * 88 * Fill a remote device memory with requested value. this is used for instance 89 * to clear a memory on the remote firmware load. 90 * 91 * [in] params[0].value.a: Unique 32bit remote processor identifier 92 * [in] params[1].value.a: 32bit LSB device memory address 93 * [in] params[1].value.b: 32bit MSB device memory address 94 * [in] params[2].value.a: 32bit LSB device memory size 95 * [in] params[2].value.b: 32bit MSB device memory size 96 * [in] params[3].value.a: Byte value to be set 97 */ 98 #define PTA_RPROC_SET_MEMORY 4 99 100 /* 101 * Firmware start. 102 * 103 * Start up a successfully loaded remote processor firmware. 104 * 105 * [in] params[0].value.a: Unique 32bit remote processor identifier 106 */ 107 #define PTA_RPROC_FIRMWARE_START 5 108 109 /* 110 * Firmware stop. 111 * 112 * Stop of the remote processor firmware and release/clean resources. 113 * After the command successful completion, remote processor firmware must be 114 * reloaded prior being started again. 115 * 116 * [in] params[0].value.a: Unique 32bit remote processor identifier 117 */ 118 #define PTA_RPROC_FIRMWARE_STOP 6 119 120 /* 121 * Firmware device to physical address conversion. 122 * 123 * Convert the physical address corresponding to an address got from the 124 * firmware address layout. 125 * 126 * [in] params[0].value.a: Unique 32bit remote processor identifier 127 * [in] params[1].value.a: 32bit LSB Device memory address 128 * [in] params[1].value.b: 32bit MSB Device memory address 129 * [in] params[2].value.a: 32bit LSB Device memory size 130 * [in] params[2].value.b: 32bit MSB Device memory size 131 * [out] params[3].value.a: 32bit LSB converted physical address 132 * [out] params[3].value.b: 32bit MSB converted physical address 133 */ 134 #define PTA_RPROC_FIRMWARE_DA_TO_PA 7 135 136 /* 137 * Verify the firmware digest against a signature 138 * 139 * Return TEE_SUCCESS if the signature is verified, 140 * TEE_ERROR_SIGNATURE_INVALID when signature is not valid, 141 * another error code for other error cases. 142 * 143 * [in] params[0].value.a: Unique 32bit remote processor identifier 144 * [in] params[1].memref: Key information (refer to @rproc_pta_key_info) 145 * [in] params[2].memref: Digest of the firmware authenticated data 146 * [in] params[3].memref: Signature of the firmware authenticated data 147 */ 148 #define PTA_RPROC_VERIFY_DIGEST 8 149 150 /* 151 * Remote processor resources release. 152 * 153 * Release the resources associated to the remote processor. 154 * 155 * [in] params[0].value.a: Unique 32bit remote processor identifier 156 */ 157 #define PTA_REMOTEPROC_RELEASE 9 158 159 #endif /* __REMOTEPROC_PTA_H */ 160