Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018, Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <arch_helpers.h> |
| 8 | #include <debug.h> |
| 9 | #include <sp_helpers.h> |
Ambroise Vincent | 602b7f5 | 2019-02-11 14:13:43 +0000 | [diff] [blame^] | 10 | #include <stdint.h> |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 11 | |
| 12 | #include "cactus.h" |
| 13 | |
| 14 | extern uintptr_t __TEXT_START__; |
| 15 | |
| 16 | void system_setup_tests(void) |
| 17 | { |
| 18 | const char *test_sect_desc = "system setup"; |
| 19 | |
| 20 | announce_test_section_start(test_sect_desc); |
| 21 | |
| 22 | /* |
| 23 | * Try accessing CTR_EL0 register. This should work if SCTLR_EL1.UCT bit |
| 24 | * has been correctly setup by TF. |
| 25 | */ |
| 26 | const char *test_desc1 = "Read CTR_EL0 register"; |
| 27 | |
| 28 | announce_test_start(test_desc1); |
| 29 | |
| 30 | uint32_t ctr __unused = read_ctr_el0(); |
| 31 | |
| 32 | INFO("CTR_EL0 = 0x%x\n", ctr); |
| 33 | announce_test_end(test_desc1); |
| 34 | |
| 35 | /* |
| 36 | * Try to execute a cache maintenance instruction. This should work if |
| 37 | * SCTLR_EL1.UCI bit has been correctly setup by TF. |
| 38 | */ |
| 39 | const char *test_desc2 = "Access to cache maintenance operations"; |
| 40 | |
| 41 | announce_test_start(test_desc2); |
| 42 | flush_dcache_range((uintptr_t)&__TEXT_START__, 1); |
| 43 | announce_test_end(test_desc2); |
| 44 | |
| 45 | /* |
| 46 | * Try accessing a floating point register. This should not trap to |
| 47 | * S-EL1. |
| 48 | */ |
| 49 | const char *test_desc3 = "Access to FP regs"; |
| 50 | |
| 51 | announce_test_start(test_desc3); |
| 52 | /* |
| 53 | * Can't use the 'double' type here because Cactus (like the rest of |
| 54 | * the TF code) is compiled with GCC's -mgeneral-regs-only compiler flag |
| 55 | * that disables floating point support in GCC. |
| 56 | */ |
| 57 | uint64_t fp_reg; |
| 58 | |
| 59 | __asm__ volatile("fmov %0, d0" : "=r" (fp_reg) :: "d0"); |
| 60 | INFO("D0 = 0x%llx\n", fp_reg); |
| 61 | __asm__ volatile( |
| 62 | "fmov d0, #1.0 \n\t" |
| 63 | "fmov %0, d0 \n\t" |
| 64 | : "=r" (fp_reg) |
| 65 | : |
| 66 | : "d0"); |
| 67 | INFO("D0 = 0x%llx\n", fp_reg); |
| 68 | announce_test_end(test_desc3); |
| 69 | |
| 70 | announce_test_section_end(test_sect_desc); |
| 71 | } |