Line 1... |
Line 1... |
//
|
////////////////////////////////////////////////////////////////////////////////
|
//
|
//
|
// Filename: ttybus.cpp
|
// Filename: ttybus.cpp
|
//
|
//
|
// Project: UART to WISHBONE FPGA library
|
// Project: OpenArty, an entirely open SoC based upon the Arty platform
|
//
|
//
|
// Purpose: This is the C++ program on the command side that will interact
|
// Purpose: This is the C++ program on the command side that will interact
|
// with a UART on an FPGA, to command the WISHBONE on that same
|
// with a UART on an FPGA, to command the WISHBONE on that same
|
// FPGA to ... whatever we wish to command it to do.
|
// FPGA to ... whatever we wish to command it to do.
|
//
|
//
|
// This code does not run on an FPGA, is not a test bench, neither
|
// This code does not run on an FPGA, is not a test bench, neither
|
// is it a simulator. It is a portion of a command program
|
// is it a simulator. It is a portion of a command program
|
// for commanding an FPGA.
|
// for commanding an FPGA.
|
//
|
//
|
// Creator: Dan Gisselquist
|
// Creator: Dan Gisselquist, Ph.D.
|
// Gisselquist Tecnology, LLC
|
// 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
|
|
// by the Free Software Foundation, either version 3 of the License, or (at
|
|
// your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
// for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License along
|
|
// with this program. (It's in the $(ROOT)/doc directory, run make with no
|
|
// target there if the PDF file isn't present.) If not, see
|
|
// <http://www.gnu.org/licenses/> for a copy.
|
//
|
//
|
// Copyright: 2015
|
// License: GPL, v3, as defined and found on www.gnu.org,
|
|
// http://www.gnu.org/licenses/gpl.html
|
|
//
|
|
//
|
|
////////////////////////////////////////////////////////////////////////////////
|
//
|
//
|
//
|
//
|
#include <sys/socket.h>
|
#include <sys/socket.h>
|
#include <sys/types.h>
|
#include <sys/types.h>
|
#include <sys/stat.h>
|
#include <sys/stat.h>
|
Line 197... |
Line 220... |
while(nw < len) {
|
while(nw < len) {
|
int ln = len-nw;
|
int ln = len-nw;
|
if ((unsigned)ln > MAXWRLEN)
|
if ((unsigned)ln > MAXWRLEN)
|
ln = MAXWRLEN;
|
ln = MAXWRLEN;
|
|
|
|
DBGPRINTF("WRITEV-SUB(%08x%s,#%d,&buf[%d])\n", a+nw, (p)?"++":"", ln, nw);
|
for(int i=0; i<ln; i++) {
|
for(int i=0; i<ln; i++) {
|
BUSW val = buf[nw+i];
|
BUSW val = buf[nw+i];
|
|
|
int caddr = 0;
|
int caddr = 0;
|
// Let's try compression
|
// Let's try compression
|
Line 270... |
Line 294... |
// message.
|
// message.
|
readidle();
|
readidle();
|
}
|
}
|
|
|
void TTYBUS::writez(const BUSW a, const int len, const BUSW *buf) {
|
void TTYBUS::writez(const BUSW a, const int len, const BUSW *buf) {
|
/*
|
|
int ln = len;
|
|
const TTYBUS::BUSW *bptr = buf;
|
|
TTYBUS::BUSW addr = a;
|
|
|
|
while((unsigned)ln > MAXWRLEN) {
|
|
writev(addr, 0, MAXWRLEN, bptr);
|
|
bptr += MAXWRLEN;
|
|
ln -= MAXWRLEN;
|
|
// addr += MAXWRLEN;
|
|
} if ((unsigned)ln > 0)
|
|
writev(addr, 0, ln, bptr);
|
|
*/
|
|
writev(a, 0, len, buf);
|
writev(a, 0, len, buf);
|
}
|
}
|
|
|
void TTYBUS::writei(const BUSW a, const int len, const BUSW *buf) {
|
void TTYBUS::writei(const BUSW a, const int len, const BUSW *buf) {
|
/*
|
|
int ln = len;
|
|
const TTYBUS::BUSW *bptr = buf;
|
|
TTYBUS::BUSW addr = a;
|
|
|
|
while((unsigned)ln > MAXWRLEN) {
|
|
writev(addr, 1, MAXWRLEN, bptr);
|
|
bptr += MAXWRLEN;
|
|
ln -= MAXWRLEN;
|
|
addr += MAXWRLEN;
|
|
} if ((unsigned)ln > 0)
|
|
writev(addr, 1, ln, bptr);
|
|
*/
|
|
writev(a, 1, len, buf);
|
writev(a, 1, len, buf);
|
}
|
}
|
|
|
TTYBUS::BUSW TTYBUS::readio(const TTYBUS::BUSW a) {
|
TTYBUS::BUSW TTYBUS::readio(const TTYBUS::BUSW a) {
|
BUSW v;
|
BUSW v;
|
Line 498... |
Line 496... |
do {
|
do {
|
// Blocking read (for now)
|
// Blocking read (for now)
|
do {
|
do {
|
nr = lclreadcode(&m_buf[0], 1);
|
nr = lclreadcode(&m_buf[0], 1);
|
} while (nr < 1);
|
} while (nr < 1);
|
DBGPRINTF("READWORD: -- lclreadcode, nr = %d, m_buf[0] = %c\n", m_buf[0]);
|
DBGPRINTF("READWORD: -- lclreadcode, nr = %d, m_buf[0] = %c\n", nr, m_buf[0]);
|
|
|
sixbits = chardec(m_buf[0]);
|
sixbits = chardec(m_buf[0]);
|
|
|
if (sixbits&(~0x03f)) {
|
if (sixbits&(~0x03f)) {
|
// Ignore new lines, unprintables, and characters
|
// Ignore new lines, unprintables, and characters
|