Manish V Badarkhe | 82e1a25 | 2022-01-04 13:45:31 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2022, Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <test_helpers.h> |
| 8 | |
| 9 | test_result_t test_afp_support(void) |
| 10 | { |
| 11 | SKIP_TEST_IF_AARCH32(); |
| 12 | |
| 13 | #ifdef __aarch64__ |
| 14 | test_result_t ret; |
| 15 | uint64_t saved_fpcr, fpcr; |
| 16 | |
| 17 | SKIP_TEST_IF_AFP_NOT_SUPPORTED(); |
| 18 | |
| 19 | saved_fpcr = read_fpcr(); |
| 20 | /* Write advanced floating point controlling bits */ |
| 21 | write_fpcr(saved_fpcr | FPCR_FIZ_BIT | FPCR_AH_BIT | FPCR_NEP_BIT); |
| 22 | |
| 23 | fpcr = read_fpcr(); |
| 24 | /* Check if all bits got written successfully */ |
| 25 | if ((fpcr | ~(FPCR_FIZ_BIT | FPCR_AH_BIT | FPCR_NEP_BIT)) == ~0ULL) { |
| 26 | ret = TEST_RESULT_SUCCESS; |
| 27 | } else { |
| 28 | ret = TEST_RESULT_FAIL; |
| 29 | } |
| 30 | |
| 31 | write_fpcr(saved_fpcr); |
| 32 | |
| 33 | return ret; |
| 34 | #endif /* __aarch64__ */ |
| 35 | } |