source: rtems/bsps/m68k/gen68360/start/alloc360.c @ 9964895

5
Last change on this file since 9964895 was 9964895, checked in by Sebastian Huber <sebastian.huber@…>, on 04/20/18 at 08:35:35

bsps: Move startup files to bsps

Adjust build support files to new directory layout.

This patch is a part of the BSP source reorganization.

Update #3285.

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