diff --git a/xpp/astribank_tool.c b/xpp/astribank_tool.c index 7a88334..f3ca976 100644 --- a/xpp/astribank_tool.c +++ b/xpp/astribank_tool.c @@ -79,9 +79,6 @@ static int reset_kind(const char *arg) static int show_hardware(struct astribank_device *astribank) { - uint8_t unit; - uint8_t card_status; - uint8_t card_type; int ret; struct eeprom_table eeprom_table; struct capabilities capabilities; @@ -95,6 +92,12 @@ static int show_hardware(struct astribank_device *astribank) if(astribank->eeprom_type == EEPROM_TYPE_LARGE) { show_capabilities(&capabilities, stdout); if(STATUS_FPGA_LOADED(astribank->status)) { + uint8_t unit; + uint8_t card_status; + uint8_t card_type; + uint8_t fpga_configuration; + uint8_t status; + for(unit = 0; unit < 5; unit++) { ret = mpps_card_info(astribank, unit, &card_type, &card_status); if(ret < 0) @@ -103,6 +106,14 @@ static int show_hardware(struct astribank_device *astribank) ((card_type >> 4) & 0xF), (card_type & 0xF), ((card_status & 0x1) ? "PIC" : "NOPIC")); } + ret = mpps_stat(astribank, unit, &fpga_configuration, &status); + if (ret < 0) + return ret; + printf("FPGA: %-17s: %d\n", "Configuration num", fpga_configuration); + printf("FPGA: %-17s: %s\n", "Watchdog Timer", + (SER_STAT_WATCHDOG_READY(status)) ? "ready" : "expired"); + printf("FPGA: %-17s: %s\n", "XPD Alive", + (SER_STAT_XPD_ALIVE(status)) ? "yes" : "no"); } ret = mpp_extrainfo_get(astribank, &extrainfo); if(ret < 0) diff --git a/xpp/mpp.h b/xpp/mpp.h index e6b8e3a..53ea81e 100644 --- a/xpp/mpp.h +++ b/xpp/mpp.h @@ -95,6 +95,9 @@ struct mpp_header { enum mpp_ser_op { SER_CARD_INFO_GET = 0x1, SER_STAT_GET = 0x3, +/* Status bits */ +#define SER_STAT_WATCHDOG_READY(s) ((s) & 0x01) +#define SER_STAT_XPD_ALIVE(s) ((s) & 0x02) }; /* Individual commands structure */ diff --git a/xpp/mpptalk.c b/xpp/mpptalk.c index 6b33743..14de689 100644 --- a/xpp/mpptalk.c +++ b/xpp/mpptalk.c @@ -599,33 +599,59 @@ int mpp_serial_cmd(struct astribank_device *astribank, const uint8_t *in, uint8_ int mpps_card_info(struct astribank_device *astribank, int unit, uint8_t *card_type, uint8_t *card_status) { - struct card_info_send { + /* + * Serial commands must have equal send/receive size + */ + struct card_info_command { uint8_t ser_op; uint8_t addr; - } *card_info_send; - struct card_info_recv { - uint8_t ser_op_undef; /* invalid data */ - uint8_t addr; uint8_t card_full_type; /* (type << 4 | subtype) */ uint8_t card_status; /* BIT(0) - PIC burned */ - } *card_info_recv; - uint8_t in[sizeof(struct card_info_recv)]; - uint8_t out[sizeof(struct card_info_recv)]; - int len; - int ret; + } PACKED; + struct card_info_command ci_send; + struct card_info_command ci_recv; + int ret; - len = sizeof(struct card_info_recv); - memset(in, 0, len); - memset(out, 0, len); - card_info_send = (struct card_info_send *)∈ - card_info_recv = (struct card_info_recv *)&out; - card_info_send->ser_op = SER_CARD_INFO_GET; - card_info_send->addr = (unit << 4); /* low nibble is subunit */ - ret = mpp_serial_cmd(astribank, in, out, len); + memset(&ci_send, 0, sizeof(ci_send)); + memset(&ci_recv, 0, sizeof(ci_recv)); + ci_send.ser_op = SER_CARD_INFO_GET; + ci_send.addr = (unit << 4); /* low nibble is subunit */ + ret = mpp_serial_cmd(astribank, + (uint8_t *)&ci_send, + (uint8_t *)&ci_recv, + sizeof(struct card_info_command)); + if (ret < 0) + return ret; + *card_type = ci_recv.card_full_type; + *card_status = ci_recv.card_status; + return 0; +} + +int mpps_stat(struct astribank_device *astribank, int unit, uint8_t *fpga_configuration, uint8_t *status) +{ + /* + * Serial commands must have equal send/receive size + */ + struct fpga_stat_command { + uint8_t ser_op; + uint8_t fpga_configuration; + uint8_t status; /* BIT(0) - Watchdog timer status */ + } PACKED; + struct fpga_stat_command fs_send; + struct fpga_stat_command fs_recv; + int ret; + + memset(&fs_send, 0, sizeof(fs_send)); + memset(&fs_recv, 0, sizeof(fs_recv)); + fs_send.ser_op = SER_STAT_GET; + ret = mpp_serial_cmd(astribank, + (uint8_t *)&fs_send, + (uint8_t *)&fs_recv, + sizeof(struct fpga_stat_command)); if(ret < 0) return ret; - *card_type = card_info_recv->card_full_type; - *card_status = card_info_recv->card_status; + *fpga_configuration = fs_recv.fpga_configuration; + *status = fs_recv.status; return 0; } diff --git a/xpp/mpptalk.h b/xpp/mpptalk.h index ca3e0f9..49db037 100644 --- a/xpp/mpptalk.h +++ b/xpp/mpptalk.h @@ -69,6 +69,7 @@ int twinstar_show(struct astribank_device *astribank, FILE *fp); * Serial commands to FPGA */ int mpps_card_info(struct astribank_device *astribank, int unit, uint8_t *card_type, uint8_t *card_status); +int mpps_stat(struct astribank_device *astribank, int unit, uint8_t *maincard_version, uint8_t *status); /* * Twinstar