diff --git a/src/altera.cpp b/src/altera.cpp index 438c54d..b1aaf4a 100644 --- a/src/altera.cpp +++ b/src/altera.cpp @@ -58,7 +58,7 @@ int Altera::idCode() unsigned char rx_data[4]; _jtag->go_test_logic_reset(); _jtag->shiftIR(tx_data, NULL, IRLENGTH); - bzero(tx_data, 4); + memset(tx_data, 0, 4); _jtag->shiftDR(tx_data, rx_data, 32); return ((rx_data[0] & 0x000000ff) | ((rx_data[1] << 8) & 0x0000ff00) | diff --git a/src/bitparser.cpp b/src/bitparser.cpp index 4ebb43f..42172a9 100644 --- a/src/bitparser.cpp +++ b/src/bitparser.cpp @@ -2,7 +2,16 @@ #include #include #include +#ifndef _WIN32 #include +#else +// WARNING: this will be incorrect on ARM-based windows platforms +// that are big-endian, but the rest of this code has not been tested for +// those platforms anyway. +uint16_t ntohs(uint16_t netshort) { + return ((netshort & 0xFF) << 8) | ((netshort & 0xFF00) >> 8); +} +#endif using namespace std; diff --git a/src/dirtyJtag.cpp b/src/dirtyJtag.cpp index fa43ead..f176395 100644 --- a/src/dirtyJtag.cpp +++ b/src/dirtyJtag.cpp @@ -169,7 +169,7 @@ int DirtyJtag::writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end) if (tx) memcpy(tx_cpy, tx, real_byte_len); else - bzero(tx_cpy, real_byte_len); + memset(tx_cpy, 0, real_byte_len); tx_ptr = tx_cpy; /* first send 30 x 8 bits */ @@ -178,7 +178,7 @@ int DirtyJtag::writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end) uint8_t bit_to_send = (real_bit_len > 240) ? 240 : real_bit_len; uint8_t byte_to_send = (bit_to_send + 7) / 8; tx_buf[1] = bit_to_send; - bzero(tx_buf + 2, 30); + memset(tx_buf + 2, 0, 30); for (int i = 0; i < bit_to_send; i++) if (tx_ptr[i >> 3] & (1 << (i & 0x07))) tx_buf[2 + (i >> 3)] |= (0x80 >> (i & 0x07)); diff --git a/src/ftdiJtagBitbang.cpp b/src/ftdiJtagBitbang.cpp index 2f8344f..19ec9ab 100644 --- a/src/ftdiJtagBitbang.cpp +++ b/src/ftdiJtagBitbang.cpp @@ -74,7 +74,7 @@ void FtdiJtagBitBang::init_internal(const FTDIpp_MPSSE::mpsse_bit_config &cable, setClkFreq(_clkHZ); _in_buf = (unsigned char *)malloc(sizeof(unsigned char) * _buffer_size); - bzero(_in_buf, _buffer_size); + memset(_in_buf, 0, _buffer_size); init(1, _tck_pin | _tms_pin | _tdi_pin, BITMODE_BITBANG, (FTDIpp_MPSSE::mpsse_bit_config &)cable); setBitmode(BITMODE_BITBANG); @@ -162,7 +162,7 @@ int FtdiJtagBitBang::writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end) if (len == 0) return 0; if (rx) - bzero(rx, len/8); + memset(rx, 0, len/8); for (uint32_t i = 0, pos = 0; i < len; i++) { /* keep tms or diff --git a/src/ftdipp_mpsse.cpp b/src/ftdipp_mpsse.cpp index 4de2277..0d220a9 100644 --- a/src/ftdipp_mpsse.cpp +++ b/src/ftdipp_mpsse.cpp @@ -2,7 +2,6 @@ #include #include #include -#include #include #include diff --git a/src/gowin.cpp b/src/gowin.cpp index ce85bee..1f2e641 100644 --- a/src/gowin.cpp +++ b/src/gowin.cpp @@ -246,7 +246,7 @@ bool Gowin::wr_rd(uint8_t cmd, xfer_len = tx_len; uint8_t xfer_tx[xfer_len], xfer_rx[xfer_len]; - bzero(xfer_tx, xfer_len); + memset(xfer_tx, 0, xfer_len); int i; if (tx != NULL) { for (i = 0; i < tx_len; i++) @@ -335,7 +335,7 @@ bool Gowin::flashFLASH(uint8_t *data, int length) int nb_iter; int byte_length = length / 8; uint8_t tt[39]; - bzero(tt, 39); + memset(tt, 0, 39); _jtag->go_test_logic_reset(); diff --git a/src/jtag.cpp b/src/jtag.cpp index 6a831d3..d48d10d 100644 --- a/src/jtag.cpp +++ b/src/jtag.cpp @@ -111,7 +111,7 @@ void Jtag::init_internal(cable_t &cable, const string &dev, } _tms_buffer = (unsigned char *)malloc(sizeof(unsigned char) * _tms_buffer_size); - bzero(_tms_buffer, _tms_buffer_size); + memset(_tms_buffer, 0, _tms_buffer_size); } int Jtag::detectChain(vector &devices, int max_dev) @@ -164,7 +164,7 @@ int Jtag::flushTMS(bool flush_buffer) ret = _jtag->writeTMS(_tms_buffer, _num_tms, flush_buffer); /* reset buffer and number of bits */ - bzero(_tms_buffer, _tms_buffer_size); + memset(_tms_buffer, 0, _tms_buffer_size); _num_tms = 0; } else if (flush_buffer) { _jtag->flush(); diff --git a/src/lattice.cpp b/src/lattice.cpp index 9e7e62c..dd0b65a 100644 --- a/src/lattice.cpp +++ b/src/lattice.cpp @@ -614,7 +614,7 @@ bool Lattice::wr_rd(uint8_t cmd, uint8_t xfer_tx[xfer_len]; uint8_t xfer_rx[xfer_len]; - bzero(xfer_tx, xfer_len); + memset(xfer_tx, 0, xfer_len); int i; if (tx != NULL) { for (i = 0; i < tx_len; i++) @@ -793,7 +793,7 @@ bool Lattice::Verify(std::vector data, bool unlock) tx_buf[0] = REG_CFG_FLASH; _jtag->shiftIR(tx_buf, NULL, 8, Jtag::PAUSE_IR); - bzero(tx_buf, 16); + memset(tx_buf, 0, 16); bool failure = false; ProgressBar progress("Verifying", data.size(), 50); for (size_t line = 0; line< data.size(); line++) { @@ -826,7 +826,7 @@ uint64_t Lattice::readFeaturesRow() uint8_t tx_buf[8]; uint8_t rx_buf[8]; uint64_t reg = 0; - bzero(tx_buf, 8); + memset(tx_buf, 0, 8); wr_rd(READ_FEATURE_ROW, tx_buf, 8, rx_buf, 8); for (int i = 0; i < 8; i++) reg |= ((uint64_t)rx_buf[i] << (i*8)); diff --git a/src/latticeBitParser.cpp b/src/latticeBitParser.cpp index 2279397..66cb9c5 100644 --- a/src/latticeBitParser.cpp +++ b/src/latticeBitParser.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #include diff --git a/src/main.cpp b/src/main.cpp index 3177d52..e97f3ae 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -185,9 +185,9 @@ int main(int argc, char **argv) delete(jtag); } -// parse double from string in enginerring notation +// parse double from string in engineering notation // can deal with postfixes k and m, add more when required -static error_t parse_eng(string arg, double *dst) { +static int parse_eng(string arg, double *dst) { try { size_t end; double base = stod(arg, &end); @@ -209,7 +209,7 @@ static error_t parse_eng(string arg, double *dst) { return EINVAL; } } catch (...) { - cerr << "error : speed: invaild format" << endl; + cerr << "error : speed: invalid format" << endl; return EINVAL; } }