source: rtems/c/src/lib/libbsp/powerpc/ep1a/console/alloc360.c @ fb557a9

4.9
Last change on this file since fb557a9 was fb557a9, checked in by Joel Sherrill <joel.sherrill@…>, on 10/16/09 at 16:42:03

2009-10-16 Jennifer Averett <jennifer@…>

  • Makefile.am, configure.ac, preinstall.am, console/alloc360.c, console/config.c, console/console.c, console/m68360.h, console/mc68360_scc.c, console/rsPMCQ1.c, console/rsPMCQ1.h, include/bsp.h, irq/irq_init.c, irq/openpic_xxx_irq.c, start/start.S, startup/bspstart.c, startup/linkcmds, vme/VMEConfig.h: Updated and tested against RTEMS 4.9. Updated README file to latest source status. Modified to use the shared irq source code. Turned off debugging, cleaned up warnings, removed unused code. Tested with two PMCQ1 serial cards. Tested MC68360 serial ports and VME using external tests.
  • README, irq/irq.h, vme/vmeconfig.c: New files.
  • Property mode set to 100644
File size: 3.8 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 *  COPYRIGHT (c) 2008.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.com/license/LICENSE.
16 *
17 *  $Id$
18 */
19
20#include <rtems.h>
21#include <bsp.h>
22#include "m68360.h"
23#include <rtems/error.h>
24#include "rsPMCQ1.h"
25#include <rtems/bspIo.h>
26
27
28#define DEBUG_PRINT 1
29
30void M360SetupMemory( M68360_t ptr ){
31  volatile m360_t  *m360;
32 
33  m360  = ptr->m360;
34
35#if DEBUG_PRINT
36printk("m360->mcr:0x%08x  Q1_360_SIM_MCR:0x%08x\n",
37       (uint32_t)&(m360->mcr), ((uint32_t)m360+Q1_360_SIM_MCR));
38#endif
39  ptr->bdregions[0].base = (uint8_t *)&m360->dpram1[0];
40  ptr->bdregions[0].size = sizeof m360->dpram1;
41  ptr->bdregions[0].used = 0;
42#if DEBUG_PRINT
43printk("%d) base 0x%x size %d used %d\n", 0,
44       (uint32_t)ptr->bdregions[0].base, ptr->bdregions[0].size, ptr->bdregions[0].used );
45#endif
46
47  ptr->bdregions[1].base = (uint8_t *)&m360->dpram3[0];
48  ptr->bdregions[1].size = sizeof m360->dpram3;
49  ptr->bdregions[1].used = 0;
50#if DEBUG_PRINT
51printk("%d) base 0x%x size %d used %d\n", 1,
52       (uint32_t)ptr->bdregions[1].base, ptr->bdregions[1].size, ptr->bdregions[1].used );
53#endif
54
55  ptr->bdregions[2].base = (uint8_t *)&m360->dpram0[0];
56  ptr->bdregions[2].size = sizeof m360->dpram0;
57  ptr->bdregions[2].used = 0;
58#if DEBUG_PRINT
59printk("%d) base 0x%x size %d used %d\n", 2,
60       (uint32_t)ptr->bdregions[2].base, ptr->bdregions[2].size, ptr->bdregions[2].used );
61#endif
62
63  ptr->bdregions[3].base = (uint8_t *)&m360->dpram2[0];
64  ptr->bdregions[3].size = sizeof m360->dpram2;
65  ptr->bdregions[3].used = 0;
66#if DEBUG_PRINT
67printk("%d) base 0x%x size %d used %d\n", 3,
68       (uint32_t)ptr->bdregions[3].base, ptr->bdregions[3].size, ptr->bdregions[3].used );
69#endif
70
71}
72
73
74/*
75 * Send a command to the CPM RISC processer
76 */
77void *
78M360AllocateBufferDescriptors (M68360_t ptr, int count)
79{
80  uint32_t     i;
81  ISR_Level    level;
82  void         *bdp  = NULL;
83  uint32_t      want  = count * sizeof(m360BufferDescriptor_t);
84  uint32_t      have;
85
86  /*
87   * Running with interrupts disabled is usually considered bad
88   * form, but this routine is probably being run as part of an
89   * initialization sequence so the effect shouldn't be too severe.
90   */
91  _ISR_Disable (level);
92
93  for (i = 0 ; i < M360_NUM_DPRAM_REAGONS ; i++) {
94
95    /*
96     * Verify that the region exists.
97     * This test is necessary since some chips have
98     * less dual-port RAM.
99     */
100    if (ptr->bdregions[i].used == 0) {
101      volatile uint8_t *cp = ptr->bdregions[i].base;
102      uint8_t data;
103
104      *cp = 0xAA;
105      data = *cp;
106      if (data != 0xAA) {
107        ptr->bdregions[i].used = ptr->bdregions[i].size;
108#if DEBUG_PRINT
109printk("%d) base 0x%x used %d expected 0xAA read 0x%x\n",i,
110       (uint32_t)ptr->bdregions[i].base, ptr->bdregions[0].used, data );
111#endif
112        continue;
113      }
114      *cp = 0x55;
115      data = *cp;
116      if (data != 0x55) {
117        ptr->bdregions[i].used = ptr->bdregions[i].size;
118#if DEBUG_PRINT
119printk("%d) base 0x%x used %d expected 0x55 read 0x%x\n",i,
120       (uint32_t)ptr->bdregions[i].base, ptr->bdregions[0].used, data );
121#endif
122        continue;
123      }
124      *cp = 0x0;
125    }
126
127    have = ptr->bdregions[i].size - ptr->bdregions[i].used;
128    if (have >= want) {
129      bdp = ptr->bdregions[i].base + ptr->bdregions[i].used;
130      ptr->bdregions[i].used += want;
131      break;
132    }
133  }
134  _ISR_Enable (level);
135  if (bdp == NULL){
136    printk("rtems_panic can't allocate %d buffer descriptor(s).\n");
137    rtems_panic ("Can't allocate %d buffer descriptor(s).\n", count);
138  }
139  return bdp;
140}
Note: See TracBrowser for help on using the repository browser.