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

Subversion Repositories amber

[/] [amber/] [trunk/] [hw/] [tests/] [ethmac_tx.S] - Blame information for rev 31

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

Line No. Rev Author Line
1 2 csantifort
/*****************************************************************
2
//                                                              //
3
//  Amber 2 System Ethernet MAC Test                            //
4
//                                                              //
5
//  This file is part of the Amber project                      //
6
//  http://www.opencores.org/project,amber                      //
7
//                                                              //
8
//  Description                                                 //
9
//  Tests ethernet MAC frame transmit and receive functions     //
10
//  and Ethmac DMA access to hiboot mem. Ethmac is put in       //
11
//  loopback mode and a packet is transmitted and received.     //
12
//                                                              //
13
//  Author(s):                                                  //
14
//      - Conor Santifort, csantifort.amber@gmail.com           //
15
//                                                              //
16
//////////////////////////////////////////////////////////////////
17
//                                                              //
18
// Copyright (C) 2010 Authors and OPENCORES.ORG                 //
19
//                                                              //
20
// This source file may be used and distributed without         //
21
// restriction provided that this copyright statement is not    //
22
// removed from the file and that any derivative work contains  //
23
// the original copyright notice and the associated disclaimer. //
24
//                                                              //
25
// This source file is free software; you can redistribute it   //
26
// and/or modify it under the terms of the GNU Lesser General   //
27
// Public License as published by the Free Software Foundation; //
28
// either version 2.1 of the License, or (at your option) any   //
29
// later version.                                               //
30
//                                                              //
31
// This source is distributed in the hope that it will be       //
32
// useful, but WITHOUT ANY WARRANTY; without even the implied   //
33
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
34
// PURPOSE.  See the GNU Lesser General Public License for more //
35
// details.                                                     //
36
//                                                              //
37
// You should have received a copy of the GNU Lesser General    //
38
// Public License along with this source; if not, download it   //
39
// from http://www.opencores.org/lgpl.shtml                     //
40
//                                                              //
41
*****************************************************************/
42
 
43
#include "amber_registers.h"
44
 
45
        .section .text
46
        .globl  main
47
main:
48
        ldr     r0, AdrEthMacMemBase
49
 
50
/* Write the Transmit Packet Buffer Descriptor */
51
        ldr     r1, TxBufferW0
52
        str     r1, [r0]
53
        ldr     r1, TxBufferW1
54
        add     r1, r1, #2      @ shift start by 2 bytes
