Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
92 lines (85 sloc) 2.72 KB
////////////////////////////////////////////////////////////////////////////////
//
// Filename: regdefs.cpp
//
// Project: dbgbus, a collection of 8b channel to WB bus debugging protocols
//
// Purpose:
//
// Creator: Dan Gisselquist, Ph.D.
// Gisselquist Technology, LLC
//
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017, Gisselquist Technology, LLC
//
// This file is part of the debugging interface demonstration.
//
// The debugging interface demonstration is free software (firmware): you can
// redistribute it and/or modify it under the terms of the GNU Lesser General
// Public License as published by the Free Software Foundation, either version
// 3 of the License, or (at your option) any later version.
//
// This debugging interface demonstration 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 Lesser
// General Public License for more details.
//
// You should have received a copy of the GNU Lesser 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.
//
// License: LGPL, v3, as defined and found on www.gnu.org,
// http://www.gnu.org/licenses/lgpl.html
//
//
////////////////////////////////////////////////////////////////////////////////
//
//
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <ctype.h>
#include "regdefs.h"
const REGNAME raw_bregs[] = {
{ R_VERSION , "VERSION" },
{ R_BUSERR , "BUSERR" },
{ R_PWRCOUNT , "PWRCOUNT" },
{ R_INT , "int" },
{ R_HALT , "halt" },
{ R_SCOPE , "SCOPE" },
{ R_SCOPD , "SCOPD" },
{ R_MEM , "MEM" },
{ R_MEM , "RAM" }
};
// REGSDEFS.CPP.INSERT for any bus masters
// And then from the peripherals
// And finally any master REGS.CPP.INSERT tags
#define RAW_NREGS (sizeof(raw_bregs)/sizeof(bregs[0]))
const REGNAME *bregs = raw_bregs;
const int NREGS = RAW_NREGS;
unsigned addrdecode(const char *v) {
if (isalpha(v[0])) {
for(int i=0; i<NREGS; i++)
if (strcasecmp(v, bregs[i].m_name)==0)
return bregs[i].m_addr;
fprintf(stderr, "Unknown register: %s\n", v);
exit(-2);
#ifdef R_ZIPCTRL
} else if (strcasecmp(v, "CPU")==0) {
return R_ZIPCTRL;
#endif // R_ZIPCTRL
#ifdef R_ZIPDATA
} else if (strcasecmp(v, "CPUD")==0) {
return R_ZIPDATA;
#endif // R_ZIPDATA
} else
return strtoul(v, NULL, 0);
}
const char *addrname(const unsigned v) {
for(int i=0; i<NREGS; i++)
if (bregs[i].m_addr == v)
return bregs[i].m_name;
return NULL;
}