OpenCores
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 7 to Rev 11
    Reverse comparison

Rev 7 → Rev 11

/usbi.cpp
1,6 → 1,6
////////////////////////////////////////////////////////////////////////////////
//
// Filename:
// Filename: usbi.cpp
//
// Project: XuLA2 board
//
/usbi.h
1,3 → 1,41
////////////////////////////////////////////////////////////////////////////////
//
// Filename: usbi.h
//
// Project: XuLA2 board
//
// Purpose: This package attempts to convet a JTAG over USB based
// communication system into something similar to a serial port
// based communication system. Some differences include the fact that,
// if the USB port isn't polled, nothing comes out of the port. Hence,
// on connecting (or polling for the first time) ... there might be a
// bunch of stuff to (initially) ignore.
//
//
// Creator: Dan Gisselquist, Ph.D.
// Gisselquist Technology, LLC
//
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015, 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.
//
// License: GPL, v3, as defined and found on www.gnu.org,
// http://www.gnu.org/licenses/gpl.html
//
//
////////////////////////////////////////////////////////////////////////////////
//
//
#ifndef USBI_H
#define USBI_H
 
/regdefs.h
131,15 → 131,11
#define SDRAMBASE 0x00800000
// Zip CPU Control and Debug registers
#define R_ZIPCTRL 0x01000000
#define R_ZIPDATA 0x01100001
#define R_ZIPDATA 0x01000001
 
 
// Interrupt control constants
#define GIE 0x80000000 // Enable all interrupts
#define ISPIF_EN 0x80040004 // Enable all, enable SPI, clear SPI
#define ISPIF_DIS 0x00040000 // Disable all, disable SPI
#define ISPIF_CLR 0x00000004 // Clear SPI interrupt
#define SCOPEN 0x80080008 // Enable WBSCOPE interrupts
 
// Flash control constants
#define ERASEFLAG 0x80000000
/ziprun.cpp
94,9 → 94,8
exit(-1);
}
 
// FPGAOPEN(m_fpga);
 
printf("Halting the CPU\n");
m_fpga->usleep(5);
m_fpga->writeio(R_ZIPCTRL, CPU_RESET|CPU_HALT);
 
fp = fopen(argv[0], "r");
149,10 → 148,9
printf("Clearing the cache\n");
m_fpga->writeio(R_ZIPCTRL, CPU_RESET|CPU_HALT|CPU_CLRCACHE);
 
// printf("Clearing all registers to zero, PC regs to MEMBASE\n");
printf("Clearing all registers to zero, PC regs to MEMBASE\n");
// Clear all registers to zero
for(int i=0; i<32; i++) {
unsigned int v;
try {
m_fpga->writeio(R_ZIPCTRL, CPU_HALT|i);
m_fpga->readio(R_ZIPCTRL);
161,9 → 159,9
}
try {
if ((i&0x0f)==0x0f)
m_fpga->writeio(R_ZIPDATA, RAMBASE);
m_fpga->writeio(R_ZIPDATA, RAMBASE);
else
m_fpga->writeio(R_ZIPDATA, 0);
m_fpga->writeio(R_ZIPDATA, 0);
// printf("REG[%2x] <= %08x\n", i, ((i&0x0f)==0x0f)?RAMBASE:0);
// m_fpga->readio(R_ZIPDATA);
// printf("\t= %08x\n", m_fpga->readio(R_ZIPDATA));
170,7 → 168,11
} catch(BUSERR a) {
fprintf(stderr, "Bus-ERR while trying to clear reg %x\n", i);
}
} for(int i=32; i<32+16; i++) {
}
 
