Harrison Mutai | 6e01164 | 2023-09-22 17:17:35 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2023, Arm Limited and Contributors. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <assert.h> |
| 8 | |
| 9 | #include <test_helpers.h> |
| 10 | #include <tftf_lib.h> |
| 11 | #include <transfer_list.h> |
| 12 | |
| 13 | extern u_register_t hw_config_base; |
| 14 | extern u_register_t ns_tl; |
| 15 | extern u_register_t tl_signature; |
| 16 | |
| 17 | #define DTB_PREAMBLE U(0xedfe0dd0) |
| 18 | |
| 19 | test_result_t test_handoff_header(void) |
| 20 | { |
| 21 | struct transfer_list_header *tl = (struct transfer_list_header *)ns_tl; |
| 22 | |
Harrison Mutai | 112498c | 2025-02-18 11:52:12 +0000 | [diff] [blame^] | 23 | #if __aarch64__ |
| 24 | uint64_t signature = TRANSFER_LIST_HANDOFF_X1_VALUE(TRANSFER_LIST_VERSION); |
| 25 | #else |
| 26 | uint32_t signature = TRANSFER_LIST_HANDOFF_R1_VALUE(TRANSFER_LIST_VERSION); |
| 27 | #endif /* __aarch64__ */ |
| 28 | |
| 29 | if (signature != tl_signature) { |
| 30 | return TEST_RESULT_FAIL; |
| 31 | } |
Harrison Mutai | 6e01164 | 2023-09-22 17:17:35 +0100 | [diff] [blame] | 32 | |
| 33 | if (transfer_list_check_header(tl) == TL_OPS_NON) { |
| 34 | return TEST_RESULT_FAIL; |
| 35 | } |
| 36 | |
| 37 | return TEST_RESULT_SUCCESS; |
| 38 | } |
| 39 | |
| 40 | test_result_t test_handoff_dtb_payload(void) |
| 41 | { |
| 42 | tftf_testcase_printf("Validating HW_CONFIG from transfer list.\n"); |
| 43 | struct transfer_list_header *tl = (struct transfer_list_header *)ns_tl; |
| 44 | struct transfer_list_entry *te = (void *)tl + tl->hdr_size; |
| 45 | uintptr_t dtb_ptr; |
| 46 | |
| 47 | te = transfer_list_find(tl, TL_TAG_FDT); |
| 48 | |
| 49 | if (te == NULL) { |
| 50 | tftf_testcase_printf( |
| 51 | "Failed to find HW CONFIG TE in transfer list!"); |
| 52 | return TEST_RESULT_FAIL; |
| 53 | } |
| 54 | |
| 55 | dtb_ptr = (unsigned long)transfer_list_entry_data(te); |
| 56 | |
| 57 | if ((dtb_ptr != hw_config_base) && |
| 58 | (*(uint32_t *)dtb_ptr != DTB_PREAMBLE)) { |
| 59 | return TEST_RESULT_FAIL; |
| 60 | } |
| 61 | |
| 62 | return TEST_RESULT_SUCCESS; |
| 63 | } |