Skip to content

Commit

Permalink
Added support for Firewire debug data
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Kazanzides committed Jan 26, 2025
1 parent 9e53108 commit 9af04d0
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 4 deletions.
3 changes: 3 additions & 0 deletions lib/FpgaIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,9 @@ class FpgaIO : public BoardIO
// data Data to write to register
bool WriteFirewirePhy(unsigned char addr, unsigned char data);

// Print FireWire debug data
static void PrintFirewireDebug(std::ostream &debugStream, const quadlet_t *data);

protected:

// Accumulated firmware time
Expand Down
56 changes: 56 additions & 0 deletions lib/code/FpgaIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -764,3 +764,59 @@ bool FpgaIO::WriteFirewirePhy(unsigned char addr, unsigned char data)
quadlet_t write_data = 0x00001000 | static_cast<quadlet_t>(addr) << 8 | static_cast<quadlet_t>(data);
return port->WriteQuadlet(BoardId, BoardIO::FW_PHY_REQ, write_data);
}


void FpgaIO::PrintFirewireDebug(std::ostream &debugStream, const quadlet_t *data)
{
// Following structure must match DebugData in Firewire.v
struct DebugData {
char header[4]; // Quad 0
uint8_t misc_info; // Quad 1
uint8_t bus_info;
uint8_t lreq_info;
uint8_t state;
uint8_t numPhyStatus; // Quad 2
uint8_t numTxGrant;
uint8_t numRecv;
uint8_t numHubSendReq;
uint16_t stcount; // Quad 3
uint8_t numPktRecv;
uint8_t numEthSendReq;
};
const DebugData *p = reinterpret_cast<const DebugData *>(data);
if (strncmp(p->header, "DBG", 3) != 0) {
debugStream << " PrintFirewireDebug: Unexpected header string: " << p->header[0]
<< p->header[1] << p->header[2] << " (should be DBG)" << std::endl;
return;
}
debugStream << " State: " << static_cast<uint16_t>(p->state >> 4)
<< ", Next: " << static_cast<uint16_t>(p->state & 0xf0) << std::endl;
if (p->lreq_info & 0x80)
debugStream << " lreq_type: " << static_cast<uint16_t>((p->lreq_info & 0x70) >> 4) << std::endl;
if (p->lreq_info & 0x08)
debugStream << " lreq_busy" << std::endl;
debugStream << " tx_type: " << static_cast<uint16_t>(p->lreq_info & 0x07) << std::endl;
debugStream << " ";
if (p->bus_info & 0x80)
debugStream << "req_write_bus ";
if (p->bus_info & 0x40)
debugStream << "grant_write_bus ";
debugStream << "node_id: " << static_cast<uint16_t>(p->bus_info & 0x3f) << std::endl;
debugStream << " ";
if (p->misc_info & 0x80)
debugStream << "data_block ";
if (p->misc_info & 0x08)
debugStream << "recvCtlInvalid ";
if (p->misc_info & 0x04)
debugStream << "recvPktNull ";
if (p->misc_info & 0x02)
debugStream << "link_active ";
debugStream << " rx_speed: " << static_cast<uint16_t>((p->misc_info & 0x70)>>4) << std::endl;
debugStream << " numHubSendReq: " << static_cast<uint16_t>(p->numHubSendReq) << std::endl;
debugStream << " numRecv: " << static_cast<uint16_t>(p->numRecv) << std::endl;
debugStream << " numPktRecv: " << static_cast<uint16_t>(p->numPktRecv) << std::endl;
debugStream << " numTxGrant: " << static_cast<uint16_t>(p->numTxGrant) << std::endl;
debugStream << " numPhyStatus: " << static_cast<uint16_t>(p->numPhyStatus) << std::endl;
debugStream << " numEthSendReq: " << static_cast<uint16_t>(p->numEthSendReq) << std::endl;
debugStream << " stcount: " << p->stcount << std::endl;
}
20 changes: 16 additions & 4 deletions tests/mainEth1394.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1368,8 +1368,7 @@ int main(int argc, char **argv)
std::cout << " x) Read Ethernet debug data" << std::endl;
std::cout << " X) Clear Ethernet errors" << std::endl;
}
if (curBoardEth)
std::cout << " y) Read Firewire data via Ethernet" << std::endl;
std::cout << " y) Read Firewire debug data" << std::endl;
if (curBoardFw)
std::cout << " z) Check Ethernet initialization" << std::endl;
std::cout << "Select option: ";
Expand Down Expand Up @@ -1725,8 +1724,21 @@ int main(int argc, char **argv)
break;

case 'y':
if (curBoardEth && (curBoardEth->ReadFirewireData(buffer, 0, 64)))
EthBasePort::PrintFirewirePacket(std::cout, buffer, 64);
if (curBoardEth) {
if (curBoardEth->ReadFirewireData(buffer, 0, 64)) {
EthBasePort::PrintFirewirePacket(std::cout, buffer, 64);
}
if (curBoardEth->ReadFirewireData(buffer, 0x200, 4)) {
std::cout << "Firewire debug data (via " << EthPortString << "):" << std::endl;
FpgaIO::PrintFirewireDebug(std::cout, buffer);
}
}
if (curBoardFw) {
if (curBoardEth->ReadFirewireData(buffer, 0x200, 4)) {
std::cout << "Firewire debug data (via " << FwPortString << "):" << std::endl;
FpgaIO::PrintFirewireDebug(std::cout, buffer);
}
}
break;

case 'z':
Expand Down

0 comments on commit 9af04d0

Please sign in to comment.