source: rtems/c/src/lib/libbsp/m68k/gen68360/startup/alloc360.c @ e2d79559

4.104.114.84.95
Last change on this file since e2d79559 was e2d79559, checked in by Joel Sherrill <joel.sherrill@…>, on 04/09/97 at 14:05:50

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@…).

The network demo programs are not included in the tree at this point.

  • Property mode set to 100644
File size: 2.3 KB
Line 
1/*
2 * MC68360 buffer descriptor allocation routines
3 *
4 * W. Eric Norum
5 * Saskatchewan Accelerator Laboratory
6 * University of Saskatchewan
7 * Saskatoon, Saskatchewan, CANADA
8 * eric@skatter.usask.ca
9 *
10 *  $Id$
11 */
12
13#include <rtems.h>
14#include <bsp.h>
15#include <m68360.h>
16#include <rtems/error.h>
17
18/*
19 * Allocation order:
20 *      - Dual-Port RAM section 1
21 *      - Dual-Port RAM section 3
22 *      - Dual-Port RAM section 0
23 *      - Dual-Port RAM section 2
24 */
25static struct {
26        char            *base;
27        unsigned int    size;
28        unsigned int    used;
29} bdregions[] = {
30        { (char *)&m360.dpram1[0],      sizeof m360.dpram1,     0 },
31        { (char *)&m360.dpram3[0],      sizeof m360.dpram3,     0 },
32        { (char *)&m360.dpram0[0],      sizeof m360.dpram0,     0 },
33        { (char *)&m360.dpram2[0],      sizeof m360.dpram2,     0 },
34};
35
36/*
37 * Send a command to the CPM RISC processer
38 */
39void *
40M360AllocateBufferDescriptors (int count)
41{
42        unsigned int i;
43        ISR_Level level;
44        void *bdp = NULL;
45        unsigned int want = count * sizeof(m360BufferDescriptor_t);
46
47        /*
48         * Running with interrupts disabled is usually considered bad
49         * form, but this routine is probably being run as part of an
50         * initialization sequence so the effect shouldn't be too severe.
51         */
52        _ISR_Disable (level);
53        for (i = 0 ; i < sizeof(bdregions) / sizeof(bdregions[0]) ; i++) {
54                /*
55                 * Verify that the region exists.
56                 * This test is necessary since some chips have
57                 * less dual-port RAM.
58                 */
59                if (bdregions[i].used == 0) {
60                        volatile unsigned char *cp = bdregions[i].base;
61                        *cp = 0xAA;
62                        if (*cp != 0xAA) {
63                                bdregions[i].used = bdregions[i].size;
64                                continue;
65                        }
66                        *cp = 0x55;
67                        if (*cp != 0x55) {
68                                bdregions[i].used = bdregions[i].size;
69                                continue;
70                        }
71                        *cp = 0x0;
72                }
73                if (bdregions[i].size - bdregions[i].used >= want) {
74                        bdp = bdregions[i].base + bdregions[i].used;
75                        bdregions[i].used += want;
76                        break;
77                }
78        }
79        _ISR_Enable (level);
80        if (bdp == NULL)
81                rtems_panic ("Can't allocate %d buffer descriptor(s).\n", count);
82        return bdp;
83}
84
85void *
86M360AllocateRiscTimers (int count)
87{
88        /*
89         * Convert the count to the number of buffer descriptors
90         * of equal or larger size.  This ensures that all buffer
91         * descriptors are allocated with appropriate alignment.
92         */
93        return M360AllocateBufferDescriptors (((count * 4) +
94                                        sizeof(m360BufferDescriptor_t) - 1) /
95                                        sizeof(m360BufferDescriptor_t));
96}
Note: See TracBrowser for help on using the repository browser.