openFPGALoader/src/device.hpp

69 lines
1.5 KiB
C++
Raw Normal View History

2021-06-26 15:24:07 +02:00
// SPDX-License-Identifier: Apache-2.0
/*
* Copyright (C) 2019 Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
*/
2019-09-26 18:29:20 +02:00
#ifndef DEVICE_HPP
#define DEVICE_HPP
#include <iostream>
2021-02-18 21:09:34 +01:00
#include <string>
2019-09-26 18:29:20 +02:00
#include "display.hpp"
#include "jtag.hpp"
2019-09-26 18:29:20 +02:00
/* GGM: TODO: program must have an optional
* offset
* and question: bitstream to load bitstream in SPI mode must
* be hardcoded or provided by user?
*/
class Device {
public:
enum prog_mode {
NONE_MODE = 0,
SPI_MODE = 1,
FLASH_MODE = 1,
MEM_MODE = 2,
READ_MODE = 3,
2019-09-26 18:29:20 +02:00
};
2021-02-18 21:09:34 +01:00
typedef enum {
WR_SRAM = 0,
WR_FLASH = 1,
RD_FLASH = 2,
PRG_NONE = 3
2021-02-18 21:09:34 +01:00
} prog_type_t;
Device(Jtag *jtag, std::string filename, const std::string &file_type,
bool verify, int8_t verbose = false);
virtual ~Device();
virtual void program(unsigned int offset,
bool unprotect_flash) = 0;
/**********************/
/* flash access */
/**********************/
virtual bool dumpFlash(uint32_t base_addr, uint32_t len) {
(void) base_addr; (void) len;
printError("dump flash not supported"); return false;}
virtual bool protect_flash(uint32_t len) = 0;
virtual bool unprotect_flash() = 0;
virtual bool bulk_erase_flash() = 0;
virtual int idCode() = 0;
virtual void reset();
2021-02-18 21:09:34 +01:00
virtual bool connectJtagToMCU() {return false;}
2019-09-26 18:29:20 +02:00
protected:
Jtag *_jtag;
2019-09-26 18:29:20 +02:00
std::string _filename;
std::string _file_extension;
2019-09-26 18:29:20 +02:00
enum prog_mode _mode;
bool _verify; /**< verify flash write */
2019-11-21 08:38:11 +01:00
bool _verbose;
bool _quiet;
2019-09-26 18:29:20 +02:00
};
#endif