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

Subversion Repositories amber

[/] [amber/] [trunk/] [hw/] [tests/] [irq_disable.S] - Blame information for rev 60

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 60 csantifort
/*****************************************************************
2
//                                                              //
3
//  Amber 2 Core Interrupt Test                                 //
4
//                                                              //
5
//  This file is part of the Amber project                      //
6
//  http://www.opencores.org/project,amber                      //
7
//                                                              //
8
//  Description                                                 //
9
//  Tests running a simple algorithm to add a bunch of numbers  //
10
//  and check that the result is correct. This algorithm runs   //
11
//  80 times. During this, a whole bunch of IRQ interrupts are  //
12
//  triggered using the random timer.                           //
13
//                                                              //
14
//  The test passes if the add algorithm runs successfully      //
15
//  each time.                                                  //
16
//                                                              //
17
//  Author(s):                                                  //
18
//      - Conor Santifort, csantifort.amber@gmail.com           //
19
//                                                              //
20
//////////////////////////////////////////////////////////////////
21
//                                                              //
22
// Copyright (C) 2010 Authors and OPENCORES.ORG                 //
23
//                                                              //
24
// This source file may be used and distributed without         //
25
// restriction provided that this copyright statement is not    //
26
// removed from the file and that any derivative work contains  //
27
// the original copyright notice and the associated disclaimer. //
28
//                                                              //
29
// This source file is free software; you can redistribute it   //
30
// and/or modify it under the terms of the GNU Lesser General   //
31
// Public License as published by the Free Software Foundation; //
32
// either version 2.1 of the License, or (at your option) any   //
33
// later version.                                               //
34
//                                                              //
35
// This source is distributed in the hope that it will be       //
36
// useful, but WITHOUT ANY WARRANTY; without even the implied   //
37
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
38
// PURPOSE.  See the GNU Lesser General Public License for more //
39
// details.                                                     //
40
//                                                              //
41
// You should have received a copy of the GNU Lesser General    //
42
// Public License along with this source; if not, download it   //
43
// from http://www.opencores.org/lgpl.shtml                     //
44
//                                                              //
45
*****************************************************************/
46
 
47
#include "amber_registers.h"
48
 
49
        .section .text
50
        .globl  main
51
main:
52
 
53
        /* 0x00 Reset Interrupt vector address */
54
        b       start
55
 
56
        /* 0x04 Undefined Instruction Interrupt vector address */
57
        b       testfail
58
 
59
        /* 0x08 SWI Interrupt vector address */
60
        b       testfail
61
 
62
        /* 0x0c Prefetch abort Interrupt vector address */
63
        b       testfail
64
 
65
        /* 0x10 Data abort Interrupt vector address */
66
        b       testfail
67
        b       testfail
68
 
69
        /* 0x18 IRQ vector address */
70
        b       service_irq
71
 
72
        /* 0x1c FIRQ vector address */
73
        b       testfail
74
 
75
        /* This doesn't actually disabe the irq because
76
           you can't disable it uin user mode */
77
disable_irq:
78
        orr lr, lr, #0x08000000
79
        mov pc, lr
80
 
81
start:
82
        /* Set Supervisor Mode stack pointer */
83
        ldr     sp, AdrSVCStack
84
 
85
        /* Test that lr is immediately accessible after a mode switch */
86
        mov     lr, #0x8000
87
        mov     r0, #0x08000002
88
        teqp    pc, r0 @ move to irq mode
89
        nop
90
        nop
91
 
92
        @ Switch back to supervisor mode
93
        mov     r0, #0x08000003
94
        teqp    pc, r0
95
        sub     lr, lr, #4  @ access lr immediately after mode switch
96
 
97
        mov     r0, #0x8000
98
        sub     r0, r0, #4
99
        cmp     lr, r0
100
        movne   r10, #200
101
        bne     testfail
102
 
103
        /* Switch to IRQ Mode */
104
        mov     r0, #0x00000002
105
        teqp    pc, r0
106
        /* Set IRQ Mode stack pointer */
107
        ldr     sp, AdrIRQStack
108
 
109
        /* Switch to User Mode */
110
        /* and unset interrupt mask bits */
111
        mov     r0, #0x00000000
112
        teqp    pc, r0
113
 
114
        bl      disable_irq
