blob: eee2b82c5443180cdc8a53e6ebb72db71b86f7de [file] [log] [blame]
Harrison Mutai6e011642023-09-22 17:17:35 +01001/*
2 * Copyright (c) 2023, Linaro Limited and Contributors. All rights reserved.
3 *
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
13#include <lib/utils_def.h>
14
Harrison Mutaie15bc802023-12-18 15:21:13 +000015#define TRANSFER_LIST_SIGNATURE U(0x4a0fb10b)
Harrison Mutai6e011642023-09-22 17:17:35 +010016#define TRANSFER_LIST_VERSION U(0x0001)
17
18// Init value of maximum alignment required by any TE data in the TL
19// specified as a power of two
20#define TRANSFER_LIST_INIT_MAX_ALIGN U(3)
21
22// alignment required by TE header start address, in bytes
23#define TRANSFER_LIST_GRANULE U(8)
24
25// version of the register convention used.
26// Set to 1 for both AArch64 and AArch32 according to fw handoff spec v0.9
Levi Yunb47ccd02024-07-10 16:18:47 +010027#define REGISTER_CONVENTION_VERSION_SHIFT_64 UL(32)
28#define REGISTER_CONVENTION_VERSION_SHIFT_32 UL(24)
29#define REGISTER_CONVENTION_VERSION_MASK UL(0xff)
30
31#define TRANSFER_LIST_HANDOFF_X1_VALUE(__version) \
32 ((TRANSFER_LIST_SIGNATURE & \
33 ((1UL << REGISTER_CONVENTION_VERSION_SHIFT_64) - 1)) | \
34 (((__version) & REGISTER_CONVENTION_VERSION_MASK) << \
35 REGISTER_CONVENTION_VERSION_SHIFT_64))
36
37#define TRANSFER_LIST_HANDOFF_R1_VALUE(__version) \
38 ((TRANSFER_LIST_SIGNATURE & \
39 ((1UL << REGISTER_CONVENTION_VERSION_SHIFT_32) - 1)) | \
40 (((__version) & REGISTER_CONVENTION_VERSION_MASK) << \
41 REGISTER_CONVENTION_VERSION_SHIFT_32))
Harrison Mutai6e011642023-09-22 17:17:35 +010042
43#ifndef __ASSEMBLER__
44
45enum transfer_list_tag_id {
46 TL_TAG_EMPTY = 0,
47 TL_TAG_FDT = 1,
48 TL_TAG_HOB_BLOCK = 2,
49 TL_TAG_HOB_LIST = 3,
50 TL_TAG_ACPI_TABLE_AGGREGATE = 4,
Harrison Mutai089c9ad2025-04-25 16:03:54 +000051 TL_TAG_TPM_EVLOG = 5,
Harrison Mutai6e011642023-09-22 17:17:35 +010052};
53
54enum transfer_list_ops {
55 TL_OPS_NON, // invalid for any operation
56 TL_OPS_ALL, // valid for all operations
57};
58
59struct transfer_list_header {
60 uint32_t signature;
61 uint8_t checksum;
62 uint8_t version;
63 uint8_t hdr_size;
64 uint8_t alignment; // max alignment of TE data
65 uint32_t size; // TL header + all TEs
66 uint32_t max_size;
67 /*
68 * Commented out element used to visualize dynamic part of the
69 * data structure.
70 *
71 * Note that struct transfer_list_entry also is dynamic in size
72 * so the elements can't be indexed directly but instead must be
73 * traversed in order
74 *
75 * struct transfer_list_entry entries[];
76 */
77};
78
79struct transfer_list_entry {
80 uint16_t tag_id;
81 uint8_t reserved0; // place holder
82 uint8_t hdr_size;
83 uint32_t data_size;
84 /*
85 * Commented out element used to visualize dynamic part of the
86 * data structure.
87 *
88 * Note that padding is added at the end of @data to make to reach
89 * a 8-byte boundary.
90 *
91 * uint8_t data[ROUNDUP(data_size, 8)];
92 */
93};
94
Harrison Mutai089c9ad2025-04-25 16:03:54 +000095struct transfer_list_entry *
96transfer_list_next(struct transfer_list_header *tl,
97 struct transfer_list_entry *last);
98
Harrison Mutai6e011642023-09-22 17:17:35 +010099bool transfer_list_verify_checksum(const struct transfer_list_header *tl);
100
101void *transfer_list_entry_data(struct transfer_list_entry *entry);
102
103struct transfer_list_entry *transfer_list_find(struct transfer_list_header *tl,
104 uint16_t tag_id);
105
106enum transfer_list_ops
107transfer_list_check_header(const struct transfer_list_header *tl);
108
109#endif /*__ASSEMBLER__*/
110#endif /*__TRANSFER_LIST_H*/