summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Hellstrom <daniel@gaisler.com>2012-03-21 17:05:42 +0100
committerDaniel Hellstrom <daniel@gaisler.com>2012-03-27 15:20:19 +0200
commit64462290cb7d6a6c9d3ff5e2085442b93a8bf46e (patch)
treea8e907489c93336b6c57efc312ea71824b4734eb
parentab9dfd9e47e91625ffba496fe703bb764eb53431 (diff)
GRETH-DRVMGR: moved the MEM-load (force-cache-miss) logic to BSP
-rw-r--r--c/src/lib/libbsp/sparc/shared/net/greth.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/c/src/lib/libbsp/sparc/shared/net/greth.c b/c/src/lib/libbsp/sparc/shared/net/greth.c
index a4ab6bfa02..4ed7faf276 100644
--- a/c/src/lib/libbsp/sparc/shared/net/greth.c
+++ b/c/src/lib/libbsp/sparc/shared/net/greth.c
@@ -12,12 +12,12 @@
* 2007-09-07, Ported GBIT support from 4.6.5
*/
#include <rtems.h>
-
-#define GRETH_SUPPORTED
#define _KERNEL
#define CPU_U32_FIX
#include <bsp.h>
+#ifdef GRETH_SUPPORTED
+
#include <inttypes.h>
#include <errno.h>
#include <rtems/bspIo.h>
@@ -67,13 +67,10 @@ extern rtems_isr_entry set_vector( rtems_isr_entry, rtems_vector_number, int );
extern void ipalign(struct mbuf *m);
#endif
-static inline unsigned int sparc_load_no_cache(unsigned int addr)
-{
- unsigned int tmp;
- asm volatile (" lda [%1] 1, %0\n" : "=r"(tmp) : "r"(addr) );
- return tmp;
-}
-#define NO_CACHE_LOAD(addr) sparc_load_no_cache((unsigned int)addr)
+/* Used when reading from memory written by GRETH DMA unit */
+#ifndef GRETH_MEM_LOAD
+#define GRETH_MEM_LOAD(addr) (*(volatile unsigned int *)(addr))
+#endif
/*
* Number of OCs supported by this driver
@@ -594,7 +591,7 @@ greth_Daemon (void *arg)
/* Scan for Received packets */
again:
while (!((len_status =
- NO_CACHE_LOAD(&dp->rxdesc[dp->rx_ptr].ctrl)) & GRETH_RXD_ENABLE))
+ GRETH_MEM_LOAD(&dp->rxdesc[dp->rx_ptr].ctrl)) & GRETH_RXD_ENABLE))
{
bad = 0;
if (len_status & GRETH_RXD_TOOLONG)
@@ -711,7 +708,7 @@ sendpacket (struct ifnet *ifp, struct mbuf *m)
/*
* Is there a free descriptor available?
*/
- if ( NO_CACHE_LOAD(&dp->txdesc[dp->tx_ptr].ctrl) & GRETH_TXD_ENABLE ){
+ if (GRETH_MEM_LOAD(&dp->txdesc[dp->tx_ptr].ctrl) & GRETH_TXD_ENABLE){
/* No. */
inside = 0;
return 1;
@@ -721,7 +718,7 @@ sendpacket (struct ifnet *ifp, struct mbuf *m)
n = m;
len = 0;
- temp = (unsigned char *) NO_CACHE_LOAD(&dp->txdesc[dp->tx_ptr].addr);
+ temp = (unsigned char *) GRETH_MEM_LOAD(&dp->txdesc[dp->tx_ptr].addr);
drvmgr_translate(dp->dev, 1, 1, (void *)temp, (void **)&temp);
#ifdef GRETH_DEBUG
printf("TXD: 0x%08x : BUF: 0x%08x\n", (int) m->m_data, (int) temp);
@@ -885,7 +882,7 @@ int greth_process_tx_gbit(struct greth_softc *sc)
*/
for (;;){
/* Reap Sent packets */
- while((sc->tx_cnt > 0) && !(NO_CACHE_LOAD(&sc->txdesc[sc->tx_dptr].ctrl) & GRETH_TXD_ENABLE)) {
+ while((sc->tx_cnt > 0) && !(GRETH_MEM_LOAD(&sc->txdesc[sc->tx_dptr].ctrl) & GRETH_TXD_ENABLE)) {
m_free(sc->txmbuf[sc->tx_dptr]);
sc->tx_dptr = (sc->tx_dptr + 1) % sc->txbufs;
sc->tx_cnt--;
@@ -1394,3 +1391,5 @@ static int greth_info(
return DRVMGR_OK;
}
#endif
+
+#endif