Harrison Mutai | e0bc2c8 | 2025-05-08 15:36:08 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
Harrison Mutai | e0bc2c8 | 2025-05-08 15:36:08 +0000 | [diff] [blame] | 11 | struct entry_point_info * |
| 12 | transfer_list_set_handoff_args(struct transfer_list_header *tl, |
| 13 | struct entry_point_info *ep_info) |
| 14 | { |
| 15 | struct transfer_list_entry *te = NULL; |
| 16 | void *dt = NULL; |
| 17 | |
| 18 | if (!ep_info || !tl || transfer_list_check_header(tl) == TL_OPS_NON) { |
| 19 | return NULL; |
| 20 | } |
| 21 | |
| 22 | te = transfer_list_find(tl, TL_TAG_FDT); |
| 23 | dt = transfer_list_entry_data(te); |
| 24 | |
| 25 | #ifdef __aarch64__ |
| 26 | if (GET_SPSR_RW(ep_info->spsr) == 0U) { |
| 27 | ep_info->args.arg0 = (uintptr_t)dt; |
| 28 | ep_info->args.arg1 = TRANSFER_LIST_HANDOFF_X1_VALUE( |
| 29 | REGISTER_CONVENTION_VERSION); |
| 30 | ep_info->args.arg2 = 0; |
| 31 | } else |
| 32 | #endif |
| 33 | { |
| 34 | ep_info->args.arg0 = 0; |
| 35 | ep_info->args.arg1 = TRANSFER_LIST_HANDOFF_R1_VALUE( |
| 36 | REGISTER_CONVENTION_VERSION); |
| 37 | ep_info->args.arg2 = (uintptr_t)dt; |
| 38 | } |
| 39 | |
| 40 | ep_info->args.arg3 = (uintptr_t)tl; |
| 41 | |
| 42 | return ep_info; |
| 43 | } |