printf("Clearing all peripherals\n");
for(int i=32; i<32+16; i++) {
try {
if (i==33)
continue; // Don't start the watchdog
/ttybus.cpp
68,10 → 68,25
const unsigned TTYBUS::MAXRDLEN = 1024;
const unsigned TTYBUS::MAXWRLEN = 32;
 
#define DBGPRINTF null
// #define DBGPRINTF null
// #define DBGPRINTF printf
void null(...) {}
// void null(...) {}
#define DBGPRINTF filedump
 
#include <stdarg.h>
// #include <varargs.h>
void filedump(const char *fmt, ...) {
static FILE *dbgfp = NULL;
va_list args;
 
if (!dbgfp)
dbgfp = fopen("debug.txt", "w");
va_start(args, fmt);
vfprintf(dbgfp, fmt, args);
va_end(args);
fflush(dbgfp);
}
 
char TTYBUS::charenc(const int sixbitval) {
if (sixbitval < 10)
return '0' + sixbitval;
265,6 → 280,7
 
// I/O reads are now the same as vector reads, but with a vector length
// of one.
DBGPRINTF("READIO(0x%08x)\n", a);
try {
readv(a, 0, 1, &v);
} catch(BUSERR b) {
312,7 → 328,7
*ptr++ = charenc( diffaddr & 0x03f);
}
*ptr = '\0';
// DBGPRINTF("DIF-ADDR: (%ld) \'%s\'\n", ptr-m_buf, m_buf);
DBGPRINTF("DIF-ADDR: (%ld) \'%s\'\n", ptr-m_buf, m_buf);
}
 
{
325,13 → 341,13
*ptr++ = charenc(0x08);
*ptr++ = charenc(addr);
} else if((addr <= 0x0fff)&&((ptr == m_buf)||(ptr >= &m_buf[3]))) {
// DBGPRINTF("Setting ADDR.3 to %08x\n", addr);
DBGPRINTF("Setting ADDR.3 to %08x\n", addr);
ptr = m_buf;
*ptr++ = charenc(0x0a);
*ptr++ = charenc((addr>> 6) & 0x03f);
*ptr++ = charenc( addr & 0x03f);
} else if((addr <= 0x03ffff)&&((ptr == m_buf)||(ptr >= &m_buf[4]))) {
// DBGPRINTF("Setting ADDR.4 to %08x\n", addr);
DBGPRINTF("Setting ADDR.4 to %08x\n", addr);
ptr = m_buf;
*ptr++ = charenc(0x0c);
*ptr++ = charenc((addr>>12) & 0x03f);
338,7 → 354,7
*ptr++ = charenc((addr>> 6) & 0x03f);
*ptr++ = charenc( addr & 0x03f);
} else if((addr <= 0x0ffffff)&&((ptr == m_buf)||(ptr >= &m_buf[5]))) {
// DBGPRINTF("Setting ADDR.5 to %08x\n", addr);
DBGPRINTF("Setting ADDR.5 to %08x\n", addr);
ptr = m_buf;
*ptr++ = charenc(0x0e);
*ptr++ = charenc((addr>>18) & 0x03f);
353,7 → 369,7
}
 
*ptr = '\0';
// DBGPRINTF("ADDR-CMD: (%ld) \'%s\'\n", ptr-m_buf, m_buf);
DBGPRINTF("ADDR-CMD: (%ld) \'%s\'\n", ptr-m_buf, m_buf);
m_rdaddr = 0;
 
return ptr;
362,7 → 378,7
char *TTYBUS::readcmd(const int inc, const int len, char *buf) {
char *ptr = buf;
 
// DBGPRINTF("READCMD: LEN = %d\n", len);
DBGPRINTF("READCMD: LEN = %d\n", len);
assert(len < 520);
assert(len > 0);
 
384,7 → 400,7
 
if (len <= 0)
return;
// DBGPRINTF("READV(%08x,%d,#%4d)\n", a, inc, len);
DBGPRINTF("READV(%08x,%d,#%4d)\n", a, inc, len);
 
ptr = encode_address(a);
try {
414,6 → 430,7
}
if ((unsigned)m_lastaddr != (a+((inc)?(len):0))) {
DBGPRINTF("TTYBUS::READV(a=%08x,inc=%d,len=%4x,x) ERR: (Last) %08x != %08x + %08x (Expected)\n", a, inc, len, m_lastaddr, a, (inc)?(len):0);
printf("TTYBUS::READV(a=%08x,inc=%d,len=%4x,x) ERR: (Last) %08x != %08x + %08x (Expected)\n", a, inc, len, m_lastaddr, a, (inc)?(len):0);
sleep(1);
assert((int)m_lastaddr == (a+(inc)?(len):0));
434,7 → 451,7
int nr;
unsigned sixbits;
 
// DBGPRINTF("READ-WORD()\n");
DBGPRINTF("READ-WORD()\n");
 
bool found_start = false;
do {
481,7 → 498,7
m_addr_set = true;
m_lastaddr = val;
 
// DBGPRINTF("RCVD ADDR: 0x%08x\n", val);
DBGPRINTF("RCVD ADDR: 0x%08x\n", val);
} else if (0x0c == (sixbits & 0x03c)) { // Set 32-bit address,compressed
int nw = (sixbits & 0x03) + 2;
do {
506,7 → 523,7
 
m_addr_set = true;
m_lastaddr = val;
// DBGPRINTF("RCVD ADDR: 0x%08x (%d bytes)\n", val, nw+1);
DBGPRINTF("RCVD ADDR: 0x%08x (%d bytes)\n", val, nw+1);
} else
found_start = true;
} while(!found_start);
563,16 → 580,16
} for(int i=0; i<nr; i++) {
if (m_buf[i] == TTYC_INT) {
m_interrupt_flag = true;
// DBGPRINTF("!!!!!!!!!!!!!!!!! ----- INTERRUPT!\n");
DBGPRINTF("!!!!!!!!!!!!!!!!! ----- INTERRUPT!\n");
} else if (m_buf[i] == TTYC_IDLE) {
// DBGPRINTF("Interface is now idle\n");
DBGPRINTF("Interface is now idle\n");
} else if (m_buf[i] == TTYC_WRITE) {
} else if (m_buf[i] == TTYC_RESET) {
// DBGPRINTF("Bus was RESET!\n");
DBGPRINTF("Bus was RESET!\n");
} else if (m_buf[i] == TTYC_ERR) {
DBGPRINTF("Bus error\n");
} else if (m_buf[i] == TTYC_BUSY) {
// DBGPRINTF("Interface is ... busy ??\n");
DBGPRINTF("Interface is ... busy ??\n");
}
// else if (m_buf[nr] == 'Q')
// else if (m_buf[nr] == 'W')
/Makefile
33,7 → 33,7
##
.PHONY: all
PROGRAMS := $(OBJDIR) usbtst wbregs netusb wbsettime dumpflash \
dumpsdram ziprun ramscope
dumpsdram ziprun ramscope zipstate zipdbg
all: $(PROGRAMS)
CXX := g++
LIBUSBINC := -I/usr/include/libusb-1.0/
81,6 → 81,8
$(CXX) $(CFLAGS) $^ $(LIBS) -o $@
ziprun: $(OBJDIR)/ziprun.o $(BUSOBJS)
$(CXX) $(CFLAGS) $^ $(LIBS) -o $@
zipstate: $(OBJDIR)/zipstate.o $(BUSOBJS)
$(CXX) $(CFLAGS) $^ $(LIBS) -o $@
ZIPOBJS_RAW := twoc.o zparser.o zopcodes.o
ZIPOBJS := $(addprefix $(ZIPD)/$(OBJDIR)/,$(ZIPOBJS_RAW))
zipdbg: $(OBJDIR)/zipdbg.o $(BUSOBJS) $(ZIPOBJS)

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.