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

Subversion Repositories amber

[/] [amber/] [trunk/] [hw/] [tests/] [irq_stm.S] - Blame information for rev 17

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

Line No. Rev Author Line
1 17 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 executes a loop of stm instructions. During this,     //
10
//  a whole bunch of IRQ interrupts are triggered using         //
11
//  the random timer. The test checks that the stm is           //
12
//  not executed twice in a row, once before the interrupt      //
13
//  and again after the interrupt.                              //
14
//                                                              //
15
//  Author(s):                                                  //
16
//      - Conor Santifort, csantifort.amber@gmail.com           //
17
//                                                              //
18
//////////////////////////////////////////////////////////////////
19
//                                                              //
20
// Copyright (C) 2010 Authors and OPENCORES.ORG                 //
21
//                                                              //
22
// This source file may be used and distributed without         //
23
// restriction provided that this copyright statement is not    //
24
// removed from the file and that any derivative work contains  //
25
// the original copyright notice and the associated disclaimer. //
26
//                                                              //
27
// This source file is free software; you can redistribute it   //
28
// and/or modify it under the terms of the GNU Lesser General   //
29
// Public License as published by the Free Software Foundation; //
30
// either version 2.1 of the License, or (at your option) any   //
31
// later version.                                               //
32
//                                                              //
33
// This source is distributed in the hope that it will be       //
34
// useful, but WITHOUT ANY WARRANTY; without even the implied   //
35
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
36
// PURPOSE.  See the GNU Lesser General Public License for more //
37
// details.                                                     //
38
//                                                              //
39
// You should have received a copy of the GNU Lesser General    //
40
// Public License along with this source; if not, download it   //
41
// from http://www.opencores.org/lgpl.shtml                     //
42
//                                                              //
43
*****************************************************************/
44
 
45
#include "amber_registers.h"
46
 
47
        .section .text
48
        .globl  main
49
main:
50
 
51
        /* 0x00 Reset Interrupt vector address */
52
        b       start
53
 
54
        /* 0x04 Undefined Instruction Interrupt vector address */
55
        b       testfail
56
 
57
        /* 0x08 SWI Interrupt vector address */
58
        b       testfail
59
 
60
        /* 0x0c Prefetch abort Interrupt vector address */
61
        b       testfail
62
 
63
        /* 0x10 Data abort Interrupt vector address */
64
        b       testfail
65
        b       testfail
66
 
67
        /* 0x18 IRQ vector address */
68
        b       service_irq
69
 
70
        /* 0x1c FIRQ vector address */
71
        b       testfail
72
 
73
 
74
start:
75
        @ ---------------------
76
        @ Enable the cache
77
        @ ---------------------
78
        mvn     r0,  #0
79
        mcr     15, 0, r0, cr3, cr0, 0   @ cacheable area
80
        mov     r0,  #1
81
        mcr     15, 0, r0, cr2, cr0, 0   @ cache enable
82
 
83
        /* Set Supervisor Mode stack pointer */
84
        ldr     sp, AdrSVCStack
85
 
86
        /* Switch to IRQ Mode */
87
        mov     r0, #0x00000002
88
        teqp    pc, r0
89
        /* Set IRQ Mode stack pointer */
90
        ldr     sp, AdrIRQStack
91
 
92
        /* Switch to User Mode */
93
        /* and unset interrupt mask bits */
94
        mov     r0,   #0x00000000
95
        teqp    pc, r0
96
 
97
        /* Set User Mode stack pointer */
98
        ldr     sp, AdrUSRStack
99
 
100
        /* Configure IRQ Timer with a random time */
101
        ldr     r4, AdrRanNum
102
        ldr     r5, [r4]
103
        and     r5, r5, #0x1c
104
        add     r5, r5, #5
105
        ldr     r6, AdrIRQTimer
106
        str     r5, [r6]
107
 
108
        mov     r2, #40
109
        mov     r3, #7
110
        mov     r7, #0x700
111
        mov     r13, r7
112
        @ fill area with zeros
113
        mov     r8, #0x200
114
 
115
1:      str     r8, [r7, -r8]
116
        subs    r8, r8, #4
117
        beq     loop
118
        b       1b
119
 
120
 
121
 
122
loop:
123
 
124
        mov     r3, #5
125
        ldmdb   r7!, {r8-r11}
126
        orr     r3,  r3,  r11, lsr #8
127
        mov     r11, r11, lsl #24
128
 
129
        @ Follow the r7 address pointer and make
130
        @ sure it decrements correctly on each
131
        @ iteration of the loop
132
        sub     r13, r13, #16
133
        cmp     r7, r13
134
        movne   r10, #100
135
        bne     testfail
136
 
137
        subs    r2, r2, #1
138
        beq     testpass
139
        b       loop
140
 
141
        @ just put these here in case
142
        @ the cpu incorrectly executes some instructions
143
        b       testfail
144
        b       testfail
145
        b       testfail
146
 
147
 
148
service_irq:
149
        @ Save lr to the stack
150
        stmfd   sp!, {lr}
151
 
152
        @ Set the IRQ Timer to a random number
153
        ldr     r5, [r4]
154
        and     r5, r5, #0x7f
155
 
156
        @ Ensure that never set the IRQ timer to zero
157
        add     r5, r5, #30
158
        str     r5, [r6]
159
 
160
        @ Restore lr from the stack
161
        ldmfd   sp!, {lr}
162
 
163
        @ Jump straight back to normal execution
164
        subs    pc, lr, #4
165
 
166
@ ------------------------------------------
167
@ ------------------------------------------
168
 
169
testfail:
170
        ldr     r11, AdrTestStatus
171
        str     r10, [r11]
172
        b       testfail
173
 
174
testpass:
175
        ldr     r11, AdrTestStatus
176
        mov     r10, #17
177
        str     r10, [r11]
178
        b       testpass
179
 
180
 
181
 
182
 
183
/* Write 17 to this address to generate a Test Passed message */
184
AdrTestStatus:  .word ADR_AMBER_TEST_STATUS
185
AdrRanNum:      .word ADR_AMBER_TEST_RANDOM_NUM
186
AdrIRQTimer:    .word ADR_AMBER_TEST_IRQ_TIMER
187
 
188
AdrText1:       .word  Text1
189
 
190
AdrSVCStack:    .word  0x0800
191
AdrUSRStack:    .word  0x1000
192
AdrIRQStack:    .word  0x1800
193
 
194
 
195
        .align 2
196
Text1:  .ascii  "Interrupt!\n\000"
197
 
198
/* ========================================================================= */
199
/* ========================================================================= */
200
 
201
 

powered by: WebSVN 2.1.0

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