summaryrefslogtreecommitdiffstats
path: root/tools/cpu
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tools/cpu/configure.ac3
-rw-r--r--tools/cpu/nios2/Makefile.am21
-rw-r--r--tools/cpu/nios2/README146
-rw-r--r--tools/cpu/nios2/bridges.c112
-rw-r--r--tools/cpu/nios2/bridges.h29
-rw-r--r--tools/cpu/nios2/clocks.c75
-rw-r--r--tools/cpu/nios2/clocks.h26
-rw-r--r--tools/cpu/nios2/configure.ac23
-rw-r--r--tools/cpu/nios2/devices.c130
-rw-r--r--tools/cpu/nios2/devices.h30
-rw-r--r--tools/cpu/nios2/linkcmds.c120
-rw-r--r--tools/cpu/nios2/linkcmds.h23
-rw-r--r--tools/cpu/nios2/memory.c101
-rw-r--r--tools/cpu/nios2/memory.h27
-rw-r--r--tools/cpu/nios2/nios2gen.c494
-rw-r--r--tools/cpu/nios2/output.c193
-rw-r--r--tools/cpu/nios2/output.h25
-rw-r--r--tools/cpu/nios2/ptf.c857
-rw-r--r--tools/cpu/nios2/ptf.h69
-rw-r--r--tools/cpu/nios2/sample.ptf462
20 files changed, 0 insertions, 2966 deletions
diff --git a/tools/cpu/configure.ac b/tools/cpu/configure.ac
index 8e96cf9c13..220311bf80 100644
--- a/tools/cpu/configure.ac
+++ b/tools/cpu/configure.ac
@@ -18,9 +18,6 @@ RTEMS_TOOLPATHS
AC_SUBST(program_prefix)
AC_CONFIG_SUBDIRS(generic)
-case "$RTEMS_CPU" in
-nios2 ) AC_CONFIG_SUBDIRS(nios2);;
-esac
# Explicitly list all Makefiles here
AC_CONFIG_FILES([Makefile])
diff --git a/tools/cpu/nios2/Makefile.am b/tools/cpu/nios2/Makefile.am
deleted file mode 100644
index 5d67affcdc..0000000000
--- a/tools/cpu/nios2/Makefile.am
+++ /dev/null
@@ -1,21 +0,0 @@
-ACLOCAL_AMFLAGS = -I ../../../aclocal
-
-noinst_PROGRAMS = nios2gen
-
-nios2gen_SOURCES = nios2gen.c \
- bridges.c bridges.h \
- devices.c devices.h \
- clocks.c clocks.h \
- output.c output.h \
- linkcmds.c linkcmds.h \
- memory.c memory.h \
- ptf.h ptf.c
-
-if HELP2MAN
-man_MANS = nios2gen.1
-
-nios2gen.1: nios2gen$(EXEEXT)
- $(HELP2MAN) -N ./nios2gen >$@
-endif
-
-include $(top_srcdir)/../../../automake/host.am
diff --git a/tools/cpu/nios2/README b/tools/cpu/nios2/README
deleted file mode 100644
index 1edcdb653e..0000000000
--- a/tools/cpu/nios2/README
+++ /dev/null
@@ -1,146 +0,0 @@
-nios2gen:
- Tool to generate BSP data for boards utilizing NIOS2 soft core processor.
-
-=================================
-What it does
-
-It creates a sopc.h and linkcmds file for RTEMS nios2 BSPs from one or more inputs:
-
-1. SOPC System Description PTF
-
-As an output from SOPC Builder you get a file with extension ".ptf" that fully
-describes the SOPC, including all CPUs, memory and integrated peripherals.
-(PTF simply means "plain-text file").
-
-2. BSP Configuration PTF
-
-This file, using the same format as the SOPC System Description PTF, describes
-which components of the SOPC shall be used by the BSP. For example, there may
-be several timers, but a BSP wants at least one named "CLOCK" and optionally
-another named "TIMER". This mapping can be specified in the BSP.
-
-=================================
-Contents of the configuration PTF
-
-There can be definitions of ...
-
-HEADER: This is written to sopc.h before anything else. Example:
-
- HEADER = "
- #ifndef __SOPC_H
- #define __SOPC_H 1
- ";
-
-EPILOG: This is written to sopc.h after anything else. Example:
-
- EPILOG = "
- #endif
- ";
-
-CLOCKS section: Used to specify names for clocks to be used in definitions in
-the sopc.h. The default name (if none is specified here) is the uppercased name
-as in the system description PTF. Specify the name you want on the left, the
-name in the sopc PTF on the right! Example:
-
- CLOCKS
- {
- GLOBAL_CLOCK = "sys_clk";
- }
-
-MODULES section: Same as clocks but for modules / peripherals. As a special definition,
-if the PTF contains more than one nios2 CPU, it /must/ define a CPU to use. Example to
-select cpu_0 and rename timer_0 to CLOCK and timer_1 to TIMER:
-
- MODULES
- {
- CPU = "cpu_0";
- CLOCK = "timer_0";
- TIMER = "timer_1";
- }
-
-CLASS xyz sections: These specify what you want in the sopc.h, and how the definitions
-shall be named. Actually, the CLASS xyz should look exactly like the corresponding MODULE
-specification in the system description PTF of modules belonging to that class; e.g. a
-a JTAG UART is originally described like this:
-
- MODULE jtag_uart_0
- {
- class = "altera_avalon_jtag_uart";
- class_version = "1.0";
- iss_model_name = "altera_avalon_jtag_uart";
- SLAVE avalon_jtag_slave
- {
- SYSTEM_BUILDER_INFO
- {
- Bus_Type = "avalon";
- Is_Printable_Device = "1";
- Address_Alignment = "native";
- Address_Width = "1";
- Data_Width = "32";
- Has_IRQ = "1";
- Read_Wait_States = "peripheral_controlled";
- Write_Wait_States = "peripheral_controlled";
- JTAG_Hub_Base_Id = "0x04006E";
- JTAG_Hub_Instance_Id = "0";
- MASTERED_BY cpu_0/data_master
- {
- priority = "1";
- }
- IRQ_MASTER cpu_0/data_master
- {
- IRQ_Number = "2";
- }
- Base_Address = "0x08000000";
- }
- }
- ...
- }
-
-If you want to have definitions about its base address and irq number in your sopc.h,
-define a CLASS for altera_avalon_jtag_uart that matches the MODULE description above,
-but instead of values for the items you specify names to be used in your sopc.h (You
-can omit items from the MODULE as you like, but the section nesting must match; and
-section names (such as avalon_jtag_slave for the SLAVE section) also have to match)
-
- CLASS altera_avalon_jtag_uart
- {
- SLAVE avalon_jtag_slave
- {
- SYSTEM_BUILDER_INFO
- {
- Base_Address = "BASE_ADDR";
- IRQ_MASTER { IRQ_Number = "IRQ"; }
- }
- }
- }
-
-The output for jtag_uart_0 will be:
-
- #define JTAG_UART_BASE_ADDR 0x021208D0
- #define JTAG_UART_IRQ 1
-
-There are some values with special meaning to nios2gen,
-
-N2G_CLOCKREF_CLOCK: This should be used whereever the value in the SOPC PTF
-specifies the name of a clock. nios2gen will use whatever you configured for
-the selected clock in your CLOCKS section.
-
-N2G_CLOCKREF_DEVICE: This should be used whereever the value in the SOPC PTF
-specifies the name of a module. nios2gen will use whatever you configured for
-the selected module in your MODULES section.
-
-Additionally, you can specify items in your CLASSes so that nios2gen will include
-constant definitions in the sopc.h whenever such CLASS is present. The format is
-
- N2G_DEFINE_xyz = "123"
-
-and will result in
-
-#define MODULENAME_xyz 123
-
-
-
-
-
-
-
diff --git a/tools/cpu/nios2/bridges.c b/tools/cpu/nios2/bridges.c
deleted file mode 100644
index feb90f9971..0000000000
--- a/tools/cpu/nios2/bridges.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * 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.org/license/LICENSE.
- */
-
-/********************************************************/
-/* Find bus bridges */
-
-/* This part of the program builds a list with pairs of bus
- master port names (each is "device name/master port name").
- It is then possible to find if a given master is actually
- available under a different master port name through bridges.
- */
-
-/* Typical example with external SRAM that is slave of
- tristate_bridge_0/tristate_master, and
- tristate_bridge_0 itself is slave of cpu0/data_master, the
- bridge information would be stored as this bus_bridge_pair:
- mastered_by = "cpu0/data_master" and
- bridges_to = "tristate_bridge_0/tristate_master".
- That allows to deduce that SRAM is actually mastered by
- cpu0/data_master. If there were any address or bus width
- translations, it should be noted in the bridges list... For
- now we simply assume that bridges never translate anything.
- */
-
-#include <string.h>
-#include <stdlib.h>
-
-#include "ptf.h"
-#include "bridges.h"
-
-int is_bridged(
- char *cpu_master,
- char *dev_master,
- bus_bridge_pair *bridges)
-{
- char *curr_master;
- bus_bridge_pair *bbp;
-
- if(strcmp(cpu_master, dev_master) == 0) return 1; /* cpu directly masters dev */
-
- for(bbp = bridges; bbp != NULL; bbp=bbp->next)
- {
- if(strcmp(cpu_master, bbp->mastered_by) == 0 &&
- is_bridged(bbp->bridges_to, dev_master, bridges))
- {
- return 1; /* cpu masters dev via bridge */
- }
- };
-
- return 0;
-}
-
-void add_bridge_master(struct ptf_item *pi, void *arg)
-{
- struct { char *bt; bus_bridge_pair **bridges; } *binfo = arg;
- bus_bridge_pair *new_pair;
-
- if(binfo->bridges == 0) return;
-
- new_pair = (bus_bridge_pair *)malloc(sizeof(bus_bridge_pair));
- if(new_pair == NULL) return;
-
- new_pair->bridges_to = binfo->bt;
- new_pair->mastered_by = pi->item[pi->level]->value;
- new_pair->next = *(binfo->bridges);
- *(binfo->bridges) = new_pair;
-}
-
-void add_bridge_dest(struct ptf_item *pi, void *arg)
-{
- struct ptf maby_section = { section, "MASTERED_BY", 0, 0, 0 };
- struct ptf_item maby = { 1, &maby_section };
-
- char *bridge_name = pi->item[1]->value;
- char *bridge_dest = pi->item[pi->level]->value;
- struct { char *bt; bus_bridge_pair **bridges; } binfo;
-
- binfo.bridges = arg;
- binfo.bt = (char*)malloc(strlen(bridge_name)+strlen(bridge_dest) + 2);
- strcpy(binfo.bt, bridge_name);
- strcat(binfo.bt, "/");
- strcat(binfo.bt, bridge_dest);
-
- ptf_match(pi->item[pi->level-1]->sub, &maby, add_bridge_master, &binfo);
-
- /* binfo.bt is NOT freed here */
-}
-
-bus_bridge_pair *find_bridges(struct ptf *p)
-{
- bus_bridge_pair *bridges = 0;
-
- struct ptf system = { section, "SYSTEM", 0, 0, 0 };
- struct ptf module = { section, "MODULE", 0, 0, 0 };
- struct ptf slave = { section, "SLAVE", 0, 0, 0 };
- struct ptf syb = { section, "SYSTEM_BUILDER_INFO", 0, 0, 0 };
- struct ptf to = { item, "Bridges_To", 0, 0, 0 };
- struct ptf_item brdg = { 5, &system, &module, &slave, &syb, &to };
-
- ptf_match(p, &brdg, add_bridge_dest, &bridges);
-
- return bridges;
-}
-
-
-
-
diff --git a/tools/cpu/nios2/bridges.h b/tools/cpu/nios2/bridges.h
deleted file mode 100644
index 7c2b85141b..0000000000
--- a/tools/cpu/nios2/bridges.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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.org/license/LICENSE.
- */
-
-#ifndef __NIOS2GEN_BRIDGES_H
-#define __NIOS2GEN_BRIDGES_H 1
-
-typedef struct bus_bridge_pair
-{
- char *mastered_by;
- char *bridges_to;
- struct bus_bridge_pair *next;
-}
-bus_bridge_pair;
-
-bus_bridge_pair *find_bridges(struct ptf *p);
-
-int is_bridged(
- char *cpu_master,
- char *dev_master,
- bus_bridge_pair *bridges);
-
-#endif
-
-
diff --git a/tools/cpu/nios2/clocks.c b/tools/cpu/nios2/clocks.c
deleted file mode 100644
index cb2befa04c..0000000000
--- a/tools/cpu/nios2/clocks.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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.org/license/LICENSE.
- */
-
-#include "ptf.h"
-#include "clocks.h"
-
-#include <stdlib.h>
-
-void add_clock_spec(struct ptf_item *pi, void *arg)
-{
- clock_desc **clocks = arg;
- clock_desc *new_clock;
- unsigned long freq;
-
- new_clock = (clock_desc*)malloc(sizeof(clock_desc));
- if(new_clock == NULL) return;
-
- new_clock->freq = strtoul(pi->item[pi->level]->value, 0, 0);
-
- new_clock->cfgname = NULL;
- new_clock->name = pi->item[pi->level-1]->value;
- new_clock->next = *clocks;
-
-
- *clocks = new_clock;
-}
-
-void set_clock_cfgname(struct ptf_item *pi, void *arg)
-{
- clock_desc *clock = arg;
- clock->cfgname = pi->item[pi->level]->name;
-}
-
-clock_desc *find_clocks( struct ptf *sopc, struct ptf *cfg )
-{
- clock_desc *clocks, *reverse;
-
- struct ptf system = { section, "SYSTEM", 0, 0, 0 };
- struct ptf wizargs = { section, "WIZARD_SCRIPT_ARGUMENTS", 0, 0, 0 };
- struct ptf all = { section, "CLOCKS", 0, 0, 0 };
- struct ptf clock = { section, "CLOCK", 0, 0, 0 };
- struct ptf freq = { item, "frequency", 0, 0, 0 };
- struct ptf_item clk_spec = { 5, &system, &wizargs, &all, &clock, &freq };
-
- struct ptf named = { item, 0, 0, 0, 0 };
- struct ptf_item clk_cfg = { 2, &all, &named };
-
- clocks = NULL;
- ptf_match(sopc, &clk_spec, add_clock_spec, &clocks);
-
- /* Reverse the linked list and look for configured names */
-
- reverse = NULL;
- while(clocks)
- {
- clock_desc *tmp = clocks;
- clocks = clocks->next;
- tmp->next = reverse;
- reverse = tmp;
-
- named.value = tmp->name;
- ptf_match(cfg, &clk_cfg, set_clock_cfgname, tmp);
- if(tmp->cfgname == NULL) tmp->cfgname = ptf_defused_name(tmp->name);
- };
-
- return reverse;
-}
-
-
-
diff --git a/tools/cpu/nios2/clocks.h b/tools/cpu/nios2/clocks.h
deleted file mode 100644
index 9129c79a28..0000000000
--- a/tools/cpu/nios2/clocks.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.org/license/LICENSE.
- */
-
-#ifndef __NIOS2GEN_CLOCKS_H
-#define __NIOS2GEN_CLOCKS_H 1
-
-#include "ptf.h"
-
-typedef struct clockdsc
-{
- char *name;
- char *cfgname;
- unsigned long freq;
- struct clockdsc *next;
-}
-clock_desc;
-
-clock_desc *find_clocks( struct ptf *ptf, struct ptf *cfg );
-
-#endif
-
diff --git a/tools/cpu/nios2/configure.ac b/tools/cpu/nios2/configure.ac
deleted file mode 100644
index b0fbc85949..0000000000
--- a/tools/cpu/nios2/configure.ac
+++ /dev/null
@@ -1,23 +0,0 @@
-## Process this file with autoconf to produce a configure script.
-
-AC_PREREQ([2.69])
-AC_INIT([rtems-tools-cpu-nios2],[_RTEMS_VERSION],[https://devel.rtems.org/newticket])
-AC_CONFIG_SRCDIR([nios2gen.c])
-RTEMS_TOP(../../..)
-RTEMS_SOURCE_TOP
-RTEMS_BUILD_TOP
-
-RTEMS_CANONICAL_TARGET_CPU
-
-AM_INIT_AUTOMAKE([foreign subdir-objects 1.12.2])
-AM_MAINTAINER_MODE
-
-AC_PROG_CC
-AC_CHECK_PROGS(HELP2MAN,help2man)
-AM_CONDITIONAL(HELP2MAN,test -n "$HELP2MAN" )
-
-RTEMS_TOOLPATHS
-
-# Explicitly list all Makefiles here
-AC_CONFIG_FILES([Makefile])
-AC_OUTPUT
diff --git a/tools/cpu/nios2/devices.c b/tools/cpu/nios2/devices.c
deleted file mode 100644
index 7894294ebf..0000000000
--- a/tools/cpu/nios2/devices.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * 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.org/license/LICENSE.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "ptf.h"
-#include "bridges.h"
-#include "devices.h"
-
-void add_device(device_desc **dl, struct ptf *dev)
-{
- device_desc *eds;
-
- for(eds = *dl; eds; eds = eds->next)
- {
- if(eds->ptf == dev)
- {
- eds->slaves++;
- return;
- };
- };
-
- eds = (device_desc *)malloc(sizeof(device_desc));
- eds->slaves = 1;
- eds->ptf = dev;
- eds->next = *dl;
- *dl = eds;
-}
-
-void check_and_add_device(struct ptf_item *pi, void *arg)
-{
- struct ptf *module = pi->item[pi->level-3];
- struct ptf *sysinfo = pi->item[pi->level-2];
- char *master_name = pi->item[pi->level]->value;
-
- struct { char *dm; char *im; device_desc **dl; bus_bridge_pair *bridges; } *dinfo = arg;
-
- if(is_bridged(dinfo->dm, master_name, dinfo->bridges) ||
- is_bridged(dinfo->im, master_name, dinfo->bridges))
- {
- struct ptf *ni = ptf_alloc_item(item, "N2G_Selected", "1");
- if(ni != NULL)
- {
- ni->next = sysinfo->sub;
- sysinfo->sub = ni;
- };
- add_device(dinfo->dl, module);
- };
-}
-
-void set_dev_cfgname(struct ptf_item *pi, void *arg)
-{
- device_desc *dev = arg;
- dev->cfgname = pi->item[pi->level]->name;
-}
-
-
-device_desc *find_devices(
- struct ptf *ptf,
- struct ptf *cfg,
- struct ptf *cpu,
- bus_bridge_pair *bridges)
-{
- struct ptf system = { section, "SYSTEM", 0, 0, 0 };
- struct ptf module = { section, "MODULE", 0, 0, 0 };
- struct ptf slave = { section, "SLAVE", 0, 0, 0 };
- struct ptf syb = { section, "SYSTEM_BUILDER_INFO", 0, 0, 0 };
- struct ptf maby = { section, "MASTERED_BY", 0, 0, 0 };
- struct ptf_item brdg = { 5, &system, &module, &slave, &syb, &maby };
-
- struct ptf modules = { section, "MODULES", 0, 0, 0 };
- struct ptf named = { item, 0, 0, 0, 0};
- struct ptf_item devcf = { 2, &modules, &named };
-
- struct { char *dm; char *im; device_desc **dl; bus_bridge_pair *bridges; } dinfo;
-
- device_desc *found, *reverse;
-
- found = NULL;
-
- add_device(&found, cpu); /* The CPU is "self-connected", add it */
-
- dinfo.dl = &found;
- dinfo.bridges = bridges;
- dinfo.dm = (char *)malloc(strlen(cpu->value)+13);
- dinfo.im = (char *)malloc(strlen(cpu->value)+20);
-
- strcpy(dinfo.im, cpu->value);
- strcat(dinfo.im, "/");
- strcpy(dinfo.dm, dinfo.im);
- strcat(dinfo.dm, "data_master");
- strcat(dinfo.im, "instruction_master");
-
- /* "Available" is any MODULE with a SLAVE section that is MASTERED_BY
- either instr_master or data_master of selected CPU, either directly
- or through a bridge. See code above for more info about bridges.
- */
-
- ptf_match(ptf, &brdg, check_and_add_device, &dinfo);
-
- free(dinfo.dm);
- free(dinfo.im);
-
- /* Reverse the linked list */
-
- reverse = NULL;
- while(found)
- {
- device_desc *tmp = found;
- found = found->next;
-
- tmp->next = reverse;
- reverse = tmp;
-
- named.value = tmp->ptf->value;
- tmp->cfgname = NULL;
- ptf_match(cfg, &devcf, set_dev_cfgname, tmp);
- if(tmp->cfgname == NULL) tmp->cfgname = ptf_defused_name(tmp->ptf->value);
- };
-
- return reverse;
-}
-
diff --git a/tools/cpu/nios2/devices.h b/tools/cpu/nios2/devices.h
deleted file mode 100644
index f0e8208eb0..0000000000
--- a/tools/cpu/nios2/devices.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.org/license/LICENSE.
- */
-
-#ifndef __NIOS2GEN_DEVICES_H
-#define __NIOS2GEN_DEVICES_H 1
-
-#include "ptf.h"
-#include "bridges.h"
-
-typedef struct dev_descr
-{
- int slaves;
- char *cfgname;
- struct ptf *ptf;
- struct dev_descr *next;
-}
-device_desc;
-
-device_desc *find_devices(
- struct ptf *ptf,
- struct ptf *cfg,
- struct ptf *cpu,
- bus_bridge_pair *bridges);
-
-#endif
diff --git a/tools/cpu/nios2/linkcmds.c b/tools/cpu/nios2/linkcmds.c
deleted file mode 100644
index 8ed0ddbff7..0000000000
--- a/tools/cpu/nios2/linkcmds.c
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * 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.org/license/LICENSE.
- */
-
-#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);
-}
-
-
diff --git a/tools/cpu/nios2/linkcmds.h b/tools/cpu/nios2/linkcmds.h
deleted file mode 100644
index 9d34124ce3..0000000000
--- a/tools/cpu/nios2/linkcmds.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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.org/license/LICENSE.
- */
-
-#ifndef __LINKCMDS_H
-#define __LINKCMDS_H 1
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "ptf.h"
-#include "devices.h"
-
-void fwrite_linkcmds_file(FILE *file, struct ptf *cfg, struct ptf *cpu, device_desc *devices, memory_desc *memory);
-
-#endif
-
-
diff --git a/tools/cpu/nios2/memory.c b/tools/cpu/nios2/memory.c
deleted file mode 100644
index cb1ea7f31e..0000000000
--- a/tools/cpu/nios2/memory.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * 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.org/license/LICENSE.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "ptf.h"
-#include "devices.h"
-#include "memory.h"
-
-memory_desc *find_memory(device_desc *devices)
-{
- struct ptf *p;
- struct ptf_item pi;
- memory_desc *tmd;
- memory_desc *memory = NULL;
-
- /********************************************************/
- /* Check which of the devices are memory, sort by size */
-
- if(devices)
- {
- struct ptf *p, *s;
- struct ptf_item pi;
- device_desc *dd;
-
- for(dd = devices; dd; dd=dd->next)
- {
- p = ptf_find(dd->ptf->sub, &pi, item, "Is_Memory_Device", "1");
- if(p != NULL && pi.level>0)
- {
- s = pi.item[pi.level-1];
- p = ptf_find(s, &pi, item, "Base_Address", 0);
- };
-
- if(p != NULL)
- {
- tmd = (memory_desc*)malloc(sizeof(memory_desc));
-
- if(tmd != NULL)
- {
- tmd->base = strtoul(p->value, 0, 0);
-
- p = ptf_find(s, &pi, item, "Address_Span", 0);
- if(p != 0)
- {
- tmd->size = strtoul(p->value, 0, 0);
- }
- else
- {
- tmd->size = 0;
- p = ptf_find(s, &pi, item, "Address_Width", 0);
- if(p) tmd->size = 1 << strtoul(p->value, 0, 0);
- p = ptf_find(s, &pi, item, "Data_Width", 0);
- if(p) tmd->size *= (strtoul(p->value, 0, 0) >> 3);
- };
-
- if(tmd->size == 0)
- {
- free(tmd);
- }
- else
- {
- tmd->dev = dd;
-
- if(memory == NULL)
- {
- tmd->next = NULL;
- memory = tmd;
- }
- else
- {
- if(tmd->size > memory->size)
- {
- tmd->next = memory;
- memory = tmd;
- }
- else
- {
- memory_desc *uplink = memory;
- while(uplink->next != NULL && uplink->next->size > tmd->size) uplink=uplink->next;
- tmd->next = uplink->next;
- uplink->next = tmd;
- };
- };
- };
- };
- };
- };
- };
-
- return memory;
-}
-
-
diff --git a/tools/cpu/nios2/memory.h b/tools/cpu/nios2/memory.h
deleted file mode 100644
index 43c20787c8..0000000000
--- a/tools/cpu/nios2/memory.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * 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.org/license/LICENSE.
- */
-
-#ifndef __MEMORY_H
-#define __MEMORY_H 1
-
-#include "devices.h"
-
-typedef struct memdsc
-{
- unsigned long base;
- unsigned long size;
- device_desc *dev;
- struct memdsc *next;
-}
-memory_desc;
-
-memory_desc *find_memory(device_desc *devices);
-
-#endif
-
-
diff --git a/tools/cpu/nios2/nios2gen.c b/tools/cpu/nios2/nios2gen.c
deleted file mode 100644
index 6ad5360d97..0000000000
--- a/tools/cpu/nios2/nios2gen.c
+++ /dev/null
@@ -1,494 +0,0 @@
-/*
- * 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.org/license/LICENSE.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "ptf.h"
-#include "bridges.h"
-#include "clocks.h"
-#include "devices.h"
-#include "memory.h"
-#include "output.h"
-#include "linkcmds.h"
-
-#define NIOS2GEN_PACKAGE PACKAGE
-#define NIOS2GEN_VERSION VERSION
-
-#include "getopt.h"
-
-/********************************************************/
-
-void store_ptf_parent(struct ptf_item *pi, void *arg)
-{
- struct ptf *p = pi->item[pi->level-1];
- *(struct ptf **)arg = p;
-}
-
-/********************************************************/
-
-void store_ptf_ptr(struct ptf_item *pi, void *arg)
-{
- struct ptf *p = pi->item[pi->level];
- *(struct ptf **)arg = p;
-}
-
-/********************************************************/
-
-void printf_ptf_value(struct ptf_item *pi, void *arg)
-{
- struct ptf *p = pi->item[pi->level];
- printf(*(char **)arg, p->value);
-}
-
-/********************************************************/
-
-void read_include_file(struct ptf_item *pi, void *arg)
-{
- struct ptf *inc, *next;
- struct ptf *p = pi->item[pi->level];
-
- inc = ptf_parse_file(p->value);
-
- if(inc == NULL)
- {
- fprintf(stderr, "Warning: couldn't parse included '%s'.\n", p->value);
- return;
- };
-
- printf("Successfully read included PTF file %s.\n", p->value);
-
- next = p->next;
- for(p->next = inc; p->next != NULL; p = p->next);
- p->next = next;
-}
-
-/********************************************************/
-
-void version(FILE *f)
-{
-fprintf(f,
- "nios2gen (" __DATE__ ")\n"
- " Copyright (c) 2006 Kolja Waschk rtemsdev/ixo.de\n"
- "\n"
- " The license and distribution terms for this file may be\n"
- " found in the file LICENSE in this distribution or at\n"
- " http://www.rtems.org/license/LICENSE.\n"
- , VERSION
-);
-}
-
-void usage (FILE *f, char *errmsg)
-{
- char *info = "Purpose:\n Create RTEMS nios2 BSP configuration from Altera SOPC description\n";
- if(errmsg) info=errmsg;
- version(f);
- fprintf(f,"\n%s\nUsage: nios2gen [OPTIONS] <SOPC PTF> [CONFIG PTF] [CONFIG PTF]...\n", info);
- fprintf(f," -h --help Print help and exit\n");
- fprintf(f," -V --version Print version and exit\n");
- fprintf(f," -bFILENAME --bspheader=FILENAME Output BSP configuration header file (default='sopc.h')\n");
- fprintf(f," -B --no-bspheader Do not output BSP configuration header file\n");
- fprintf(f," -lFILENAME --linkcmds=FILENAME Output linker script (default='linkcmds')\n");
- fprintf(f," -L --no-linkcmds Do not output linker script\n");
- fprintf(f," -pFILENAME --parsed=FILENAME Output PTF contents as long list (default: don't)\n");
- fprintf(f," -P --no-parsed Do not output PTF contents as long list\n");
- fprintf(f," -q --quiet Do not print progress info to stdout\n\n");
- fprintf(f,"Using \"-\" as the FILENAME means standard output (stdout).\n");
-}
-
-/********************************************************/
-
-int main(int argc, char *argv[])
-{
- struct ptf *sopc, *cfg, *p, *cpu;
- struct ptf_item pi;
- device_desc *devices;
- bus_bridge_pair *bridges;
- clock_desc *clocks;
- memory_desc *memory;
-
- int verbose = 1;
- int output_order = 127;
- char *parsed_filename = NULL;
- int output_parsed = 0;
- char *bspheader_filename = "sopc.h";
- int output_bspheader = 1;
- char *linkcmds_filename = "linkcmds";
- int output_linkcmds = 2;
-
- optarg = 0;
- optind = 1;
- opterr = 1;
- optopt = '?';
-
- if(argc > 126)
- {
- usage(stderr,"Too many commandline arguments!\n");
- return -1;
- };
-
- while(1)
- {
- int c, long_index = 0;
- static char *optstring = "hVBb:Ll:Pp:q";
-
- static struct option long_options[] =
- {
- { "help", 0, NULL, 'h' },
- { "version", 0, NULL, 'V' },
- { "no-bspheader", 0, NULL, 'B' },
- { "bspheader", 1, NULL, 'b' },
- { "no-linkcmds", 0, NULL, 'L' },
- { "linkcmds", 1, NULL, 'l' },
- { "no-parsed", 0, NULL, 'P' },
- { "parsed", 1, NULL, 'p' },
- { "quiet", 0, NULL, 'q' },
- { NULL, 0, NULL, 0 }
- };
-
- c = getopt_long (argc, argv, optstring, long_options, &long_index);
-
- if(c == -1) break; /* Exit from while(1) loop */
-
- switch(c)
- {
- case 'q': /* Be quiet */
- verbose = 0;
- break;
-
- case 'h': /* Print help and exit */
- usage(stdout,NULL);
- return 0;
-
- case 'V': /* Print version and exit */
- version(stdout);
- return 0;
-
- case 'B': /* Do not output BSP configuration header file */
- output_bspheader = 0;
- break;
-
- case 'b': /* Output BSP configuration header file */
- bspheader_filename = optarg;
- output_bspheader = output_order;
- output_order--;
- break;
-
- case 'L': /* Do not output linker script */
- output_linkcmds = 0;
- break;
-
- case 'l': /* Output linker script */
- linkcmds_filename = optarg;
- output_linkcmds = output_order;
- output_order--;
- break;
-
- case 'P': /* Do not output PTF contents */
- output_parsed = 0;
- break;
-
- case 'p': /* Output PTF contents as long list */
- parsed_filename = optarg;
- output_parsed = output_order;
- output_order--;
- break;
-
- case 0:
- case '?':
- return -1;
-
- default:
- fprintf(stderr, "%s: unknown option: %c\n", NIOS2GEN_PACKAGE, c);
- };
- };
-
- if(optind >= argc)
- {
- usage(stderr,"No PTF specified!\n");
- return -1;
- };
-
- /********************************************************/
-
- sopc = ptf_parse_file(argv[optind]);
- if(sopc == NULL)
- {
- fprintf(stderr, "Could not parse system description PTF '%s'.\n", argv[optind]);
- return -1;
- };
-
- if(verbose) printf("Successfully read SOPC PTF file %s.\n", argv[optind]);
-
- /********************************************************/
-
- cfg = NULL;
-
- for(optind++;optind<argc;optind++)
- {
- struct ptf *morecfg = ptf_parse_file(argv[optind]);
-
- if(morecfg == NULL)
- {
- fprintf(stderr, "Couldn't parse '%s'.\n", argv[optind]);
- return -1;
- };
-
- if(verbose) printf("Successfully read config PTF file %s.\n", argv[optind]);
-
- cfg = ptf_concat(cfg, morecfg);
- };
-
- /********************************************************/
- /* Pull in include files specified in the configs; */
- /* Only one level is read; included files are not */
- /* checked for further INCLUDEs */
-
- {
- struct ptf include_item = { item, "INCLUDE", 0, 0, 0 };
- struct ptf_item inc_file_spec = { 1, &include_item };
- ptf_match(cfg, &inc_file_spec, read_include_file, NULL);
- }
-
- /********************************************************/
- /* Find CPU */
-
- if(verbose) printf("Looking for usable CPUs...\n");
-
- /* Check if a CPU has been specified in the config PTF */
- {
- struct ptf modules = { section, "MODULES", 0, 0, 0 };
- struct ptf cpu_def = { item, "CPU", 0, 0, 0 };
- struct ptf_item cpu_spec = { 2, &modules, &cpu_def };
-
- ptf_match(cfg, &cpu_spec, store_ptf_ptr, &cpu);
- };
-
- /* Look for CPUs in system description PTF */
- {
- int cpu_count;
- struct ptf system = { section, "SYSTEM", 0, 0, 0 };
- struct ptf module = { section, "MODULE", 0, 0, 0 };
- struct ptf nios2_cpu_class = { item, "class", "altera_nios2", 0, 0 };
- struct ptf_item class_spec = { 3, &system, &module, &nios2_cpu_class };
-
- if(cpu) if(cpu->value) class_spec.item[1]->value = cpu->value;
-
- cpu_count = ptf_match(sopc, &class_spec, store_ptf_parent, &cpu);
-
- if(cpu_count > 1)
- {
- fprintf(stderr, "There is more than one CPU. Please specify the one\n");
- fprintf(stderr, "you want to use with this BSP in your config file.\n");
- fprintf(stderr, "The available CPUs are named as follows:\n");
- ptf_match(sopc, &class_spec, printf_ptf_value, " %s\n");
- return -1;
- };
-
- if(cpu_count == 0)
- {
- fprintf(stderr, "There is no NIOS2 cpu in the system.\n");
- return -1;
- }
- };
-
- if(verbose)
- {
- printf("Using NIOS II CPU '%s'.\n", cpu->value);
- printf("Only modules mastered by this CPU are considered now.\n");
- };
-
- /********************************************************/
- /* Find Bridges */
-
- if(verbose) printf("Looking for bus bridges...\n");
-
- bridges = find_bridges(sopc);
-
- if(verbose)
- {
- if(bridges)
- {
- bus_bridge_pair *bbp;
- for(bbp = bridges; bbp; bbp=bbp->next)
- {
- printf("Found bridge: %s\n", bbp->mastered_by);
- printf(" \\_%s\n", bbp->bridges_to);
- };
- }
- else
- {
- printf("No bridges present.\n");
- };
- };
-
- /********************************************************/
- /* Find clocks */
-
- if(verbose) printf("Looking for clock definitions...\n");
-
- clocks = find_clocks(sopc, cfg);
-
- if(verbose)
- {
- if(clocks)
- {
- clock_desc *cs;
- for(cs = clocks; cs; cs = cs->next)
- {
- printf("Found clock \"%s\" (%lu Hz), naming it %s\n", cs->name, cs->freq, cs->cfgname);
- };
- }
- else
- {
- printf("No clocks present.\n");
- };
- };
-
- /********************************************************/
- /* Find other devices available to the selected CPU */
-
- if(verbose) printf("Looking for devices...\n");
-
- devices = find_devices(sopc, cfg, cpu, bridges);
-
- if(verbose)
- {
- if(devices)
- {
- device_desc *dd;
- for(dd = devices; dd; dd=dd->next)
- {
- printf("Found device \"%s\", naming it %s\n", dd->ptf->value, dd->cfgname);
- };
- }
- else
- {
- printf("No devices present.\n");
- };
- };
-
- /********************************************************/
- /* Find out which devices are actually memory */
-
- if(verbose) printf("Looking for memory...\n");
-
- memory = find_memory(devices);
-
- if(verbose)
- {
- if(memory)
- {
- memory_desc *md;
- for(md = memory; md; md=md->next)
- {
- printf("Found memory in \"%s\", base=0x%08X, size=%lu bytes\n",
- md->dev->cfgname,
- md->base, md->size);
- };
- }
- else
- {
- printf("None of the devices seems to provide memory?!\n");
- };
- };
-
-
- /********************************************************/
- /* Output files in the order they were specified
- on the command line */
-
- {
- int i;
- for(i=0;i<3;i++)
- {
- if(output_bspheader>0
- && output_bspheader>=output_linkcmds
- && output_bspheader>=output_parsed)
- {
- output_bspheader = 0;
- if(bspheader_filename == NULL || (bspheader_filename[0]=='-' && bspheader_filename[1]==0))
- {
- fwrite_header_file(stdout, cfg, devices, clocks);
- }
- else
- {
- FILE *f = fopen(bspheader_filename, "w");
- if(!f)
- {
- perror(bspheader_filename);
- return -1;
- }
- else
- {
- fwrite_header_file(f, cfg, devices, clocks);
- fclose(f);
- }
- }
- };
- if(output_linkcmds>0
- && output_linkcmds>=output_bspheader
- && output_linkcmds>=output_parsed)
- {
- output_linkcmds = 0;
- if(linkcmds_filename == NULL || (linkcmds_filename[0]=='-' && linkcmds_filename[1]==0))
- {
- fwrite_linkcmds_file(stdout, cfg, cpu, devices, memory);
- }
- else
- {
- FILE *f = fopen(linkcmds_filename, "w");
- if(!f)
- {
- perror(linkcmds_filename);
- return -1;
- }
- else
- {
- fwrite_linkcmds_file(f, cfg, cpu, devices, memory);
- fclose(f);
- }
- }
- };
- if(output_parsed>0
- && output_parsed>=output_linkcmds
- && output_parsed>=output_bspheader)
- {
- output_parsed = 0;
- if(parsed_filename == NULL || (parsed_filename[0]=='-' && parsed_filename[1]==0))
- {
- ptf_printf(stdout, sopc, "");
- }
- else
- {
- FILE *f = fopen(parsed_filename, "w");
- if(!f)
- {
- perror(parsed_filename);
- return -1;
- }
- else
- {
- ptf_printf(f, sopc, "");
- fclose(f);
- }
- }
- };
- }
- };
-
- if(verbose) printf("Done.\n");
-
- return 0;
-}
-
-/* vi:ts=4:
- */
-
-
diff --git a/tools/cpu/nios2/output.c b/tools/cpu/nios2/output.c
deleted file mode 100644
index 088ebe807c..0000000000
--- a/tools/cpu/nios2/output.c
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * 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.org/license/LICENSE.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "ptf.h"
-#include "devices.h"
-#include "output.h"
-
-typedef struct
-{
- FILE *file;
- device_desc *dev;
- char *def_name;
- char *orig_value;
- clock_desc *clocks;
- device_desc *devices;
-}
-out_desc;
-
-int is_not_connected(struct ptf_item *pi)
-{
- if(pi->item[0] == NULL) return 0;
- if(pi->item[0]->name == NULL) return 0;
-
- if(strcmp(pi->item[0]->name, "SLAVE") == 0)
- {
- struct ptf *t;
- struct ptf_item ti;
- t = ptf_find(pi->item[0]->sub, &ti, item, "N2G_Selected", "1");
-
- if(t == NULL) return 1;
- };
-
- return 0;
-}
-
-void fwrite_devhead_def(struct ptf_item *pi, void *arg)
-{
- out_desc *dinfo = arg;
-
- if(pi != NULL) if(is_not_connected(pi)) return;
-
- fprintf(dinfo->file, "#define %s_%s %s\n",
- dinfo->dev->cfgname, dinfo->def_name, dinfo->orig_value);
-}
-
-void fwrite_devhead_line(struct ptf_item *pi, void *arg)
-{
- out_desc *dinfo = arg;
-
- if(is_not_connected(pi)) return;
-
- if(strncmp(dinfo->orig_value, "N2G_", 4)==0)
- {
- if(strncmp(dinfo->orig_value, "N2G_CLOCKREF_", 13)==0)
- {
- clock_desc *c;
- for(c = dinfo->clocks; c; c=c->next)
- {
- if(strcmp(c->name, pi->item[pi->level]->value) == 0)
- {
- fprintf(dinfo->file, "#define %s_%s %s\n",
- dinfo->dev->cfgname, dinfo->orig_value + 13, c->cfgname);
- break;
- };
- };
- }
- else if(strncmp(dinfo->orig_value, "N2G_DEVICEREF_", 14)==0)
- {
- device_desc *d;
- for(d = dinfo->devices; d; d=d->next)
- {
- if(strcmp(d->ptf->value, pi->item[pi->level]->value) == 0)
- {
- fprintf(dinfo->file, "#define %s_%s %s\n",
- dinfo->dev->cfgname, dinfo->orig_value + 14, d->cfgname);
- break;
- };
- };
- }
- }
- else
- {
- fprintf(dinfo->file, "#define %s_%s %s\n",
- dinfo->dev->cfgname, dinfo->orig_value,
- pi->item[pi->level]->value);
- };
-}
-
-void fwrite_device_header(struct ptf_item *pi, void *arg)
-{
- struct ptf *f;
- struct ptf_item fi;
- out_desc *dinfo = arg;
-
- /* This is called for every matching CLASS section in the
- configuration. The following loop iterates through all
- items in the CLASS section regardless of their nesting level */
-
- f = ptf_find(pi->item[pi->level]->sub, &fi, item, 0, 0);
-
- while(f != NULL)
- {
- dinfo->orig_value = f->value;
- if(f->name && strncmp(f->name, "N2G_DEFINE_", 11)==0)
- {
- dinfo->def_name = f->name + 11;
- if(fi.level >= 2)
- {
- fi.level--; /* match only the enclosing section */
- ptf_match(dinfo->dev->ptf->sub, &fi, fwrite_devhead_def, dinfo);
- fi.level++;
- }
- else
- {
- fwrite_devhead_def( 0, dinfo );
- };
- }
- else
- {
- f->value = 0; /* Match ANY value */
- ptf_match(dinfo->dev->ptf->sub, &fi, fwrite_devhead_line, dinfo);
- f->value = dinfo->orig_value;
- };
- f = ptf_next(&fi, item, 0, 0);
- };
-}
-
-void fwrite_value(struct ptf_item *pi, void *arg)
-{
- FILE *file = arg;
- fputs(pi->item[pi->level]->value, file);
-}
-
-void fwrite_header_file( FILE *file, struct ptf *cfg, device_desc *devices, clock_desc *clocks)
-{
- struct ptf *p;
- struct ptf_item pi;
-
- struct ptf aclass = { section, "CLASS", 0, 0, 0 };
- struct ptf_item matchaclass = { 1, &aclass };
-
- struct ptf bspsect = { section, "BSPHEADER", 0, 0, 0 };
- struct ptf leadtext = { item, "LEADTEXT", 0, 0, 0 };
- struct ptf_item matchleadtext = { 2, &bspsect, &leadtext };
-
- struct ptf epilog = { item, "EPILOG", 0, 0, 0 };
- struct ptf_item matchepilog = { 2, &bspsect, &epilog };
-
- out_desc dinfo;
-
- dinfo.file = file;
- dinfo.clocks = clocks;
- dinfo.devices = devices;
-
- ptf_match(cfg, &matchleadtext, fwrite_value, file);
-
- if(clocks)
- {
- clock_desc *cs;
- for(cs = clocks; cs; cs = cs->next)
- {
- fprintf(file, "#define %s_FREQ %luu\n", cs->cfgname, cs->freq);
- };
- };
-
- if(devices)
- {
- for(dinfo.dev = devices; dinfo.dev; dinfo.dev=dinfo.dev->next)
- {
- /* fprintf(file, "\n#define SOPC_HAS_%s 1\n", dinfo.dev->cfgname); */
-
- p = ptf_find(dinfo.dev->ptf, &pi, item, "class", 0);
- if(p)
- {
- aclass.value = p->value;
- ptf_match(cfg, &matchaclass, fwrite_device_header, &dinfo);
- };
- };
- };
-
- ptf_match(cfg, &matchepilog, fwrite_value, file);
-}
-
-
diff --git a/tools/cpu/nios2/output.h b/tools/cpu/nios2/output.h
deleted file mode 100644
index 80a9bb0c28..0000000000
--- a/tools/cpu/nios2/output.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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.org/license/LICENSE.
- */
-
-#ifndef __OUTPUT_H
-#define __OUTPUT_H 1
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "ptf.h"
-#include "clocks.h"
-#include "devices.h"
-
-void fwrite_value(struct ptf_item *pi, void *arg);
-void fwrite_header_file(FILE *file, struct ptf *cfg, device_desc *devices, clock_desc *clocks);
-
-#endif
-
-
diff --git a/tools/cpu/nios2/ptf.c b/tools/cpu/nios2/ptf.c
deleted file mode 100644
index 07d6183a44..0000000000
--- a/tools/cpu/nios2/ptf.c
+++ /dev/null
@@ -1,857 +0,0 @@
-/*
- * 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.org/license/LICENSE.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <ctype.h>
-#include "ptf.h"
-
-#define PTFPARSER_MAXDEPTH 20
-#define PTFPARSER_NAMEBUFSIZE 1024
-#define PTFPARSER_VALUEBUFSIZE 4096
-
-#define DEBUG_EXPECTATIONS 1
-#define DEBUG_READVALUES 2
-#define DEBUG_FINDER 4
-#define DEBUG 0
-
-struct ptf_parser_state
-{
- struct ptf *tree;
- struct ptf *current_in[PTFPARSER_MAXDEPTH];
- struct ptf *current_item;
-
- long line; /* starts with 1, increments whenever a LF (ASCII 10) passes */
- int section_level; /* starts at 0, incremented at {, decremented at } */
- char *filename;
- char name_buffer[PTFPARSER_NAMEBUFSIZE];
- int name_length;
- char value_buffer[PTFPARSER_VALUEBUFSIZE];
- int value_length;
- struct
- {
- unsigned error:1;
- unsigned escaped:1;
- unsigned single_quoted:1;
- unsigned double_quoted:1;
- } flag;
-
- enum
- {
- section_or_item_specification,
- more_section_type_or_item_name_chars,
- whitespace_after_section_specification,
- whitespace_after_section_or_item_name,
- whitespace_before_item_value,
- more_section_name_chars,
- more_item_value_chars,
- } expectation;
-};
-
-/***************************************************************************/
-struct ptf *ptf_alloc_item(ptf_item_type t, char *name, char *value)
-{
- struct ptf *new_item;
- new_item = (struct ptf *)malloc(sizeof(struct ptf));
- if(!new_item) return NULL;
-
- new_item->type = t;
- new_item->sub = NULL;
- new_item->next = NULL;
- new_item->name = NULL;
- new_item->value = NULL;
-
- if(name != NULL)
- {
- int n = strlen(name);
- if(n > 0)
- {
- new_item->name = (char *)malloc(n + 1);
- if(new_item->name == NULL)
- {
- free(new_item);
- return NULL;
- };
- strcpy(new_item->name, name);
- }
- };
-
- if(value != NULL)
- {
- int n = strlen(value);
- if(n > 0)
- {
- new_item->value = (char *)malloc(n + 1);
- if(new_item->value == NULL)
- {
- if(name != NULL) free(new_item->name);
- free(new_item);
- return NULL;
- };
- strcpy(new_item->value, value);
- };
- };
-
- return new_item;
-}
-
-/***************************************************************************/
-void add_ptf_item(struct ptf_parser_state *state, struct ptf *item)
-{
- if(state->current_item == NULL)
- {
- if(state->section_level > 0)
- state->current_in[state->section_level-1]->sub = item;
- else
- state->tree = item;
- }
- else
- state->current_item->next = item;
-}
-
-
-/***************************************************************************/
-void parse_error(struct ptf_parser_state *state, char *errmsg)
-{
- fprintf(stderr, "Error while parsing %s (line %lu): %s\n",
- state->filename, state->line, errmsg);
-
- state->flag.error = 1;
-}
-
-/***************************************************************************/
-void init_parser(struct ptf_parser_state *state, char *filename)
-{
- int i;
-
- state->line = 1;
- state->flag.error = 0;
- state->flag.escaped = 0;
- state->flag.double_quoted = 0;
- state->flag.single_quoted = 0;
- state->section_level = 0;
-
- state->filename = (char *)malloc(strlen(filename)+1);
- if(state->filename != NULL) strcpy(state->filename, filename);
-
- state->expectation = section_or_item_specification;
-
- state->tree = NULL;
- state->current_item = NULL;
- for(i=1; i<PTFPARSER_MAXDEPTH; i++) state->current_in[i] = NULL;
-}
-
-/***************************************************************************/
-void ptf_free(struct ptf *ptf)
-{
- struct ptf *this, *next;
- for(this = ptf; this != NULL; this = next)
- {
- next = this->next;
- if(this->value != NULL) free(this->value);
- if(this->name != NULL) free(this->name);
- if(this->type == section) ptf_free(this->sub);
- free(this);
- };
-}
-
-/***************************************************************************/
-void abort_parsing(struct ptf_parser_state *state)
-{
- if(state->filename != NULL) free(state->filename);
- ptf_free(state->tree);
-}
-
-/***************************************************************************/
-int add_char_to_buffer(int *len, char *buf, int maxlen, char c)
-{
- if(*len >= maxlen) return 0;
-
- buf[(*len)++] = c;
-
- return 1;
-}
-
-/***************************************************************************/
-void parse_char(struct ptf_parser_state *state, int c)
-{
- int is_not_quoted;
- int is_no_space;
- enum { item_parsed, section_opened, section_closed, none } parser_event;
-
- switch(c)
- {
- case '\\':
- {
- if(state->flag.escaped == 0)
- {
- state->flag.escaped = 1;
- return;
- };
- break;
- };
- case '"':
- {
- if(!state->flag.escaped && !state->flag.single_quoted)
- {
- state->flag.double_quoted = 1 - state->flag.double_quoted;
- return;
- }
- break;
- };
- case '\'':
- {
- if(!state->flag.escaped && !state->flag.double_quoted)
- {
- state->flag.single_quoted = 1 - state->flag.single_quoted;
- return;
- }
- break;
- };
- case '\n':
- {
- state->line++;
- break;
- };
- default:
- break;
- };
-
- parser_event = none;
-
- is_not_quoted = !(state->flag.escaped ||
- state->flag.single_quoted || state->flag.double_quoted);
- is_no_space = (!is_not_quoted || !isspace(c));
- state->flag.escaped = 0;
-
- switch(state->expectation)
- {
- case section_or_item_specification:
- {
-#if DEBUG&DEBUG_EXPECTATIONS
- printf("Expectation: section_or_item_specification\n");
-#endif
-
- if(is_not_quoted && c == '}')
- {
- parser_event = section_closed;
- }
- else if(is_no_space)
- {
- state->name_length = 1;
- state->name_buffer[0] = c;
- state->expectation = more_section_type_or_item_name_chars;
- };
- break;
- };
-
- case more_section_type_or_item_name_chars:
- {
-#if DEBUG&DEBUG_EXPECTATIONS
- printf("Expectation: more_section_type_or_item_name_chars\n");
-#endif
-
- /* Item name is stored in name_buffer */
- /* Section type is stored in name_buffer */
- if(is_no_space)
- {
- if(!add_char_to_buffer(&state->name_length, state->name_buffer, PTFPARSER_NAMEBUFSIZE, c))
- parse_error(state, "First word is too long; I expected a shorter section type or item name");
- }
- else
- {
- state->expectation = whitespace_after_section_or_item_name;
- }
- break;
- };
-
- case whitespace_after_section_specification:
- {
-#if DEBUG&DEBUG_EXPECTATIONS
- printf("Expectation: whitespace_after_section_specification\n");
-#endif
-
- if(c == '{')
- parser_event = section_opened;
- else if(is_no_space)
- parse_error(state, "Expected section content within brackets {...}");
- break;
- };
-
- case whitespace_after_section_or_item_name:
- {
-#if DEBUG&DEBUG_EXPECTATIONS
- printf("Expectation: whitespace_after_section_or_item_name\n");
-#endif
-
- if(c == '{')
- {
- state->value_length = 0;
- parser_event = section_opened;
- }
- else if(c == '=')
- state->expectation = whitespace_before_item_value;
- else if(is_no_space)
- {
- state->value_length = 1;
- state->value_buffer[0] = c;
- state->expectation = more_section_name_chars;
- };
- break;
- };
-
- case more_section_name_chars:
- {
-#if DEBUG&DEBUG_EXPECTATIONS
- printf("Expectation: more_section_name_chars\n");
-#endif
-
- /* Section name is stored in value_buffer */
- if(is_no_space)
- {
- if(!add_char_to_buffer(&state->value_length, state->value_buffer, PTFPARSER_VALUEBUFSIZE, c))
- parse_error(state, "Section name is too long");
- }
- else
- state->expectation = whitespace_after_section_specification;
- break;
- }
-
- case whitespace_before_item_value:
- {
-#if DEBUG&DEBUG_EXPECTATIONS
- printf("Expectation: whitespace_before_item_value\n");
-#endif
-
- if(is_not_quoted && c == ';')
- {
- state->value_length = 0;
- parser_event = item_parsed;
- }
- else if(is_no_space)
- {
- state->value_length = 1;
- state->value_buffer[0] = c;
- state->expectation = more_item_value_chars;
- };
- break;
- };
-
- case more_item_value_chars:
- {
-#if DEBUG&DEBUG_EXPECTATIONS
- printf("Expectation: more_item_value_chars\n");
-#endif
-
- /* Item value is stored in value_buffer */
- if(is_not_quoted && c == ';')
- parser_event = item_parsed;
- else if(is_no_space)
- {
- if(!add_char_to_buffer(&state->value_length, state->value_buffer, PTFPARSER_VALUEBUFSIZE, c))
- parse_error(state, "Item value is too long");
- }
- else
- parser_event = item_parsed;
- break;
- }
-
- default:
-#if DEBUG&DEBUG_EXPECTATIONS
- printf("Expectation: %d (?)\n", state->expectation);
-#endif
-
- parse_error(state, "Internal error: Unhandled state of expectation");
- };
-
- switch(parser_event)
- {
- /* TODO: pointer tuff */
-
- case item_parsed:
- {
- struct ptf *new_item;
- state->name_buffer[state->name_length] = 0;
- state->value_buffer[state->value_length] = 0;
-#if DEBUG&DEBUG_READVALUES
- printf("== Item %s is '%s' ==\n", state->name_buffer, state->value_buffer);
-#endif
-
- new_item = ptf_alloc_item(item, state->name_buffer, state->value_buffer);
- if(new_item == NULL)
- {
- parse_error(state, "Internal error: "
- "Could not allocate memory for new item");
- return;
- };
-
- add_ptf_item(state, new_item);
- state->current_item = new_item;
- state->expectation = section_or_item_specification;
-
- break;
- };
- case section_opened:
- {
- struct ptf *new_section;
- state->name_buffer[state->name_length] = 0;
- state->value_buffer[state->value_length] = 0;
-#if DEBUG&DEBUG_READVALUES
- printf("== New %s section '%s' opened ==\n", state->name_buffer, state->value_buffer);
-#endif
-
- if(state->section_level >= PTFPARSER_MAXDEPTH-1)
- {
- parse_error(state, "Internal error: "
- "cannot handle sections nested as deep as here.");
- return;
- };
-
- new_section = ptf_alloc_item(section, state->name_buffer, state->value_buffer);
- if(new_section == NULL)
- {
- parse_error(state, "Internal error: "
- "Could not allocate memory for new section");
- return;
- };
-
- add_ptf_item(state, new_section);
- state->current_item = NULL;
- state->current_in[state->section_level] = new_section;
- state->section_level++;
-
- state->expectation = section_or_item_specification;
- break;
- };
- case section_closed:
- {
- if(state->section_level < 1)
- {
- parse_error(state, "Found closing '}' without opening '{' before");
- return;
- };
-
- state->section_level--;
- state->current_item = state->current_in[state->section_level];
- state->expectation = section_or_item_specification;
-#if DEBUG&DEBUG_READVALUES
- printf("-- Closed section --\n");
-#endif
- break;
- };
- default:
- break;
- };
-}
-
-/***************************************************************************/
-struct ptf *ptf_parse_file(char *filename)
-{
- FILE *f;
- char buffer[1024];
-
- struct ptf *root;
- struct ptf_parser_state state;
-
- if(filename == NULL)
- {
- fprintf(stderr, "Internal error: "
- "No filename was given to ptf_read()\n");
- return NULL;
- };
-
- f = fopen(filename, "r");
- if(f == NULL)
- {
- perror(filename);
- return NULL;
- };
-
- init_parser(&state, filename);
-
- while(!feof(f))
- {
- size_t r, n;
-
- if(ferror(f))
- {
- perror(filename);
- abort_parsing(&state);
- fclose(f);
- return NULL;
- };
-
- n = fread(buffer, 1, 1024, f);
- for(r=0; r<n && (state.flag.error==0); r++) parse_char(&state, buffer[r]);
- };
-
- fclose(f);
-
- if(state.section_level != 0)
- {
- parse_error(&state, "Input file seems to be incomplete, "
- "one or more sections are not closed with '}'\n");
- };
-
- if(state.flag.error)
- {
- abort_parsing(&state);
- return NULL;
- };
-
- return state.tree;
-}
-
-/***************************************************************************/
-
-struct ptf *ptf_concat(struct ptf *a, struct ptf *b)
-{
- struct ptf *leaf = a;
-
- if(!a) return b;
- if(!b) return a;
-
- for(leaf = a; leaf->next != NULL; leaf = leaf->next);
- leaf->next = b;
- return a;
-}
-
-/***************************************************************************/
-
-void ptf_dump_ptf_item(FILE *f, struct ptf_item *pi)
-{
- int i;
- fprintf(f, "level=%d in %p\n", pi->level, pi);
- for(i=pi->level;i>=0;i--)
- {
- if(pi->item[i] != NULL)
- {
- fprintf(f, " %d: %s name=%s value=%s\n",
- i,
- pi->item[i]->type == item ? "item":"section",
- pi->item[i]->name,
- pi->item[i]->value);
- }
- else
- {
- fprintf(f, " %d: NULL\n", i);
- }
- fflush(f);
- }
-}
-
-/***************************************************************************/
-
-void ptf_printf(FILE *s, struct ptf *tree, char *prefix)
-{
- struct ptf *leaf;
-
- for(leaf = tree; leaf != NULL; leaf = leaf->next)
- {
- switch(leaf->type)
- {
- case section:
- {
- char *new_prefix;
- int new_prefix_len;
- new_prefix_len = strlen(prefix) + strlen(leaf->name) + 2;
- if(leaf->value != NULL && leaf->value[0] != 0)
- {
- new_prefix_len += strlen(leaf->value) + 1;
- };
- new_prefix = (char *)malloc(new_prefix_len);
- if (new_prefix != NULL)
- {
- strcpy(new_prefix, prefix);
- strcat(new_prefix, leaf->name);
- if(leaf->value != NULL && leaf->value[0] != 0)
- {
- strcat(new_prefix, ":");
- strcat(new_prefix, leaf->value);
- };
- strcat(new_prefix, "/");
- fputs(new_prefix, s);
- fputs("\n", s);
- ptf_printf(s, leaf->sub, new_prefix);
- free(new_prefix);
- }
- break;
- };
-
- case item:
- {
- char *c;
- fputs(prefix, s);
- fputs(leaf->name, s);
- fputs(" = \"", s);
- if(leaf->value == NULL)
- {
- fputs("(NULL)", s);
- }
- else
- {
- for(c=leaf->value; *c; c++)
- {
- if(*c=='\\' || *c=='"') putc('\\', s);
- putc(*c, s);
- };
- }
- fprintf(s, "\"\n");
- break;
- };
-
- default:
- break;
- };
- };
-}
-
-/***************************************************************************/
-
-int ptf_advance_one(struct ptf_item *item)
-{
- int d;
- struct ptf *leaf;
-
- d = item->level;
- leaf = item->item[d];
-
- if(leaf != NULL)
- {
- if(leaf->type == section && leaf->sub != NULL)
- {
- if(item->level >= MAX_SECTION_NESTING-1)
- {
- /* raise an error? hm, for now we silently ignore the subtree */
- }
- else
- {
- d++;
- item->item[d] = leaf->sub;
- item->level = d;
- return 0;
- }
- }
- item->item[item->level] = leaf->next;
- };
-
- while(item->item[d] == NULL)
- {
- if(d == 0)
- {
- item->level = 0;
- item->item[0] = NULL;
- errno = ENOENT;
- return -1;
- }
- d --;
- leaf = item->item[d];
- if(leaf != NULL) item->item[d] = leaf->next;
- };
-
- item->level = d;
- return 0;
-}
-
-/***************************************************************************/
-
-int ptf_advance_until(
- struct ptf_item *item,
- ptf_item_type ttype,
- char *name,
- char *value)
-{
- int r;
- struct ptf *leaf;
-
- do
- {
- leaf = item->item[item->level];
-#if DEBUG&DEBUG_FINDER
- printf(" Does %s/%s match %s/%s?\n", leaf->name, leaf->value, name, value);
-#endif
-
- if(leaf->type == ttype)
- {
- if(name == NULL)
- {
- if(value == NULL)
- {
- return 0; /* got it (any value) */
- }
- else if (leaf->value != NULL)
- {
- if(strcmp(leaf->value, value) == 0) return 0; /* got it */
- }
- }
- else if(leaf->name != NULL)
- {
- if(strcmp(leaf->name, name) == 0)
- {
- if(value == NULL)
- {
- return 0; /* got it (any value) */
- }
- else if(leaf->value != NULL)
- {
- if(strcmp(leaf->value, value) == 0) return 0; /* got it */
- }
- }
- }
- };
- r = ptf_advance_one(item);
-
- } while(r == 0);
-
- return r;
-}
-
-/***************************************************************************/
-
-struct ptf *ptf_find(
- struct ptf *tree,
- struct ptf_item *item,
- ptf_item_type ttype,
- char *name,
- char *value)
-{
- int r;
-
- if(item == NULL) { errno = EINVAL; return NULL; };
- if(tree == NULL) { errno = ENOENT; return NULL; };
-
- item->level = 0;
- item->item[0] = tree;
-
- if(ptf_advance_until(item, ttype, name, value) != 0) return NULL;
-
- r = item->level;
- item->level++; /* To match ptf_match */
- return item->item[r];
-}
-
-/***************************************************************************/
-
-struct ptf *ptf_next(
- struct ptf_item *item,
- ptf_item_type ttype,
- char *name,
- char *value)
-{
- int r;
- struct ptf *leaf;
-
- if(item == NULL) { errno = EINVAL; return NULL; };
-
- if(item->level < 1) return NULL;
- item->level--; /* To match ptf_match */
-
- r = ptf_advance_one(item);
-
- if(r == 0) r = ptf_advance_until(item, ttype, name, value);
-
- if(r != 0) return NULL;
-
- r = item->level;
- item->level++; /* To match ptf_match */
- return item->item[r];
-}
-
-/***************************************************************************/
-
-int ptf_match(
- struct ptf *const ptf,
- struct ptf_item *const match,
- const ptf_match_action action,
- void *arg)
-{
- int count;
- struct ptf *p;
- struct ptf_item pi;
-
- p = ptf;
- count = 0;
- pi.level = 0;
-
- while(p != NULL)
- {
- ptf_item_type mtype = match->item[pi.level]->type;
- char *mname = match->item[pi.level]->name;
- char *mvalue = match->item[pi.level]->value;
-
-#if DEBUG&DEBUG_FINDER
- printf("Looking for %s/%s, checking %s/%s\n",
- mname, mvalue, p->name, p->value);
-#endif
-
- if(mtype == p->type &&
- (mname==NULL || p->name==NULL || strcmp(mname, p->name)==0) &&
- (mvalue==NULL || p->value==NULL || strcmp(mvalue, p->value)==0))
- {
- pi.item[pi.level] = p;
-
- if(pi.level == match->level - 1)
- {
- if(action != NULL) action(&pi, arg);
- p = p->next;
- count++;
- }
- else
- {
- if(p->sub != NULL && pi.level < MAX_SECTION_NESTING-1)
- {
- pi.item[pi.level] = p;
- pi.level++;
- p = p->sub;
- }
- else
- {
- p = p->next;
- };
- };
- }
- else
- {
- p = p->next;
- };
-
- while(p == NULL && pi.level > 0)
- {
- pi.level--;
- p = pi.item[pi.level]->next;
- };
- };
- return count;
-}
-
-/***************************************************************************/
-
-char *ptf_defused_name(char *orig_name)
-{
- int i,j;
- char *s = (char *)malloc(1+strlen(orig_name));
-
- if(!s) return NULL;
-
- for(i=j=0;orig_name[i];i++)
- {
- if(!isalnum(orig_name[i]))
- {
- if(j>0) if(s[j-1]!='_') s[j++]='_';
- }
- else
- {
- s[j++] = toupper(orig_name[i]);
- };
- };
- s[j] = 0;
- return s;
-}
-
diff --git a/tools/cpu/nios2/ptf.h b/tools/cpu/nios2/ptf.h
deleted file mode 100644
index b1c181b593..0000000000
--- a/tools/cpu/nios2/ptf.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.org/license/LICENSE.
- */
-
-#if !defined(__PTF_H)
-#define __PTF_H 1
-
-#include <stdio.h>
-
-#define MAX_SECTION_NESTING 20
-
-typedef enum
-{
- item, section
-}
-ptf_item_type;
-
-struct ptf
-{
- ptf_item_type type;
- char *name;
- char *value;
- struct ptf *sub;
- struct ptf *next;
-};
-
-struct ptf_item
-{
- int level;
- struct ptf *item[MAX_SECTION_NESTING];
-};
-
-
-typedef void (*ptf_match_action)(struct ptf_item *x, void *arg);
-
-struct ptf *ptf_parse_file(char *filename);
-struct ptf *ptf_concat(struct ptf *a, struct ptf *b);
-struct ptf *ptf_alloc_item(ptf_item_type t, char *name, char *value);
-void ptf_printf(FILE *s, struct ptf *tree, char *prefix);
-void ptf_dump_ptf_item(FILE *s, struct ptf_item *pi);
-
-struct ptf *ptf_find(
- struct ptf *tree,
- struct ptf_item *item,
- ptf_item_type ttype,
- char *name,
- char *value);
-
-struct ptf *ptf_next(
- struct ptf_item *item,
- ptf_item_type ttype,
- char *name,
- char *value);
-
-int ptf_match(
- struct ptf *const ptf,
- struct ptf_item *const match,
- const ptf_match_action action,
- void *arg);
-
-char *ptf_defused_name(char *);
-
-
-#endif /* !defined(__PTF_H) */
-
diff --git a/tools/cpu/nios2/sample.ptf b/tools/cpu/nios2/sample.ptf
deleted file mode 100644
index eb4cf7fea4..0000000000
--- a/tools/cpu/nios2/sample.ptf
+++ /dev/null
@@ -1,462 +0,0 @@
-N2GCOMM = "=============== Header output settings ===========================";
-
-BSPHEADER
-{
- LEADTEXT =
-"/* Autogenerated by nios2gen, (C) 2006 K. Waschk rtemsdev/ixo.de */
-
-#ifndef __SOPC_H
-#define __SOPC_H 1
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define CLOCK_FREQ_REF(clock) clock ## _FREQ
-#define CLOCK_FREQ(x) CLOCK_FREQ_REF(x)
-
-";
-
- EPILOG =
-"
-#ifdef __cplusplus
-}
-#endif
-#endif
-";
-}
-
-N2GCOMM = "=============== Class templates ==================================";
-
-CLASS altera_nios2
-{
- N2G_DEFINE_IS_AVAILABLE = "1";
-
- SYSTEM_BUILDER_INFO
- {
- Clock_Source = "N2G_CLOCKREF_CLOCK";
- }
- SLAVE jtag_debug_module
- {
- SYSTEM_BUILDER_INFO { Base_Address = "BASE_ADDR"; }
- }
- WIZARD_SCRIPT_ARGUMENTS
- {
- cache_has_dcache = "HAS_DCACHE";
- cache_has_icache = "HAS_ICACHE";
- cache_dcache_size = "DCACHE_SIZE";
- cache_icache_size = "ICACHE_SIZE";
- cache_dcache_line_size = "DCACHE_LINE_SIZE";
- cache_icache_line_size = "ICACHE_LINE_SIZE";
- cache_dcache_bursts = "DCACHE_BURSTS";
- cache_icache_burst_type = "ICACHE_BURST_TYPE";
- hardware_multiply_present = "HAS_HWMULT";
- }
-}
-
-CLASS altera_avalon_onchip_memory2
-{
- N2G_DEFINE_IS_AVAILABLE = "1";
-
- WIZARD_SCRIPT_ARGUMENTS
- {
- Writeable = "WRITEABLE";
- dual_port = "DUAL_PORT";
- Size_Value = "SIZE_VALUE";
- Size_Multiple = "SIZE_MULTIPLE";
- }
- SYSTEM_BUILDER_INFO
- {
- Clock_Source = "N2G_CLOCKREF_CLOCK";
- }
- SLAVE s1
- {
- N2G_DEFINE_CONNECTED_PORT = "S1";
-
- SYSTEM_BUILDER_INFO
- {
- Base_Address = "S1_BASE_ADDR";
- Data_Width = "S1_DATA_WIDTH";
- Address_Width = "S1_ADDR_WIDTH";
- Address_Span = "S1_ADDR_SPAN";
- }
- }
- SLAVE s2
- {
- N2G_DEFINE_CONNECTED_PORT = "S2";
-
- SYSTEM_BUILDER_INFO
- {
- Base_Address = "S2_BASE_ADDR";
- Data_Width = "S2_DATA_WIDTH";
- Address_Width = "S2_ADDR_WIDTH";
- Address_Span = "S2_ADDR_SPAN";
- }
- }
-}
-
-CLASS sram_256k_x_16_bit
-{
- N2G_DEFINE_IS_AVAILABLE = "1";
-
- SLAVE sram
- {
- SYSTEM_BUILDER_INFO
- {
- Base_Address = "BASE_ADDR";
- Data_Width = "DATA_WIDTH";
- Address_Width = "ADDR_WIDTH";
- Address_Span = "ADDR_SPAN";
- }
- }
-}
-
-CLASS altera_avalon_sysid
-{
- N2G_DEFINE_IS_AVAILABLE = "1";
-
- SLAVE control_slave
- {
- SYSTEM_BUILDER_INFO
- {
- Base_Address = "BASE_ADDR";
- }
- }
- WIZARD_SCRIPT_ARGUMENTS
- {
- id = "ID";
- timestamp = "TIMESTAMP";
- }
-}
-
-CLASS altera_avalon_timer
-{
- N2G_DEFINE_IS_AVAILABLE = "1";
-
- SLAVE s1
- {
- SYSTEM_BUILDER_INFO
- {
- Base_Address = "BASE_ADDR";
- IRQ_MASTER { IRQ_Number = "IRQ"; }
- }
- }
- WIZARD_SCRIPT_ARGUMENTS
- {
- snapshot = "SNAPSHOT";
- always_run = "ALWAYS_RUN";
- mult = "MULT";
- period = "PERIOD";
- period_units = "PERIOD_UNITS";
- fixed_period = "FIXED_PERIOD";
- }
- SYSTEM_BUILDER_INFO
- {
- Clock_Source = "N2G_CLOCKREF_CLOCK";
- }
-}
-
-
-CLASS altera_avalon_uart
-{
- N2G_DEFINE_IS_AVAILABLE = "1";
-
- SYSTEM_BUILDER_INFO
- {
- Clock_Source = "N2G_CLOCKREF_CLOCK";
- }
- WIZARD_SCRIPT_ARGUMENTS
- {
- use_cts_rts = "USE_CTS_RTS";
- use_eop_register = "USE_EOP_REG";
- }
- SLAVE s1
- {
- SYSTEM_BUILDER_INFO
- {
- Base_Address = "BASE_ADDR";
- IRQ_MASTER { IRQ_Number = "IRQ"; }
- }
- }
-}
-
-CLASS altera_avalon_jtag_uart
-{
- N2G_DEFINE_IS_AVAILABLE = "1";
-
- SLAVE avalon_jtag_slave
- {
- SYSTEM_BUILDER_INFO
- {
- Base_Address = "BASE_ADDR";
- IRQ_MASTER { IRQ_Number = "IRQ"; }
- }
- }
-}
-
-CLASS altera_avalon_pio
-{
- N2G_DEFINE_IS_AVAILABLE = "1";
-
- SYSTEM_BUILDER_INFO
- {
- Clock_Source = "N2G_CLOCKREF_CLOCK";
- }
- SLAVE
- {
- SYSTEM_BUILDER_INFO
- {
- Base_Address = "BASE_ADDR";
- IRQ_MASTER { IRQ_Number = "IRQ"; }
- }
- }
-}
-
-N2GCOMM = "=============== Linkcmds output settings =========================";
-
-LINKCMDS
-{
- LEADTEXT = "
-OUTPUT_FORMAT( "elf32-littlenios2",
- "elf32-littlenios2",
- "elf32-littlenios2" )
-OUTPUT_ARCH( nios2 )
-ENTRY( _start )
-"
-
- SECTION entry
- {
- COMMANDS =
-" KEEP (*(.entry))
-";
- }
-
- SECTION exceptions
- {
- COMMANDS =
-" PROVIDE (__ram_exceptions_start = ABSOLUTE(.));
- . = ALIGN(0x20);
- *(.irq)
- KEEP (*(.exceptions.entry.label));
- KEEP (*(.exceptions.entry.user));
- KEEP (*(.exceptions.entry));
- KEEP (*(.exceptions.irqtest.user));
- KEEP (*(.exceptions.irqtest));
- KEEP (*(.exceptions.irqhandler.user));
- KEEP (*(.exceptions.irqhandler));
- KEEP (*(.exceptions.irqreturn.user));
- KEEP (*(.exceptions.irqreturn));
- KEEP (*(.exceptions.notirq.label));
- KEEP (*(.exceptions.notirq.user));
- KEEP (*(.exceptions.notirq));
- KEEP (*(.exceptions.soft.user));
- KEEP (*(.exceptions.soft));
- KEEP (*(.exceptions.unknown.user));
- KEEP (*(.exceptions.unknown));
- KEEP (*(.exceptions.exit.label));
- KEEP (*(.exceptions.exit.user));
- KEEP (*(.exceptions.exit));
- KEEP (*(.exceptions));
- PROVIDE (__ram_exceptions_end = ABSOLUTE(.));
-";
- }
-
- SECTION text
- {
- LOCATION = "SDRAM";
- COMMANDS =
-" PROVIDE (stext = ABSOLUTE(.));
-
- *(.interp)
- *(.hash)
- *(.dynsym)
- *(.dynstr)
- *(.gnu.version)
- *(.gnu.version_d)
- *(.gnu.version_r)
- *(.rel.init)
- *(.rela.init)
- *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
- *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
- *(.rel.fini)
- *(.rela.fini)
- *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
- *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
- *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
- *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
- *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
- *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
- *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
- *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
- *(.rel.ctors)
- *(.rela.ctors)
- *(.rel.dtors)
- *(.rela.dtors)
- *(.rel.got)
- *(.rela.got)
- *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*)
- *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*)
- *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*)
- *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*)
- *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*)
- *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*)
- *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*)
- *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*)
- *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
- *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
- *(.rel.plt)
- *(.rela.plt)
-
- KEEP (*(.init))
- *(.plt)
- *(.text .stub .text.* .gnu.linkonce.t.*)
-
- /* Special FreeBSD sysctl sections. */
- . = ALIGN (16);
- __start_set_sysctl_set = .;
- *(set_sysctl_*);
- __stop_set_sysctl_set = ABSOLUTE(.);
- *(set_domain_*);
- *(set_pseudo_*);
-
- *(.gnu.warning.*)
- KEEP (*(.fini))
- PROVIDE (__etext = ABSOLUTE(.));
- PROVIDE (_etext = ABSOLUTE(.));
- PROVIDE (etext = ABSOLUTE(.));
-
- *(.eh_frame_hdr)
- /* Ensure the __preinit_array_start label is properly aligned. We
- could instead move the label definition inside the section, but
- the linker would then create the section even if it turns out to
- be empty, which isn't pretty. */
- . = ALIGN(32 / 8);
- PROVIDE (__preinit_array_start = ABSOLUTE(.));
- *(.preinit_array)
- PROVIDE (__preinit_array_end = ABSOLUTE(.));
- PROVIDE (__init_array_start = ABSOLUTE(.));
- *(.init_array)
- PROVIDE (__init_array_end = ABSOLUTE(.));
- PROVIDE (__fini_array_start = ABSOLUTE(.));
- *(.fini_array)
- PROVIDE (__fini_array_end = ABSOLUTE(.));
- SORT(CONSTRUCTORS)
- KEEP (*(.eh_frame))
- *(.gcc_except_table)
- *(.dynamic)
- PROVIDE (__CTOR_LIST__ = ABSOLUTE(.));
- KEEP (*(.ctors))
- KEEP (*(SORT(.ctors.*)))
- PROVIDE (__CTOR_END__ = ABSOLUTE(.));
- PROVIDE (__DTOR_LIST__ = ABSOLUTE(.));
- KEEP (*(.dtors))
- KEEP (*(SORT(.dtors.*)))
- PROVIDE (__DTOR_END__ = ABSOLUTE(.));
- KEEP (*(.jcr))
- . = ALIGN(32 / 8);
-";
- }
-
- SECTION rodata
- {
- LOCATION = "SDRAM";
- COMMANDS =
-" PROVIDE (__ram_rodata_start = ABSOLUTE(.));
- . = ALIGN(32 / 8);
- *(.rodata .rodata.* .gnu.linkonce.r.*)
- *(.rodata1)
- . = ALIGN(32 / 8);
- PROVIDE (__ram_rodata_end = ABSOLUTE(.));
-";
- }
-
- SECTION rwdata
- {
- LOCATION = "SDRAM";
- COMMANDS =
-" PROVIDE (__ram_rwdata_start = ABSOLUTE(.));
- . = ALIGN(32 / 8);
- *(.got.plt) *(.got)
- *(.data1)
- *(.data .data.* .gnu.linkonce.d.*)
-
- _gp = ABSOLUTE(. + 0x8000);
- PROVIDE(gp = _gp);
-
- *(.sdata .sdata.* .gnu.linkonce.s.*)
- *(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
-
- . = ALIGN(32 / 8);
- _edata = ABSOLUTE(.);
- PROVIDE (edata = ABSOLUTE(.));
- PROVIDE (__ram_rwdata_end = ABSOLUTE(.));
-";
- }
-
- SECTION bss
- {
- LOCATION = "SDRAM";
- COMMANDS =
-" __bss_start = ABSOLUTE(.);
- PROVIDE (__sbss_start = ABSOLUTE(.));
- PROVIDE (___sbss_start = ABSOLUTE(.));
-
- *(.dynsbss)
- *(.sbss .sbss.* .gnu.linkonce.sb.*)
- *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)
- *(.scommon)
-
- PROVIDE (__sbss_end = ABSOLUTE(.));
- PROVIDE (___sbss_end = ABSOLUTE(.));
-
- *(.dynbss)
- *(.bss .bss.* .gnu.linkonce.b.*)
- *(COMMON)
-
- . = ALIGN(32 / 8);
- __bss_end = ABSOLUTE(.);
-";
- }
-
- STABS =
-" .stab 0 : { *(.stab) }
- .stabstr 0 : { *(.stabstr) }
- .stab.excl 0 : { *(.stab.excl) }
- .stab.exclstr 0 : { *(.stab.exclstr) }
- .stab.index 0 : { *(.stab.index) }
- .stab.indexstr 0 : { *(.stab.indexstr) }
- .comment 0 : { *(.comment) }
- /* DWARF debug sections.
- Symbols in the DWARF debugging sections are relative to the beginning
- of the section so we begin them at 0. */
- /* DWARF 1 */
- .debug 0 : { *(.debug) }
- .line 0 : { *(.line) }
- /* GNU DWARF 1 extensions */
- .debug_srcinfo 0 : { *(.debug_srcinfo) }
- .debug_sfnames 0 : { *(.debug_sfnames) }
- /* DWARF 1.1 and DWARF 2 */
- .debug_aranges 0 : { *(.debug_aranges) }
- .debug_pubnames 0 : { *(.debug_pubnames) }
- /* DWARF 2 */
- .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
- .debug_abbrev 0 : { *(.debug_abbrev) }
- .debug_line 0 : { *(.debug_line) }
- .debug_frame 0 : { *(.debug_frame) }
- .debug_str 0 : { *(.debug_str) }
- .debug_loc 0 : { *(.debug_loc) }
- .debug_macinfo 0 : { *(.debug_macinfo) }
- /* SGI/MIPS DWARF 2 extensions */
- .debug_weaknames 0 : { *(.debug_weaknames) }
- .debug_funcnames 0 : { *(.debug_funcnames) }
- .debug_typenames 0 : { *(.debug_typenames) }
- .debug_varnames 0 : { *(.debug_varnames) }
-
- /* Altera debug extensions */
- .debug_alt_sim_info 0 : { *(.debug_alt_sim_info) }
-";
-
- HEAP = "SDRAM";
- STACK = "SDRAM";
-}
-