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

Subversion Repositories amber

[/] [amber/] [trunk/] [hw/] [tests/] [ethmac_tx.S] - Diff between revs 2 and 35

Only display areas with differences | Details | Blame | View Log

Rev 2 Rev 35
/*****************************************************************
/*****************************************************************
//                                                              //
//                                                              //
//  Amber 2 System Ethernet MAC Test                            //
//  Amber 2 System Ethernet MAC Test                            //
//                                                              //
//                                                              //
//  This file is part of the Amber project                      //
//  This file is part of the Amber project                      //
//  http://www.opencores.org/project,amber                      //
//  http://www.opencores.org/project,amber                      //
//                                                              //
//                                                              //
//  Description                                                 //
//  Description                                                 //
//  Tests ethernet MAC frame transmit and receive functions     //
//  Tests ethernet MAC frame transmit and receive functions     //
//  and Ethmac DMA access to hiboot mem. Ethmac is put in       //
//  and Ethmac DMA access to hiboot mem. Ethmac is put in       //
//  loopback mode and a packet is transmitted and received.     //
//  loopback mode and a packet is transmitted and received.     //
//                                                              //
//                                                              //
//  Author(s):                                                  //
//  Author(s):                                                  //
//      - Conor Santifort, csantifort.amber@gmail.com           //
//      - Conor Santifort, csantifort.amber@gmail.com           //
//                                                              //
//                                                              //
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//                                                              //
//                                                              //
// Copyright (C) 2010 Authors and OPENCORES.ORG                 //
// Copyright (C) 2010 Authors and OPENCORES.ORG                 //
//                                                              //
//                                                              //
// This source file may be used and distributed without         //
// This source file may be used and distributed without         //
// restriction provided that this copyright statement is not    //
// restriction provided that this copyright statement is not    //
// removed from the file and that any derivative work contains  //
// removed from the file and that any derivative work contains  //
// the original copyright notice and the associated disclaimer. //
// the original copyright notice and the associated disclaimer. //
//                                                              //
//                                                              //
// This source file is free software; you can redistribute it   //
// This source file is free software; you can redistribute it   //
// and/or modify it under the terms of the GNU Lesser General   //
// and/or modify it under the terms of the GNU Lesser General   //
// Public License as published by the Free Software Foundation; //
// Public License as published by the Free Software Foundation; //
// either version 2.1 of the License, or (at your option) any   //
// either version 2.1 of the License, or (at your option) any   //
// later version.                                               //
// later version.                                               //
//                                                              //
//                                                              //
// This source is distributed in the hope that it will be       //
// This source is distributed in the hope that it will be       //
// useful, but WITHOUT ANY WARRANTY; without even the implied   //
// useful, but WITHOUT ANY WARRANTY; without even the implied   //
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
// PURPOSE.  See the GNU Lesser General Public License for more //
// PURPOSE.  See the GNU Lesser General Public License for more //
// details.                                                     //
// details.                                                     //
//                                                              //
//                                                              //
// You should have received a copy of the GNU Lesser General    //
// You should have received a copy of the GNU Lesser General    //
// Public License along with this source; if not, download it   //
// Public License along with this source; if not, download it   //
// from http://www.opencores.org/lgpl.shtml                     //
// from http://www.opencores.org/lgpl.shtml                     //
//                                                              //
//                                                              //
*****************************************************************/
*****************************************************************/
#include "amber_registers.h"
#include "amber_registers.h"
        .section .text
        .section .text
        .globl  main
        .globl  main
main:
main:
        ldr     r0, AdrEthMacMemBase
        ldr     r0, AdrEthMacMemBase
