summaryrefslogtreecommitdiffstats
path: root/tools/cpu/nios2/linkcmds.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2006-08-15 21:02:55 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2006-08-15 21:02:55 +0000
commit16fd5a99e1a8c433077e70c1a48e42cc01bf7d29 (patch)
tree72d3d6b2daa4c48f453ac18e32ab20fbaa11d92a /tools/cpu/nios2/linkcmds.c
parent5f885443699b77018acccb9fff05f7d436f4fbb8 (diff)
downloadrtems-16fd5a99e1a8c433077e70c1a48e42cc01bf7d29.tar.bz2
2006-08-15 Kolja Waschk <kawk@telos.de>
* 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
Diffstat (limited to 'tools/cpu/nios2/linkcmds.c')
-rw-r--r--tools/cpu/nios2/linkcmds.c122
1 files changed, 122 insertions, 0 deletions
diff --git a/tools/cpu/nios2/linkcmds.c b/tools/cpu/nios2/linkcmds.c
new file mode 100644
index 0000000000..46e0c05755
--- /dev/null
+++ b/tools/cpu/nios2/linkcmds.c
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2006 Kolja Waschk rtemsdev/ixo.de
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "ptf.h"
+#include "devices.h"
+#include "output.h" /* is_not_connected, fwrite_value, etc */
+#include "memory.h"
+#include "linkcmds.h"
+
+typedef struct
+{
+ FILE *file;
+ struct ptf *cfg, *cpu;
+ device_desc *devices;
+ memory_desc *memory;
+}
+lcmd_desc;
+
+void fwrite_lcmds_section(struct ptf_item *pi, void *arg)
+{
+ lcmd_desc *li = (lcmd_desc *)arg;
+ struct ptf *p;
+ struct ptf_item lpi;
+ char *location = NULL;
+ char *section_name = pi->item[1]->value;
+
+ if(section_name == 0)
+ {
+ fprintf(stderr, "Found a LINKER/SECTION without name, ignoring it.\n");
+ return;
+ };
+
+ p = ptf_find(pi->item[1]->sub, &lpi, item, "LOCATION", 0);
+ if(p)
+ {
+ location = p->value;
+ }
+ else
+ {
+ if(strcmp(section_name, "entry") == 0)
+ {
+ p = ptf_find(li->cpu, &lpi, item, "reset_slave", 0);
+ }
+ else if(strcmp(section_name, "exceptions") == 0)
+ {
+ p = ptf_find(li->cpu, &lpi, item, "exc_slave", 0);
+ };
+ if(p) location = p->value;
+ /* TODO: This doesn't work yet, parse full slave address, translate into our naming */
+ }
+
+ if(location == 0)
+ {
+ fprintf(stderr, "No LOCATION configured for section '%s'!\n", pi->item[1]->value);
+ return;
+ };
+
+ fprintf(li->file, " .%s :\n {\n", pi->item[1]->value);
+ fprintf(li->file, pi->item[2]->value);
+ fprintf(li->file, " } > %s\n\n", location);
+}
+
+void fwrite_linkcmds_file(FILE *file, struct ptf *cfg, struct ptf *cpu, device_desc *devices, memory_desc *memory)
+{
+ struct ptf *p;
+ struct ptf_item pi;
+ memory_desc *tmd;
+ lcmd_desc linfo;
+
+ struct ptf ptlink = { section, "LINKCMDS", 0, 0, 0 };
+ struct ptf ptleadtext = { item, "LEADTEXT", 0, 0, 0 };
+ struct ptf ptepilog = { item, "EPILOG", 0, 0, 0 };
+ struct ptf_item malihead = { 2, &ptlink, &ptleadtext };
+ struct ptf_item maliepil = { 2, &ptlink, &ptepilog };
+
+ struct ptf ptsect = { section, "SECTION", 0, 0, 0 };
+ struct ptf ptcmds = { item, "COMMANDS", 0, 0, 0 };
+ struct ptf ptstabs = { item, "STABS", 0, 0, 0 };
+ struct ptf_item malisect = { 3, &ptlink, &ptsect, &ptcmds };
+ struct ptf_item malistabs = { 2, &ptlink, &ptstabs };
+
+ linfo.cfg = cfg;
+ linfo.cpu = cpu;
+ linfo.file = file;
+ linfo.devices = devices;
+ linfo.memory = memory;
+
+ ptf_match(cfg, &malihead, fwrite_value, file);
+
+ fprintf(file, "MEMORY\n{\n");
+ for(tmd = linfo.memory; tmd; tmd = tmd->next)
+ {
+ fprintf(file, " %s : ORIGIN = 0x%08X, LENGTH = 0x%08X\n", tmd->dev->cfgname, tmd->base, tmd->size);
+ }
+ fprintf(file, "}\n\nSECTIONS\n{\n");
+
+ ptf_match(cfg, &malisect, fwrite_lcmds_section, &linfo);
+ ptf_match(cfg, &malistabs, fwrite_value, file);
+
+ for(tmd = linfo.memory; tmd; tmd = tmd->next)
+ {
+ fprintf(file, " %s : ORIGIN = 0x%08X, LENGTH = 0x%08X\n", tmd->dev->cfgname, tmd->base, tmd->size);
+ }
+
+
+ fprintf(file, "}\n\n");
+
+ ptf_match(cfg, &maliepil, fwrite_value, file);
+}
+
+