trabucayre/openFPGALoader#38 minor adjustments for MinGW build - use memset instead of bzero, errno_t may be replaced by int, provide ad-hoc ntohs on windows (alternative is link against winsock)
This commit is contained in:
parent
3f4086ec89
commit
d24c63ec8a
|
|
@ -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) |
|
||||
|
|
|
|||
|
|
@ -2,7 +2,16 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
#ifndef _WIN32
|
||||
#include <arpa/inet.h>
|
||||
#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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <iostream>
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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<int> &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();
|
||||
|
|
|
|||
|
|
@ -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<std::string> 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));
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue