blob: bc915a43119730db8e9aab2e29e121f5c0d03a03 [file] [log] [blame]
Raymond Mao98983392023-07-25 07:53:35 -07001/*
Harrison Mutai60438ee2023-12-01 14:57:57 +00002 * Copyright (c) 2023-2024, Linaro Limited and Contributors. All rights reserved.
Raymond Mao98983392023-07-25 07:53:35 -07003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef __TRANSFER_LIST_H
8#define __TRANSFER_LIST_H
9
10#include <stdbool.h>
11#include <stdint.h>
12
Raymond Mao60c3c972023-10-04 09:19:16 -070013#include <common/ep_info.h>
Raymond Mao98983392023-07-25 07:53:35 -070014#include <lib/utils_def.h>
15
Raymond Mao60c3c972023-10-04 09:19:16 -070016#define TRANSFER_LIST_SIGNATURE U(0x4a0fb10b)
17#define TRANSFER_LIST_VERSION U(0x0001)
Raymond Mao98983392023-07-25 07:53:35 -070018
Raymond Mao60c3c972023-10-04 09:19:16 -070019/*
20 * Init value of maximum alignment required by any TE data in the TL
21 * specified as a power of two
22 */
23#define TRANSFER_LIST_INIT_MAX_ALIGN U(3)
Raymond Mao98983392023-07-25 07:53:35 -070024
Raymond Mao60c3c972023-10-04 09:19:16 -070025/* Alignment required by TE header start address, in bytes */
26#define TRANSFER_LIST_GRANULE U(8)
Raymond Mao98983392023-07-25 07:53:35 -070027
Raymond Mao60c3c972023-10-04 09:19:16 -070028/*
29 * Version of the register convention used.
30 * Set to 1 for both AArch64 and AArch32 according to fw handoff spec v0.9
31 */
Raymond Mao98983392023-07-25 07:53:35 -070032#define REGISTER_CONVENTION_VERSION_MASK (1 << 24)
33
34#ifndef __ASSEMBLER__
35
Raymond Mao60c3c972023-10-04 09:19:16 -070036#define TL_FLAGS_HAS_CHECKSUM BIT(0)
37
Raymond Mao98983392023-07-25 07:53:35 -070038enum transfer_list_tag_id {
39 TL_TAG_EMPTY = 0,
40 TL_TAG_FDT = 1,
41 TL_TAG_HOB_BLOCK = 2,
42 TL_TAG_HOB_LIST = 3,
43 TL_TAG_ACPI_TABLE_AGGREGATE = 4,
Raymond Mao60c3c972023-10-04 09:19:16 -070044 TL_TAG_OPTEE_PAGABLE_PART = 0x100,
Harrison Mutai60438ee2023-12-01 14:57:57 +000045 TL_TAG_DT_SPMC_MANIFEST = 0x101,
46 TL_TAG_EXEC_EP_INFO64 = 0x102,
Raymond Mao98983392023-07-25 07:53:35 -070047};
48
49enum transfer_list_ops {
Raymond Mao60c3c972023-10-04 09:19:16 -070050 TL_OPS_NON, /* invalid for any operation */
51 TL_OPS_ALL, /* valid for all operations */
52 TL_OPS_RO, /* valid for read only */
53 TL_OPS_CUS, /* abort or switch to special code to interpret */
Raymond Mao98983392023-07-25 07:53:35 -070054};
55
56struct transfer_list_header {
Raymond Mao60c3c972023-10-04 09:19:16 -070057 uint32_t signature;
58 uint8_t checksum;
59 uint8_t version;
60 uint8_t hdr_size;
61 uint8_t alignment; /* max alignment of TE data */
62 uint32_t size; /* TL header + all TEs */
63 uint32_t max_size;
64 uint32_t flags;
65 uint32_t reserved; /* spare bytes */
Raymond Mao98983392023-07-25 07:53:35 -070066 /*
67 * Commented out element used to visualize dynamic part of the
68 * data structure.
69 *
70 * Note that struct transfer_list_entry also is dynamic in size
71 * so the elements can't be indexed directly but instead must be
72 * traversed in order
73 *
74 * struct transfer_list_entry entries[];
75 */
76};
77
78struct transfer_list_entry {
Raymond Mao60c3c972023-10-04 09:19:16 -070079 uint16_t tag_id;
80 uint8_t reserved0; /* place holder */
81 uint8_t hdr_size;
82 uint32_t data_size;
Raymond Mao98983392023-07-25 07:53:35 -070083 /*
84 * Commented out element used to visualize dynamic part of the
85 * data structure.
86 *
87 * Note that padding is added at the end of @data to make to reach
88 * a 8-byte boundary.
89 *
90 * uint8_t data[ROUNDUP(data_size, 8)];
91 */
92};
93
94void transfer_list_dump(struct transfer_list_header *tl);
Raymond Mao60c3c972023-10-04 09:19:16 -070095entry_point_info_t *
96transfer_list_set_handoff_args(struct transfer_list_header *tl,
97 entry_point_info_t *ep_info);
Raymond Mao98983392023-07-25 07:53:35 -070098struct transfer_list_header *transfer_list_init(void *addr, size_t max_size);
99
Raymond Mao60c3c972023-10-04 09:19:16 -0700100struct transfer_list_header *
101transfer_list_relocate(struct transfer_list_header *tl, void *addr,
102 size_t max_size);
103enum transfer_list_ops
104transfer_list_check_header(const struct transfer_list_header *tl);
Raymond Mao98983392023-07-25 07:53:35 -0700105
106void transfer_list_update_checksum(struct transfer_list_header *tl);
107bool transfer_list_verify_checksum(const struct transfer_list_header *tl);
108
109bool transfer_list_set_data_size(struct transfer_list_header *tl,
110 struct transfer_list_entry *entry,
111 uint32_t new_data_size);
112
113void *transfer_list_entry_data(struct transfer_list_entry *entry);
Raymond Mao60c3c972023-10-04 09:19:16 -0700114bool transfer_list_rem(struct transfer_list_header *tl,
115 struct transfer_list_entry *entry);
Raymond Mao98983392023-07-25 07:53:35 -0700116
117struct transfer_list_entry *transfer_list_add(struct transfer_list_header *tl,
Raymond Mao60c3c972023-10-04 09:19:16 -0700118 uint16_t tag_id,
119 uint32_t data_size,
Raymond Mao98983392023-07-25 07:53:35 -0700120 const void *data);
121
Raymond Mao60c3c972023-10-04 09:19:16 -0700122struct transfer_list_entry *
123transfer_list_add_with_align(struct transfer_list_header *tl, uint16_t tag_id,
124 uint32_t data_size, const void *data,
125 uint8_t alignment);
Raymond Mao98983392023-07-25 07:53:35 -0700126
Raymond Mao60c3c972023-10-04 09:19:16 -0700127struct transfer_list_entry *
128transfer_list_next(struct transfer_list_header *tl,
129 struct transfer_list_entry *last);
Raymond Mao98983392023-07-25 07:53:35 -0700130
131struct transfer_list_entry *transfer_list_find(struct transfer_list_header *tl,
132 uint16_t tag_id);
133
134#endif /*__ASSEMBLER__*/
135#endif /*__TRANSFER_LIST_H*/