blob: f1e4181c71c32330319ac01bee53d3e7e9c5273c [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,
51};
52
53enum transfer_list_ops {
54 TL_OPS_NON, // invalid for any operation
55 TL_OPS_ALL, // valid for all operations
56};
57
58struct transfer_list_header {
59 uint32_t signature;
60 uint8_t checksum;
61 uint8_t version;
62 uint8_t hdr_size;
63 uint8_t alignment; // max alignment of TE data
64 uint32_t size; // TL header + all TEs
65 uint32_t max_size;
66 /*
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 {
79 uint16_t tag_id;
80 uint8_t reserved0; // place holder
81 uint8_t hdr_size;
82 uint32_t data_size;
83 /*
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
94bool transfer_list_verify_checksum(const struct transfer_list_header *tl);
95
96void *transfer_list_entry_data(struct transfer_list_entry *entry);
97
98struct transfer_list_entry *transfer_list_find(struct transfer_list_header *tl,
99 uint16_t tag_id);
100
101enum transfer_list_ops
102transfer_list_check_header(const struct transfer_list_header *tl);
103
104#endif /*__ASSEMBLER__*/
105#endif /*__TRANSFER_LIST_H*/