source: rtems/tools/cpu/nios2/linkcmds.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: 3.1 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 "output.h" /* is_not_connected, fwrite_value, etc */
18#include "memory.h"
19#include "linkcmds.h"
20
21typedef struct
22{
23  FILE *file;
24  struct ptf *cfg, *cpu;
25  device_desc *devices;
26  memory_desc *memory;
27}
28lcmd_desc;
29
30void fwrite_lcmds_section(struct ptf_item *pi, void *arg)
31{
32  lcmd_desc *li = (lcmd_desc *)arg;
33  struct ptf *p;
34  struct ptf_item lpi;
35  char *location = NULL;
36  char *section_name = pi->item[1]->value;
37
38  if(section_name == 0)
39  {
40    fprintf(stderr, "Found a LINKER/SECTION without name, ignoring it.\n");
41    return;
42  };
43
44  p = ptf_find(pi->item[1]->sub, &lpi, item, "LOCATION", 0);
45  if(p)
46  {
47    location = p->value;
48  }
49  else
50  {
51    if(strcmp(section_name, "entry") == 0)
52    {
53      p = ptf_find(li->cpu, &lpi, item, "reset_slave", 0);
54    }
55    else if(strcmp(section_name, "exceptions") == 0)
56    {
57      p = ptf_find(li->cpu, &lpi, item, "exc_slave", 0);
58    };
59    if(p) location = p->value;
60    /* TODO: This doesn't work yet, parse full slave address, translate into our naming */
61  }
62
63  if(location == 0)
64  {
65    fprintf(stderr, "No LOCATION configured for section '%s'!\n", pi->item[1]->value);
66    return;
67  };
68
69  fprintf(li->file, "    .%s :\n    {\n", pi->item[1]->value);
70  fprintf(li->file, pi->item[2]->value);
71  fprintf(li->file, "    } > %s\n\n", location);
72}
73
74void fwrite_linkcmds_file(FILE *file, struct ptf *cfg, struct ptf *cpu, device_desc *devices, memory_desc *memory)
75{
76  struct ptf *p;
77  struct ptf_item pi;
78  memory_desc *tmd;
79  lcmd_desc linfo;
80
81  struct ptf ptlink = { section, "LINKCMDS", 0, 0, 0 };
82  struct ptf ptleadtext = { item,    "LEADTEXT", 0, 0, 0 };
83  struct ptf ptepilog = { item,    "EPILOG", 0, 0, 0 };
84  struct ptf_item malihead = { 2, &ptlink, &ptleadtext };
85  struct ptf_item maliepil = { 2, &ptlink, &ptepilog };
86
87  struct ptf ptsect = { section, "SECTION", 0, 0, 0 };
88  struct ptf ptcmds = { item, "COMMANDS", 0, 0, 0 };
89  struct ptf ptstabs = { item, "STABS", 0, 0, 0 };
90  struct ptf_item malisect = { 3, &ptlink, &ptsect, &ptcmds };
91  struct ptf_item malistabs = { 2, &ptlink, &ptstabs };
92
93  linfo.cfg     = cfg;
94  linfo.cpu     = cpu;
95  linfo.file    = file;
96  linfo.devices = devices;
97  linfo.memory  = memory;
98
99  ptf_match(cfg, &malihead, fwrite_value, file);
100
101  fprintf(file, "MEMORY\n{\n");
102  for(tmd = linfo.memory; tmd; tmd = tmd->next)
103  {
104    fprintf(file, "    %s : ORIGIN = 0x%08X, LENGTH = 0x%08X\n", tmd->dev->cfgname, tmd->base, tmd->size);
105  }
106  fprintf(file, "}\n\nSECTIONS\n{\n");
107
108  ptf_match(cfg, &malisect, fwrite_lcmds_section, &linfo);
109  ptf_match(cfg, &malistabs, fwrite_value, file);
110
111  for(tmd = linfo.memory; tmd; tmd = tmd->next)
112  {
113    fprintf(file, "    %s : ORIGIN = 0x%08X, LENGTH = 0x%08X\n", tmd->dev->cfgname, tmd->base, tmd->size);
114  }
115 
116
117  fprintf(file, "}\n\n");
118
119  ptf_match(cfg, &maliepil, fwrite_value, file);
120}
121
122 
Note: See TracBrowser for help on using the repository browser.