From f6ef823a22c18ea2bb097b2ce43ebf9ba1a8baed Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 13 Nov 2000 22:58:36 +0000 Subject: 2000-11-13 Jiri Gaisler * network/sonic.c: Added ipalign() routine to align the received packet so that the ip header is on a 32-bit boundary. Necessary for cpu's that do not allow unaligned loads and stores and when the 32-bit DMA mode is used. --- c/src/libchip/ChangeLog | 7 +++++++ c/src/libchip/network/sonic.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) (limited to 'c/src/libchip') diff --git a/c/src/libchip/ChangeLog b/c/src/libchip/ChangeLog index a70c693e45..8010566c46 100644 --- a/c/src/libchip/ChangeLog +++ b/c/src/libchip/ChangeLog @@ -1,3 +1,10 @@ +2000-11-13 Jiri Gaisler + + * network/sonic.c: Added ipalign() routine to align the + received packet so that the ip header is on a 32-bit boundary. + Necessary for cpu's that do not allow unaligned loads and stores + and when the 32-bit DMA mode is used. + 2000-11-09 Ralf Corsepius * Makefile.am: Use ... instead of RTEMS_TOPdir in ACLOCAL_AMFLAGS. diff --git a/c/src/libchip/network/sonic.c b/c/src/libchip/network/sonic.c index 66c12d570c..e361d234ea 100644 --- a/c/src/libchip/network/sonic.c +++ b/c/src/libchip/network/sonic.c @@ -887,6 +887,40 @@ SONIC_STATIC void sonic_rda_wait( } +#ifdef CPU_U32_FIX + +/* + * Routine to align the received packet so that the ip header + * is on a 32-bit boundary. Necessary for cpu's that do not + * allow unaligned loads and stores and when the 32-bit DMA + * mode is used. + * + * Transfers are done on word basis to avoid possibly slow byte + * and half-word writes. + */ + +void ipalign(struct mbuf *m) +{ + unsigned int *first, *last, data; + unsigned int tmp = 0; + + if ((((int) m->m_data) & 2) && (m->m_len)) { + last = (unsigned int *) ((((int) m->m_data) + m->m_len + 8) & ~3); + first = (unsigned int *) (((int) m->m_data) & ~3); + tmp = *first << 16; + first++; + do { + data = *first; + *first = tmp | (data >> 16); + tmp = data << 16; + first++; + } while (first <= last); + + m->m_data = (caddr_t)(((int) m->m_data) + 2); + } +} +#endif + /* * SONIC reader task */ -- cgit v1.2.3