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

4.104.114.95
Last change on this file since e36390a6 was e36390a6, checked in by Joel Sherrill <joel.sherrill@…>, on 09/03/08 at 20:35:43

2008-09-03 Joel Sherrill <joel.sherrill@…>

  • Makefile.am, configure.ac, console/alloc360.c, console/console.c, console/console.h, console/m68360.h, console/mc68360_scc.c, console/ns16550cfg.c, console/rsPMCQ1.c, console/rsPMCQ1.h, include/bsp.h, irq/irq_init.c, vme/VMEConfig.h: Initiate update and testing. Add missing files. Does not run hello yet.
  • console/debugio.c, console/polled_io.c, irq/openpic_xxx_irq.c: New files.
  • Property mode set to 100644
File size: 2.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       (unsigned int)&(m360->mcr), ((unsigned int)m360+Q1_360_SIM_MCR));
38#endif
39  ptr->bdregions[0].base = (char *)&m360->dpram1[0];
40  ptr->bdregions[0].size = sizeof m360->dpram1;
41  ptr->bdregions[0].used = 0;
42
43  ptr->bdregions[1].base = (char *)&m360->dpram3[0];
44  ptr->bdregions[1].size = sizeof m360->dpram3;
45  ptr->bdregions[1].used = 0;
46
47  ptr->bdregions[2].base = (char *)&m360->dpram0[0];
48  ptr->bdregions[2].size = sizeof m360->dpram0;
49  ptr->bdregions[2].used = 0;
50
51  ptr->bdregions[3].base = (char *)&m360->dpram2[0];
52  ptr->bdregions[3].size = sizeof m360->dpram2;
53  ptr->bdregions[3].used = 0;
54}
55
56
57/*
58 * Send a command to the CPM RISC processer
59 */
60void *
61M360AllocateBufferDescriptors (M68360_t ptr, int count)
62{
63  unsigned int i;
64  ISR_Level    level;
65  void         *bdp  = NULL;
66  unsigned int want  = count * sizeof(m360BufferDescriptor_t);
67  int          have;
68
69  /*
70   * Running with interrupts disabled is usually considered bad
71   * form, but this routine is probably being run as part of an
72   * initialization sequence so the effect shouldn't be too severe.
73   */
74  _ISR_Disable (level);
75
76  for (i = 0 ; i < M360_NUM_DPRAM_REAGONS ; i++) {
77
78    /*
79     * Verify that the region exists.
80     * This test is necessary since some chips have
81     * less dual-port RAM.
82     */
83    if (ptr->bdregions[i].used == 0) {
84      volatile unsigned char *cp = ptr->bdregions[i].base;
85      *cp = 0xAA;
86      if (*cp != 0xAA) {
87        ptr->bdregions[i].used = ptr->bdregions[i].size;
88        continue;
89      }
90      *cp = 0x55;
91      if (*cp != 0x55) {
92        ptr->bdregions[i].used = ptr->bdregions[i].size;
93        continue;
94      }
95      *cp = 0x0;
96    }
97
98    have = ptr->bdregions[i].size - ptr->bdregions[i].used;
99    if (have >= want) {
100      bdp = ptr->bdregions[i].base + ptr->bdregions[i].used;
101      ptr->bdregions[i].used += want;
102      break;
103    }
104  }
105  _ISR_Enable (level);
106  if (bdp == NULL){
107    printk("rtems_panic can't allocate %d buffer descriptor(s).\n");
108    rtems_panic ("Can't allocate %d buffer descriptor(s).\n", count);
109  }
110  return bdp;
111}
Note: See TracBrowser for help on using the repository browser.