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 | |
| 23 | assert((uint32_t)tl_signature == |
| 24 | (REGISTER_CONVENTION_VERSION_MASK | TRANSFER_LIST_SIGNATURE)); |
| 25 | |
| 26 | if (transfer_list_check_header(tl) == TL_OPS_NON) { |
| 27 | return TEST_RESULT_FAIL; |
| 28 | } |
| 29 | |
| 30 | return TEST_RESULT_SUCCESS; |
| 31 | } |
| 32 | |
| 33 | test_result_t test_handoff_dtb_payload(void) |
| 34 | { |
| 35 | tftf_testcase_printf("Validating HW_CONFIG from transfer list.\n"); |
| 36 | struct transfer_list_header *tl = (struct transfer_list_header *)ns_tl; |
| 37 | struct transfer_list_entry *te = (void *)tl + tl->hdr_size; |
| 38 | uintptr_t dtb_ptr; |
| 39 | |
| 40 | te = transfer_list_find(tl, TL_TAG_FDT); |
| 41 | |
| 42 | if (te == NULL) { |
| 43 | tftf_testcase_printf( |
| 44 | "Failed to find HW CONFIG TE in transfer list!"); |
| 45 | return TEST_RESULT_FAIL; |
| 46 | } |
| 47 | |
| 48 | dtb_ptr = (unsigned long)transfer_list_entry_data(te); |
| 49 | |
| 50 | if ((dtb_ptr != hw_config_base) && |
| 51 | (*(uint32_t *)dtb_ptr != DTB_PREAMBLE)) { |
| 52 | return TEST_RESULT_FAIL; |
| 53 | } |
| 54 | |
| 55 | return TEST_RESULT_SUCCESS; |
| 56 | } |