Kludge scsimon back together so it compiles

This commit is contained in:
Tony Kuker 2022-10-28 20:53:25 -05:00
parent 6f855715a1
commit feda864def
6 changed files with 80 additions and 63 deletions

View File

@ -60,12 +60,6 @@ public:
// Get the string phase name, based upon the raw data
static const char* GetPhaseStrRaw(phase_t current_phase);
// Extract as specific pin field from a raw data capture
static inline uint32_t GetPinRaw(uint32_t raw_data, uint32_t pin_num)
{
return ((raw_data >> pin_num) & 1);
}
virtual bool GetBSY() const = 0;
virtual void SetBSY(bool ast) = 0;

View File

@ -466,6 +466,16 @@ bool GPIOBUS::GetDP() const
return GetSignal(board->pin_dp);
}
// Extract as specific pin field from a raw data capture
uint32_t GPIOBUS::GetPinRaw(uint32_t raw_data, board_type::pi_physical_pin_e pin_num){
// return GetSignalRaw(raw_data, pin_num);
(void)raw_data;
(void)pin_num;
LOGWARN("THIS FUNCTION ISN'T IMPLEMENTED YET");
return 0;
}
//---------------------------------------------------------------------------
//
// Receive command handshake

View File

@ -326,6 +326,14 @@ class GPIOBUS : public BUS
// Set REQ signal
bool GetDP() const override;
// Get Data parity signal
// Extract as specific pin field from a raw data capture
uint32_t GetPinRaw(uint32_t raw_data, board_type::pi_physical_pin_e pin_num);
// TODO: SCSIMON needs to be re-worked to work differently. For now, a quick
// and dirty hack is just to expose the current board type data structure.
shared_ptr<board_type::Rascsi_Board_Type> GetBoard(){return board;}
int CommandHandShake(BYTE *buf) override;
// Command receive handshake
int ReceiveHandShake(BYTE *buf, int count) override;

View File