55
        str     r1, [r0, #4]
56
 
57
/* Write the Receive Packet Buffer Descriptor */
58
        ldr     r1, RxBufferW0
59
        str     r1, [r0, #0x200]
60
        ldr     r1, RxBufferW1
61
        str     r1, [r0, #0x204]
62
 
63
/* Copy a Frame into the transmit buffer */
64
        ldr     r0, TxBufferW1
65
        ldr     r1, =TxFrame
66
        ldr     r2, =EndTxFrame
67
 
68
        @ copy 8 words at a time
69
1:      ldmia   r1!, {r3-r10}
70
        stmia   r0!, {r3-r10}
71
 
72
        cmp     r1, r2
73
        blt     1b
74
 
75
 
76
/*  Set Mode Register */
77
        ldr     r0, AdrEthMacModer
78
        ldr     r1, EthMacModerValue
79
        str     r1, [r0]
80
 
81
 
82
/* Start transmit */
83
        ldr     r0, AdrEthMacMemBase
84
        ldr     r1, TxBufferW0
85
        orr     r1, r1, #0x8000
86
        str     r1, [r0]
87
 
88
 
89
/* Wait until receive complete - Wait for Empty bit to go low */
90
2:      ldr     r1, [r0, #0x200]
91
        ands    r1, r1, #0x8000
92
        bne     2b
93
 
94
/* Wait a bit */
95
        mov     r0, #20
96
3:      subs    r0, r0, #1
97
        bne     3b
98
 
99
 
100
/* Check receive buffer */
101
        ldr     r0, RxBufferW1
102
        add     r3, r0, #2
103
        ldr     r1, =TxFrame
104
        add     r1, r1, #4
105
        ldr     r2, =EndTxFrame
106
        @ end of frame is crc which is different so dont check it
107
        sub     r2, r2, #4
108
 
109
        @ there is a 2-byte shift from tx to rx buffer
110
        @ so load in the data from the rx buffer in 2 byte chunks
111
        @ and re-arrange to match the tx buffer
112
 4:     ldr     r4, [r0, #4]!
113
        mov     r6, r4, lsl #16
114
        ldr     r5, [r3], #4
115
        ldr     r12, LoMask
116
        and     r5, r5, r12
117
        orr     r7, r5, r6
118
 
119
        ldr     r8, [r1], #4
120
 
121
        cmp     r7, r8
122
        movne   r10, #100
123
        bne     testfail
124
 
125
        cmp     r1, r2
126
        blt     4b
127
 
128
 
129
        b       testpass
130
 
131
 
132
 
133
testfail:
134
        ldr     r11, AdrTestStatus
135
        str     r10, [r11]
136
        b       testfail
137
 
138
testpass:
139
        ldr     r11, AdrTestStatus
140
        mov     r10, #17
141
        str     r10, [r11]
142
        b       testpass
143
 
144
 
145
/* Write 17 to this address to generate a Test Passed message */
146
AdrTestStatus:          .word  ADR_AMBER_TEST_STATUS
147
AdrEthMacModer:         .word  ADR_ETHMAC_MODER
148
AdrEthMacMIIModer:      .word  ADR_ETHMAC_MIIMODER
149
AdrEthMacMIICommand:    .word  ADR_ETHMAC_MIICOMMAND
150
AdrEthMacMIIAddress:    .word  ADR_ETHMAC_MIIADDRESS
151
AdrEthMacMIITxData:     .word  ADR_ETHMAC_MIITXDATA
152
AdrEthMacMIIRxData:     .word  ADR_ETHMAC_MIIRXDATA
153
AdrEthMacMIIStatus:     .word  ADR_ETHMAC_MIISTATUS
154
AdrEthMacMemBase:       .word  ADR_ETHMAC_BDBASE
155
EthMacModerDefault:     .word  0x0000a000
156
ExpectedMIIReadBack:    .word  0x0000ffff
157
LoMask:                 .word  0x0000ffff
158
 
159
/* [31:16] = length in bytes, Bit[15] = ready, Bit [13] = wrap bit */
160
TxBufferW0:             .word  0x00a02800
161
/* [31:16] = length in bytes, Bit[15] = empty, Bit [13] = wrap bit */
162
RxBufferW0:             .word  0x0000a800
163
 
164
/* Buffer Pointer */
165
TxBufferW1:             .word  0x28001000
166
RxBufferW1:             .word  0x28001200
167
 
168
 
169
 
170
/*
171
 Ethmac Mode Register
172
 [15] = Add pads to short frames
173
 [13] = CRCEN
174
 [7]  = loopback
175
 [5]  = 1 for promiscuous, 0 rx only frames that match mac address
176
 [1]  = txen
177
 [0]  = rxen
178
*/
179
EthMacModerValue:       .word  0xa0a3
180
 
181
TxFrame:
182
.word  0x0e000000
183
.word  0xa0583e0c  @ rx  1200: 3e0c 0e00
184
.word  0x554e5300  @ rx  1204: 5300 a058
185
.word  0x0008304c
186
.word  0x90000045
187
.word  0x00400000
188
.word  0xd5b61140
189
.word  0x0501a8c0
190
.word  0x3201a8c0
191
.word  0x01080203
192
.word  0xb6c47c00
193
.word  0xf67d4fc7
194
.word  0x00000000
195
.word  0x02000000
196
.word  0xa3860100
197
.word  0x03000000
198
.word  0x06000000
199
.word  0x01000000
200
.word  0x18000000
201
.word  0x025b8f02
202
.word  0x02000000
203
.word  0x00003170
204
.word  0x00000000
205
.word  0x00000000
206
.word  0x00000000
207
.word  0x00000000
208
.word  0x00000000
209
.word  0x24000000
210
.word  0x01070001
211
.word  0x00143ed5
212
.word  0x00000000
213
.word  0x2c043c7f
214
.word  0x6c41657c
215
.word  0x8cc37e87
216
.word  0x2340a928
217
.word  0x0026048e
218
.word  0xec587a0e
219
.word  0x00000000
220
.word  0x00080000
221
.word  0x00080000
222
.word  0x00000000
223
EndTxFrame:
224
.word  0
225
.word  0
226
.word  0
227
.word  0
228
.word  0
229
.word  0
230
.word  0
231
 
232
/* ========================================================================= */
233
/* ========================================================================= */
234
 

powered by: WebSVN 2.1.0

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