OpenCores
URL https://opencores.org/ocsvn/amber/amber/trunk

Subversion Repositories amber

[/] [amber/] [trunk/] [hw/] [tests/] [cache_swap_bug.S] - Blame information for rev 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 csantifort
/*****************************************************************
2
//                                                              //
3
//  Amber 2 Core Cache Test                                     //
4
//                                                              //
5
//  This file is part of the Amber project                      //
6
//  http://www.opencores.org/project,amber                      //
7
//                                                              //
8
//  Description                                                 //
9
//  Tests the interaction between a swap instruction            //
10
//  and the cache.                                              //
11
//                                                              //
12
//  Author(s):                                                  //
13
//      - Conor Santifort, csantifort.amber@gmail.com           //
14
//                                                              //
15
//////////////////////////////////////////////////////////////////
16
//                                                              //
17
// Copyright (C) 2010 Authors and OPENCORES.ORG                 //
18
//                                                              //
19
// This source file may be used and distributed without         //
20
// restriction provided that this copyright statement is not    //
21
// removed from the file and that any derivative work contains  //
22
// the original copyright notice and the associated disclaimer. //
23
//                                                              //
24
// This source file is free software; you can redistribute it   //
25
// and/or modify it under the terms of the GNU Lesser General   //
26
// Public License as published by the Free Software Foundation; //
27
// either version 2.1 of the License, or (at your option) any   //
28
// later version.                                               //
29
//                                                              //
30
// This source is distributed in the hope that it will be       //
31
// useful, but WITHOUT ANY WARRANTY; without even the implied   //
32
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
33
// PURPOSE.  See the GNU Lesser General Public License for more //
34
// details.                                                     //
35
//                                                              //
36
// You should have received a copy of the GNU Lesser General    //
37
// Public License along with this source; if not, download it   //
38
// from http://www.opencores.org/lgpl.shtml                     //
39
//                                                              //
40
*****************************************************************/
41
 
42
/*
43
Bug is caused by very subtle timing interactions in the Cache
44
 
45
It does not detect a hit, which it should, on the read phase of the swap
46
operation. It doesnt detect the hit because it is still completing
47
a fill started by the memory request to load an instructuion
48
at swap instruction + 8.
49
This only occurs when the swap target address is in the cache
50
but the cache instruction address is not, and the instruction
51
address the third of a group of 4 instruction words.
52
 
53
Test copies sequence to another bit of memory and runs it.
54
Repeats this a few times moving the sequence to slightly
55
different memory locations each time
56
*/
57
 
58
#include "amber_registers.h"
59
 
60
        .section .text
61
        .globl  main
62
main:
63
 
64
        @ ------------------------------------------
65
        @ Copy code
66
        @ ------------------------------------------
67
        @ Copy code sequence to another area in memory
68
        mov     r13, #4
69
 
70
big_loop:
71
        ldr     r9,  Loc1
72
        add     r9,  r9, r13
73
        mov     r11, r9
74
 
75
        ldr     r8,  Adrseq
76
        ldr     r10, Adrseqend
77
 
78
copy:
79
        ldmia   r8!,  {r0-r7}
80
        stmia   r11!, {r0-r7}
81
 
82
        cmp     r8, r10
83
        blt     copy
84
 
85
 
86
        @ ------------------------------------------
87
        @ Enable and clear cache
88
        @ ------------------------------------------
89
        @ ---------------------
90
        @ Enable the cache
91
        @ ---------------------
92
        mov     r0,  #0xffffffff
93
        mcr     p15, 0, r0, c3, c0, 0   @ cacheable area
94
        mov     r0,  #1
95
        mcr     p15, 0, r0, c2, c0, 0   @ cache enable
96
        nop
97
        nop
98
 
99
        @ flush the cache
100
        mcr     p15, 0, r0, c1,  c0,  0
101
        nop
102
        nop
103
 
104
 
105
        @ jump to special sequence
106
        @ want to return to the instruction immediately after mov pc, r9
107
        mov     lr, pc
108
        mov     pc, r9
109
return:
110
        ldr     r3, [r5]
111
 
112
        cmp     r3, #0
113
        movne   r10, #10
114
        bne     testfail
115
 
116
        cmp     r13, #40
117
        beq     testpass
118
        add     r13, r13, #4
119
        mov     r0, r13
120
        b       big_loop
121
 
122
        @ ------------------------------------------
123
        @ ------------------------------------------
124
        @ puts swap address into cache
125
        @ move 0x7ff32c0 into r5
126
seq:    mov     r5,     #0x000000c0
127
        orr     r5, r5, #0x00003200
128
        orr     r5, r5, #0x00ff0000
129
        orr     r5, r5, #0x07000000
130
        ldr     r8, [r5]
131
        mov     ip, #0
132
        mov     r2, #1
133
        str     r2, [r5]
134
        nop
135
        nop
136
        nop
137
        nop
138
 
139
        @ ------------------------------------------
140
        @ busybox code
141
        @ ------------------------------------------
142
        str     r2, [r5, #4]
143
        nop
144
        nop
145
        nop
146
        nop
147
        str     ip, [r5, #4]
148
        nop
149
        nop
150
        nop
151
        nop
152
        nop
153
        nop
154
        str     ip, [r5, #8]
155
        swp     r3, ip, [r5]
156
        nop
157
        nop
158
        nop
159
        nop
160
        ldr     r3, [r5, #8]
161
        nop
162
        nop
163
        nop
164
        nop
165
        mov     pc, lr
166
        nop
167
        nop
168
        nop
169
seqend: nop
170
 
171
        @ ------------------------------------------
172
        @ ------------------------------------------
173
 
174
 
175
testfail:
176
        ldr     r11, AdrTestStatus
177
        str     r10, [r11]
178
        b       testfail
179
 
180
testpass:
181
        ldr     r11, AdrTestStatus
182
        mov     r10, #17
183
        str     r10, [r11]
184
        b       testpass
185
 
186
 
187
 
188
Loc1:           .word  0x200
189
Adrseq:         .word  seq
190
Adrseqend:      .word  seqend
191
 
192
/* Write 17 to this address to generate a Test Passed message */
193
AdrTestStatus:  .word  ADR_AMBER_TEST_STATUS
194
 
195
/* ========================================================================= */
196
/* ========================================================================= */
197
 
198
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.