source: rtems/tools/cpu/nios2/memory.c @ 67eede5

4.104.114.84.95
Last change on this file since 67eede5 was 16fd5a9, checked in by Joel Sherrill <joel.sherrill@…>, on 08/15/06 at 21:02:55

2006-08-15 Kolja Waschk <kawk@…>

  • linkcmds.c, linkcmds.h, memory.c, memory.h, sample.ptf: New files.
  • bridges.c: corrected detection of bridged connections
  • clocks.c: removed a printf
  • linkcmds.[ch] new files, added output of linker script
  • Makefile.am: added new files
  • memory.[ch]: new files, detection of memory in SOPC configuration
  • nios2gen.c: updated command line parsing and output control
  • output.[ch]: improved output of BSP header file
  • ptf.[ch]: added ptf_dump_ptf_item and small fixes
  • sample.ptf: new file, sample configuration for nios2gen
  • README: updated
  • Property mode set to 100644
File size: 2.3 KB
Line 
1/*
2 *  Copyright (c) 2006 Kolja Waschk rtemsdev/ixo.de
3 *
4 *  The license and distribution terms for this file may be
5 *  found in the file LICENSE in this distribution or at
6 *  http://www.rtems.com/license/LICENSE.
7 *
8 *  $Id$
9 */
10
11#include <stdio.h>
12#include <stdlib.h>
13#include <string.h>
14
15#include "ptf.h"
16#include "devices.h"
17#include "memory.h"
18
19memory_desc *find_memory(device_desc *devices)
20{
21  struct ptf *p;
22  struct ptf_item pi;
23  memory_desc *tmd, *memory;
24
25  /********************************************************/
26  /* Check which of the devices are memory, sort by size */
27
28  if(devices)
29  {
30    struct ptf *p, *s;
31    struct ptf_item pi;
32    device_desc *dd;
33
34    memory = NULL;
35
36    for(dd = devices; dd; dd=dd->next)
37    {
38      p = ptf_find(dd->ptf->sub, &pi, item, "Is_Memory_Device", "1");
39      if(p != NULL && pi.level>0)
40      {
41        s = pi.item[pi.level-1];
42        p = ptf_find(s, &pi, item, "Base_Address", 0);
43      };
44
45      if(p != NULL)
46      {
47        tmd = (memory_desc*)malloc(sizeof(memory_desc));
48
49        if(tmd != NULL)
50        {
51          tmd->base = strtoul(p->value, 0, 0);
52
53          p = ptf_find(s, &pi, item, "Address_Span", 0);
54          if(p != 0)
55          {
56            tmd->size = strtoul(p->value, 0, 0);
57          }
58          else
59          {
60            tmd->size = 0;
61            p = ptf_find(s, &pi, item, "Address_Width", 0);
62            if(p) tmd->size = 1 << strtoul(p->value, 0, 0);
63            p = ptf_find(s, &pi, item, "Data_Width", 0);
64            if(p) tmd->size *= (strtoul(p->value, 0, 0) >> 3);
65          };
66
67          if(tmd->size == 0)
68          {
69            free(tmd);
70          }
71          else
72          {
73            tmd->dev = dd;
74
75            if(memory == NULL)
76            {
77              tmd->next = NULL;
78              memory = tmd;
79            }
80            else
81            {
82              if(tmd->size > memory->size)
83              {
84                tmd->next = memory;
85                memory = tmd;
86              }
87              else
88              {
89                memory_desc *uplink = memory;
90                while(uplink->next != NULL && uplink->next->size > tmd->size) uplink=uplink->next;
91                tmd->next = uplink->next;
92                uplink->next = tmd;
93              };
94            };
95          };
96        };
97      };
98    };
99  };
100
101  return memory;
102}
103
104 
Note: See TracBrowser for help on using the repository browser.