diff options
author | Eric Norum <WENorum@lbl.gov> | 2005-01-31 19:03:41 +0000 |
---|---|---|
committer | Eric Norum <WENorum@lbl.gov> | 2005-01-31 19:03:41 +0000 |
commit | 518edef387ec306d7c7a3eda153d8625e54a4324 (patch) | |
tree | 485c6da5a84de4fa020723552a4f54f5af5ff79b /c/src/lib/libbsp/m68k | |
parent | Add ColdFire cache information. (diff) | |
download | rtems-518edef387ec306d7c7a3eda153d8625e54a4324.tar.bz2 |
Processor doesn't snoop FEC DMA so we must invalidate the cache appropriately.
Diffstat (limited to 'c/src/lib/libbsp/m68k')
-rw-r--r-- | c/src/lib/libbsp/m68k/uC5282/ChangeLog | 6 | ||||
-rw-r--r-- | c/src/lib/libbsp/m68k/uC5282/network/network.c | 49 | ||||
-rw-r--r-- | c/src/lib/libbsp/m68k/uC5282/startup/bspstart.c | 13 |
3 files changed, 50 insertions, 18 deletions
diff --git a/c/src/lib/libbsp/m68k/uC5282/ChangeLog b/c/src/lib/libbsp/m68k/uC5282/ChangeLog index 0a8614af75..dd4f772b18 100644 --- a/c/src/lib/libbsp/m68k/uC5282/ChangeLog +++ b/c/src/lib/libbsp/m68k/uC5282/ChangeLog @@ -1,3 +1,9 @@ +2005-01-31 Eric Norum <norume@aps.anl.gov> + + * network/network.c, startup/bspstart.c: Processor doesn't snoop FEC DMA + so we must invalidate the cache appropriately. + + 2005-01-31 Joel Sherrill <joel@OARcorp.com> * .cvsignore: New file. diff --git a/c/src/lib/libbsp/m68k/uC5282/network/network.c b/c/src/lib/libbsp/m68k/uC5282/network/network.c index 72685f6a09..8758f5c171 100644 --- a/c/src/lib/libbsp/m68k/uC5282/network/network.c +++ b/c/src/lib/libbsp/m68k/uC5282/network/network.c @@ -10,6 +10,7 @@ #include <errno.h> #include <stdarg.h> #include <string.h> +#include <rtems.h> #include <rtems/error.h> #include <rtems/rtems_bsdnet.h> @@ -122,20 +123,19 @@ mcf5282_fec_tx_interrupt_handler( rtems_vector_number v ) } /* - * Allocate buffer descriptors from SRAM - * Ensure 128-bit (16-byte)alignment + * Allocate buffer descriptors + * Ensure 128-bit (16-byte) alignment */ -static void * +static mcf5282BufferDescriptor_t * mcf5282_bd_allocate(unsigned int count) { - char *p; - + mcf5282BufferDescriptor_t *p; + p = malloc((count * sizeof(mcf5282BufferDescriptor_t)) + 15, 0, M_NOWAIT); if (!p) rtems_panic("FEC BD"); if ((int)p & 0xF) - p += 16 - ((int)p & 0xF); -printf("Allocate %d at %p\n", count, p); + p = (mcf5282BufferDescriptor_t *)((char *)p + (16 - ((int)p & 0xF))); return p; } @@ -171,7 +171,7 @@ mcf5282_fec_initialize_hardware(struct mcf5282_enet_struct *sc) * Issue reset to FEC */ MCF5282_FEC_ECR = MCF5282_FEC_ECR_RESET; - rtems_task_wake_after( 1 ); + rtems_task_wake_after(1); /* * Configuration of I/O ports is done outside of this function */ @@ -302,9 +302,15 @@ static void fec_retire_tx_bd(volatile struct mcf5282_enet_struct *sc ) { struct mbuf *m, *n; + volatile mcf5282BufferDescriptor_t *txBd; - while ((sc->txBdActiveCount != 0) - && ((sc->txBdBase[sc->txBdTail].status & MCF5282_FEC_TxBD_R) == 0)) { + for (;;) { + if (sc->txBdActiveCount == 0) + return; + txBd = sc->txBdBase + sc->txBdTail; + rtems_cache_invalidate_multiple_data_lines(txBd, sizeof *txBd); + if ((txBd->status & MCF5282_FEC_TxBD_R) != 0) + return; m = sc->txMbuf[sc->txBdTail]; MFREE(m, n); if (++sc->txBdTail == sc->txBdCount) @@ -353,7 +359,9 @@ fec_rxDaemon (void *arg) /* * Wait for packet if there's not one ready */ + rtems_cache_invalidate_multiple_data_lines(rxBd, sizeof *rxBd); if ((status = rxBd->status) & MCF5282_FEC_RxBD_E) { +int chkCount=0 ; /* * Clear old events. */ @@ -365,10 +373,15 @@ fec_rxDaemon (void *arg) * This catches the case when a packet arrives between the * `if' above, and the clearing of the RXF bit in the EIR. */ - while ((status = rxBd->status) & MCF5282_FEC_RxBD_E) { + for (;;) { rtems_event_set events; int level; + rtems_cache_invalidate_multiple_data_lines(rxBd, sizeof *rxBd); + if (((status = rxBd->status) & MCF5282_FEC_RxBD_E) == 0) + break; + +if(chkCount++)printf("ACK -- CACHE WOES\n"); rtems_interrupt_disable(level); MCF5282_FEC_EIMR |= MCF5282_FEC_EIMR_RXF; rtems_interrupt_enable(level); @@ -388,14 +401,19 @@ fec_rxDaemon (void *arg) * FIXME: Packet filtering hook could be done here. */ struct ether_header *eh; + int len = rxBd->length - sizeof(rtems_unsigned32);; /* - * Invalidate the buffer for this descriptor + * Invalidate the cache and push the packet up + * The cache is so small that it's more efficient to just + * invalidate the whole thing unless the packet is very small. */ m = sc->rxMbuf[rxBdIndex]; - m->m_len = m->m_pkthdr.len = rxBd->length - - sizeof(rtems_unsigned32) - - sizeof(struct ether_header); + if (len < 128) + rtems_cache_invalidate_multiple_data_lines(m->m_data, len); + else + rtems_cache_invalidate_entire_data(); + m->m_len = m->m_pkthdr.len = len - sizeof(struct ether_header); eh = mtod(m, struct ether_header *); m->m_data += sizeof(struct ether_header); ether_input(ifp, eh, m); @@ -763,7 +781,6 @@ rtems_fec_driver_attach(struct rtems_bsdnet_ifconfig *config, int attaching ) char *unitName; unsigned char *hwaddr; -printf("attaching\n"); rtems_task_wake_after(10); /* * Parse driver name */ diff --git a/c/src/lib/libbsp/m68k/uC5282/startup/bspstart.c b/c/src/lib/libbsp/m68k/uC5282/startup/bspstart.c index 2b050a0276..c179b61497 100644 --- a/c/src/lib/libbsp/m68k/uC5282/startup/bspstart.c +++ b/c/src/lib/libbsp/m68k/uC5282/startup/bspstart.c @@ -109,7 +109,11 @@ void _CPU_cache_invalidate_entire_instruction(void) void _CPU_cache_invalidate_1_instruction_line(const void *addr) { - asm volatile ("cpushl %%ic,(%0)" :: "a" (addr)); + /* + * Top half of cache is I-space + */ + addr = (void *)((int)addr | 0x400); + asm volatile ("cpushl %%bc,(%0)" :: "a" (addr)); } void _CPU_cache_enable_data(void) @@ -127,6 +131,7 @@ void _CPU_cache_disable_data(void) rtems_interrupt_level level; rtems_interrupt_disable(level); + rtems_interrupt_disable(level); cacr_mode |= MCF5XXX_CACR_DISD; m68k_set_cacr(cacr_mode); rtems_interrupt_enable(level); @@ -139,7 +144,11 @@ void _CPU_cache_invalidate_entire_data(void) void _CPU_cache_invalidate_1_data_line(const void *addr) { - asm volatile ("cpushl %%dc,(%0)" :: "a" (addr)); + /* + * Bottom half of cache is D-space + */ + addr = (void *)((int)addr & ~0x400); + asm volatile ("cpushl %%bc,(%0)" :: "a" (addr)); } /* |