Changeset 4b3c8b82 in rtems for bsps/arm


Ignore:
Timestamp:
May 25, 2018, 6:21:18 AM (19 months ago)
Author:
Christian Mauderer <christian.mauderer@…>
Branches:
master
Children:
baee0dc5
Parents:
0fe48afa
git-author:
Christian Mauderer <christian.mauderer@…> (05/25/18 06:21:18)
git-committer:
Christian Mauderer <christian.mauderer@…> (05/30/18 06:45:57)
Message:

bsp/atsam: Remove side effect from gmac functions.

Quite a number of GMAC_... functions had a side effect of enabling the
transmit and receive. During the initialization of the ethernet driver,
that lead to the situation that the receive has been already enabled
while the DMA isn't set up correctly. Therefore the DMA interpreted the
values at address 0 as an DMA descriptor. When a packet is received
during that time, the behaviour is quite undefined.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • bsps/arm/atsam/contrib/libraries/libchip/source/gmac.c

    r0fe48afa r4b3c8b82  
    100100{
    101101        uint32_t clock_dividor;
     102#ifndef __rtems__
    102103        pGmac->GMAC_NCR &=  ~(GMAC_NCR_RXEN | GMAC_NCR_TXEN);
     104#else /* __rtems__ */
     105        assert((pGmac->GMAC_NCR & (GMAC_NCR_RXEN | GMAC_NCR_TXEN)) == 0);
     106#endif /* __rtems__ */
    103107
    104108        if (mck <= 20000000) {
     
    118122
    119123        pGmac->GMAC_NCFGR = (pGmac->GMAC_NCFGR & (~GMAC_NCFGR_CLK_Msk)) | clock_dividor;
     124#ifndef __rtems__
    120125        pGmac->GMAC_NCR |=  (GMAC_NCR_RXEN | GMAC_NCR_TXEN);
     126#endif /* __rtems__ */
    121127        return 1;
    122128}
     
    128134void GMAC_EnableMdio(Gmac *pGmac)
    129135{
     136#ifndef __rtems__
    130137        pGmac->GMAC_NCR &=  ~(GMAC_NCR_RXEN | GMAC_NCR_TXEN);
     138#else /* __rtems__ */
     139        assert((pGmac->GMAC_NCR & (GMAC_NCR_RXEN | GMAC_NCR_TXEN)) == 0);
     140#endif /* __rtems__ */
    131141        pGmac->GMAC_NCR |= GMAC_NCR_MPE;
     142#ifndef __rtems__
    132143        pGmac->GMAC_NCR |=  (GMAC_NCR_RXEN | GMAC_NCR_TXEN);
     144#endif /* __rtems__ */
    133145}
    134146
     
    139151void GMAC_DisableMdio(Gmac *pGmac)
    140152{
     153#ifndef __rtems__
    141154        pGmac->GMAC_NCR &=  ~(GMAC_NCR_RXEN | GMAC_NCR_TXEN);
     155#else /* __rtems__ */
     156        assert((pGmac->GMAC_NCR & (GMAC_NCR_RXEN | GMAC_NCR_TXEN)) == 0);
     157#endif /* __rtems__ */
    142158        pGmac->GMAC_NCR &= ~GMAC_NCR_MPE;
     159#ifndef __rtems__
    143160        pGmac->GMAC_NCR |=  (GMAC_NCR_RXEN | GMAC_NCR_TXEN);
     161#endif /* __rtems__ */
    144162}
    145163
     
    150168void GMAC_EnableMII(Gmac *pGmac)
    151169{
     170#ifndef __rtems__
    152171        pGmac->GMAC_NCR &=  ~(GMAC_NCR_RXEN | GMAC_NCR_TXEN);
     172#else /* __rtems__ */
     173        assert((pGmac->GMAC_NCR & (GMAC_NCR_RXEN | GMAC_NCR_TXEN)) == 0);
     174#endif /* __rtems__ */
    153175        pGmac->GMAC_UR &= ~GMAC_UR_RMII;
     176#ifndef __rtems__
    154177        pGmac->GMAC_NCR |=  (GMAC_NCR_RXEN | GMAC_NCR_TXEN);
     178#endif /* __rtems__ */
    155179}
    156180
     
    161185void GMAC_EnableGMII(Gmac *pGmac)
    162186{
     187#ifndef __rtems__
    163188        pGmac->GMAC_NCR &=  ~(GMAC_NCR_RXEN | GMAC_NCR_TXEN);
     189#else /* __rtems__ */
     190        assert((pGmac->GMAC_NCR & (GMAC_NCR_RXEN | GMAC_NCR_TXEN)) == 0);
     191#endif /* __rtems__ */
    164192        /* RGMII disable */
    165193        pGmac->GMAC_UR &= ~GMAC_UR_RMII;
     194#ifndef __rtems__
    166195        pGmac->GMAC_NCR |=  (GMAC_NCR_RXEN | GMAC_NCR_TXEN);
     196#endif /* __rtems__ */
    167197}
    168198
     
    176206void GMAC_EnableRGMII(Gmac *pGmac, uint32_t duplex, uint32_t speed)
    177207{
     208#ifndef __rtems__
    178209        pGmac->GMAC_NCR &=  ~(GMAC_NCR_RXEN | GMAC_NCR_TXEN);
     210#else /* __rtems__ */
     211        assert((pGmac->GMAC_NCR & (GMAC_NCR_RXEN | GMAC_NCR_TXEN)) == 0);
     212#endif /* __rtems__ */
    179213
    180214        if (duplex == GMAC_DUPLEX_HALF)
     
    194228        pGmac->GMAC_UR = 0;
    195229        pGmac->GMAC_NCFGR &= ~GMAC_NCFGR_GBE;
     230#ifndef __rtems__
    196231        pGmac->GMAC_NCR |=  (GMAC_NCR_RXEN | GMAC_NCR_TXEN);
     232#endif /* __rtems__ */
    197233        return;
    198234}
     
    217253
    218254        pGmac->GMAC_NCFGR = ncfgr;
     255#ifndef __rtems__
    219256        pGmac->GMAC_NCR |=  (GMAC_NCR_RXEN | GMAC_NCR_TXEN);
     257#endif /* __rtems__ */
    220258}
    221259
Note: See TracChangeset for help on using the changeset viewer.