diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-24 18:42:24 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-24 18:42:24 +0000 |
commit | f508189682b6fba62e08feeb1596f682bad5fff9 (patch) | |
tree | 28aeb0e6c19386c385c1ce5edf8a92c1bca15281 /src/progs/picdem_bootloader | |
download | piklab-f508189682b6fba62e08feeb1596f682bad5fff9.tar.gz piklab-f508189682b6fba62e08feeb1596f682bad5fff9.zip |
Added KDE3 version of PikLab
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/piklab@1095639 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/progs/picdem_bootloader')
16 files changed, 534 insertions, 0 deletions
diff --git a/src/progs/picdem_bootloader/Makefile.am b/src/progs/picdem_bootloader/Makefile.am new file mode 100644 index 0000000..fccf96d --- /dev/null +++ b/src/progs/picdem_bootloader/Makefile.am @@ -0,0 +1,3 @@ +INCLUDES = -I$(top_srcdir)/src $(all_includes) +METASOURCES = AUTO +SUBDIRS = xml base gui diff --git a/src/progs/picdem_bootloader/base/Makefile.am b/src/progs/picdem_bootloader/base/Makefile.am new file mode 100644 index 0000000..13a3add --- /dev/null +++ b/src/progs/picdem_bootloader/base/Makefile.am @@ -0,0 +1,11 @@ +INCLUDES = -I$(top_srcdir)/src $(all_includes) +METASOURCES = AUTO + +noinst_LTLIBRARIES = libpicdembootloader.la +libpicdembootloader_la_SOURCES = picdem_bootloader_data.cpp picdem_bootloader.cpp picdem_bootloader_prog.cpp +libpicdembootloader_la_DEPENDENCIES = picdem_bootloader_data.cpp + +noinst_DATA = picdem_bootloader.xml +picdem_bootloader_data.cpp: ../xml/xml_picdem_bootloader_parser picdem_bootloader.xml + ../xml/xml_picdem_bootloader_parser +CLEANFILES = picdem_bootloader_data.cpp diff --git a/src/progs/picdem_bootloader/base/base.pro b/src/progs/picdem_bootloader/base/base.pro new file mode 100644 index 0000000..8551799 --- /dev/null +++ b/src/progs/picdem_bootloader/base/base.pro @@ -0,0 +1,6 @@ +STOPDIR = ../../../.. +include($${STOPDIR}/lib.pro) + +TARGET = picdem_bootloader +HEADERS += picdem_bootloader.h picdem_bootloader_prog.h picdem_bootloader_data.h +SOURCES += picdem_bootloader.cpp picdem_bootloader_prog.cpp picdem_bootloader_data.cpp diff --git a/src/progs/picdem_bootloader/base/picdem_bootloader.cpp b/src/progs/picdem_bootloader/base/picdem_bootloader.cpp new file mode 100644 index 0000000..f22eecb --- /dev/null +++ b/src/progs/picdem_bootloader/base/picdem_bootloader.cpp @@ -0,0 +1,184 @@ +/*************************************************************************** + * 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 "picdem_bootloader.h" + +#include "progs/icd2/base/microchip.h" + +//----------------------------------------------------------------------------- +uint PicdemBootloader::Config::readVendorId() +{ + Config config; + return qMin(config.readUIntEntry("vendor_id", Microchip::VENDOR_ID), uint(0xFFFF)); +} +void PicdemBootloader::Config::writeVendorId(uint id) +{ + Config config; + config.writeEntry("vendor_id", id); +} + +uint PicdemBootloader::Config::readProductId() +{ + Config config; + return qMin(config.readUIntEntry("product_id", 0x000B), uint(0xFFFF)); +} +void PicdemBootloader::Config::writeProductId(uint id) +{ + Config config; + config.writeEntry("product_id", id); +} + +//----------------------------------------------------------------------------- +PicdemBootloader::Port::Port(Log::Base &log) + : Port::USB(log, Config::readVendorId(), Config::readProductId(), 1, 0) +{} + +bool PicdemBootloader::Port::receive(uint nb, QMemArray<uchar> &data) +{ + data.resize(nb); + if ( !read(0x81, (char *)data.data(), nb) ) return false; + log(Log::DebugLevel::Max, QString("received: \"%1\"").arg(toPrintable(data, PrintEscapeAll))); + return true; +} + +bool PicdemBootloader::Port::send(const QMemArray<uchar> &cmd) +{ + log(Log::DebugLevel::Extra, QString("send: \"%1\"").arg(toPrintable(cmd, PrintEscapeAll))); + return write(0x01, (const char *)cmd.data(), cmd.count()); +} + +bool PicdemBootloader::Port::sendAndReceive(QMemArray<uchar> &data, uint nb) +{ + if ( !send(data) ) return false; + return receive(nb, data); +} + +QMemArray<uchar> PicdemBootloader::Port::command(uchar instruction, uint address, uint len, uint nb) const +{ + QMemArray<uchar> cmd(5+nb); + cmd[0] = instruction; + cmd[1] = len; + cmd[2] = address & 0xFF; + cmd[3] = (address >> 8) & 0xFF; + cmd[4] = (address >> 16) & 0xFF; + return cmd; +} + +//----------------------------------------------------------------------------- +PicdemBootloader::Hardware::Hardware(::Programmer::Base &base) + : Bootloader::Hardware(base, new Port(base)) +{} + +bool PicdemBootloader::Hardware::internalConnectHardware() +{ + if ( !openPort() ) return false; + QMemArray<uchar> cmd(5); + cmd.fill(0); + if ( !port().sendAndReceive(cmd, 4) ) return false; + VersionData version(cmd[3], cmd[2], 0); + log(Log::LineType::Information, i18n("Bootloader version %1 detected").arg(version.pretty())); + if ( version.majorNum()!=1 ) { + log(Log::LineType::Error, i18n("Only bootloader version 1.x is supported")); + return false; + } + return true; +} + +uchar PicdemBootloader::Hardware::writeInstruction(Pic::MemoryRangeType type) +{ + switch (type.type()) { + case Pic::MemoryRangeType::Code: return 0x02; + case Pic::MemoryRangeType::Eeprom: return 0x05; + case Pic::MemoryRangeType::UserId: return 0x07; + default: Q_ASSERT(false); break; + } + return 0x00; +} + +bool PicdemBootloader::Hardware::write(Pic::MemoryRangeType type, const Device::Array &data) +{ + Q_ASSERT( data.count()==device().nbWords(type) ); + if ( type==Pic::MemoryRangeType::Code ) { // check that there is nothing in bootloader reserved area + for (uint i=0; i<data.count(); i++) { + if ( i>=0x400 ) continue; + if ( data[i]==device().mask(Pic::MemoryRangeType::Code) ) continue; + uint address = device().addressIncrement(Pic::MemoryRangeType::Code) * i; + log(Log::LineType::Warning, " " + i18n("Code is present in bootloader reserved area (at address %1). It will be ignored.").arg(toHexLabel(address, device().nbCharsAddress()))); + break; + } + } + uint nbBytesWord = device().nbBytesWord(type); + uint nbBytes = nbBytesWord * device().nbWords(type); + uint offset = (type==Pic::MemoryRangeType::Code ? 0x0800 : 0x00); + for (; offset<nbBytes; offset+=16) { + QMemArray<uchar> cmd = port().command(0x02, device().range(type).start.toUInt() + offset, 16, 16); + for (uint k=0; k<16; k += nbBytesWord) { + uint index = (offset + k) / nbBytesWord; + cmd[5 + k] = data[index].byte(0); + if ( nbBytesWord==2 ) cmd[5 + k+1] = data[index].byte(1); + } + if ( !port().sendAndReceive(cmd, 1) ) return false; + } + return true; +} + +uchar PicdemBootloader::Hardware::readInstruction(Pic::MemoryRangeType type) +{ + switch (type.type()) { + case Pic::MemoryRangeType::Code: return 0x01; + case Pic::MemoryRangeType::Eeprom: return 0x04; + case Pic::MemoryRangeType::Config: + case Pic::MemoryRangeType::DeviceId: + case Pic::MemoryRangeType::UserId: return 0x06; + default: Q_ASSERT(false); break; + } + return 0x00; +} + +bool PicdemBootloader::Hardware::read(Pic::MemoryRangeType type, Device::Array &data, const ::Programmer::VerifyData *vdata) +{ + data.resize(device().nbWords(type)); + Device::Array varray; + if (vdata) varray = static_cast<const Pic::Memory &>(vdata->memory).arrayForWriting(type); + uint nbBytesWord = device().nbBytesWord(type); + uint nbBytes = nbBytesWord * device().nbWords(type); + uint nb = QMIN(uint(16), nbBytes); + for (uint offset=0; offset<nbBytes; offset+=16) { + QMemArray<uchar> cmd = port().command(readInstruction(type), device().range(type).start.toUInt() + offset, nb, 0); + if ( !port().sendAndReceive(cmd, 5+nb) ) return false; + for (uint k=0; k<nb; k += nbBytesWord) { + uint index = (offset + k) / nbBytesWord; + data[index]= cmd[5 + k] & 0xFF; + if ( nbBytesWord==2 ) data[index] |= (cmd[5 + k+1] << 8); + if ( vdata && index>=0x0800 && data[index]!=varray[index] ) { + log(Log::LineType::Error, i18n("Device memory does not match hex file (at address 0x%2: reading 0x%3 and expecting 0x%4).") + .arg(QString(toHex(index/2, device().nbCharsAddress()))) + .arg(QString(toHex(data[index], device().nbCharsWord(type)))) + .arg(QString(toHex(varray[index], device().nbCharsWord(type))))); + return false; + } + } + } + return true; +} + +bool PicdemBootloader::Hardware::erase(Pic::MemoryRangeType type) +{ + if ( type==Pic::MemoryRangeType::Eeprom ) { + Pic::Memory memory(device()); + Device::Array data = memory.arrayForWriting(Pic::MemoryRangeType::Eeprom); + return write(Pic::MemoryRangeType::Eeprom, data); + } + uint nbBytesWord = device().nbBytesWord(type); + uint nbBytes = nbBytesWord * device().nbWords(type); + for (uint offset=0x0800; offset<nbBytes; offset+=64) { + QMemArray<uchar> cmd = port().command(0x03, device().range(type).start.toUInt() + offset, 1, 0); + if ( !port().sendAndReceive(cmd, 1) ) return false; + } + return true; +} diff --git a/src/progs/picdem_bootloader/base/picdem_bootloader.h b/src/progs/picdem_bootloader/base/picdem_bootloader.h new file mode 100644 index 0000000..3081382 --- /dev/null +++ b/src/progs/picdem_bootloader/base/picdem_bootloader.h @@ -0,0 +1,72 @@ +/*************************************************************************** + * 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 PICDEM_BOOTLOADER_H +#define PICDEM_BOOTLOADER_H + +#include "progs/bootloader/base/bootloader.h" +#include "common/port/usb_port.h" + +namespace PicdemBootloader +{ +//----------------------------------------------------------------------------- +class Config : public GenericConfig +{ +public: + static uint readVendorId(); + static void writeVendorId(uint id); + static uint readProductId(); + static void writeProductId(uint id); + +private: + Config() : GenericConfig("picdem_bootloader") {} +}; + +//----------------------------------------------------------------------------- +class Port : public ::Port::USB +{ +public: + Port(Log::Base &base); + bool receive(uint nb, QMemArray<uchar> &array); + bool send(const QMemArray<uchar> &array); + bool sendAndReceive(QMemArray<uchar> &data, uint nb); + QMemArray<uchar> command(uchar instruction, uint address, uint len, uint nb) const; +}; + +//----------------------------------------------------------------------------- +class Hardware : public Bootloader::Hardware +{ +public: + Hardware(::Programmer::Base &base); + Port &port() { return static_cast<Port &>(*_port); } + virtual bool write(Pic::MemoryRangeType type, const Device::Array &data); + virtual bool read(Pic::MemoryRangeType type, Device::Array &data, const ::Programmer::VerifyData *vdata); + virtual bool erase(Pic::MemoryRangeType type); + virtual bool internalConnectHardware(); + +private: + static uchar readInstruction(Pic::MemoryRangeType type); + static uchar writeInstruction(Pic::MemoryRangeType type); +}; + +//----------------------------------------------------------------------------- +class DeviceSpecific : public Bootloader::DeviceSpecific +{ +public: + DeviceSpecific(::Programmer::Base &base) : Bootloader::DeviceSpecific(base) {} + virtual bool canEraseAll() const { return true; } + virtual bool canEraseRange(Pic::MemoryRangeType type) const { return ( type==Pic::MemoryRangeType::Eeprom || type==Pic::MemoryRangeType::Code ); } + virtual bool canReadRange(Pic::MemoryRangeType) const { return true; } + virtual bool canWriteRange(Pic::MemoryRangeType type) const { return ( type==Pic::MemoryRangeType::Eeprom || type==Pic::MemoryRangeType::Code ); } + virtual bool doEraseRange(Pic::MemoryRangeType type) { return static_cast<Hardware &>(hardware()).erase(type); } + virtual bool doErase(bool) { return doEraseRange(Pic::MemoryRangeType::Code) && doEraseRange(Pic::MemoryRangeType::Eeprom); } +}; + +} // namespace + +#endif diff --git a/src/progs/picdem_bootloader/base/picdem_bootloader.xml b/src/progs/picdem_bootloader/base/picdem_bootloader.xml new file mode 100644 index 0000000..1cbfecb --- /dev/null +++ b/src/progs/picdem_bootloader/base/picdem_bootloader.xml @@ -0,0 +1,16 @@ +<!-- ************************************************************************* --> +<!-- * 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. * --> +<!-- *************************************************************************/--> +<!DOCTYPE piklab> + +<type name="picdem_bootloader"> + <device name="18F2455" family="generic" id="0x00" /> + <device name="18F2550" family="generic" id="0x00" /> + <device name="18F4455" family="generic" id="0x00" /> + <device name="18F4550" family="generic" id="0x00" /> +</type> diff --git a/src/progs/picdem_bootloader/base/picdem_bootloader_data.h b/src/progs/picdem_bootloader/base/picdem_bootloader_data.h new file mode 100644 index 0000000..bf2a40f --- /dev/null +++ b/src/progs/picdem_bootloader/base/picdem_bootloader_data.h @@ -0,0 +1,19 @@ +/*************************************************************************** + * 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 PICDEM_BOOTLOADER_DATA_H +#define PICDEM_BOOTLOADER_DATA_H + +namespace PicdemBootloader +{ + struct Data {}; + extern bool isSupported(const QString &device); + extern const Data &data(const QString &device); +} // namespace + +#endif diff --git a/src/progs/picdem_bootloader/base/picdem_bootloader_prog.cpp b/src/progs/picdem_bootloader/base/picdem_bootloader_prog.cpp new file mode 100644 index 0000000..72fc384 --- /dev/null +++ b/src/progs/picdem_bootloader/base/picdem_bootloader_prog.cpp @@ -0,0 +1,14 @@ +/*************************************************************************** + * 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 "picdem_bootloader_prog.h" + +//----------------------------------------------------------------------------- +PicdemBootloader::ProgrammerBase::ProgrammerBase(const Programmer::Group &group, const Pic::Data *data) + : Bootloader::ProgrammerBase(group, data, "picdem_bootloader_programmer_base") +{} diff --git a/src/progs/picdem_bootloader/base/picdem_bootloader_prog.h b/src/progs/picdem_bootloader/base/picdem_bootloader_prog.h new file mode 100644 index 0000000..698d612 --- /dev/null +++ b/src/progs/picdem_bootloader/base/picdem_bootloader_prog.h @@ -0,0 +1,46 @@ +/*************************************************************************** + * 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 PICDEM_BOOTLOADER_PROG_H +#define PICDEM_BOOTLOADER_PROG_H + +#include "progs/bootloader/base/bootloader_prog.h" +#include "picdem_bootloader.h" + +namespace PicdemBootloader +{ + +//----------------------------------------------------------------------------- +class ProgrammerBase : public Bootloader::ProgrammerBase +{ +Q_OBJECT +public: + ProgrammerBase(const Programmer::Group &group, const Pic::Data *data); +}; + +//----------------------------------------------------------------------------- +class Group : public ::Bootloader::Group +{ +public: + virtual QString name() const { return "picdem_bootloader"; } + virtual QString label() const { return i18n("Picdem Bootloader"); } + virtual ::Programmer::Properties properties() const { return ::Programmer::Programmer | ::Programmer::CanReadMemory; } + virtual ::Programmer::TargetPowerMode targetPowerMode() const { return ::Programmer::TargetSelfPowered; } + virtual bool isPortSupported(PortType type) const { return type==PortType::USB; } + virtual bool canReadVoltage(Pic::VoltageType) const { return false; } + +protected: + virtual void initSupported(); + virtual ::Programmer::Base *createBase(const Device::Data *data) const { return new ProgrammerBase(*this, static_cast<const Pic::Data *>(data)); } + virtual ::Programmer::Hardware *createHardware(::Programmer::Base &base, const ::Programmer::HardwareDescription &) const { return new Hardware(base); } + virtual ::Programmer::DeviceSpecific *createDeviceSpecific(::Programmer::Base &base) const { return new DeviceSpecific(base); } +}; + +} // namespace + +#endif diff --git a/src/progs/picdem_bootloader/gui/Makefile.am b/src/progs/picdem_bootloader/gui/Makefile.am new file mode 100644 index 0000000..57d10bb --- /dev/null +++ b/src/progs/picdem_bootloader/gui/Makefile.am @@ -0,0 +1,6 @@ +INCLUDES = -I$(top_srcdir)/src $(all_includes) +METASOURCES = AUTO + +noinst_LTLIBRARIES = libpicdembootloaderui.la +libpicdembootloaderui_la_LDFLAGS = $(all_libraries) +libpicdembootloaderui_la_SOURCES = picdem_bootloader_ui.cpp diff --git a/src/progs/picdem_bootloader/gui/picdem_bootloader_ui.cpp b/src/progs/picdem_bootloader/gui/picdem_bootloader_ui.cpp new file mode 100644 index 0000000..c958249 --- /dev/null +++ b/src/progs/picdem_bootloader/gui/picdem_bootloader_ui.cpp @@ -0,0 +1,48 @@ +/*************************************************************************** + * 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 "picdem_bootloader_ui.h" + +#include "progs/picdem_bootloader/base/picdem_bootloader.h" + +//----------------------------------------------------------------------------- +PicdemBootloader::ConfigWidget::ConfigWidget(const ::Programmer::Group &group, QWidget *parent) + : ::Programmer::ConfigWidget(group, parent) +{ + uint row = numRows(); + + QLabel *label = new QLabel(i18n("USB Vendor Id:"), this); + addWidget(label, row,row, 0,0); + _vendorId = new HexWordEditor(4, this); + addWidget(_vendorId, row,row, 1,1); + row++; + + label = new QLabel(i18n("USB Product Id:"), this); + addWidget(label, row,row, 0,0); + _productId = new HexWordEditor(4, this); + addWidget(_productId, row,row, 1,1); + row++; +} + +void PicdemBootloader::ConfigWidget::saveConfig() +{ + Config::writeVendorId(_vendorId->value().toUInt()); + Config::writeProductId(_productId->value().toUInt()); +} + +void PicdemBootloader::ConfigWidget::loadConfig() +{ + _vendorId->setValue(Config::readVendorId()); + _productId->setValue(Config::readProductId()); +} + +//----------------------------------------------------------------------------- +::Programmer::ConfigWidget *PicdemBootloader::GroupUI::createConfigWidget(QWidget *parent) const +{ + return new ConfigWidget(static_cast<const ::Programmer::Group &>(group()), parent); +} diff --git a/src/progs/picdem_bootloader/gui/picdem_bootloader_ui.h b/src/progs/picdem_bootloader/gui/picdem_bootloader_ui.h new file mode 100644 index 0000000..50777af --- /dev/null +++ b/src/progs/picdem_bootloader/gui/picdem_bootloader_ui.h @@ -0,0 +1,37 @@ +/*************************************************************************** + * 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 PICDEM_BOOTLOADER_UI_H +#define PICDEM_BOOTLOADER_UI_H + +#include "progs/bootloader/gui/bootloader_ui.h" + +namespace PicdemBootloader +{ +//---------------------------------------------------------------------------- +class ConfigWidget: public ::Programmer::ConfigWidget +{ +Q_OBJECT +public: + ConfigWidget(const ::Programmer::Group &group, QWidget *parent); + virtual void loadConfig(); + virtual void saveConfig(); + +private: + HexWordEditor *_vendorId, *_productId; +}; + +//---------------------------------------------------------------------------- +class GroupUI : public ::Bootloader::GroupUI +{ +public: + virtual ::Programmer::ConfigWidget *createConfigWidget(QWidget *parent) const; +}; +} // namespace + +#endif diff --git a/src/progs/picdem_bootloader/picdem_bootloader.pro b/src/progs/picdem_bootloader/picdem_bootloader.pro new file mode 100644 index 0000000..60ac0f5 --- /dev/null +++ b/src/progs/picdem_bootloader/picdem_bootloader.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +SUBDIRS = xml base diff --git a/src/progs/picdem_bootloader/xml/Makefile.am b/src/progs/picdem_bootloader/xml/Makefile.am new file mode 100644 index 0000000..5ed38e6 --- /dev/null +++ b/src/progs/picdem_bootloader/xml/Makefile.am @@ -0,0 +1,14 @@ +INCLUDES = -I$(top_srcdir)/src $(all_includes) +METASOURCES = AUTO + +noinst_PROGRAMS = xml_picdem_bootloader_parser +xml_picdem_bootloader_parser_SOURCES = xml_picdem_bootloader_parser.cpp +OBJECTS = $(top_builddir)/src/devices/list/libdevicelistnoui.la \ + $(top_builddir)/src/devices/pic/pic/libpic.la $(top_builddir)/src/devices/pic/base/libpicbase.la \ + $(top_builddir)/src/devices/pic/xml_data/libpicxml.la \ + $(top_builddir)/src/devices/mem24/mem24/libmem24.la $(top_builddir)/src/devices/mem24/base/libmem24base.la \ + $(top_builddir)/src/devices/mem24/xml_data/libmem24xml.la \ + $(top_builddir)/src/xml_to_data/libxmltodata.la $(top_builddir)/src/devices/base/libdevicebase.la \ + $(top_builddir)/src/common/common/libcommon.la +xml_picdem_bootloader_parser_DEPENDENCIES = $(OBJECTS) +xml_picdem_bootloader_parser_LDADD = $(OBJECTS) $(LIB_KDECORE) diff --git a/src/progs/picdem_bootloader/xml/xml.pro b/src/progs/picdem_bootloader/xml/xml.pro new file mode 100644 index 0000000..4e2eb15 --- /dev/null +++ b/src/progs/picdem_bootloader/xml/xml.pro @@ -0,0 +1,17 @@ +STOPDIR = ../../../.. +include($${STOPDIR}/app.pro) + +TARGET = xml_picdem_bootloader_parser +SOURCES += xml_picdem_bootloader_parser.cpp +LIBS += ../../../devices/list/libdevicelist.a \ + ../../../devices/mem24/mem24/libmem24.a ../../../devices/mem24/xml_data/libmem24xml.a \ + ../../../devices/mem24/base/libmem24base.a \ + ../../../devices/pic/pic/libpic.a ../../../devices/pic/xml_data/libpicxml.a \ + ../../../devices/pic/base/libpicbase.a ../../../xml_to_data/libxmltodata.a \ + ../../../devices/base/libdevicebase.a ../../../common/global/libglobal.a \ + ../../../common/nokde/libnokde.a ../../../common/common/libcommon.a + +unix:QMAKE_POST_LINK = cd ../base && ../xml/xml_picdem_bootloader_parser +unix:QMAKE_CLEAN += ../base/picdem_bootloader_data.cpp +win32:QMAKE_POST_LINK = cd ..\base && ..\xml\xml_picdem_bootloader_parser.exe +win32:QMAKE_CLEAN += ..\base\picdem_bootloader_data.cpp diff --git a/src/progs/picdem_bootloader/xml/xml_picdem_bootloader_parser.cpp b/src/progs/picdem_bootloader/xml/xml_picdem_bootloader_parser.cpp new file mode 100644 index 0000000..745b6a0 --- /dev/null +++ b/src/progs/picdem_bootloader/xml/xml_picdem_bootloader_parser.cpp @@ -0,0 +1,39 @@ +/*************************************************************************** + * 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 "xml_to_data/prog_xml_to_data.h" + +#include "progs/picdem_bootloader/base/picdem_bootloader_data.h" +#include "devices/base/device_group.h" +#include "devices/pic/base/pic.h" + +//----------------------------------------------------------------------------- +namespace PicdemBootloader +{ + +class XmlToData : public Programmer::XmlToData<Data> +{ +public: + XmlToData() : Programmer::XmlToData<Data>("picdem_bootloader", "PicdemBootloader") {} + +private: + virtual void parseData(QDomElement element, Data &data); +}; + +void PicdemBootloader::XmlToData::parseData(QDomElement, Data &) +{ + const Device::Data *ddata = Device::lister().data(currentDevice()); + if ( ddata->group().name()!="pic" ) qFatal("non-pic device not supported"); + const Pic::Data *pdata = static_cast<const Pic::Data *>(ddata); + if ( !pdata->hasFeature(Pic::Feature::USB) ) qFatal("device does not have USB"); +} + +} // namespace + +//----------------------------------------------------------------------------- +XML_MAIN(PicdemBootloader::XmlToData) |