chipset.c.html 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  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. chipset.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='checksum32.c.html' title=' checksum32.c '>PREV</a>]
  17. [<a href='toolkit.html' title=' Index '>HOME</a>]
  18. [<a href='chknvm2.c.html' title=' chknvm2.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. #ifndef CHIPSET_SOURCE
  62. #define CHIPSET_SOURCE
  63. /*====================================================================*
  64. * custom header files;
  65. *--------------------------------------------------------------------*/
  66. #include &quot;../plc/plc.h&quot;
  67. #include &quot;../tools/types.h&quot;
  68. #include &quot;../tools/symbol.h&quot;
  69. /*====================================================================*
  70. *
  71. * char const * chipsetname (uint8_t MDEVICE)
  72. *
  73. * plc.h
  74. *
  75. * return the ASCII name string associated with the MDEVICE_CLASS
  76. * field in the VS_SW_VER.CNF message; this field represents the
  77. * chipset family or class of device;
  78. *
  79. * the MDEVICE_CLASS field was named MDEVICEID at one time;
  80. *
  81. * Contributor(s):
  82. * Charles Maier &lt;cmaier@qca.qualcomm.com&gt;
  83. *
  84. *--------------------------------------------------------------------*/
  85. char const * chipsetname (uint8_t MDEVICE_CLASS)
  86. {
  87. static const struct _type_ chipname [] =
  88. {
  89. {
  90. CHIPSET_UNKNOWN,
  91. &quot;UNKNOWN&quot;
  92. },
  93. {
  94. CHIPSET_INT6000A1,
  95. &quot;INT6000&quot;
  96. },
  97. {
  98. CHIPSET_INT6300A0,
  99. &quot;INT6300&quot;
  100. },
  101. {
  102. CHIPSET_INT6400A0,
  103. &quot;INT6400&quot;
  104. },
  105. {
  106. CHIPSET_AR7400A0,
  107. &quot; AR7400&quot;
  108. },
  109. {
  110. CHIPSET_AR6405A0,
  111. &quot; AR6405&quot;
  112. },
  113. {
  114. CHIPSET_PANTHER_LYNX,
  115. &quot;PANTHER/LYNX&quot;
  116. },
  117. {
  118. CHIPSET_QCA7450A0,
  119. &quot;QCA7450&quot;
  120. },
  121. {
  122. CHIPSET_QCA7451A0,
  123. &quot;QCA7451&quot;
  124. },
  125. {
  126. CHIPSET_QCA7420A0,
  127. &quot;QCA7420&quot;
  128. },
  129. {
  130. CHIPSET_QCA6410A0,
  131. &quot;QCA6410&quot;
  132. },
  133. {
  134. CHIPSET_QCA7000A0,
  135. &quot;QCA7000&quot;
  136. },
  137. {
  138. CHIPSET_QCA7005A0,
  139. &quot;QCA7005&quot;
  140. },
  141. {
  142. CHIPSET_QCA7500A0,
  143. &quot;QCA7500&quot;
  144. }
  145. };
  146. return (typename (chipname, SIZEOF (chipname), MDEVICE_CLASS, chipname [0].name));
  147. }
  148. /*====================================================================*
  149. *
  150. * void chipset (void const * memory);
  151. *
  152. * Chipset.h
  153. *
  154. * replace VS_SW_VER message MDEVICE_CLASS field with correct value;
  155. * the MDEVICE_CLASS field was named MDEVICEID at one time;
  156. *
  157. * Atheros chipsets are identified by code in the VS_SW_VER vendor
  158. * specific management message; the chipset [] vector translates a
  159. * chipset code to a chipset name;
  160. *
  161. * the basic assumption is that the firmware always tells the truth
  162. * but the bootrom does not; because of engineering changes, the
  163. * firmware uses a different device identification scheme than that
  164. * used by the bootrom and that information appears in different
  165. * locations depending on the source of the VS_SW_VER confirmation;
  166. * see the Programmer's Guide for more information.
  167. *
  168. * INT6000 0x01 / 0x01 0x00000042 / NA
  169. * INT6300 0x01 / 0x02 0x00006300 / NA
  170. * INT6400 0x03 / 0x03 0x00006400 / NA
  171. * AR7400 0x03 / 0x04 0x00007400 / NA
  172. * AR6405 0x03 / 0x05 0x00006400 / NA
  173. * QCA7450 0x03 / 0x20 0x0F001D1A / NA
  174. * QCA7420 0x06 / 0x20 0x001CFCFC
  175. * QCA6410 0x06 / 0x21 0x001B58EC
  176. * QCA6411 0x06 / 0x21 0x001B58BC
  177. * QCA7000 0x06 / 0x22 0x001B589C
  178. * QCA7000 0x06 / 0x22 0x001B58DC
  179. * QCA7005 0x06 / 0x22 0x001B587C
  180. * QCA7500 0x06 / 0x30 0x001D4C0F
  181. *
  182. * some chipsets have have multiple STRAP field values; this is
  183. * not an error; there may be multiple versions of a chipset;
  184. *
  185. *--------------------------------------------------------------------*/
  186. void chipset (void const * memory)
  187. {
  188. #ifndef __GNUC__
  189. #pragma pack (push,1)
  190. #endif
  191. struct __packed vs_sw_ver_confirm
  192. {
  193. struct ethernet_hdr ethernet;
  194. struct qualcomm_hdr qualcomm;
  195. uint8_t MSTATUS;
  196. uint8_t MDEVICE_CLASS;
  197. uint8_t MVERLENGTH;
  198. char MVERSION [254];
  199. }
  200. * confirm = (struct vs_sw_ver_confirm *) (memory);
  201. struct __packed chipinfo
  202. {
  203. uint8_t RESVD;
  204. uint32_t STRAP;
  205. uint32_t STEP_NUMBER;
  206. }
  207. * chipinfo = (struct chipinfo *) (&amp; confirm-&gt;MVERSION [64]);
  208. typedef struct __packed
  209. {
  210. uint32_t STRAP;
  211. uint8_t CLASS;
  212. uint8_t DEVICE;
  213. }
  214. chipdata;
  215. #ifndef __GNUC__
  216. #pragma pack (pop)
  217. #endif
  218. chipdata bootrom [] =
  219. {
  220. {
  221. 0x00000042,
  222. 0x01,
  223. CHIPSET_INT6000A1
  224. },
  225. {
  226. 0x00006300,
  227. 0x01,
  228. CHIPSET_INT6300A0
  229. },
  230. {
  231. 0x00006400,
  232. 0x03,
  233. CHIPSET_INT6400A0
  234. },
  235. {
  236. 0x00007400,
  237. 0x03,
  238. CHIPSET_AR7400A0
  239. },
  240. {
  241. 0x0F001D1A,
  242. 0x03,
  243. CHIPSET_QCA7450A0
  244. },
  245. {
  246. 0x0E001D1A,
  247. 0x03,
  248. CHIPSET_QCA7451A0
  249. },
  250. {
  251. 0x001CFC00,
  252. 0x05,
  253. CHIPSET_QCA7420A0
  254. },
  255. {
  256. 0x001CFCFC,
  257. 0x05,
  258. CHIPSET_QCA7420A0
  259. },
  260. {
  261. 0x001CFCFC,
  262. 0x06,
  263. CHIPSET_QCA7420A0
  264. },
  265. {
  266. 0x001B58EC,
  267. 0x06,
  268. CHIPSET_QCA6410A0
  269. },
  270. {
  271. 0x001B58BC,
  272. 0x06,
  273. CHIPSET_QCA6411A0
  274. },
  275. {
  276. 0x001B58DC,
  277. 0x06,
  278. CHIPSET_QCA7000A0
  279. },
  280. {
  281. 0x001B587C,
  282. 0x06,
  283. CHIPSET_QCA7005A0
  284. },
  285. {
  286. 0x001D4C00,
  287. 0x06,
  288. CHIPSET_QCA7500A0
  289. },
  290. {
  291. 0x001D4C0F,
  292. 0x06,
  293. CHIPSET_QCA7500A0
  294. }
  295. };
  296. chipdata firmware [] =
  297. {
  298. {
  299. 0x00000000,
  300. 0x01,
  301. CHIPSET_INT6000A1
  302. },
  303. {
  304. 0x00000000,
  305. 0x02,
  306. CHIPSET_INT6300A0
  307. },
  308. {
  309. 0x00000000,
  310. 0x03,
  311. CHIPSET_INT6400A0
  312. },
  313. {
  314. 0x00000000,
  315. 0x05,
  316. CHIPSET_AR6405A0
  317. },
  318. {
  319. 0x00000000,
  320. 0x04,
  321. CHIPSET_AR7400A0
  322. },
  323. {
  324. 0x0F001D1A,
  325. 0x20,
  326. CHIPSET_QCA7450A0
  327. },
  328. {
  329. 0x0E001D1A,
  330. 0x20,
  331. CHIPSET_QCA7451A0
  332. },
  333. {
  334. 0x001CFCFC,
  335. 0x20,
  336. CHIPSET_QCA7420A0
  337. },
  338. {
  339. 0x001B58EC,
  340. 0x21,
  341. CHIPSET_QCA6410A0
  342. },
  343. {
  344. 0x001B58BC,
  345. 0x21,
  346. CHIPSET_QCA6411A0
  347. },
  348. {
  349. 0x001B58DC,
  350. 0x22,
  351. CHIPSET_QCA7000A0
  352. },
  353. {
  354. 0x001D4C00,
  355. 0x30,
  356. CHIPSET_QCA7500A0
  357. },
  358. {
  359. 0x001D4C0F,
  360. 0x30,
  361. CHIPSET_QCA7500A0
  362. }
  363. };
  364. unsigned chip;
  365. if (! strcmp (confirm-&gt;MVERSION, &quot;BootLoader&quot;))
  366. {
  367. for (chip = 0; chip &lt; SIZEOF (bootrom); chip++)
  368. {
  369. if (bootrom [chip].CLASS != confirm-&gt;MDEVICE_CLASS)
  370. {
  371. continue;
  372. }
  373. if (bootrom [chip].STRAP != LE32TOH (chipinfo-&gt;STRAP))
  374. {
  375. continue;
  376. }
  377. confirm-&gt;MDEVICE_CLASS = bootrom [chip].DEVICE;
  378. return;
  379. }
  380. }
  381. else
  382. {
  383. for (chip = 0; chip &lt; SIZEOF (firmware); chip++)
  384. {
  385. if (firmware [chip].CLASS != confirm-&gt;MDEVICE_CLASS)
  386. {
  387. continue;
  388. }
  389. if (firmware [chip].STRAP &lt; CHIPSET_PANTHER_LYNX)
  390. {
  391. confirm-&gt;MDEVICE_CLASS = firmware [chip].DEVICE;
  392. return;
  393. }
  394. chipinfo = (struct chipinfo *) (&amp; confirm-&gt;MVERSION [64]);
  395. if (firmware [chip].STRAP == LE32TOH (chipinfo-&gt;STRAP))
  396. {
  397. confirm-&gt;MDEVICE_CLASS = firmware [chip].DEVICE;
  398. return;
  399. }
  400. chipinfo = (struct chipinfo *) (&amp; confirm-&gt;MVERSION [128]);
  401. if (firmware [chip].STRAP == LE32TOH (chipinfo-&gt;STRAP))
  402. {
  403. confirm-&gt;MDEVICE_CLASS = firmware [chip].DEVICE;
  404. return;
  405. }
  406. chipinfo = (struct chipinfo *) (&amp; confirm-&gt;MVERSION [253]);
  407. if (firmware [chip].STRAP == LE32TOH (chipinfo-&gt;STRAP))
  408. {
  409. confirm-&gt;MDEVICE_CLASS = firmware [chip].DEVICE;
  410. return;
  411. }
  412. }
  413. }
  414. return;
  415. }
  416. #endif
  417. </pre>
  418. <div class='footerlink'>
  419. [<a href='checksum32.c.html' title=' checksum32.c '>PREV</a>]
  420. [<a href='toolkit.html' title=' Index '>HOME</a>]
  421. [<a href='chknvm2.c.html' title=' chknvm2.c '>NEXT</a>]
  422. </div>
  423. </body>
  424. </html>