summaryrefslogtreecommitdiffstats
path: root/c/src/libchip
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2000-11-13 22:58:36 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2000-11-13 22:58:36 +0000
commitf6ef823a22c18ea2bb097b2ce43ebf9ba1a8baed (patch)
treeeffc341012e541bafb98d404c7a3f825669afb12 /c/src/libchip
parent2000-11-13 Jiri Gaisler <jgais@ws.estec.esa.nl> (diff)
downloadrtems-f6ef823a22c18ea2bb097b2ce43ebf9ba1a8baed.tar.bz2
2000-11-13 Jiri Gaisler <jgais@ws.estec.esa.nl>
* 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.
Diffstat (limited to 'c/src/libchip')
-rw-r--r--c/src/libchip/ChangeLog7
-rw-r--r--c/src/libchip/network/sonic.c34
2 files changed, 41 insertions, 0 deletions
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 <jgais@ws.estec.esa.nl>
+
+ * 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 <corsepiu@faw.uni-ulm.de>
* 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
*/