Attributes2.c.html 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <?xml version='1.0' encoding='iso-8859-1'?>
  2. <!doctype html public '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
  3. <html xmlns='http://www.w3c.org/1999/xhtml' lang='en-us'>
  4. <head>
  5. <title>
  6. Attributes2.c
  7. </title>
  8. <meta http-equiv='content-type' content='text/html;iso-8859-1'/>
  9. <meta name='generator' content='motley-tools 1.9.4 13:40:33 Feb 18 2015'/>
  10. <meta name='author' content='cmaier@cmassoc.net'/>
  11. <meta name='robots' content='noindex,nofollow'/>
  12. <link href='toolkit.css' rel='stylesheet' type='text/css'/>
  13. </head>
  14. <body>
  15. <div class='headerlink'>
  16. [<a href='Attributes1.c.html' title=' Attributes1.c '>PREV</a>]
  17. [<a href='toolkit.html' title=' Index '>HOME</a>]
  18. [<a href='Attributes.c.html' title=' Attributes.c '>NEXT</a>]
  19. </div>
  20. <pre>
  21. /*====================================================================*
  22. *
  23. * Copyright (c) 2013 Qualcomm Atheros, Inc.
  24. *
  25. * All rights reserved.
  26. *
  27. * Redistribution and use in source and binary forms, with or
  28. * without modification, are permitted (subject to the limitations
  29. * in the disclaimer below) provided that the following conditions
  30. * are met:
  31. *
  32. * * Redistributions of source code must retain the above copyright
  33. * notice, this list of conditions and the following disclaimer.
  34. *
  35. * * Redistributions in binary form must reproduce the above
  36. * copyright notice, this list of conditions and the following
  37. * disclaimer in the documentation and/or other materials
  38. * provided with the distribution.
  39. *
  40. * * Neither the name of Qualcomm Atheros nor the names of
  41. * its contributors may be used to endorse or promote products
  42. * derived from this software without specific prior written
  43. * permission.
  44. *
  45. * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
  46. * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE
  47. * COPYRIGHT HOLDERS AND CONTRIBUTORS &quot;AS IS&quot; AND ANY EXPRESS OR
  48. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  49. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  50. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
  51. * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  52. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  53. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  54. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  55. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  56. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  57. * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  58. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  59. *
  60. *--------------------------------------------------------------------*/
  61. /*====================================================================*
  62. *
  63. * signed Attributes2 (struct plc * plc);
  64. *
  65. * plc.h
  66. *
  67. * This plugin for program plc requests device attributes using
  68. * a VS_OP_ATTRIBUTES message; attributes are pre-parsed versions
  69. * of information returned by VS_SW_VER and other messages;
  70. *
  71. * The VS_OP_ATTRIBUTES message structure changed between FW 3.3.4
  72. * and 3.3.5 and fields are ocassionally appended to the end; you
  73. * should not use this message for operational systems because the
  74. * format may change again; it was originally intended for PTS use
  75. * only;
  76. *
  77. *
  78. * Contributor(s):
  79. * Charles Maier &lt;cmaier@qca.qualcomm.com&gt;
  80. *
  81. *--------------------------------------------------------------------*/
  82. #ifndef ATTRIBUTES2_SOURCE
  83. #define ATTRIBUTES2_SOURCE
  84. #include &lt;stdint.h&gt;
  85. #include &lt;memory.h&gt;
  86. #include &quot;../plc/plc.h&quot;
  87. #include &quot;../tools/memory.h&quot;
  88. #include &quot;../tools/format.h&quot;
  89. #include &quot;../tools/error.h&quot;
  90. #include &quot;../tools/flags.h&quot;
  91. #ifdef WIN32
  92. #define snprintf _snprintf
  93. #endif
  94. signed Attributes2 (struct plc * plc)
  95. {
  96. struct channel * channel = (struct channel *)(plc-&gt;channel);
  97. struct message * message = (struct message *)(plc-&gt;message);
  98. #ifndef __GNUC__
  99. #pragma pack (push,1)
  100. #endif
  101. struct __packed vs_op_attributes_request
  102. {
  103. struct ethernet_hdr ethernet;
  104. struct qualcomm_hdr qualcomm;
  105. uint32_t COOKIE;
  106. uint8_t RTYPE;
  107. }
  108. * request = (struct vs_op_attributes_request *) (message);
  109. struct __packed vs_op_attributes_confirm
  110. {
  111. struct ethernet_hdr ethernet;
  112. struct qualcomm_hdr qualcomm;
  113. uint16_t MSTATUS;
  114. uint32_t COOKIE;
  115. uint8_t RTYPE;
  116. uint16_t MLENGTH;
  117. uint8_t MBUFFER [1024];
  118. }
  119. * confirm = (struct vs_op_attributes_confirm *) (message);
  120. struct __packed attributes
  121. {
  122. uint8_t DEVICEFAMILY [16];
  123. uint8_t DEVICETYPE [16];
  124. uint32_t FWMAJORVERSION;
  125. uint32_t FWMINORVERSION;
  126. uint32_t COMPOSITEVERSION;
  127. uint32_t SUSTAININGVERSION;
  128. uint32_t BUILDNUMBER;
  129. uint8_t BUILDDATE [8];
  130. uint8_t RELEASETYPE [12];
  131. uint8_t FLAGS [3];
  132. uint32_t DRAMSIZE;
  133. uint32_t RAMBLOCKRXCOUNT;
  134. uint32_t RAMBLOCKTXCOUNT;
  135. uint32_t RAMBLOCKSHAREDCOUNT;
  136. uint32_t RAMBLOCKFREERXCOUNT;
  137. uint32_t RAMBLOCKFREETXCOUNT;
  138. uint32_t RAMBLOCKFREESHAREDCOUNT;
  139. uint32_t RELATIVESNRDIFFDB;
  140. uint32_t DSP384THREGVAL;
  141. uint8_t AFETXGAINDB;
  142. uint8_t AUTHMODE;
  143. uint8_t MICROCONTROLLERDIAGENABLED;
  144. }
  145. * attributes = (struct attributes *)(confirm-&gt;MBUFFER);
  146. #ifndef __GNUC__
  147. #pragma pack (pop)
  148. #endif
  149. Request (plc, &quot;Fetch Device Attributes&quot;);
  150. memset (message, 0, sizeof (* message));
  151. EthernetHeader (&amp;request-&gt;ethernet, channel-&gt;peer, channel-&gt;host, channel-&gt;type);
  152. QualcommHeader (&amp;request-&gt;qualcomm, 0, (VS_OP_ATTRIBUTES | MMTYPE_REQ));
  153. plc-&gt;packetsize = (ETHER_MIN_LEN - ETHER_CRC_LEN);
  154. request-&gt;COOKIE = HTOLE32 (plc-&gt;cookie);
  155. request-&gt;RTYPE = 0;
  156. if (SendMME (plc) &lt;= 0)
  157. {
  158. error (PLC_EXIT (plc), errno, CHANNEL_CANTSEND);
  159. return (-1);
  160. }
  161. while (ReadMME (plc, 0, (VS_OP_ATTRIBUTES | MMTYPE_CNF)) &gt; 0)
  162. {
  163. #if 0
  164. static char const * frequency [] =
  165. {
  166. &quot;Unknown Frequency&quot;,
  167. &quot;50Hz&quot;,
  168. &quot;60Hz&quot;,
  169. };
  170. static char const * zero_cross [] =
  171. {
  172. &quot;Not yet detected&quot;,
  173. &quot;Detected&quot;,
  174. &quot;Missing&quot;,
  175. };
  176. #endif
  177. char string [512];
  178. size_t length = 0;
  179. if (confirm-&gt;MSTATUS)
  180. {
  181. Failure (plc, PLC_WONTDOIT);
  182. continue;
  183. }
  184. #if 0
  185. #if defined (__GNUC__)
  186. #warning &quot;Debug code active in module Attributes2&quot;
  187. #endif
  188. fprintf (stderr, &quot;DEVICE FAMILY=[%-16.16s]\n&quot;, attributes-&gt;DEVICEFAMILY);
  189. fprintf (stderr, &quot;DEVICE TYPE=[%-16.16s]\n&quot;, attributes-&gt;DEVICETYPE);
  190. fprintf (stderr, &quot;FIRMWARE MAJOR VERSION=(%d)\n&quot;, LE32TOH (attributes-&gt;FWMAJORVERSION));
  191. fprintf (stderr, &quot;FIRMWARE MINOR VERSION=(%d)\n&quot;, LE32TOH (attributes-&gt;FWMINORVERSION));
  192. fprintf (stderr, &quot;COMPOSITE VERSION=(%d)\n&quot;, LE32TOH (attributes-&gt;COMPOSITEVERSION));
  193. fprintf (stderr, &quot;SUSTAINING VERSION=(%d)\n&quot;, LE32TOH (attributes-&gt;SUSTAININGVERSION));
  194. fprintf (stderr, &quot;BUILD NUMBER=(%d)\n&quot;, LE32TOH (attributes-&gt;BUILDNUMBER));
  195. fprintf (stderr, &quot;BUILD DATE=[%-8.8s]\n&quot;, attributes-&gt;BUILDDATE);
  196. fprintf (stderr, &quot;RELEASE TYPE=[%-12.12s]\n&quot;, attributes-&gt;RELEASETYPE);
  197. fprintf (stderr, &quot;DRAM SIZE=[0x%08X](%d)\n&quot;, LE32TOH (attributes-&gt;DRAMSIZE), LE32TOH (attributes-&gt;DRAMSIZE));
  198. fprintf (stderr, &quot;DRAM TYPES=[0x%02X]\n&quot;, attributes-&gt;FLAGS [0]);
  199. fprintf (stderr, &quot;RESERVED FLAG=[0x%02X]\n&quot;, attributes-&gt;FLAGS [1]);
  200. fprintf (stderr, &quot;LINE FREQUENCY=[0x%02X]\n&quot;, attributes-&gt;FLAGS [2]);
  201. fprintf (stderr, &quot;AUTHORIZATION MODE=[0x%02X]\n&quot;, attributes-&gt;AUTHMODE);
  202. fprintf (stderr, &quot;DSP384THREGVAL=[0x%02X]\n&quot;, attributes-&gt;DSP384THREGVAL);
  203. fprintf (stderr, &quot;AFETXGAINDB=[0x%02X]\n&quot;, attributes-&gt;AFETXGAINDB);
  204. fprintf (stderr, &quot;AUTHORIZATION MODE=[0x%02X]\n&quot;, attributes-&gt;AUTHMODE);
  205. #if 0
  206. fprintf (stderr, &quot;DSP384THREGVAL=[0x%08X]\n&quot;, LE32TOH (attributes-&gt;DSP384THREGVAL));
  207. fprintf (stderr, &quot;AFETXGAINDB=[0x%02X]\n&quot;, attributes-&gt;AFETXGAINDB);
  208. #endif
  209. #endif
  210. length += snprintf (string + length, sizeof (string) - length, &quot;%s&quot;, attributes-&gt;DEVICEFAMILY);
  211. length += snprintf (string + length, sizeof (string) - length, &quot;-%s&quot;, attributes-&gt;DEVICETYPE);
  212. length += snprintf (string + length, sizeof (string) - length, &quot;-%s&quot;, attributes-&gt;DEVICEFAMILY);
  213. length += snprintf (string + length, sizeof (string) - length, &quot;-%d&quot;, LE32TOH (attributes-&gt;FWMAJORVERSION));
  214. length += snprintf (string + length, sizeof (string) - length, &quot;.%d&quot;, LE32TOH (attributes-&gt;FWMINORVERSION));
  215. length += snprintf (string + length, sizeof (string) - length, &quot;.%d&quot;, LE32TOH (attributes-&gt;COMPOSITEVERSION));
  216. length += snprintf (string + length, sizeof (string) - length, &quot;.%d&quot;, LE32TOH (attributes-&gt;BUILDNUMBER));
  217. length += snprintf (string + length, sizeof (string) - length, &quot;-%02d&quot;, LE32TOH (attributes-&gt;SUSTAININGVERSION));
  218. length += snprintf (string + length, sizeof (string) - length, &quot;-%8.8s&quot;, attributes-&gt;BUILDDATE);
  219. length += snprintf (string + length, sizeof (string) - length, &quot;-%s&quot;, attributes-&gt;RELEASETYPE);
  220. length += snprintf (string + length, sizeof (string) - length, &quot; (%dmb)&quot;, LE32TOH (attributes-&gt;DRAMSIZE));
  221. Display (plc, &quot;%s&quot;, string);
  222. }
  223. return (0);
  224. }
  225. #endif
  226. </pre>
  227. <div class='footerlink'>
  228. [<a href='Attributes1.c.html' title=' Attributes1.c '>PREV</a>]
  229. [<a href='toolkit.html' title=' Index '>HOME</a>]
  230. [<a href='Attributes.c.html' title=' Attributes.c '>NEXT</a>]
  231. </div>
  232. </body>
  233. </html>