URL
https://opencores.org/ocsvn/xulalx25soc/xulalx25soc/trunk
Subversion Repositories xulalx25soc
Compare Revisions
- This comparison shows the changes necessary to convert path
/xulalx25soc/trunk/sw
- from Rev 78 to Rev 91
- ↔ Reverse comparison
Rev 78 → Rev 91
/usbi.cpp
13,7 → 13,7
// |
//////////////////////////////////////////////////////////////////////////////// |
// |
// Copyright (C) 2015, Gisselquist Technology, LLC |
// Copyright (C) 2015-2016, Gisselquist Technology, LLC |
// |
// This program is free software (firmware): you can redistribute it and/or |
// modify it under the terms of the GNU General Public License as published |
44,6 → 44,8
#include "llcomms.h" |
#include "usbi.h" |
|
const bool DEBUG = false; |
|
// Walk us through the JTAG Chain: |
// 5-1's to go to test/reset |
// 0 to go to Run-Test/Idle |
291,7 → 293,7
if (len > 26) |
len = 26; |
|
// printf("USBI::RAW-READ(%d, was %d)\n", len, clen); |
if (DEBUG) printf("USBI::RAW-READ(%d, was %d)\n", len, clen); |
memcpy(m_txbuf, REQ_RX_BITS, REQ_RX_LEN); |
|
// I have chased process hangs to this line, but have no more |
306,11 → 308,11
// to it. Therefore, be careful to clear the device upon starting |
// any process. |
// |
// fprintf(stderr, "["); |
if(DEBUG) { printf("["); fflush(stdout); } |
int r = libusb_bulk_transfer(m_xula_usb_device, XESS_ENDPOINT_OUT, |
(unsigned char *)m_txbuf, REQ_RX_LEN, &actual_length, |
timeout_ms); |
// fprintf(stderr, "]"); |
if(DEBUG) { printf("]"); fflush(stdout); } |
|
if ((r==0)&&(actual_length == REQ_RX_LEN)) { |
} else if (r == -7) { |
329,12 → 331,12
r = libusb_bulk_transfer(m_xula_usb_device, XESS_ENDPOINT_IN, |
(unsigned char *)m_rxbuf, USB_PKTLEN, &actual_length, 0); |
if ((r==0)&&(actual_length > 0)) { |
/* |
printf("RAW-READ() -> %d Read\n", actual_length); |
for(int i=0; i<actual_length; i++) |
printf("%02x ", m_rxbuf[i] & 0x0ff); |
printf("\n"); |
*/ |
if (DEBUG) { |
printf("RAW-READ() -> %d Read\n", actual_length); |
for(int i=0; i<actual_length; i++) |
printf("%02x ", m_rxbuf[i] & 0x0ff); |
printf("\n"); |
} |
push_fifo(m_rxbuf, actual_length); |
} else if (r == -7) { |
// Nothing to read in the timeout provided |
361,6 → 363,8
// printf("Pushing %d items onto FIFO (%d - %d)\n", len, m_rend, m_rbeg); |
if (m_rbeg != m_rend) |
last = m_rbuf[m_rend]; |
if (DEBUG) |
printf("\tPushing:"); |
for(int i=0; i<len; i++) { |
char v = *sptr++; |
if (((v & 0x80)||((unsigned char)v < 0x10))&&(v == last)) { |
369,9 → 373,10
} else { |
m_rbuf[m_rbeg] = v; |
m_rbeg = (m_rbeg+1)&(RCV_BUFMASK); |
// printf("\tPushing: %02x\n", v & 0x0ff); |
if (DEBUG) |
printf(" %02x", v & 0x0ff); |
} last = v; |
} |
} if (DEBUG) printf("\n"); |
} |
|
int USBI::pop_fifo(char *buf, int len) { |
393,10 → 398,12
m_rend = (m_rend + ln)&(RCV_BUFMASK); |
nr += ln; |
|
// printf("P:"); |
// for(int i=0; i<ln; i++) |
// printf("%02x ", buf[len-left-ln+i]); |
} // printf("\n"); |
if (DEBUG) { |
printf("P:"); |
for(int i=0; i<ln; i++) |
printf("%02x ", buf[len-left-ln+i]); |
} |
} if (DEBUG) printf("\n"); |
|
/* |
if (nr > 0) |
434,3 → 441,14
// printf("USBI::poll() -> %s (%d avail)\n", (r)?"true":"false", avail); |
return r; |
} |
|
int USBI::available(void) { |
int avail = (m_rbeg-m_rend)&(RCV_BUFMASK); |
|
if (avail > 1) |
return avail; |
else if ((avail == 1)&&((m_rbuf[m_rend]&0x80)||(m_rbuf[m_rend]<0x10))) |
return 1; |
else |
return 0; |
} |
/llcomms.cpp
16,7 → 16,7
// |
//////////////////////////////////////////////////////////////////////////////// |
// |
// Copyright (C) 2015, Gisselquist Technology, LLC |
// Copyright (C) 2015-2016, Gisselquist Technology, LLC |
// |
// This program is free software (firmware): you can redistribute it and/or |
// modify it under the terms of the GNU General Public License as published |
78,8 → 78,10
} |
|
void LLCOMMSI::close(void) { |
if(m_fdw>=0) ::close(m_fdw); |
if((m_fdr>=0)&&(m_fdr != m_fdw)) ::close(m_fdr); |
if(m_fdw>=0) |
::close(m_fdw); |
if((m_fdr>=0)&&(m_fdr != m_fdw)) |
::close(m_fdr); |
m_fdw = m_fdr = -1; |
} |
|
95,6 → 97,10
} else return false; |
} |
|
int LLCOMMSI::available(void) { |
return poll(0)?1:0; |
} |
|
TTYCOMMS::TTYCOMMS(const char *dev) { |
m_fdr = ::open(dev, O_RDWR | O_NONBLOCK); |
if (m_fdr < 0) { |
/usbi.h
17,7 → 17,7
// |
//////////////////////////////////////////////////////////////////////////////// |
// |
// Copyright (C) 2015, Gisselquist Technology, LLC |
// Copyright (C) 2015-2016, Gisselquist Technology, LLC |
// |
// This program is free software (firmware): you can redistribute it and/or |
// modify it under the terms of the GNU General Public License as published |
85,6 → 85,7
virtual int read(char *buf, int len, int timeout_ms); |
virtual void write(char *buf, int len); |
virtual bool poll(unsigned ms); |
virtual int available(void); |
}; |
|
#endif // USBI_H |
/llcomms.h
16,7 → 16,7
// |
//////////////////////////////////////////////////////////////////////////////// |
// |
// Copyright (C) 2015, Gisselquist Technology, LLC |
// Copyright (C) 2015-2016, Gisselquist Technology, LLC |
// |
// This program is free software (firmware): you can redistribute it and/or |
// modify it under the terms of the GNU General Public License as published |
52,6 → 52,10
virtual void write(char *buf, int len); |
virtual int read(char *buf, int len); |
virtual bool poll(unsigned ms); |
|
// Tests whether or not bytes are available to be read, returns a |
// count of the bytes that may be immediately read |
virtual int available(void); // { return 0; }; |
}; |
|
class TTYCOMMS : public LLCOMMSI { |
/twoc.cpp
14,7 → 14,7
// |
/////////////////////////////////////////////////////////////////////////// |
// |
// Copyright (C) 2015, Gisselquist Technology, LLC |
// Copyright (C) 2015-2016, Gisselquist Technology, LLC |
// |
// This program is free software (firmware): you can redistribute it and/or |
// modify it under the terms of the GNU General Public License as published |
50,7 → 50,6
} |
|
bool sfits(const long val, const int bits) { |
// long alt = sbits(val, bits); |
return (sbits(val, bits) == bits); |
} |
|
/ziprun.cpp
23,7 → 23,7
// |
//////////////////////////////////////////////////////////////////////////////// |
// |
// Copyright (C) 2015, Gisselquist Technology, LLC |
// Copyright (C) 2015-2016, Gisselquist Technology, LLC |
// |
// This program is free software (firmware): you can redistribute it and/or |
// modify it under the terms of the GNU General Public License as published |
511,6 → 511,7
} |
} m_fpga->readio(R_VERSION); // Check for buserrors |
|
printf("Loading memory\n"); |
for(int i=0; secpp[i]->m_len; i++) { |
bool inflash=false; |
|
523,8 → 524,27
if (!flash) |
flash = new FLASHDRVR(m_fpga); |
flash->write(secp->m_start, secp->m_len, secp->m_data, true); |
} else |
} else if (secp->m_len < (1<<16)) { |
m_fpga->writei(secp->m_start, secp->m_len, secp->m_data); |
} else { |
// The load amount is so big, we'd like to let |
// the user know where we're at along the way. |
for(unsigned k=0; k<secp->m_len; k+=(1<<16)) { |
unsigned ln = (1<<16), |
st = secp->m_start+k; |
if (st+ln > secp->m_start+secp->m_len) |
ln = (secp->m_start+secp->m_len-st); |
if (ln <= 0) break; |
printf("Loading MEM[%08x]-MEM[%08x] ...\r", |
st,st+ln-1); fflush(stdout); |
m_fpga->writei(st, ln, &secp->m_data[k]); |
m_fpga->readio(R_VERSION); // Check for buserrors |
} printf("Loaded MEM[%08x]-MEM[%08x] \n", |
secp->m_start, |
secp->m_start+secp->m_len-1); |
fflush(stdout); |
} |
printf("%08x - %08x\n", secp->m_start, secp->m_start+secp->m_len); |
} |
m_fpga->readio(R_ZIPCTRL); // Check for bus errors |
|
553,7 → 573,7
printf("The CPU should be fully loaded, you may now start\n"); |
printf("it. To start the CPU, type wbregs cpu 0\n"); |
} catch(BUSERR a) { |
fprintf(stderr, "XULA-BUS error\n"); |
fprintf(stderr, "\nXULA-BUS error @0x%08x\n", a.addr); |
m_fpga->writeio(R_ZIPCTRL, CPU_RESET|CPU_HALT|CPU_CLRCACHE); |
exit(-2); |
} |