summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/m68k/gen68360/startup/alloc360.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1997-04-09 14:05:50 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1997-04-09 14:05:50 +0000
commite2d795597310f976af211f9bac2466dbf89b50c8 (patch)
tree7d3053fa42d08569c75a1add4c5715a5fc8ff4fa /c/src/lib/libbsp/m68k/gen68360/startup/alloc360.c
parentadded cast to eliminate warning. (diff)
downloadrtems-e2d795597310f976af211f9bac2466dbf89b50c8.tar.bz2
Added ka9q tcpip stack and network driver for the gen68360. This effort
was done based on the 3.6.0 release and had to be autoconf'ed locally. It is turned on is the bsp enables it and it is not explicitly disabled via the configure option --disable-tcpip. As many warnings as possible were removed locally after the code was merged. Only the gen68360 and mvme136 bsps were compiled this way. The ka9q port and network driver were submitted by Eric Norum (eric@skatter.USask.Ca). The network demo programs are not included in the tree at this point.
Diffstat (limited to 'c/src/lib/libbsp/m68k/gen68360/startup/alloc360.c')
-rw-r--r--c/src/lib/libbsp/m68k/gen68360/startup/alloc360.c96
1 files changed, 96 insertions, 0 deletions
diff --git a/c/src/lib/libbsp/m68k/gen68360/startup/alloc360.c b/c/src/lib/libbsp/m68k/gen68360/startup/alloc360.c
new file mode 100644
index 0000000000..99bfb3352e
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/gen68360/startup/alloc360.c
@@ -0,0 +1,96 @@
+/*
+ * MC68360 buffer descriptor allocation routines
+ *
+ * W. Eric Norum
+ * Saskatchewan Accelerator Laboratory
+ * University of Saskatchewan
+ * Saskatoon, Saskatchewan, CANADA
+ * eric@skatter.usask.ca
+ *
+ * $Id$
+ */
+
+#include <rtems.h>
+#include <bsp.h>
+#include <m68360.h>
+#include <rtems/error.h>
+
+/*
+ * Allocation order:
+ * - Dual-Port RAM section 1
+ * - Dual-Port RAM section 3
+ * - Dual-Port RAM section 0
+ * - Dual-Port RAM section 2
+ */
+static struct {
+ char *base;
+ unsigned int size;
+ unsigned int used;
+} bdregions[] = {
+ { (char *)&m360.dpram1[0], sizeof m360.dpram1, 0 },
+ { (char *)&m360.dpram3[0], sizeof m360.dpram3, 0 },
+ { (char *)&m360.dpram0[0], sizeof m360.dpram0, 0 },
+ { (char *)&m360.dpram2[0], sizeof m360.dpram2, 0 },
+};
+
+/*
+ * Send a command to the CPM RISC processer
+ */
+void *
+M360AllocateBufferDescriptors (int count)
+{
+ unsigned int i;
+ ISR_Level level;
+ void *bdp = NULL;
+ unsigned int want = count * sizeof(m360BufferDescriptor_t);
+
+ /*
+ * Running with interrupts disabled is usually considered bad
+ * form, but this routine is probably being run as part of an
+ * initialization sequence so the effect shouldn't be too severe.
+ */
+ _ISR_Disable (level);
+ for (i = 0 ; i < sizeof(bdregions) / sizeof(bdregions[0]) ; i++) {
+ /*
+ * Verify that the region exists.
+ * This test is necessary since some chips have
+ * less dual-port RAM.
+ */
+ if (bdregions[i].used == 0) {
+ volatile unsigned char *cp = bdregions[i].base;
+ *cp = 0xAA;
+ if (*cp != 0xAA) {
+ bdregions[i].used = bdregions[i].size;
+ continue;
+ }
+ *cp = 0x55;
+ if (*cp != 0x55) {
+ bdregions[i].used = bdregions[i].size;
+ continue;
+ }
+ *cp = 0x0;
+ }
+ if (bdregions[i].size - bdregions[i].used >= want) {
+ bdp = bdregions[i].base + bdregions[i].used;
+ bdregions[i].used += want;
+ break;
+ }
+ }
+ _ISR_Enable (level);
+ if (bdp == NULL)
+ rtems_panic ("Can't allocate %d buffer descriptor(s).\n", count);
+ return bdp;
+}
+
+void *
+M360AllocateRiscTimers (int count)
+{
+ /*
+ * Convert the count to the number of buffer descriptors
+ * of equal or larger size. This ensures that all buffer
+ * descriptors are allocated with appropriate alignment.
+ */
+ return M360AllocateBufferDescriptors (((count * 4) +
+ sizeof(m360BufferDescriptor_t) - 1) /
+ sizeof(m360BufferDescriptor_t));
+}