blob: f6b26be922495881b7eb6a14a8ad54913eb0091d [file] [log] [blame]
Harrison Mutaie0bc2c82025-05-08 15:36:08 +00001/*
2 * Copyright The Transfer List Library Contributors
3 *
4 * SPDX-License-Identifier: MIT OR GPL-2.0-or-later
5 */
6
7#include <ep_info.h>
8#include <stddef.h>
9#include <transfer_list.h>
10
11/**
12 * Set handoff arguments in the entry point info structure.
13 *
14 * This function populates the provided entry point info structure with data
15 * from the transfer list.
16 *
17 * @param[in] tl Pointer to the transfer list.
18 * @param[out] ep_info Pointer to the entry point info structure to populate.
19 *
20 * @return Pointer to the populated entry point info structure.
21 */
22struct entry_point_info *
23transfer_list_set_handoff_args(struct transfer_list_header *tl,
24 struct entry_point_info *ep_info)
25{
26 struct transfer_list_entry *te = NULL;
27 void *dt = NULL;
28
29 if (!ep_info || !tl || transfer_list_check_header(tl) == TL_OPS_NON) {
30 return NULL;
31 }
32
33 te = transfer_list_find(tl, TL_TAG_FDT);
34 dt = transfer_list_entry_data(te);
35
36#ifdef __aarch64__
37 if (GET_SPSR_RW(ep_info->spsr) == 0U) {
38 ep_info->args.arg0 = (uintptr_t)dt;
39 ep_info->args.arg1 = TRANSFER_LIST_HANDOFF_X1_VALUE(
40 REGISTER_CONVENTION_VERSION);
41 ep_info->args.arg2 = 0;
42 } else
43#endif
44 {
45 ep_info->args.arg0 = 0;
46 ep_info->args.arg1 = TRANSFER_LIST_HANDOFF_R1_VALUE(
47 REGISTER_CONVENTION_VERSION);
48 ep_info->args.arg2 = (uintptr_t)dt;
49 }
50
51 ep_info->args.arg3 = (uintptr_t)tl;
52
53 return ep_info;
54}