1 /*-----------------------------------------------------------------------------
3 * Purpose: CMSIS CORE validation tests implementation
4 *-----------------------------------------------------------------------------
5 * Copyright (c) 2017 ARM Limited. All rights reserved.
6 *----------------------------------------------------------------------------*/
8 #include "CV_Framework.h"
11 /*-----------------------------------------------------------------------------
13 *----------------------------------------------------------------------------*/
15 /*-----------------------------------------------------------------------------
17 *----------------------------------------------------------------------------*/
19 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
20 void TC_CAL1Cache_EnDisable(void) {
22 uint32_t orig = __get_SCTLR();
26 uint32_t sctlr = __get_SCTLR();
27 ASSERT_TRUE((sctlr & SCTLR_I_Msk) == SCTLR_I_Msk);
28 ASSERT_TRUE((sctlr & SCTLR_C_Msk) == SCTLR_C_Msk);
33 sctlr = __get_SCTLR();
34 ASSERT_TRUE((sctlr & SCTLR_I_Msk) == 0U);
35 ASSERT_TRUE((sctlr & SCTLR_C_Msk) == 0U);
41 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
42 void TC_CAL1Cache_EnDisableBTAC(void) {
43 uint32_t orig = __get_SCTLR();
47 uint32_t sctlr = __get_SCTLR();
48 ASSERT_TRUE((sctlr & SCTLR_Z_Msk) == SCTLR_Z_Msk);
52 sctlr = __get_SCTLR();
54 // On Cortex-A7 SCTLR_Z is RAO/WI.
55 ASSERT_TRUE((sctlr & SCTLR_Z_Msk) == SCTLR_Z_Msk);
57 ASSERT_TRUE((sctlr & SCTLR_Z_Msk) == 0U);
64 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
65 void TC_CAL1Cache_log2_up(void) {
66 uint8_t log2 = __log2_up(0U);
67 ASSERT_TRUE(log2 == 0U);
70 ASSERT_TRUE(log2 == 0U);
73 ASSERT_TRUE(log2 == 1U);
76 ASSERT_TRUE(log2 == 2U);
79 ASSERT_TRUE(log2 == 2U);
81 log2 = __log2_up(0x80000000U);
82 ASSERT_TRUE(log2 == 31U);
84 log2 = __log2_up(0x80000001U);
85 ASSERT_TRUE(log2 == 32U);
87 log2 = __log2_up(0xFFFFFFFFU);
88 ASSERT_TRUE(log2 == 32U);
91 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
92 void TC_CAL1Cache_InvalidateDCacheAll(void) {
95 uint32_t orig = __get_SCTLR();
96 volatile uint32_t value = 0x0815U;
100 L1C_CleanDCacheAll();
102 /* test cached value gets lost */
104 // WHEN a value is written
107 // ... and the cache is invalidated
108 L1C_InvalidateDCacheAll();
110 // ... and the cache is disabled
113 // THEN the new value has been lost
114 ASSERT_TRUE(value == 0x0815U);
117 L1C_InvalidateDCacheAll();
122 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
123 void TC_CAL1Cache_CleanDCacheAll(void) {
125 uint32_t orig = __get_SCTLR();
126 uint32_t value = 0x0815U;
130 L1C_CleanDCacheAll();
132 /* test cached value is preserved */
134 // WHEN a value is written
137 // ... and the cache is cleaned
138 L1C_CleanDCacheAll();
140 // ... and the cache is disabled
143 // THEN the new value is preserved
144 ASSERT_TRUE(value == 0x4711U);
147 L1C_InvalidateDCacheAll();
152 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
153 void TC_CAL1Cache_CleanInvalidateDCacheAll(void) {
155 uint32_t orig = __get_SCTLR();
156 uint32_t value = 0x0815U;
160 L1C_CleanDCacheAll();
162 /* test cached value is preserved */
164 // WHEN a value is written
167 // ... and the cache is cleaned/invalidated
168 L1C_CleanInvalidateDCacheAll();
170 // ... and the cache is disabled
173 // THEN the new value is preserved
174 ASSERT_TRUE(value == 0x4711U);
177 L1C_InvalidateDCacheAll();