1 /* 2 * Copyright (C) 2022 Huawei Technologies Co., Ltd. 3 * Licensed under the Mulan PSL v2. 4 * You can use this software according to the terms and conditions of the Mulan PSL v2. 5 * You may obtain a copy of Mulan PSL v2 at: 6 * http://license.coscl.org.cn/MulanPSL2 7 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR 8 * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR 9 * PURPOSE. 10 * See the Mulan PSL v2 for more details. 11 */ 12 13 14 #ifndef TEE_LOADER_TLV_SHAREDMEM_H 15 #define TEE_LOADER_TLV_SHAREDMEM_H 16 17 #include <stdint.h> 18 19 #ifndef UINT64_MAX 20 #define UINT64_MAX 0xffffffffffffffffull 21 #endif 22 23 #define MAGIC_START 0xfd544c56 24 #define MAX_TAG_LEN 32 25 #define MIN_TAG_LEN 3 26 #define TLV_ITEM_DATA(item) ((void *)((char *)(item) + sizeof(struct tlv_item_tag))) 27 28 struct tlv_item_tag { 29 char type[MAX_TAG_LEN]; 30 uint32_t owner_len; 31 uint32_t length; 32 uint32_t magic; 33 } __attribute__((__packed__)); 34 35 struct tlv_item_data { 36 char *type; 37 uint32_t type_size; 38 void *owner_list; 39 uint32_t owner_len; 40 void *value; 41 uint32_t value_len; 42 } __attribute__((__packed__)); 43 44 struct tlv_tag { 45 uint32_t magic; 46 uint32_t tlv_num; 47 uint32_t total_len; 48 } __attribute__((__packed__)); 49 50 uint32_t put_tlv_shared_mem(struct tlv_item_data tlv_item_data); 51 uint32_t update_share_mem_tlv(struct tlv_item_data tlv_item_data); 52 53 #endif 54