summaryrefslogtreecommitdiffstats
path: root/src/tools/gputils
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/gputils')
-rw-r--r--src/tools/gputils/Makefile.am9
-rw-r--r--src/tools/gputils/gputils.cpp107
-rw-r--r--src/tools/gputils/gputils.h54
-rw-r--r--src/tools/gputils/gputils_compile.cpp109
-rw-r--r--src/tools/gputils/gputils_compile.h73
-rw-r--r--src/tools/gputils/gputils_config.cpp19
-rw-r--r--src/tools/gputils/gputils_config.h30
-rw-r--r--src/tools/gputils/gputils_generator.cpp256
-rw-r--r--src/tools/gputils/gputils_generator.h29
-rw-r--r--src/tools/gputils/gui/Makefile.am6
-rw-r--r--src/tools/gputils/gui/gputils_ui.cpp53
-rw-r--r--src/tools/gputils/gui/gputils_ui.h41
12 files changed, 786 insertions, 0 deletions
diff --git a/src/tools/gputils/Makefile.am b/src/tools/gputils/Makefile.am
new file mode 100644
index 0000000..157784c
--- /dev/null
+++ b/src/tools/gputils/Makefile.am
@@ -0,0 +1,9 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libgputils.la
+libgputils_la_LDFLAGS = $(all_libraries)
+libgputils_la_SOURCES = gputils_compile.cpp gputils_config.cpp gputils.cpp \
+ gputils_generator.cpp
+
+SUBDIRS = gui \ No newline at end of file
diff --git a/src/tools/gputils/gputils.cpp b/src/tools/gputils/gputils.cpp
new file mode 100644
index 0000000..3219598
--- /dev/null
+++ b/src/tools/gputils/gputils.cpp
@@ -0,0 +1,107 @@
+/***************************************************************************
+ * Copyright (C) 2005-2007 Nicolas Hadacek <hadacek@kde.org> *
+ * Copyright (C) 2003-2004 Alain Gibaud <alain.gibaud@free.fr> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+#include "gputils.h"
+
+#include <qregexp.h>
+
+#include "gputils_compile.h"
+#include "gputils_config.h"
+#include "devices/pic/pic/pic_memory.h"
+#include "common/global/process.h"
+#include "gputils_generator.h"
+
+//----------------------------------------------------------------------------
+QString GPUtils::Base::baseExecutable(bool, Tool::OutputExecutableType) const
+{
+ switch (_category.type()) {
+ case Tool::Category::Assembler: return "gpasm";
+ case Tool::Category::Linker: return "gplink";
+ case Tool::Category::Librarian: return "gplib";
+ default: break;
+ }
+ return QString::null;
+}
+
+bool GPUtils::Base::checkExecutableResult(bool withWine, QStringList &lines) const
+{
+ return ( lines.count()>0 && lines[0].startsWith(baseExecutable(withWine, Tool::OutputExecutableType::Coff)) );
+}
+
+//----------------------------------------------------------------------------
+QString GPUtils::Group::informationText() const
+{
+ return i18n("<a href=\"%1\">GPUtils</a> is an open-source assembler and linker suite.<br>").arg("http://gputils.sourceforge.net");
+}
+
+Tool::Group::BaseData GPUtils::Group::baseFactory(Tool::Category category) const
+{
+ if ( category==Tool::Category::Assembler ) return BaseData(new ::GPUtils::Base, Both);
+ if ( category==Tool::Category::Linker || category==Tool::Category::Librarian ) return BaseData(new ::GPUtils::Base, ProjectOnly);
+ return BaseData();
+}
+
+PURL::Directory GPUtils::Group::autodetectDirectory(Compile::DirectoryType type, const PURL::Directory &execDir, bool withWine) const
+{
+ switch (type.type()) {
+ case Compile::DirectoryType::LinkerScript: {
+ QString exec = execDir.path() + base(Tool::Category::Linker)->baseExecutable(withWine, Tool::OutputExecutableType::Coff);
+ ::Process::StringOutput process;
+ process.setup(exec, "-h", withWine);
+ if ( ::Process::runSynchronously(process, ::Process::Start, 1000)!=::Process::Exited ) return PURL::Directory();
+ QString s = process.sout() + process.serr();
+ QRegExp re(".*Default linker script path ([^\\n]*)\\n.*");
+ if ( !re.exactMatch(s) ) return PURL::Directory();
+ return PURL::Directory(re.cap(1));
+ }
+ case Compile::DirectoryType::Header: {
+ QString exec = execDir.path() + base(Tool::Category::Assembler)->baseExecutable(withWine, Tool::OutputExecutableType::Coff);
+ ::Process::StringOutput process;
+ process.setup(exec, "-h", withWine);
+ if ( ::Process::runSynchronously(process, ::Process::Start, 1000)!=::Process::Exited ) return PURL::Directory();
+ QString s = process.sout() + process.serr();
+ QRegExp re(".*Default header file path ([^\\n]*)\\n.*");
+ if ( !re.exactMatch(s) ) return PURL::Directory();
+ return PURL::Directory(re.cap(1));
+ }
+ case Compile::DirectoryType::Executable:
+ case Compile::DirectoryType::Library:
+ case Compile::DirectoryType::Source:
+ case Compile::DirectoryType::Nb_Types: break;
+ }
+ return PURL::Directory();
+}
+
+Compile::Process *GPUtils::Group::processFactory(const Compile::Data &data) const
+{
+ switch (data.category.type()) {
+ case Tool::Category::Assembler:
+ if (data.project) return new GPUtils::AssembleProjectFile;
+ return new GPUtils::AssembleStandaloneFile;
+ case Tool::Category::Linker:
+ Q_ASSERT(data.project);
+ return new GPUtils::LinkProject;
+ case Tool::Category::Librarian:
+ Q_ASSERT(data.project);
+ return new GPUtils::LibraryProject;
+ default: break;
+ }
+ Q_ASSERT(false);
+ return 0;
+}
+
+Compile::Config *GPUtils::Group::configFactory(::Project *project) const
+{
+ return new Config(project);
+}
+
+Tool::SourceGenerator *GPUtils::Group::sourceGeneratorFactory() const
+{
+ return new SourceGenerator;
+}
diff --git a/src/tools/gputils/gputils.h b/src/tools/gputils/gputils.h
new file mode 100644
index 0000000..b8bcded
--- /dev/null
+++ b/src/tools/gputils/gputils.h
@@ -0,0 +1,54 @@
+/***************************************************************************
+ * Copyright (C) 2005-2007 Nicolas Hadacek <hadacek@kde.org> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+#ifndef GPUTILS_H
+#define GPUTILS_H
+
+#include "tools/base/tool_group.h"
+#include "gputils_generator.h"
+
+namespace GPUtils
+{
+//----------------------------------------------------------------------------
+class Base : public Tool::Base
+{
+public:
+ virtual QString baseExecutable(bool withWine, Tool::OutputExecutableType type) const;
+
+private:
+ virtual QStringList checkExecutableOptions(bool) const { return "-v"; }
+ virtual bool checkExecutableResult(bool withWine, QStringList &lines) const;
+};
+
+//----------------------------------------------------------------------------
+class Group : public Tool::Group
+{
+public:
+ virtual QString name() const { return "gputils"; }
+ virtual QString label() const { return i18n("GPUtils"); }
+ virtual QString informationText() const;
+ virtual Tool::Category checkDevicesCategory() const { return Tool::Category::Assembler; }
+ virtual QStringList checkDevicesOptions(uint) const { return "-l"; }
+ virtual PURL::Directory autodetectDirectory(Compile::DirectoryType type, const PURL::Directory &execDir, bool withWine) const;
+ virtual bool hasDirectory(Compile::DirectoryType type) const { return type==Compile::DirectoryType::Header || type==Compile::DirectoryType::LinkerScript; }
+ virtual PURL::FileType linkerScriptType() const { return PURL::Lkr; }
+ virtual Tool::ExecutableType preferedExecutableType() const { return Tool::ExecutableType::Unix; }
+ virtual Tool::CompileType compileType() const { return Tool::SeparateFiles; }
+ virtual PURL::FileType implementationType(PURL::ToolType type) const { return (type==PURL::ToolType::Assembler ? PURL::AsmGPAsm : PURL::Nb_FileTypes); }
+
+protected:
+ virtual BaseData baseFactory(Tool::Category c) const;
+ virtual QValueList<const Device::Data *> getSupportedDevices(const QString &s) const { return GPUtils::getSupportedDevices(s); }
+ virtual Compile::Process *processFactory(const Compile::Data &data) const;
+ virtual Compile::Config *configFactory(::Project *project) const;
+ virtual Tool::SourceGenerator *sourceGeneratorFactory() const;
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/gputils/gputils_compile.cpp b/src/tools/gputils/gputils_compile.cpp
new file mode 100644
index 0000000..c59828c
--- /dev/null
+++ b/src/tools/gputils/gputils_compile.cpp
@@ -0,0 +1,109 @@
+/***************************************************************************
+ * Copyright (C) 2005-2006 Nicolas Hadacek <hadacek@kde.org> *
+ * Copyright (C) 2003-2004 Alain Gibaud <alain.gibaud@free.fr> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+#include "gputils_compile.h"
+
+#include "gputils.h"
+#include "gputils_config.h"
+#include "devices/list/device_list.h"
+#include "coff/base/disassembler.h"
+
+//-----------------------------------------------------------------------------
+QString GPUtils::Process::deviceName() const
+{
+ return toDeviceName(_data.device);
+}
+
+//-----------------------------------------------------------------------------
+void GPUtils::AssembleFile::logStderrLine(const QString &line)
+{
+ if ( parseErrorLine(line, Compile::ParseErrorData("([^:]*):([0-9]+):(.+)\\[[0-9]+\\](.+)", 1, 2, 4, 3)) ) return;
+ if ( parseErrorLine(line, Compile::ParseErrorData("([^:]*):([^:]+):([0-9]+):(.+)", 2, 3, 4, Log::LineType::Warning)) ) return;
+ doLog(Log::LineType::Normal, line, QString::null, 0); // unrecognized
+}
+
+//-----------------------------------------------------------------------------
+QStringList GPUtils::AssembleStandaloneFile::genericArguments(const Compile::Config &config) const
+{
+ QStringList args;
+ args += "-L"; // force list
+ args += "-o%O";
+ uint wl = static_cast<const Config &>(config).gpasmWarningLevel();
+ if ( wl!=Config::Nb_WarningLevels ) args += "-w" + QString::number(wl);
+ args += config.includeDirs(Tool::Category::Assembler, "-I");
+ args += "$NO_AUTO_DEVICE(-p%DEVICE)";
+ HexBuffer::Format format = config.hexFormat();
+ if( format!=HexBuffer::Nb_Formats ) args += QString("-a") + HexBuffer::FORMATS[format];
+ args += config.customOptions(Tool::Category::Assembler);
+ args += "%I";
+ return args;
+}
+
+QString GPUtils::AssembleStandaloneFile::outputFiles() const
+{
+ return "PURL::Lst PURL::Cod PURL::Hex";
+}
+
+//-----------------------------------------------------------------------------
+QStringList GPUtils::AssembleProjectFile::genericArguments(const Compile::Config &config) const
+{
+ QStringList args;
+ args += "-c"; // relocatable code
+ args += config.includeDirs(Tool::Category::Assembler, "-I");
+ if ( !_data.items[0].generated ) args += "-p%DEVICE";
+ uint wl = static_cast<const Config &>(config).gpasmWarningLevel() ;
+ if( wl!=Config::Nb_WarningLevels ) args += "-w" + QString::number(wl);
+ args += config.customOptions(Tool::Category::Assembler);
+ args += "%I";
+ return args;
+}
+
+QString GPUtils::AssembleProjectFile::outputFiles() const
+{
+ return "PURL::Object PURL::Lst";
+}
+
+//-----------------------------------------------------------------------------
+QStringList GPUtils::LinkProject::genericArguments(const Compile::Config &config) const
+{
+ QStringList args;
+ args += "-o%O";
+ args += "-c"; // create coff file
+ HexBuffer::Format f = config.hexFormat();
+ if ( f!=HexBuffer::Nb_Formats ) args += QString("-a") + HexBuffer::FORMATS[f];
+ args += "-m"; // with map
+ args += config.includeDirs(Tool::Category::Linker, "-I");
+ args += "$LKR(-s%LKR)";
+ args += config.customOptions(Tool::Category::Linker);
+ args += "%OBJS";
+ args += "%LIBS";
+ return args;
+}
+
+QString GPUtils::LinkProject::outputFiles() const
+{
+ return "PURL::Lkr PURL::Map PURL::Lst PURL::Cod PURL::Coff PURL::Hex";
+}
+
+//-----------------------------------------------------------------------------
+QStringList GPUtils::LibraryProject::genericArguments(const Compile::Config &config) const
+{
+ QStringList args;
+ args += "-c"; // create archive
+ args += "%O";
+ args += config.customOptions(Tool::Category::Librarian);
+ args += "%OBJS";
+ args += "%LIBS";
+ return args;
+}
+
+QString GPUtils::LibraryProject::outputFiles() const
+{
+ return "PURL::Library";
+}
diff --git a/src/tools/gputils/gputils_compile.h b/src/tools/gputils/gputils_compile.h
new file mode 100644
index 0000000..a6a09c9
--- /dev/null
+++ b/src/tools/gputils/gputils_compile.h
@@ -0,0 +1,73 @@
+/***************************************************************************
+ * Copyright (C) 2005-2006 Nicolas Hadacek <hadacek@kde.org> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+#ifndef GPUTILS_COMPILE_H
+#define GPUTILS_COMPILE_H
+
+#include "tools/list/compile_process.h"
+
+namespace GPUtils
+{
+//-----------------------------------------------------------------------------
+class Process : public Compile::Process
+{
+Q_OBJECT
+private:
+ virtual QString deviceName() const;
+ virtual bool hasLinkerScript() const { return ( _data.linkType==Compile::Icd2Linking || Compile::Process::hasLinkerScript() ); }
+};
+
+//-----------------------------------------------------------------------------
+class AssembleFile : public Process
+{
+Q_OBJECT
+private:
+ virtual void logStderrLine(const QString &line);
+};
+
+//-----------------------------------------------------------------------------
+class AssembleStandaloneFile : public AssembleFile
+{
+Q_OBJECT
+private:
+ virtual QString outputFiles() const;
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+};
+
+//-----------------------------------------------------------------------------
+class AssembleProjectFile : public AssembleFile
+{
+Q_OBJECT
+private:
+ virtual QString outputFiles() const;
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+};
+
+//-----------------------------------------------------------------------------
+class LinkProject : public Process
+{
+Q_OBJECT
+private:
+ virtual QString outputFiles() const;
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+ virtual void logStderrLine(const QString &line) { doLog(filterType(line), line, QString::null, 0); }
+};
+
+//-----------------------------------------------------------------------------
+class LibraryProject : public Process
+{
+Q_OBJECT
+private:
+ virtual QString outputFiles() const;
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+ virtual void logStderrLine(const QString &line) { doLog(filterType(line), line, QString::null, 0); }
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/gputils/gputils_config.cpp b/src/tools/gputils/gputils_config.cpp
new file mode 100644
index 0000000..8f7bca2
--- /dev/null
+++ b/src/tools/gputils/gputils_config.cpp
@@ -0,0 +1,19 @@
+/***************************************************************************
+ * Copyright (C) 2005-2006 Nicolas Hadacek <hadacek@kde.org> *
+ * Copyright (C) 2003-2004 Alain Gibaud <alain.gibaud@free.fr> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+#include "gputils_config.h"
+
+const char * const GPUtils::Config::WARNING_LEVEL_LABELS[Nb_WarningLevels] = {
+ I18N_NOOP("All messages"), I18N_NOOP("Warning and errors"), I18N_NOOP("Errors only")
+};
+
+uint GPUtils::Config::gpasmWarningLevel() const
+{
+ return QMIN(warningLevel(Tool::Category::Assembler), uint(Nb_WarningLevels));
+}
diff --git a/src/tools/gputils/gputils_config.h b/src/tools/gputils/gputils_config.h
new file mode 100644
index 0000000..cdaa66e
--- /dev/null
+++ b/src/tools/gputils/gputils_config.h
@@ -0,0 +1,30 @@
+/***************************************************************************
+ * Copyright (C) 2005-2006 Nicolas Hadacek <hadacek@kde.org> *
+ * Copyright (C) 2003-2004 Alain Gibaud <alain.gibaud@free.fr> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+#ifndef GPUTILS_CONFIG_H
+#define GPUTILS_CONFIG_H
+
+#include "tools/list/compile_config.h"
+
+namespace GPUtils
+{
+
+class Config : public Compile::Config
+{
+public:
+ Config(Project *project) : Compile::Config(project) {}
+ enum { Nb_WarningLevels = 3 };
+ static const char * const WARNING_LEVEL_LABELS[Nb_WarningLevels];
+ uint gpasmWarningLevel() const;
+ void setGPAsmWarningLevel(uint level) { setWarningLevel(Tool::Category::Assembler, level); }
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/gputils/gputils_generator.cpp b/src/tools/gputils/gputils_generator.cpp
new file mode 100644
index 0000000..3bcebac
--- /dev/null
+++ b/src/tools/gputils/gputils_generator.cpp
@@ -0,0 +1,256 @@
+/***************************************************************************
+ * Copyright (C) 2007 Nicolas Hadacek <hadacek@kde.org> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+#include "gputils_generator.h"
+
+#include "devices/pic/pic/pic_memory.h"
+#include "devices/pic/base/pic_register.h"
+#include "devices/list/device_list.h"
+
+//----------------------------------------------------------------------------
+QValueList<const Device::Data *> GPUtils::getSupportedDevices(const QString &s)
+{
+ QStringList devices = QStringList::split(' ', s.simplifyWhiteSpace().upper());
+ QValueList<const Device::Data *> list;
+ for (uint i=0; i<devices.count(); i++) {
+ QString name = devices[i];
+ if ( devices[i].startsWith("P1") ) name = name.mid(1);
+ const Device::Data *data = Device::lister().data(name);
+ if (data) list.append(data);
+ }
+ return list;
+}
+
+//----------------------------------------------------------------------------
+SourceLine::List GPUtils::SourceGenerator::configLines(PURL::ToolType, const Device::Memory &memory, bool &ok) const
+{
+ return GPUtils::generateConfigLines(static_cast<const Pic::Memory &>(memory), ok);
+}
+
+SourceLine::List GPUtils::SourceGenerator::includeLines(PURL::ToolType, const Device::Data &data) const
+{
+ return GPUtils::includeLines(data);
+}
+
+SourceLine::List GPUtils::SourceGenerator::sourceFileContent(PURL::ToolType, const Device::Data &data, bool &ok) const
+{
+ ok = true;
+ SourceLine::List lines;
+ lines.appendSeparator();
+ const Pic::Data &pdata = static_cast<const Pic::Data &>(data);
+ const Pic::RegistersData &rdata = static_cast<const Pic::RegistersData &>(*data.registersData());
+ switch (pdata.architecture().type()) {
+ case Pic::Architecture::P10X:
+ lines.appendTitle(i18n("relocatable code"));
+ lines.appendNotIndentedCode("PROG CODE");
+ lines.appendNotIndentedCode("start");
+ lines.appendIndentedCode(QString::null, "<< " + i18n("insert code") + " >>");
+ lines.appendIndentedCode("goto $", i18n("loop forever"));
+ lines.appendEmpty();
+ lines.appendNotIndentedCode("END");
+ break;
+ case Pic::Architecture::P16X: {
+ lines.appendTitle(i18n("Variables declaration"));
+ bool needPCLATH = ( pdata.nbWords(Pic::MemoryRangeType::Code)>0x400 );
+ uint first;
+ bool allShared;
+ bool hasShared = rdata.hasSharedGprs(first, allShared);
+ if ( hasShared && !allShared ) lines.appendNotIndentedCode("INT_VAR UDATA_SHR");
+ else {
+ first = rdata.firstGprIndex();
+ lines.appendNotIndentedCode("INT_VAR UDATA " + toHexLabel(first, rdata.nbCharsAddress()));
+ }
+ lines.appendNotIndentedCode("w_saved RES 1", i18n("variable used for context saving"));
+ lines.appendNotIndentedCode("status_saved RES 1", i18n("variable used for context saving"));
+ first += 2;
+ if (needPCLATH) {
+ lines.appendNotIndentedCode("pclath_saved RES 1", i18n("variable used for context saving"));
+ first++;
+ }
+ lines.appendEmpty();
+ lines.appendNotIndentedCode("var1 RES 1", i18n("example variable"));
+ if ( !hasShared ) {
+ for (uint i=1; i<rdata.nbBanks; i++) {
+ uint address = first + i*rdata.nbBytesPerBank();
+ lines.appendNotIndentedCode(QString("INT_VAR%1 UDATA ").arg(i) + toHexLabel(address, rdata.nbCharsAddress()), i18n("variables used for context saving"));
+ lines.appendNotIndentedCode(QString("w_saved%1 RES 1").arg(i), i18n("variable used for context saving"));
+ }
+ }
+ lines.appendEmpty();
+ lines.appendSeparator();
+ lines.appendTitle(i18n("reset vector"));
+ lines.appendNotIndentedCode("STARTUP CODE 0x000");
+ lines.appendIndentedCode("nop", i18n("needed for ICD2 debugging"));
+ lines.appendIndentedCode("movlw high start", i18n("load upper byte of 'start' label"));
+ lines.appendIndentedCode("movwf PCLATH", i18n("initialize PCLATH"));
+ lines.appendIndentedCode("goto start", i18n("go to start of main code"));
+ lines.appendEmpty();
+ lines.appendTitle(i18n("interrupt vector"));
+ lines.appendNotIndentedCode("INT_VECTOR CODE 0x004");
+ lines.appendIndentedCode("goto interrupt", i18n("go to start of interrupt code"));
+ lines.appendEmpty();
+ lines.appendTitle(i18n("relocatable code"));
+ lines.appendNotIndentedCode("PROG CODE");
+ lines.appendNotIndentedCode("interrupt");
+ lines.appendIndentedCode("movwf w_saved", i18n("save context"));
+ lines.appendIndentedCode("swapf STATUS,w");
+ if ( !hasShared ) lines.appendIndentedCode("clrf STATUS");
+ lines.appendIndentedCode("movwf status_saved");
+ if (needPCLATH) {
+ lines.appendIndentedCode("movf PCLATH,w", i18n("only required if using more than first page"));
+ lines.appendIndentedCode("movwf pclath_saved");
+ lines.appendIndentedCode("clrf PCLATH");
+ }
+ lines.appendIndentedCode(QString::null, "<< " + i18n("insert interrupt code") + " >>");
+ if (needPCLATH) {
+ lines.appendIndentedCode("movf pclath_saved,w", i18n("restore context"));
+ lines.appendIndentedCode("movwf PCLATH");
+ lines.appendIndentedCode("swapf status_saved,w");
+ } else lines.appendIndentedCode("swapf status_saved,w", i18n("restore context"));
+ lines.appendIndentedCode("movwf STATUS");
+ lines.appendIndentedCode("swapf w_saved,f");
+ lines.appendIndentedCode("swapf w_saved,w");
+ lines.appendIndentedCode("retfie");
+ lines.appendEmpty();
+ lines.appendNotIndentedCode("start");
+ lines.appendIndentedCode(QString::null, "<< " + i18n("insert main code") + " >>");
+ lines.appendIndentedCode("goto $", i18n("loop forever"));
+ lines.appendEmpty();
+ lines.appendNotIndentedCode("END");
+ break;
+ }
+ case Pic::Architecture::P17C:
+ lines.appendTitle(i18n("Variables declaration"));
+ lines.appendNotIndentedCode("INT_VAR UDATA " + toHexLabel(rdata.accessBankSplit, rdata.nbCharsAddress()));
+ lines.appendNotIndentedCode("wred_saved RES 1", i18n("variable used for context saving (for low-priority interrupts only)"));
+ lines.appendNotIndentedCode("alusta_saved RES 1", i18n("variable used for context saving (for low-priority interrupts only)"));
+ lines.appendNotIndentedCode("bsr_saved RES 1", i18n("variable used for context saving (for low-priority interrupts only)"));
+ lines.appendNotIndentedCode("pclath_saved RES 1", i18n("variable used for context saving (for low-priority interrupts only)"));
+ lines.appendEmpty();
+ lines.appendNotIndentedCode("var1 RES 1", i18n("example variable"));
+ lines.appendEmpty();
+ lines.appendSeparator();
+ lines.appendTitle(i18n("Macros"));
+ lines.appendNotIndentedCode("PUSH MACRO", i18n("for saving context"));
+ lines.appendIndentedCode("movpf WREG,wred_saved");
+ lines.appendIndentedCode("movpf ALUSTA,alusta_saved");
+ lines.appendIndentedCode("movpf BSR,bsr_saved");
+ lines.appendIndentedCode("movpf PCLATH,pclath_saved");
+ lines.appendIndentedCode("ENDM");
+ lines.appendEmpty();
+ lines.appendNotIndentedCode("POP MACRO", i18n("for restoringing context"));
+ lines.appendIndentedCode("movfp pclath_saved,PCLATH");
+ lines.appendIndentedCode("movfp bsr_saved,BSR");
+ lines.appendIndentedCode("movfp alusta_saved,ALUSTA");
+ lines.appendIndentedCode("movfp wred_saved,WREG");
+ lines.appendIndentedCode("ENDM");
+ lines.appendSeparator();
+ lines.appendTitle(i18n("reset vector"));
+ lines.appendNotIndentedCode("STARTUP CODE 0x0000");
+ lines.appendIndentedCode("nop", i18n("needed for ICD2 debugging"));
+ lines.appendIndentedCode("nop", i18n("needed for ICD2 debugging"));
+ lines.appendIndentedCode("goto start", i18n("go to start of main code"));
+ lines.appendEmpty();
+ lines.appendNotIndentedCode("INT_PIN_VECTOR CODE 0x0008");
+ lines.appendIndentedCode("PUSH");
+ lines.appendIndentedCode("goto int_pin_isr", i18n("go to start of int pin interrupt code"));
+ lines.appendEmpty();
+ lines.appendNotIndentedCode("TIMER0_VECTOR CODE 0x0010");
+ lines.appendIndentedCode("PUSH");
+ lines.appendIndentedCode("goto timer0_isr", i18n("go to start of timer0 interrupt code"));
+ lines.appendEmpty();
+ lines.appendNotIndentedCode("T0CKI_VECTOR CODE 0x00018");
+ lines.appendIndentedCode("PUSH");
+ lines.appendIndentedCode("goto t0cki_isr", i18n("go to start of t0cki interrupt code"));
+ lines.appendEmpty();
+ lines.appendNotIndentedCode("PERIPHERAL_VECTOR CODE 0x0020");
+ lines.appendIndentedCode("PUSH");
+ lines.appendIndentedCode("goto peripheral_isr", i18n("go to start of peripheral interrupt code"));
+ lines.appendEmpty();
+ lines.appendNotIndentedCode("start:");
+ lines.appendIndentedCode(QString::null, "<< " + i18n("insert main code") + " >>");
+ lines.appendIndentedCode("goto $", i18n("loop forever"));
+ lines.appendEmpty();
+ lines.appendTitle(i18n("INT pin interrupt service routine"));
+ lines.appendNotIndentedCode("int_pin_isr:");
+ lines.appendIndentedCode(QString::null, "<< " + i18n("insert INT pin interrupt code") + " >>");
+ lines.appendIndentedCode("POP");
+ lines.appendIndentedCode("retfie");
+ lines.appendEmpty();
+ lines.appendTitle(i18n("TIMER0 interrupt service routine"));
+ lines.appendNotIndentedCode("timer0_isr:");
+ lines.appendIndentedCode(QString::null, "<< " + i18n("insert TIMER0 interrupt code") + " >>");
+ lines.appendIndentedCode("POP");
+ lines.appendIndentedCode("retfie");
+ lines.appendEmpty();
+ lines.appendTitle(i18n("T0CKI interrupt service routine"));
+ lines.appendNotIndentedCode("t0cki_isr:");
+ lines.appendIndentedCode(QString::null, "<< " + i18n("insert T0CKI interrupt code") + " >>");
+ lines.appendIndentedCode("POP");
+ lines.appendIndentedCode("retfie");
+ lines.appendEmpty();
+ lines.appendTitle(i18n("peripheral interrupt service routine"));
+ lines.appendNotIndentedCode("peripheral_isr:");
+ lines.appendIndentedCode(QString::null, "<< " + i18n("insert peripheral interrupt code") + " >>");
+ lines.appendIndentedCode("POP");
+ lines.appendIndentedCode("retfie");
+ lines.appendEmpty();
+ lines.appendNotIndentedCode("END");
+ break;
+ case Pic::Architecture::P18C:
+ case Pic::Architecture::P18F:
+ case Pic::Architecture::P18J: // ??
+ lines.appendTitle(i18n("Variables declaration"));
+ lines.appendNotIndentedCode("INT_VAR UDATA " + toHexLabel(rdata.accessBankSplit, rdata.nbCharsAddress()));
+ lines.appendNotIndentedCode("w_saved RES 1", i18n("variable used for context saving (for low-priority interrupts only)"));
+ lines.appendNotIndentedCode("status_saved RES 1", i18n("variable used for context saving (for low-priority interrupts only)"));
+ lines.appendNotIndentedCode("bsr_saved RES 1", i18n("variable used for context saving (for low-priority interrupts only)"));
+ lines.appendEmpty();
+ lines.appendNotIndentedCode("var1 RES 1", i18n("example variable"));
+ lines.appendEmpty();
+ lines.appendSeparator();
+ lines.appendTitle(i18n("reset vector"));
+ lines.appendNotIndentedCode("STARTUP CODE 0x0000");
+ lines.appendIndentedCode("nop", i18n("needed for ICD2 debugging"));
+ lines.appendIndentedCode("nop", i18n("needed for ICD2 debugging"));
+ lines.appendIndentedCode("goto start", i18n("go to start of main code"));
+ lines.appendEmpty();
+ lines.appendTitle(i18n("high priority interrupt vector"));
+ lines.appendNotIndentedCode("HIGH_INT_VECTOR CODE 0x0008");
+ lines.appendIndentedCode("bra high_interrupt", i18n("go to start of high priority interrupt code"));
+ lines.appendEmpty();
+ lines.appendTitle(i18n("low priority interrupt vector"));
+ lines.appendNotIndentedCode("LOW_INT_VECTOR CODE 0x0018");
+ lines.appendIndentedCode("movff STATUS,status_saved", i18n("save context"));
+ lines.appendIndentedCode("movff WREG,w_saved");
+ lines.appendIndentedCode("movff BSR,bsr_saved");
+ lines.appendIndentedCode(QString::null, "<< " + i18n("insert low priority interrupt code") + " >>");
+ lines.appendIndentedCode("movff bsr_saved,BSR", i18n("restore context"));
+ lines.appendIndentedCode("movff w_saved,WREG");
+ lines.appendIndentedCode("movff status_saved,STATUS");
+ lines.appendIndentedCode("retfie");
+ lines.appendEmpty();
+ lines.appendTitle(i18n("high priority interrupt service routine"));
+ lines.appendNotIndentedCode("high_interrupt:");
+ lines.appendIndentedCode(QString::null, "<< " + i18n("insert high priority interrupt code") + " >>");
+ lines.appendIndentedCode("retfie FAST");
+ lines.appendEmpty();
+ lines.appendNotIndentedCode("start:");
+ lines.appendIndentedCode(QString::null, "<< " + i18n("insert main code") + " >>");
+ lines.appendIndentedCode("goto $", i18n("loop forever"));
+ lines.appendEmpty();
+ lines.appendNotIndentedCode("END");
+ break;
+ case Pic::Architecture::P24F:
+ case Pic::Architecture::P24H:
+ case Pic::Architecture::P30F:
+ case Pic::Architecture::P33F: ok = false; break;
+ case Pic::Architecture::Nb_Types: Q_ASSERT(false); break;
+ }
+ return lines;
+}
diff --git a/src/tools/gputils/gputils_generator.h b/src/tools/gputils/gputils_generator.h
new file mode 100644
index 0000000..38da66d
--- /dev/null
+++ b/src/tools/gputils/gputils_generator.h
@@ -0,0 +1,29 @@
+/***************************************************************************
+ * Copyright (C) 2007 Nicolas Hadacek <hadacek@kde.org> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+#ifndef GPUTILS_GENERATOR_H
+#define GPUTILS_GENERATOR_H
+
+#include "coff/base/disassembler.h"
+
+namespace GPUtils
+{
+
+extern QValueList<const Device::Data *> getSupportedDevices(const QString &s);
+
+class SourceGenerator : public Tool::SourceGenerator
+{
+public:
+ virtual SourceLine::List configLines(PURL::ToolType type, const Device::Memory &memory, bool &ok) const;
+ virtual SourceLine::List sourceFileContent(PURL::ToolType type, const Device::Data &data, bool &ok) const;
+ virtual SourceLine::List includeLines(PURL::ToolType type, const Device::Data &data) const;
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/gputils/gui/Makefile.am b/src/tools/gputils/gui/Makefile.am
new file mode 100644
index 0000000..0ac81c9
--- /dev/null
+++ b/src/tools/gputils/gui/Makefile.am
@@ -0,0 +1,6 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libgputilsui.la
+libgputilsui_la_LDFLAGS = $(all_libraries)
+libgputilsui_la_SOURCES = gputils_ui.cpp
diff --git a/src/tools/gputils/gui/gputils_ui.cpp b/src/tools/gputils/gui/gputils_ui.cpp
new file mode 100644
index 0000000..35cdce8
--- /dev/null
+++ b/src/tools/gputils/gui/gputils_ui.cpp
@@ -0,0 +1,53 @@
+/***************************************************************************
+ * Copyright (C) 2005-2006 Nicolas Hadacek <hadacek@kde.org> *
+ * Copyright (C) 2003-2004 Alain Gibaud <alain.gibaud@free.fr> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+#include "gputils_ui.h"
+
+#include <qlabel.h>
+#include "tools/gputils/gputils_config.h"
+
+//----------------------------------------------------------------------------
+GPUtils::ConfigWidget::ConfigWidget(Project *project)
+ : ToolConfigWidget(project), _gpasmWarning(0)
+{}
+
+void GPUtils::ConfigWidget::initEntries()
+{
+ if ( _category==Tool::Category::Assembler ) {
+ uint row = container()->numRows();
+ QLabel *label = new QLabel(i18n("Warning level:"), container());
+ container()->addWidget(label, row,row, 0,0);
+ _gpasmWarning = new QComboBox(container());
+ connect(_gpasmWarning, SIGNAL(activated(int)), SIGNAL(changed()));
+ for (uint i=0; i<GPUtils::Config::Nb_WarningLevels; i++)
+ _gpasmWarning->insertItem(i18n(GPUtils::Config::WARNING_LEVEL_LABELS[i]));
+ _gpasmWarning->insertItem(i18n("as in LIST directive"));
+ container()->addWidget(_gpasmWarning, row,row, 1,1);
+ createIncludeDirectoriesEntry();
+ if ( _project==0 ) createHexFormatEntry();
+ }
+ if ( _category==Tool::Category::Linker ) {
+ createHexFormatEntry();
+ createIncludeDirectoriesEntry();
+ }
+}
+
+void GPUtils::ConfigWidget::loadConfig(const Compile::Config &config)
+{
+ ToolConfigWidget::loadConfig(config);
+ if ( _category==Tool::Category::Assembler )
+ _gpasmWarning->setCurrentItem(static_cast<const Config &>(config).gpasmWarningLevel());
+}
+
+void GPUtils::ConfigWidget::saveConfig(Compile::Config &config) const
+{
+ ToolConfigWidget::saveConfig(config);
+ if ( _category==Tool::Category::Assembler )
+ static_cast<Config &>(config).setGPAsmWarningLevel(_gpasmWarning->currentItem());
+}
diff --git a/src/tools/gputils/gui/gputils_ui.h b/src/tools/gputils/gui/gputils_ui.h
new file mode 100644
index 0000000..8d6daea
--- /dev/null
+++ b/src/tools/gputils/gui/gputils_ui.h
@@ -0,0 +1,41 @@
+/***************************************************************************
+ * Copyright (C) 2005-2006 Nicolas Hadacek <hadacek@kde.org> *
+ * Copyright (C) 2003-2004 Alain Gibaud <alain.gibaud@free.fr> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+#ifndef GPUTILS_UI_H
+#define GPUTILS_UI_H
+
+#include "tools/gui/tool_config_widget.h"
+#include "tools/gui/tool_group_ui.h"
+
+namespace GPUtils
+{
+//----------------------------------------------------------------------------
+class ConfigWidget : public ToolConfigWidget
+{
+Q_OBJECT
+public:
+ ConfigWidget(Project *project);
+ virtual void initEntries();
+
+protected:
+ QComboBox *_gpasmWarning;
+ virtual void loadConfig(const Compile::Config &config);
+ virtual void saveConfig(Compile::Config &config) const;
+};
+
+//----------------------------------------------------------------------------
+class GroupUI : public Tool::GroupUI
+{
+public:
+ virtual ToolConfigWidget *configWidgetFactory(Tool::Category, ::Project *project) const { return new ConfigWidget(project); }
+};
+
+} // namespace
+
+#endif