@@ -85,7 +85,6 @@ volatile uint32_t constr_test = 0; // for constructor test
85
85
86
86
volatile uint32_t dma_src ; // dma source & destination data
87
87
volatile uint32_t store_access_addr [2 ]; // variable to test store accesses
88
- volatile uint32_t amo_var ; // variable for testing atomic memory accesses
89
88
volatile uint32_t __attribute__((aligned (4 ))) pmp_access [2 ]; // variable to test pmp
90
89
volatile uint32_t trap_cnt ; // number of triggered traps
91
90
volatile uint32_t pmp_num_regions ; // number of implemented pmp regions
@@ -1976,88 +1975,6 @@ int main() {
1976
1975
}
1977
1976
1978
1977
1979
- // ----------------------------------------------------------
1980
- // Test atomic lr/sc memory access - failing access
1981
- // ----------------------------------------------------------
1982
- #if defined __riscv_atomic
1983
- neorv32_cpu_csr_write (CSR_MCAUSE , mcause_never_c );
1984
- PRINT_STANDARD ("[%i] AMO LR/SC (" , cnt_test );
1985
- PRINT_STANDARD ("failing) " );
1986
-
1987
- if (neorv32_cpu_csr_read (CSR_MXISA ) & (1 << CSR_MXISA_ZALRSC )) {
1988
- cnt_test ++ ;
1989
-
1990
- // [NOTE] LR/SC operations bypass the data cache so we need to flush/reload
1991
- // it before/after making "normal" load/store operations
1992
-
1993
- amo_var = 0x00cafe00 ; // initialize
1994
- asm volatile ("fence" ); // flush/reload d-cache
1995
-
1996
- tmp_a = neorv32_cpu_amolr ((uint32_t )& amo_var );
1997
- amo_var = 0x10cafe00 ; // break reservation
1998
- asm volatile ("fence" ); // flush/reload d-cache
1999
- tmp_b = neorv32_cpu_amosc ((uint32_t )& amo_var , 0xaaaaaaaa );
2000
- tmp_b = (tmp_b << 1 ) | neorv32_cpu_amosc ((uint32_t )& amo_var , 0xcccccccc ); // another SC: must fail
2001
- tmp_b = (tmp_b << 1 ) | neorv32_cpu_amosc ((uint32_t )ADDR_UNREACHABLE , 0 ); // another SC: must fail; no bus exception!
2002
- asm volatile ("fence" ); // flush/reload d-cache
2003
-
2004
- if ((tmp_a == 0x00cafe00 ) && // correct LR.W result
2005
- (amo_var == 0x10cafe00 ) && // atomic variable NOT updates by SC.W
2006
- (tmp_b == 0x00000007 ) && // SC.W[2] failed, SC.W[1] failed, SC.W[0] failed
2007
- (neorv32_cpu_csr_read (CSR_MCAUSE ) == mcause_never_c )) { // no exception
2008
- test_ok ();
2009
- }
2010
- else {
2011
- test_fail ();
2012
- }
2013
- }
2014
- else {
2015
- PRINT_STANDARD ("[n.a.]\n" );
2016
- }
2017
- #endif
2018
-
2019
-
2020
- // ----------------------------------------------------------
2021
- // Test atomic lr/sc memory access - succeeding access
2022
- // ----------------------------------------------------------
2023
- #if defined __riscv_atomic
2024
- neorv32_cpu_csr_write (CSR_MCAUSE , mcause_never_c );
2025
- PRINT_STANDARD ("[%i] AMO LR/SC (" , cnt_test );
2026
- PRINT_STANDARD ("succeed) " );
2027
-
2028
- if (neorv32_cpu_csr_read (CSR_MXISA ) & (1 << CSR_MXISA_ZALRSC )) {
2029
- cnt_test ++ ;
2030
-
2031
- // [NOTE] LR/SC operations bypass the data cache so we need to flush/reload
2032
- // it before/after making "normal" load/store operations
2033
-
2034
- amo_var = 0x00abba00 ; // initialize
2035
- asm volatile ("fence" ); // flush/reload d-cache
2036
-
2037
- tmp_a = neorv32_cpu_amolr ((uint32_t )& amo_var );
2038
- asm volatile ("fence" ); // flush/reload d-cache
2039
- neorv32_cpu_load_unsigned_word ((uint32_t )& amo_var ); // dummy read, must not alter reservation set state
2040
- tmp_b = neorv32_cpu_amosc ((uint32_t )& amo_var , 0xcccccccc );
2041
- tmp_b = (tmp_b << 1 ) | neorv32_cpu_amosc ((uint32_t )& amo_var , 0xcccccccc ); // another SC: must fail
2042
- tmp_b = (tmp_b << 1 ) | neorv32_cpu_amosc ((uint32_t )ADDR_UNREACHABLE , 0 ); // another SC: must fail; no bus exception!
2043
- asm volatile ("fence" ); // flush/reload d-cache
2044
-
2045
- if ((tmp_a == 0x00abba00 ) && // correct LR.W result
2046
- (amo_var == 0xcccccccc ) && // atomic variable WAS updates by SC.W
2047
- (tmp_b == 0x00000003 ) && // SC.W[2] succeeded, SC.W[1] failed, SC.W[0] failed
2048
- (neorv32_cpu_csr_read (CSR_MCAUSE ) == mcause_never_c )) { // no exception
2049
- test_ok ();
2050
- }
2051
- else {
2052
- test_fail ();
2053
- }
2054
- }
2055
- else {
2056
- PRINT_STANDARD ("[n.a.]\n" );
2057
- }
2058
- #endif
2059
-
2060
-
2061
1978
// ----------------------------------------------------------
2062
1979
// Test physical memory protection
2063
1980
// ----------------------------------------------------------
0 commit comments