[dahdi-commits] tzafrir: tools/trunk r10501 - /tools/trunk/xpp/

SVN commits to the DAHDI project dahdi-commits at lists.digium.com
Thu Mar 15 15:43:22 CDT 2012


Author: tzafrir
Date: Thu Mar 15 15:43:18 2012
New Revision: 10501

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=10501
Log:
xpp: Add info to astribank_tool -Q

* In MPP serial protocol add support for SER_STAT_GET command
* Use it to query firmware for:
  - FPGA build configuration number (1 - old main, 2 - new main)
  - Watchdog timer state bit (ready/expired)
  - XPD Alive timer state bit (yes/no)
* Also cleanup the code in mpps_card_info():
  - In all MPP serial commands the send/recive buffers must
    have identical size
  - No need to alias struct pointers to byte-buffers, just use
    the structs themselves as buffers.


Signed-off-by: Oron Peled <oron.peled at xorcom.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>

Modified:
    tools/trunk/xpp/astribank_tool.c
    tools/trunk/xpp/mpp.h
    tools/trunk/xpp/mpptalk.c
    tools/trunk/xpp/mpptalk.h

Modified: tools/trunk/xpp/astribank_tool.c
URL: http://svnview.digium.com/svn/dahdi/tools/trunk/xpp/astribank_tool.c?view=diff&rev=10501&r1=10500&r2=10501
==============================================================================
--- tools/trunk/xpp/astribank_tool.c (original)
+++ tools/trunk/xpp/astribank_tool.c Thu Mar 15 15:43:18 2012
@@ -79,9 +79,6 @@
 
 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 @@
 	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 @@
 						((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)

Modified: tools/trunk/xpp/mpp.h
URL: http://svnview.digium.com/svn/dahdi/tools/trunk/xpp/mpp.h?view=diff&rev=10501&r1=10500&r2=10501
==============================================================================
--- tools/trunk/xpp/mpp.h (original)
+++ tools/trunk/xpp/mpp.h Thu Mar 15 15:43:18 2012
@@ -95,6 +95,9 @@
 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 */

Modified: tools/trunk/xpp/mpptalk.c
URL: http://svnview.digium.com/svn/dahdi/tools/trunk/xpp/mpptalk.c?view=diff&rev=10501&r1=10500&r2=10501
==============================================================================
--- tools/trunk/xpp/mpptalk.c (original)
+++ tools/trunk/xpp/mpptalk.c Thu Mar 15 15:43:18 2012
@@ -599,33 +599,59 @@
 
 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;
-
-	len = sizeof(struct card_info_recv);
-	memset(in, 0, len);
-	memset(out, 0, len);
-	card_info_send = (struct card_info_send *)&in;
-	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);
+	} PACKED;
+	struct card_info_command ci_send;
+	struct card_info_command ci_recv;
+	int ret;
+
+	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;
 }
 

Modified: tools/trunk/xpp/mpptalk.h
URL: http://svnview.digium.com/svn/dahdi/tools/trunk/xpp/mpptalk.h?view=diff&rev=10501&r1=10500&r2=10501
==============================================================================
--- tools/trunk/xpp/mpptalk.h (original)
+++ tools/trunk/xpp/mpptalk.h Thu Mar 15 15:43:18 2012
@@ -69,6 +69,7 @@
  * 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




More information about the dahdi-commits mailing list