/* Write the Transmit Packet Buffer Descriptor */
/* Write the Transmit Packet Buffer Descriptor */
        ldr     r1, TxBufferW0
        ldr     r1, TxBufferW0
        str     r1, [r0]
        str     r1, [r0]
        ldr     r1, TxBufferW1
        ldr     r1, TxBufferW1
        add     r1, r1, #2      @ shift start by 2 bytes
        add     r1, r1, #2      @ shift start by 2 bytes
        str     r1, [r0, #4]
        str     r1, [r0, #4]
/* Write the Receive Packet Buffer Descriptor */
/* Write the Receive Packet Buffer Descriptor */
        ldr     r1, RxBufferW0
        ldr     r1, RxBufferW0
        str     r1, [r0, #0x200]
        str     r1, [r0, #0x200]
        ldr     r1, RxBufferW1
        ldr     r1, RxBufferW1
        str     r1, [r0, #0x204]
        str     r1, [r0, #0x204]
/* Copy a Frame into the transmit buffer */
/* Copy a Frame into the transmit buffer */
        ldr     r0, TxBufferW1
        ldr     r0, TxBufferW1
        ldr     r1, =TxFrame
        ldr     r1, =TxFrame
        ldr     r2, =EndTxFrame
        ldr     r2, =EndTxFrame
        @ copy 8 words at a time
        @ copy 8 words at a time
1:      ldmia   r1!, {r3-r10}
1:      ldmia   r1!, {r3-r10}
        stmia   r0!, {r3-r10}
        stmia   r0!, {r3-r10}
        cmp     r1, r2
        cmp     r1, r2
        blt     1b
        blt     1b
/*  Set Mode Register */
/*  Set Mode Register */
        ldr     r0, AdrEthMacModer
        ldr     r0, AdrEthMacModer
        ldr     r1, EthMacModerValue
        ldr     r1, EthMacModerValue
        str     r1, [r0]
        str     r1, [r0]
/* Start transmit */
/* Start transmit */
        ldr     r0, AdrEthMacMemBase
        ldr     r0, AdrEthMacMemBase
        ldr     r1, TxBufferW0
        ldr     r1, TxBufferW0
        orr     r1, r1, #0x8000
        orr     r1, r1, #0x8000
        str     r1, [r0]
        str     r1, [r0]
 
 
 
/* Check register values */
 
        ldr     r0, AdrEthMacModer
 
        ldr     r1, EthMacModerValue
 
        ldr     r2, [r0]
 
        cmp     r1, r2
 
        movne   r10, #200
 
        bne     testfail
 
 
 
        ldr     r0, AdrEthMacMemBase
 
        ldr     r1, TxBufferW0
 
        orr     r1, r1, #0x8000
 
        ldr     r2, [r0]
 
        cmp     r1, r2
 
        movne   r10, #220
 
        bne     testfail
 
 
 
 
/* Wait until receive complete - Wait for Empty bit to go low */
/* Wait until receive complete - Wait for Empty bit to go low */
2:      ldr     r1, [r0, #0x200]
2:      ldr     r1, [r0, #0x200]
        ands    r1, r1, #0x8000
        ands    r1, r1, #0x8000
        bne     2b
        bne     2b
/* Wait a bit */
/* Wait a bit */
        mov     r0, #20
        mov     r0, #80
3:      subs    r0, r0, #1
3:      subs    r0, r0, #1
        bne     3b
        bne     3b
/* Check receive buffer */
/* Check receive buffer */
        ldr     r0, RxBufferW1
        ldr     r0, RxBufferW1
        add     r3, r0, #2
        add     r3, r0, #2
        ldr     r1, =TxFrame
        ldr     r1, =TxFrame
        add     r1, r1, #4
        add     r1, r1, #4
        ldr     r2, =EndTxFrame
        ldr     r2, =EndTxFrame
        @ end of frame is crc which is different so dont check it
        @ end of frame is crc which is different so dont check it
        sub     r2, r2, #4
        sub     r2, r2, #4
        @ there is a 2-byte shift from tx to rx buffer
        @ there is a 2-byte shift from tx to rx buffer
        @ so load in the data from the rx buffer in 2 byte chunks
        @ so load in the data from the rx buffer in 2 byte chunks
        @ and re-arrange to match the tx buffer
        @ and re-arrange to match the tx buffer
 4:     ldr     r4, [r0, #4]!
 4:     ldr     r4, [r0, #4]!
        mov     r6, r4, lsl #16
        mov     r6, r4, lsl #16
        ldr     r5, [r3], #4
        ldr     r5, [r3], #4
        ldr     r12, LoMask
        ldr     r12, LoMask
        and     r5, r5, r12
        and     r5, r5, r12
        orr     r7, r5, r6
        orr     r7, r5, r6
        ldr     r8, [r1], #4
        ldr     r8, [r1], #4
        cmp     r7, r8
        cmp     r7, r8
        movne   r10, #100
        movne   r10, #100
        bne     testfail
        bne     testfail
        cmp     r1, r2
        cmp     r1, r2
        blt     4b
        blt     4b
        b       testpass
        b       testpass
testfail:
testfail:
        ldr     r11, AdrTestStatus
        ldr     r11, AdrTestStatus
        str     r10, [r11]
        str     r10, [r11]
        b       testfail
        b       testfail
testpass:
testpass:
        ldr     r11, AdrTestStatus
        ldr     r11, AdrTestStatus
        mov     r10, #17
        mov     r10, #17
        str     r10, [r11]
        str     r10, [r11]
        b       testpass
        b       testpass
/* Write 17 to this address to generate a Test Passed message */
/* Write 17 to this address to generate a Test Passed message */
AdrTestStatus:          .word  ADR_AMBER_TEST_STATUS
AdrTestStatus:          .word  ADR_AMBER_TEST_STATUS
AdrEthMacModer:         .word  ADR_ETHMAC_MODER
AdrEthMacModer:         .word  ADR_ETHMAC_MODER
AdrEthMacMIIModer:      .word  ADR_ETHMAC_MIIMODER
AdrEthMacMIIModer:      .word  ADR_ETHMAC_MIIMODER
AdrEthMacMIICommand:    .word  ADR_ETHMAC_MIICOMMAND
AdrEthMacMIICommand:    .word  ADR_ETHMAC_MIICOMMAND
AdrEthMacMIIAddress:    .word  ADR_ETHMAC_MIIADDRESS
AdrEthMacMIIAddress:    .word  ADR_ETHMAC_MIIADDRESS
AdrEthMacMIITxData:     .word  ADR_ETHMAC_MIITXDATA
AdrEthMacMIITxData:     .word  ADR_ETHMAC_MIITXDATA
AdrEthMacMIIRxData:     .word  ADR_ETHMAC_MIIRXDATA
AdrEthMacMIIRxData:     .word  ADR_ETHMAC_MIIRXDATA
AdrEthMacMIIStatus:     .word  ADR_ETHMAC_MIISTATUS
AdrEthMacMIIStatus:     .word  ADR_ETHMAC_MIISTATUS
AdrEthMacMemBase:       .word  ADR_ETHMAC_BDBASE
AdrEthMacMemBase:       .word  ADR_ETHMAC_BDBASE
EthMacModerDefault:     .word  0x0000a000
EthMacModerDefault:     .word  0x0000a000
ExpectedMIIReadBack:    .word  0x0000ffff
ExpectedMIIReadBack:    .word  0x0000ffff
LoMask:                 .word  0x0000ffff
LoMask:                 .word  0x0000ffff
/* [31:16] = length in bytes, Bit[15] = ready, Bit [13] = wrap bit */
/* [31:16] = length in bytes, Bit[15] = ready, Bit [13] = wrap bit */
TxBufferW0:             .word  0x00a02800
TxBufferW0:             .word  0x00a02800
/* [31:16] = length in bytes, Bit[15] = empty, Bit [13] = wrap bit */
/* [31:16] = length in bytes, Bit[15] = empty, Bit [13] = wrap bit */
RxBufferW0:             .word  0x0000a800
RxBufferW0:             .word  0x0000a800
 
 
/* Buffer Pointer */
 
TxBufferW1:             .word  0x28001000
 
RxBufferW1:             .word  0x28001200
 
 
 
 
/* Buffer Pointer in Main Memory */
 
TxBufferW1:             .word  0x00011000
 
RxBufferW1:             .word  0x00011200
 
 
/*
/*
 Ethmac Mode Register
 Ethmac Mode Register
 [15] = Add pads to short frames
 [15] = Add pads to short frames
 [13] = CRCEN
 [13] = CRCEN
 [7]  = loopback
 [7]  = loopback
 [5]  = 1 for promiscuous, 0 rx only frames that match mac address
 [5]  = 1 for promiscuous, 0 rx only frames that match mac address
 [1]  = txen
 [1]  = txen
 [0]  = rxen
 [0]  = rxen
*/
*/
EthMacModerValue:       .word  0xa0a3
EthMacModerValue:       .word  0xa0a3
TxFrame:
TxFrame:
.word  0x0e000000
.word  0x0e000000
.word  0xa0583e0c  @ rx  1200: 3e0c 0e00
.word  0xa0583e0c  @ rx  1200: 3e0c 0e00
.word  0x554e5300  @ rx  1204: 5300 a058
.word  0x554e5300  @ rx  1204: 5300 a058
.word  0x0008304c
.word  0x0008304c
.word  0x90000045
.word  0x90000045
.word  0x00400000
.word  0x00400000
.word  0xd5b61140
.word  0xd5b61140
.word  0x0501a8c0
.word  0x0501a8c0
.word  0x3201a8c0
.word  0x3201a8c0
.word  0x01080203
.word  0x01080203
.word  0xb6c47c00
.word  0xb6c47c00
.word  0xf67d4fc7
.word  0xf67d4fc7
.word  0x00000000
.word  0x00000000
.word  0x02000000
.word  0x02000000
.word  0xa3860100
.word  0xa3860100
.word  0x03000000
.word  0x03000000
.word  0x06000000
.word  0x06000000
.word  0x01000000
.word  0x01000000
.word  0x18000000
.word  0x18000000
.word  0x025b8f02
.word  0x025b8f02
.word  0x02000000
.word  0x02000000
.word  0x00003170
.word  0x00003170
.word  0x00000000
.word  0x00000000
.word  0x00000000
.word  0x00000000
.word  0x00000000
.word  0x00000000
.word  0x00000000
.word  0x00000000
.word  0x00000000
.word  0x00000000
.word  0x24000000
.word  0x24000000
.word  0x01070001
.word  0x01070001
.word  0x00143ed5
.word  0x00143ed5
.word  0x00000000
.word  0x00000000
.word  0x2c043c7f
.word  0x2c043c7f
.word  0x6c41657c
.word  0x6c41657c
.word  0x8cc37e87
.word  0x8cc37e87
.word  0x2340a928
.word  0x2340a928
.word  0x0026048e
.word  0x0026048e
.word  0xec587a0e
.word  0xec587a0e
.word  0x00000000
.word  0x00000000
.word  0x00080000
.word  0x00080000
.word  0x00080000
.word  0x00080000
.word  0x00000000
.word  0x00000000
EndTxFrame:
EndTxFrame:
.word  0
.word  0
.word  0
.word  0
.word  0
.word  0
.word  0
.word  0
.word  0
.word  0
.word  0
.word  0
.word  0
.word  0
/* ========================================================================= */
/* ========================================================================= */
/* ========================================================================= */
/* ========================================================================= */
 
 

powered by: WebSVN 2.1.0

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