115
 
116
        /* Set User Mode stack pointer */
117
        ldr     sp, AdrUSRStack
118
 
119
        ldr     r4, AdrRanNum
120
        ldr     r5, [r4]
121
        and     r5, r5, #0x1c
122
        add     r5, r5, #5
123
        ldr     r6, AdrIRQTimer
124
        str     r5, [r6]
125
 
126
        mov     r2,     #0
127
 
128
loop:
129
        @ set some condition bits
130
        @ to test that these get preserved
131
        @ correctly through interrupts
132
        mov     r3,     #4
133
        subs    r3, r3, #4
134
 
135
        mov     r1,     #1
136
        add     r1, r1, #2
137
        add     r1, r1, #3
138
        add     r1, r1, #4
139
        addeq   r1, r1, #5
140
        add     r1, r1, #6
141
        add     r1, r1, #7
142
        addeq   r1, r1, #8
143
        add     r1, r1, #9
144
        add     r1, r1, #10
145
        add     r1, r1, #11
146
        add     r1, r1, #12
147
 
148
        mov     r7, #13
149
        mov     r8, #14
150
        mov     r9, #15
151
 
152
        stmfd   sp!, {r7, r8, r9}
153
        mov     r7, #0
154
        mov     r8, #0
155
        mov     r9, #0
156
        ldmfd   sp!, {r7, r8, r9}
157
 
158
        add     r1, r1, r7
159
        add     r1, r1, r8
160
        add     r1, r1, r9
161
 
162
        add     r1, r1, #16
163
        add     r1, r1, #17
164
        add     r1, r1, #18
165
        add     r1, r1, #19
166
        add     r1, r1, #20
167
        add     r1, r1, #21
168
        add     r1, r1, #22
169
        add     r1, r1, #23
170
        add     r1, r1, #24
171
        add     r1, r1, #25
172
        add     r1, r1, #26
173
        add     r1, r1, #27
174
        add     r1, r1, #28
175
        add     r1, r1, #29
176
        add     r1, r1, #30
177
        add     r1, r1, #47   @ adds up to exactly 512
178
 
179
        cmp     r1, #512
180
        movne   r10, r2
181
        bne     testfail
182
 
183
        cmp     r2, #80
184
        beq     testpass
185
 
186
        add     r2, r2, #1
187
        b       loop
188
 
189
        @ just put these here in case
190
        @ the cpu incorrectly executes some instructions
191
        b       testfail
192
        b       testfail
193
        b       testfail
194
 
195
 
196
service_irq:
197
        @ Save lr to the stack
198
        stmfd   sp!, {lr}
199
 
200
        @ Set the IRQ Timer to a random number
201
        ldr     r5, [r4]
202
        and     r5, r5, #0x7f
203
 
204
        @ Ensure that never set the IRQ timer to zero
205
        add     r5, r5, #30
206
        str     r5, [r6]
207
 
208
        @ Restore lr from the stack
209
        ldmfd   sp!, {lr}
210
 
211
        @ Jump straight back to normal execution
212
        subs    pc, lr, #4
213
 
214
@ ------------------------------------------
215
@ ------------------------------------------
216
 
217
testfail:
218
        ldr     r11, AdrTestStatus
219
        str     r10, [r11]
220
        b       testfail
221
 
222
testpass:
223
        ldr     r11, AdrTestStatus
224
        mov     r10, #17
225
        str     r10, [r11]
226
        b       testpass
227
 
228
 
229
 
230
 
231
/* Write 17 to this address to generate a Test Passed message */
232
AdrTestStatus:  .word ADR_AMBER_TEST_STATUS
233
AdrRanNum:      .word ADR_AMBER_TEST_RANDOM_NUM
234
AdrIRQTimer:    .word ADR_AMBER_TEST_IRQ_TIMER
235
 
236
AdrText1:       .word  Text1
237
 
238
AdrSVCStack:    .word  0x0800
239
AdrUSRStack:    .word  0x1000
240
AdrIRQStack:    .word  0x1800
241
 
242
 
243
        .align 2
244
Text1:  .ascii  "Interrupt!\n\000"
245
 
246
/* ========================================================================= */
247
/* ========================================================================= */
248
 
249
 

powered by: WebSVN 2.1.0

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