@ -13,6 +13,7 @@
#include "scsi.h"
#include "hal/gpiobus.h"
#include "hal/board_type.h"
using data_capture_t = struct data_capture
{
@ -22,27 +23,30 @@ using data_capture_t = struct data_capture
#define GET_PIN(SAMPLE, PIN) ((bool)((SAMPLE->data >> PIN) & 1))
inline bool GetBsy(const data_capture *sample) { return BUS::GetPinRaw(sample->data, PIN_BSY); }
inline bool GetSel(const data_capture *sample) { return BUS::GetPinRaw(sample->data, PIN_SEL); }
inline bool GetAtn(const data_capture *sample) { return BUS::GetPinRaw(sample->data, PIN_ATN); }
inline bool GetAck(const data_capture *sample) { return BUS::GetPinRaw(sample->data, PIN_ACK); }
inline bool GetRst(const data_capture *sample) { return BUS::GetPinRaw(sample->data, PIN_RST); }
inline bool GetMsg(const data_capture *sample) { return BUS::GetPinRaw(sample->data, PIN_MSG); }
inline bool GetCd(const data_capture *sample) { return BUS::GetPinRaw(sample->data, PIN_CD); }
inline bool GetIo(const data_capture *sample) { return BUS::GetPinRaw(sample->data, PIN_IO); }
inline bool GetReq(const data_capture *sample) { return BUS::GetPinRaw(sample->data, PIN_REQ); }
inline bool GetDp(const data_capture *sample) { return BUS::GetPinRaw(sample->data, PIN_DP); }
extern shared_ptr<GPIOBUS> bus; // GPIO Bus
inline bool GetBsy(const data_capture *sample) { return bus->GetPinRaw(sample->data, bus->GetBoard()->pin_bsy); }
inline bool GetSel(const data_capture *sample) { return bus->GetPinRaw(sample->data, bus->GetBoard()->pin_sel); }
inline bool GetAtn(const data_capture *sample) { return bus->GetPinRaw(sample->data, bus->GetBoard()->pin_atn); }
inline bool GetAck(const data_capture *sample) { return bus->GetPinRaw(sample->data, bus->GetBoard()->pin_ack); }
inline bool GetRst(const data_capture *sample) { return bus->GetPinRaw(sample->data, bus->GetBoard()->pin_rst); }
inline bool GetMsg(const data_capture *sample) { return bus->GetPinRaw(sample->data, bus->GetBoard()->pin_msg); }
inline bool GetCd(const data_capture *sample) { return bus->GetPinRaw(sample->data, bus->GetBoard()->pin_cd); }
inline bool GetIo(const data_capture *sample) { return bus->GetPinRaw(sample->data, bus->GetBoard()->pin_io); }
inline bool GetReq(const data_capture *sample) { return bus->GetPinRaw(sample->data, bus->GetBoard()->pin_req); }
inline bool GetDp(const data_capture *sample) { return bus->GetPinRaw(sample->data, bus->GetBoard()->pin_dp); }
inline BYTE GetData(const data_capture *sample)
{
uint32_t data = sample->data;
return (BYTE)((data >> (PIN_DT0 - 0)) & (1 << 0)) |
((data >> (PIN_DT1 - 1)) & (1 << 1)) |
((data >> (PIN_DT2 - 2)) & (1 << 2)) |
((data >> (PIN_DT3 - 3)) & (1 << 3)) |
((data >> (PIN_DT4 - 4)) & (1 << 4)) |
((data >> (PIN_DT5 - 5)) & (1 << 5)) |
((data >> (PIN_DT6 - 6)) & (1 << 6)) |
((data >> (PIN_DT7 - 7)) & (1 << 7));
uint32_t result = 0;
result |= (bus->GetPinRaw(sample->data, bus->GetBoard()->pin_dt0) != 0) ? (1 << 0) : 0;
result |= (bus->GetPinRaw(sample->data, bus->GetBoard()->pin_dt1) != 0) ? (1 << 1) : 0;
result |= (bus->GetPinRaw(sample->data, bus->GetBoard()->pin_dt2) != 0) ? (1 << 2) : 0;
result |= (bus->GetPinRaw(sample->data, bus->GetBoard()->pin_dt3) != 0) ? (1 << 3) : 0;
result |= (bus->GetPinRaw(sample->data, bus->GetBoard()->pin_dt4) != 0) ? (1 << 4) : 0;
result |= (bus->GetPinRaw(sample->data, bus->GetBoard()->pin_dt5) != 0) ? (1 << 5) : 0;
result |= (bus->GetPinRaw(sample->data, bus->GetBoard()->pin_dt6) != 0) ? (1 << 6) : 0;
result |= (bus->GetPinRaw(sample->data, bus->GetBoard()->pin_dt7) != 0) ? (1 << 7) : 0;
return result;
}
const char *GetPhaseStr(const data_capture *sample);

View File

@ -20,6 +20,8 @@
using namespace std;
extern shared_ptr<GPIOBUS> bus;
//---------------------------------------------------------------------------
//
// Constant declarations
@ -49,28 +51,27 @@ const int PIN_PHASE = 0;
// Variable declarations
//
//---------------------------------------------------------------------------
static BYTE prev_value[32] = {0xFF};
// TODO: prev_value can be smaller. Just making up a big number for now
static BYTE prev_value[128] = {0xFF};
extern double ns_per_loop;
static BYTE get_pin_value(uint32_t data, int pin)
static BYTE get_pin_value(uint32_t data, board_type::pi_physical_pin_e pin)
{
return (data >> pin) & 1;
return bus->GetPinRaw(data, pin);
// return (data >> pin) & 1;
}
static BYTE get_data_field(uint32_t data)
{
const uint32_t data_out =
((data >> (PIN_DT0 - 0)) & (1 << 7)) |
((data >> (PIN_DT1 - 1)) & (1 << 6)) |
((data >> (PIN_DT2 - 2)) & (1 << 5)) |
((data >> (PIN_DT3 - 3)) & (1 << 4)) |
((data >> (PIN_DT4 - 4)) & (1 << 3)) |
((data >> (PIN_DT5 - 5)) & (1 << 2)) |
((data >> (PIN_DT6 - 6)) & (1 << 1)) |
((data >> (PIN_DT7 - 7)) & (1 << 0));
// TODO: This is a quick hack to re-use the GetData() function from data_sample.h
const struct data_capture dummy_data_capture =
{
.data = data,
.timestamp = 0,
};
return GetData(&dummy_data_capture);
return (BYTE)data_out;
}
static void vcd_output_if_changed_phase(ofstream& fp, uint32_t data, int pin, char symbol)
@ -82,11 +83,11 @@ static void vcd_output_if_changed_phase(ofstream& fp, uint32_t data, int pin, ch
}
}
static void vcd_output_if_changed_bool(ofstream& fp, uint32_t data, int pin, char symbol)
static void vcd_output_if_changed_bool(ofstream& fp, uint32_t data, board_type::pi_physical_pin_e pin, char symbol)
{
const BYTE new_value = get_pin_value(data, pin);
if (prev_value[pin] != new_value) {
prev_value[pin] = new_value;
if (prev_value[(int)pin] != new_value) {
prev_value[(int)pin] = new_value;
fp << new_value << symbol << endl;
}
}
@ -97,14 +98,14 @@ static void vcd_output_if_changed_byte(ofstream& fp, uint32_t data, int pin, cha
if (prev_value[pin] != new_value) {
prev_value[pin] = new_value;
fp << "b"
<< fmt::format("{0:b}", get_pin_value(data, PIN_DT7))
<< fmt::format("{0:b}", get_pin_value(data, PIN_DT6))
<< fmt::format("{0:b}", get_pin_value(data, PIN_DT5))
<< fmt::format("{0:b}", get_pin_value(data, PIN_DT4))
<< fmt::format("{0:b}", get_pin_value(data, PIN_DT3))
<< fmt::format("{0:b}", get_pin_value(data, PIN_DT2))
<< fmt::format("{0:b}", get_pin_value(data, PIN_DT1))
<< fmt::format("{0:b}", get_pin_value(data, PIN_DT0))
<< fmt::format("{0:b}", get_pin_value(data, bus->GetBoard()->pin_dt7))
<< fmt::format("{0:b}", get_pin_value(data, bus->GetBoard()->pin_dt6))
<< fmt::format("{0:b}", get_pin_value(data, bus->GetBoard()->pin_dt5))
<< fmt::format("{0:b}", get_pin_value(data, bus->GetBoard()->pin_dt4))
<< fmt::format("{0:b}", get_pin_value(data, bus->GetBoard()->pin_dt3))
<< fmt::format("{0:b}", get_pin_value(data, bus->GetBoard()->pin_dt2))
<< fmt::format("{0:b}", get_pin_value(data, bus->GetBoard()->pin_dt1))
<< fmt::format("{0:b}", get_pin_value(data, bus->GetBoard()->pin_dt0))
<< " " << symbol << endl;
}
}
@ -166,16 +167,16 @@ void scsimon_generate_value_change_dump(const char *filename, const data_capture
uint32_t i = 0;
while (i < capture_count) {
vcd_ofstream << "#" << (uint64_t)(data_capture_array[i].timestamp * ns_per_loop) << endl;
vcd_output_if_changed_bool(vcd_ofstream, data_capture_array[i].data, PIN_BSY, SYMBOL_PIN_BSY);
vcd_output_if_changed_bool(vcd_ofstream, data_capture_array[i].data, PIN_SEL, SYMBOL_PIN_SEL);
vcd_output_if_changed_bool(vcd_ofstream, data_capture_array[i].data, PIN_CD, SYMBOL_PIN_CD);
vcd_output_if_changed_bool(vcd_ofstream, data_capture_array[i].data, PIN_IO, SYMBOL_PIN_IO);
vcd_output_if_changed_bool(vcd_ofstream, data_capture_array[i].data, PIN_MSG, SYMBOL_PIN_MSG);
vcd_output_if_changed_bool(vcd_ofstream, data_capture_array[i].data, PIN_REQ, SYMBOL_PIN_REQ);
vcd_output_if_changed_bool(vcd_ofstream, data_capture_array[i].data, PIN_ACK, SYMBOL_PIN_ACK);
vcd_output_if_changed_bool(vcd_ofstream, data_capture_array[i].data, PIN_ATN, SYMBOL_PIN_ATN);
vcd_output_if_changed_bool(vcd_ofstream, data_capture_array[i].data, PIN_RST, SYMBOL_PIN_RST);
vcd_output_if_changed_byte(vcd_ofstream, data_capture_array[i].data, PIN_DT0, SYMBOL_PIN_DAT);
vcd_output_if_changed_bool(vcd_ofstream, data_capture_array[i].data, bus->GetBoard()->pin_bsy, SYMBOL_PIN_BSY);
vcd_output_if_changed_bool(vcd_ofstream, data_capture_array[i].data, bus->GetBoard()->pin_sel, SYMBOL_PIN_SEL);
vcd_output_if_changed_bool(vcd_ofstream, data_capture_array[i].data, bus->GetBoard()->pin_cd, SYMBOL_PIN_CD);
vcd_output_if_changed_bool(vcd_ofstream, data_capture_array[i].data, bus->GetBoard()->pin_io, SYMBOL_PIN_IO);
vcd_output_if_changed_bool(vcd_ofstream, data_capture_array[i].data, bus->GetBoard()->pin_msg, SYMBOL_PIN_MSG);
vcd_output_if_changed_bool(vcd_ofstream, data_capture_array[i].data, bus->GetBoard()->pin_req, SYMBOL_PIN_REQ);
vcd_output_if_changed_bool(vcd_ofstream, data_capture_array[i].data, bus->GetBoard()->pin_ack, SYMBOL_PIN_ACK);
vcd_output_if_changed_bool(vcd_ofstream, data_capture_array[i].data, bus->GetBoard()->pin_atn, SYMBOL_PIN_ATN);
vcd_output_if_changed_bool(vcd_ofstream, data_capture_array[i].data, bus->GetBoard()->pin_rst, SYMBOL_PIN_RST);
vcd_output_if_changed_byte(vcd_ofstream, data_capture_array[i].data, (int)bus->GetBoard()->pin_dt0, SYMBOL_PIN_DAT);
vcd_output_if_changed_phase(vcd_ofstream, data_capture_array[i].data, PIN_PHASE, SYMBOL_PIN_PHASE);
i++;
}

View File

@ -33,7 +33,7 @@ static const int _MAX_FNAME = 256;
//
//---------------------------------------------------------------------------
static volatile bool running; // Running flag
unique_ptr<GPIOBUS> bus; // GPIO Bus
shared_ptr<GPIOBUS> bus; // GPIO Bus
uint32_t buff_size = 1000000;
data_capture *data_buffer;
@ -151,7 +151,7 @@ void Banner(int, char *[])
}
else {
LOGINFO("Reading live data from the GPIO pins")
LOGINFO(" Connection type : %s", CONNECT_DESC.c_str())
LOGINFO(" Connection type : %s", bus->GetConnectDesc().c_str())
}
LOGINFO(" Data buffer size: %u", buff_size)
LOGINFO(" ")
@ -331,13 +331,13 @@ int main(int argc, char *argv[])
(void)gettimeofday(&start_time, nullptr);
LOGDEBUG("ALL_SCSI_PINS %08X\n", ALL_SCSI_PINS)
// LOGDEBUG("ALL_SCSI_PINS %08X\n", ALL_SCSI_PINS)
// Main Loop
while (running)
{
// Work initialization
this_sample = (bus->Acquire() & ALL_SCSI_PINS);
this_sample = (bus->Acquire());// & ALL_SCSI_PINS);
loop_count++;
if (loop_count > LLONG_MAX - 1)
{