summaryrefslogtreecommitdiffstats
path: root/src/progs/bootloader/base
diff options
context:
space:
mode:
Diffstat (limited to 'src/progs/bootloader/base')
-rw-r--r--src/progs/bootloader/base/Makefile.am5
-rw-r--r--src/progs/bootloader/base/base.pro6
-rw-r--r--src/progs/bootloader/base/bootloader.cpp9
-rw-r--r--src/progs/bootloader/base/bootloader.h42
-rw-r--r--src/progs/bootloader/base/bootloader_prog.cpp25
-rw-r--r--src/progs/bootloader/base/bootloader_prog.h37
6 files changed, 124 insertions, 0 deletions
diff --git a/src/progs/bootloader/base/Makefile.am b/src/progs/bootloader/base/Makefile.am
new file mode 100644
index 0000000..7c7230d
--- /dev/null
+++ b/src/progs/bootloader/base/Makefile.am
@@ -0,0 +1,5 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libbootloader.la
+libbootloader_la_SOURCES = bootloader_prog.cpp bootloader.cpp
diff --git a/src/progs/bootloader/base/base.pro b/src/progs/bootloader/base/base.pro
new file mode 100644
index 0000000..f53b730
--- /dev/null
+++ b/src/progs/bootloader/base/base.pro
@@ -0,0 +1,6 @@
+STOPDIR = ../../../..
+include($${STOPDIR}/lib.pro)
+
+TARGET = bootloader
+HEADERS += bootloader.h bootloader_prog.h
+SOURCES += bootloader.cpp bootloader_prog.cpp
diff --git a/src/progs/bootloader/base/bootloader.cpp b/src/progs/bootloader/base/bootloader.cpp
new file mode 100644
index 0000000..a45a23f
--- /dev/null
+++ b/src/progs/bootloader/base/bootloader.cpp
@@ -0,0 +1,9 @@
+/***************************************************************************
+ * 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 "bootloader.h"
diff --git a/src/progs/bootloader/base/bootloader.h b/src/progs/bootloader/base/bootloader.h
new file mode 100644
index 0000000..08a0730
--- /dev/null
+++ b/src/progs/bootloader/base/bootloader.h
@@ -0,0 +1,42 @@
+/***************************************************************************
+ * 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 BOOTLOADER_H
+#define BOOTLOADER_H
+
+#include "devices/pic/prog/pic_prog.h"
+
+namespace Bootloader
+{
+//-----------------------------------------------------------------------------
+class Hardware : public ::Programmer::PicHardware
+{
+public:
+ Hardware(::Programmer::Base &base, Port::Base *port) : ::Programmer::PicHardware(base, port, QString::null) {}
+ virtual bool write(Pic::MemoryRangeType type, const Device::Array &data) = 0;
+ virtual bool read(Pic::MemoryRangeType type, Device::Array &data, const ::Programmer::VerifyData *vdata) = 0;
+ virtual bool internalConnectHardware() = 0;
+ virtual bool openPort() { return _port->open(); }
+};
+
+//-----------------------------------------------------------------------------
+class DeviceSpecific : public ::Programmer::PicDeviceSpecific
+{
+public:
+ DeviceSpecific(::Programmer::Base &base) : ::Programmer::PicDeviceSpecific(base) {}
+ Hardware &hardware() { return static_cast<Hardware &>(*_base.hardware()); }
+ virtual bool setPowerOff() { return false; }
+ virtual bool setPowerOn() { return false; }
+ virtual bool setTargetPowerOn(bool) { return true; }
+ virtual bool doRead(Pic::MemoryRangeType type, Device::Array &data, const ::Programmer::VerifyData *vdata) { return hardware().read(type, data, vdata); }
+ virtual bool doWrite(Pic::MemoryRangeType type, const Device::Array &data, bool) { return hardware().write(type, data); }
+};
+
+} // namespace
+
+#endif
diff --git a/src/progs/bootloader/base/bootloader_prog.cpp b/src/progs/bootloader/base/bootloader_prog.cpp
new file mode 100644
index 0000000..61167f8
--- /dev/null
+++ b/src/progs/bootloader/base/bootloader_prog.cpp
@@ -0,0 +1,25 @@
+/***************************************************************************
+ * 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 "bootloader_prog.h"
+
+#include "progs/base/prog_config.h"
+
+//-----------------------------------------------------------------------------
+Bootloader::ProgrammerBase::ProgrammerBase(const Programmer::Group &group, const Pic::Data *data, const char *name)
+ : Programmer::PicBase(group, data, name)
+{}
+
+//-----------------------------------------------------------------------------
+bool Bootloader::Group::checkConnection(const ::Programmer::HardwareDescription &hd) const
+{
+ ::Programmer::Base *base = createProgrammer(false, 0, hd);
+ bool ok = static_cast<Hardware *>(base->hardware())->openPort();
+ delete base;
+ return ok;
+}
diff --git a/src/progs/bootloader/base/bootloader_prog.h b/src/progs/bootloader/base/bootloader_prog.h
new file mode 100644
index 0000000..7b9749e
--- /dev/null
+++ b/src/progs/bootloader/base/bootloader_prog.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 BOOTLOADER_PROG_H
+#define BOOTLOADER_PROG_H
+
+#include "common/global/generic_config.h"
+#include "bootloader.h"
+
+namespace Bootloader
+{
+//-----------------------------------------------------------------------------
+class ProgrammerBase : public Programmer::PicBase
+{
+Q_OBJECT
+public:
+ ProgrammerBase(const Programmer::Group &group, const Pic::Data *data, const char *name);
+
+protected:
+ Hardware &hardware() { return static_cast<Hardware &>(*_hardware); }
+};
+
+//-----------------------------------------------------------------------------
+class Group : public ::Programmer::PicGroup
+{
+public:
+ virtual bool checkConnection(const ::Programmer::HardwareDescription &hd) const;
+};
+
+} // namespace
+
+#endif