plc.h.html 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  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. plc.h
  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='pib.h.html' title=' pib.h '>PREV</a>]
  17. [<a href='toolkit.html' title=' Index '>HOME</a>]
  18. [<a href='putoptv.h.html' title=' putoptv.h '>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 PLC_HEADER
  62. #define PLC_HEADER
  63. /*====================================================================*
  64. * system header files;
  65. *--------------------------------------------------------------------*/
  66. #include &lt;stdint.h&gt;
  67. /*====================================================================*
  68. * custom header files;
  69. *--------------------------------------------------------------------*/
  70. #include &quot;../ether/channel.h&quot;
  71. #include &quot;../key/HPAVKey.h&quot;
  72. #include &quot;../tools/types.h&quot;
  73. #include &quot;../plc/chipset.h&quot;
  74. #include &quot;../mme/mme.h&quot;
  75. #include &quot;../nvm/nvm.h&quot;
  76. #include &quot;../pib/pib.h&quot;
  77. /*====================================================================*
  78. * constants; these codes are returned in the DEVICEID field of the
  79. * firmware VS_SW_VER message;
  80. *--------------------------------------------------------------------*/
  81. #define PLC_MODULE_SOFTLOADER 0x00
  82. #define PLC_MODULE_FIRMWARE (1 &lt;&lt; 0)
  83. #define PLC_MODULE_PARAMETERS (1 &lt;&lt; 1)
  84. #define PLC_MODULE_NVM_PIB (PLC_MODULE_PARAMETERS | PLC_MODULE_FIRMWARE)
  85. #define PLC_MODULE_OPERATION (1 &lt;&lt; 3)
  86. #define PLC_MODULE_UPGRADE (PLC_MODULE_OPERATION | PLC_MODULE_PARAMETERS | PLC_MODULE_FIRMWARE)
  87. #define PLC_MODULE_FORCE_FLASH (1 &lt;&lt; 4)
  88. #define PLC_MODULE_DO_NOT_REBOOT (1 &lt;&lt; 5)
  89. #define PLC_MODULE_ALTERNATE_SECTION (1 &lt;&lt; 6)
  90. #define PLC_MODULE_FORCE_SECTION (1 &lt;&lt; 7)
  91. /*====================================================================*
  92. * constants;
  93. *--------------------------------------------------------------------*/
  94. #define PLC_VERSION_STRING 0xFF
  95. #define PLC_RECORD_SIZE 1024
  96. #define PLC_MODULE_SIZE 1400
  97. #define PLC_SLOTS 6
  98. #define LEGACY_PIBOFFSET 0x01F00000
  99. #define INT6x00_PIBOFFSET 0x01000000
  100. #define AR7x00_PIBOFFSET 0x00200000
  101. #define INT_CARRIERS 1155
  102. #define AMP_CARRIERS 2880
  103. #define PLC_CARRIERS 1345
  104. #define AMP_BITS 9
  105. /*====================================================================*
  106. * device manager flagword bits;
  107. *--------------------------------------------------------------------*/
  108. /*
  109. * We reuse flagword bits in various programs to avoid proliferating
  110. * flagwords; make sure that one program does not use multiple names
  111. * ro refer to the same bit;
  112. */
  113. #define PLC_BAILOUT (1 &lt;&lt; 0)
  114. #define PLC_SILENCE (1 &lt;&lt; 1)
  115. #define PLC_VERBOSE (1 &lt;&lt; 2)
  116. #define PLC_ANALYSE (1 &lt;&lt; 3)
  117. #define PLC_ERASE_DEVICE PLC_ANALYSE /* ampinit, plcinit */
  118. #define PLC_NEWLINE PLC_ANALYSE /* ampID, plcID */
  119. #define PLC_WAITFORRESET (1 &lt;&lt; 4)
  120. #define PLC_WAITFORSTART (1 &lt;&lt; 5)
  121. #define PLC_WAITFORASSOC (1 &lt;&lt; 6)
  122. #define PLC_REMOTEHOSTS PLC_WAITFORASSOC
  123. #define PLC_RESET_DEVICE (1 &lt;&lt; 7)
  124. #define PLC_RANDOM_ADDR PLC_RESET_DEVICE
  125. #define PLC_TIM_GARGRAVE PLC_RESET_DEVICE
  126. #define PLC_BRIDGE_LIST PLC_RESET_DEVICE /* plclist, amplist */
  127. #define PLC_FACTORY_DEFAULTS (1 &lt;&lt; 8)
  128. #define PLC_FOREVER PLC_FACTORY_DEFAULTS /* plctest */
  129. #define PLC_GRAPH PLC_FACTORY_DEFAULTS /* plctone */
  130. #define PLC_DAEMON PLC_FACTORY_DEFAULTS /* plchost */
  131. #define PLC_REMOTE_LIST PLC_FACTORY_DEFAULTS /* plclist, amplist */
  132. #define PLC_BINARY PLC_FACTORY_DEFAULTS /* ampsnif */
  133. #define PLC_FORCE_FLASH PLC_FACTORY_DEFAULTS /* plchost */
  134. #define PLC_NETWORK (1 &lt;&lt; 9)
  135. #define PLC_OPEN_SESSION PLC_NETWORK /* plcmod */
  136. #define PLC_MONITOR PLC_NETWORK /* ampsnif */
  137. #define PLC_XML_FORMAT PLC_NETWORK /* int6klog */
  138. #define PLC_VERSION (1 &lt;&lt; 10)
  139. #define PLC_WRITE_MODULE PLC_VERSION /* plcmod */
  140. #define PLC_MANUFACTURER (1 &lt;&lt; 11)
  141. #define PLC_READ_MODULE PLC_MANUFACTURER /* plcmod */
  142. #define PLC_READ_MAC (1 &lt;&lt; 12)
  143. #define PLC_DUMP_MODULE PLC_READ_MAC /* int6mod */
  144. #define PLC_LOCAL_TRAFFIC PLC_READ_MAC /* int6krate, amprate, plcrate */
  145. #define PLC_READ_PIB (1 &lt;&lt; 13)
  146. #define PLC_NETWORK_TRAFFIC PLC_READ_PIB /* plcrate */
  147. #define PLC_READ_IDENTITY (1 &lt;&lt; 14)
  148. #define PLC_UNCODED_RATES PLC_READ_IDENTITY /* plcrate */
  149. #define PLC_WRITE_MAC (1 &lt;&lt; 15)
  150. #define PLC_LINK_STATS PLC_WRITE_MAC /* plcstat */
  151. #define PLC_WRITE_PIB (1 &lt;&lt; 16)
  152. #define PLC_TONE_MAP PLC_WRITE_PIB /* plcstat */
  153. #define PLC_FLASH_DEVICE (1 &lt;&lt; 17)
  154. #define PLC_COMMIT_MODULE PLC_FLASH_DEVICE /* plcmod */
  155. #define PLC_QUICK_FLASH (1 &lt;&lt; 18)
  156. #define PLC_SETLOCALKEY (1 &lt;&lt; 19)
  157. #define PLC_RXONLY PLC_SETLOCALKEY
  158. #define PLC_SETREMOTEKEY (1 &lt;&lt; 20)
  159. #define PLC_TXONLY PLC_SETREMOTEKEY
  160. #define PLC_SDRAM_INFO (1 &lt;&lt; 21)
  161. #define PLC_SDRAM_CONFIG (1 &lt;&lt; 22)
  162. #define PLC_CONFIGURE PLC_SDRAM_CONFIG /* plcotst */
  163. #define PLC_NVRAM_INFO (1 &lt;&lt; 23)
  164. #define PLC_ATTRIBUTES (1 &lt;&lt; 24)
  165. #define PLC_PUSH_BUTTON (1 &lt;&lt; 25)
  166. #define PLC_READ_CFG (1 &lt;&lt; 26)
  167. #define PLC_ERASE_SECTOR PLC_READ_CFG
  168. #define PLC_RD_MOD_WR_PIB (1 &lt;&lt; 27)
  169. #define PLC_SNIFFER PLC_RD_MOD_WR_PIB /* ampsnif */
  170. #define PLC_READ_ALL PLC_RD_MOD_WR_PIB /* ampinit */
  171. #define PLC_WATCHDOG_REPORT (1 &lt;&lt; 28)
  172. #define PLC_RESULTS PLC_WATCHDOG_REPORT /* plcotst */
  173. #define PLC_HOST_ACTION (1 &lt;&lt; 29)
  174. #define PLC_LINK_STATUS PLC_HOST_ACTION
  175. #define PLC_MULTICAST_INFO (1 &lt;&lt; 30)
  176. #define PLC_RX_TONEMAPS PLC_HOST_ACTION /* plcstat */
  177. /*====================================================================*
  178. * message format strings;
  179. *--------------------------------------------------------------------*/
  180. #define PLC_BADVALUE &quot;Invalid or suspect data&quot;
  181. #define PLC_WONTDOIT &quot;Device refused request&quot;
  182. #define PLC_NODEVICE &quot;Need a device. Try 'local' or '00:B0:52:00:00:01'.&quot;
  183. #define PLC_BADFRAME &quot;Unexpected response&quot;
  184. #define PLC_NODETECT &quot;Device must be connected&quot;
  185. #define PLC_NOMEMORY &quot;Not enough memory&quot;
  186. #define PLC_NOTREADY &quot;Function not implemented&quot;
  187. #define PLC_ERR_OFFSET &quot;Data offset error&quot;
  188. #define PLC_ERR_LENGTH &quot;Data length error&quot;
  189. #define PLC_BAD_MAC &quot;Have '%s' instead of MAC address&quot;
  190. #define PLC_BAD_DAK &quot;Have '%s' instead of DAK&quot;
  191. #define PLC_BAD_NMK &quot;Have '%s' instead of NMK&quot;
  192. #define PLC_EXIT(plc) ((signed) (plc-&gt;flags &amp; PLC_BAILOUT))
  193. /*====================================================================*
  194. * program constants;
  195. *--------------------------------------------------------------------*/
  196. #define PLCDEVICE &quot;PLC&quot;
  197. #define HARDWAREID 0
  198. #define SOFTWAREID 0
  199. #define PLCSESSION 0x78563412
  200. #define HOSTACTION 0
  201. #define SECTORCODE 0
  202. #define PUSHBUTTON 1
  203. #define MODULECODE (VS_MODULE_MAC | VS_MODULE_PIB)
  204. #define READACTION 0
  205. #define FLASH_SIZE 0x200000
  206. #define PLCOUPLING 0
  207. #define PLC_STATE 0
  208. #define PLC_TIMER 60
  209. #define PLC_SLEEP 0
  210. #define PLC_COUNT 1
  211. #define PLC_INDEX 0
  212. #define PLC_FLAGS 0
  213. #define PLC_MEMTYPE_AUTO 1
  214. #define PLC_MEMTYPE_ITCM 2
  215. #define PLC_MEMTYPE_DTCM 3
  216. #define PLC_MEMTYPE_SRAM 4
  217. #define PLC_MEMTYPE_SDRAM 5
  218. #define PLC_ECHOTIME 3
  219. #define PLC_LONGTIME (unsigned)(~0)
  220. /*====================================================================*
  221. * common mac address names;
  222. *--------------------------------------------------------------------*/
  223. #define PLCDEVICES 3
  224. extern struct _term_ const devices [PLCDEVICES];
  225. /*====================================================================*
  226. *
  227. * the plc structure holds everything needed to perform powerline
  228. * device management operations including a channel structure for
  229. * Ethernet interface management and a message structure for data
  230. * buffer management;
  231. *
  232. * the channel structure holds information needed to open, read,
  233. * write and close a raw socket; it differs in detail depending
  234. * on constants WINPCAP and LIBPCAP;
  235. *
  236. * character array address[] holds a decoded ethernet address for
  237. * display purposes because humans cannot read;
  238. *
  239. * byte array LMA[] holds the Qualcomm Local Broadcast Address
  240. * because it is used in so many places;
  241. *
  242. * byte arrays NMK[] and DAK[] hold encryption keys used by some
  243. * operations;
  244. *
  245. * the socket _file_ structure holds the descriptor and interface
  246. * name of the host NIC where the name is eth0, eth1, ... or ethn;
  247. *
  248. * the three _file_ structures, CFG, NVM, and PIB hold descriptors
  249. * and filenames for files written to the device;
  250. *
  251. * the three _file_ structures cfg, nvm and pib hold
  252. * descriptors and filenames of files read from the device;
  253. *
  254. * integers retry and timer are used by program plcwait;
  255. *
  256. * integers index, count and pause control command line looping
  257. * and waiting;
  258. *
  259. * flag_t flags contains bits that define program operations and
  260. * control utility program flow;
  261. *
  262. *--------------------------------------------------------------------*/
  263. typedef struct plc
  264. {
  265. struct channel * channel;
  266. struct message * message;
  267. void * content;
  268. ssize_t packetsize;
  269. uint8_t MAC [ETHER_ADDR_LEN];
  270. uint8_t RDA [ETHER_ADDR_LEN];
  271. uint8_t NMK [HPAVKEY_NMK_LEN];
  272. uint8_t DAK [HPAVKEY_DAK_LEN];
  273. struct _file_ CFG;
  274. struct _file_ cfg;
  275. struct _file_ SFT;
  276. struct _file_ sft;
  277. struct _file_ NVM;
  278. struct _file_ nvm;
  279. struct _file_ PIB;
  280. struct _file_ pib;
  281. struct _file_ XML;
  282. struct _file_ rpt;
  283. struct _file_ socket;
  284. uint32_t hardwareID;
  285. uint32_t softwareID;
  286. uint32_t cookie;
  287. uint8_t action;
  288. uint8_t sector;
  289. uint8_t module;
  290. uint8_t pushbutton;
  291. uint8_t readaction;
  292. uint8_t coupling;
  293. unsigned flash_size;
  294. unsigned state;
  295. unsigned timer;
  296. unsigned sleep;
  297. unsigned count;
  298. unsigned index;
  299. flag_t flags;
  300. flag_t flag2;
  301. }
  302. PLC;
  303. /*====================================================================*
  304. * fixer-upper functions that compensate for errors and omissions;
  305. *--------------------------------------------------------------------*/
  306. void chipset (void const * memory);
  307. char const * chipsetname (uint8_t chipset);
  308. /*====================================================================*
  309. * functions;
  310. *--------------------------------------------------------------------*/
  311. signed Attributes (struct plc *);
  312. signed Attributes1 (struct plc *);
  313. signed Attributes2 (struct plc *);
  314. signed BootDevice (struct plc *);
  315. signed BootDevice1 (struct plc *);
  316. signed BootDevice2 (struct plc *);
  317. signed BootDeviceFirmware (struct plc *);
  318. signed BootDeviceParameters (struct plc *);
  319. signed BootFirmware1 (struct plc *);
  320. signed BootFirmware2 (struct plc *);
  321. signed BootParameters1 (struct plc *);
  322. signed BootParameters2 (struct plc *);
  323. signed ChangeIdent (struct plc *);
  324. signed CrossTraffic (struct plc *);
  325. signed CrossTrafficOne (struct plc *);
  326. signed CrossTrafficTwo (struct plc *);
  327. signed DeviceIdent (struct plc *);
  328. signed EmulateHost (struct plc *);
  329. signed EmulateHost64 (struct plc *);
  330. signed EraseFlashSector (struct plc *);
  331. signed ExecuteApplets (struct plc *);
  332. signed ExecuteApplets1 (struct plc *);
  333. signed ExecuteApplets2 (struct plc *);
  334. signed FactoryDefaults (struct plc *);
  335. signed FactoryReset (struct plc *);
  336. signed FlashNVM (struct plc *);
  337. signed FlashPTS (struct plc *);
  338. signed FlashDevice (struct plc *);
  339. signed FlashDevice0 (struct plc *);
  340. signed FlashDevice1 (struct plc *);
  341. signed FlashDevice2 (struct plc *, uint32_t options);
  342. signed FlashFirmware (struct plc *, uint32_t options);
  343. signed FlashParameters (struct plc *, uint32_t options);
  344. signed FlashUpgrade (struct plc *, uint32_t options);
  345. signed FlashNVM (struct plc *);
  346. signed FlashSoftloader (struct plc *, uint32_t options);
  347. signed HostActionResponse (struct plc *);
  348. signed Identity (struct plc *);
  349. signed Identity1 (struct plc *);
  350. signed Identity2 (struct plc *);
  351. signed InitDevice (struct plc *);
  352. signed InitDevice1 (struct plc *);
  353. signed InitDevice2 (struct plc *);
  354. signed LinkStatistics (struct plc *);
  355. signed LinkStatus (struct plc *);
  356. signed ListLocalDevices (struct plc * plc, char const * space, char const * comma);
  357. signed LocalTrafficSend (struct plc * plc);
  358. signed Antiphon (struct plc * plc, uint8_t osa [], uint8_t oda []);
  359. signed MDUTrafficStats (struct plc *, uint8_t command, uint8_t session, uint8_t slave);
  360. signed MfgString (struct plc *);
  361. signed MulticastInfo1 (struct plc *);
  362. signed MulticastInfo2 (struct plc *);
  363. signed NVMSelect (struct plc *, signed (struct plc *), signed (struct plc *));
  364. signed NVRAMInfo (struct plc *);
  365. signed NetInfo (struct plc *);
  366. signed NetInfo1 (struct plc *);
  367. signed NetInfo2 (struct plc *);
  368. signed NetworkDevices (struct plc *, void * memory, size_t extent);
  369. signed NetworkDevices1 (struct plc *, void * memory, size_t extent);
  370. signed NetworkDevices2 (struct plc *, void * memory, size_t extent);
  371. signed NetworkInfoStats (struct plc *);
  372. signed NetworkInformation (struct plc *);
  373. signed NetworkInformation1 (struct plc *);
  374. signed NetworkInformation2 (struct plc *);
  375. signed NetworkProbe (struct plc *);
  376. signed NetworkTraffic (struct plc *);
  377. signed NetworkTraffic1 (struct plc *);
  378. signed NetworkTraffic2 (struct plc *);
  379. signed PLCSelect (struct plc *, signed method1 (struct plc *), signed method2 (struct plc *));
  380. signed PhyRates (struct plc *);
  381. signed PhyRates1 (struct plc *);
  382. signed PhyRates2 (struct plc *);
  383. signed RxRates2 (struct plc *);
  384. signed TxRates2 (struct plc *);
  385. signed PushButton (struct plc *);
  386. signed ReadFMI (struct plc *, uint8_t MMV, uint16_t MMTYPE);
  387. signed ReadMFG (struct plc *, uint8_t MMV, uint16_t MMTYPE);
  388. signed ReadMME (struct plc *, uint8_t MMV, uint16_t MMTYPE);
  389. signed ReadFirmware (struct plc *);
  390. signed ReadFirmware1 (struct plc *);
  391. signed ReadFirmware2 (struct plc *);
  392. signed ReadParameterBlock (struct plc *, void * memory, size_t extent);
  393. signed ReadParameters (struct plc *);
  394. signed ReadParameters1 (struct plc *);
  395. signed ReadParameters2 (struct plc *);
  396. signed ListRemoteDevices (struct plc *, char const * space, char const * comma);
  397. signed ListRemoteDevices1 (struct plc *, char const * space, char const * comma);
  398. signed ListRemoteDevices2 (struct plc *, char const * space, char const * comma);
  399. signed RemoteHosts (struct plc *);
  400. signed Reset (struct plc *);
  401. signed ResetAndWait (struct plc *);
  402. signed ResetDevice (struct plc *);
  403. signed SDRAMInfo (struct plc *);
  404. signed SendMME (struct plc *);
  405. signed SetNMK (struct plc *);
  406. signed SignalToNoise1 (struct plc *);
  407. signed SignalToNoise2 (struct plc *);
  408. signed SlaveMembership (struct plc *);
  409. signed StartDevice (struct plc *);
  410. signed StartDevice1 (struct plc *);
  411. signed StartDevice2 (struct plc *);
  412. signed StartFirmware (struct plc *, unsigned module, void const * header);
  413. signed StartFirmware1 (struct plc *, unsigned module, const struct nvm_header1 *);
  414. signed StartFirmware2 (struct plc *, unsigned module, const struct nvm_header2 *);
  415. signed ToneMaps1 (struct plc *);
  416. signed ToneMaps2 (struct plc *);
  417. signed Topology (struct plc *);
  418. signed Topology1 (struct plc *);
  419. signed Topology2 (struct plc *);
  420. signed Traffic (struct plc *);
  421. signed Traffic1 (struct plc *);
  422. signed Traffic2 (struct plc *);
  423. signed Traffic3 (struct plc *);
  424. signed Transmit (struct plc *, uint8_t osa [], uint8_t oda []);
  425. signed UpgradeDevice1 (struct plc *);
  426. signed MDUTrafficStats (struct plc *, uint8_t command, uint8_t session, uint8_t slave);
  427. signed VersionInfo (struct plc *);
  428. signed VersionInfo1 (struct plc *);
  429. signed VersionInfo2 (struct plc *);
  430. signed WaitForAssoc (struct plc *);
  431. signed WaitForAssoc1 (struct plc *);
  432. signed WaitForAssoc2 (struct plc *);
  433. signed WaitForBootLoader (struct plc *);
  434. signed WaitForReset (struct plc *, char buffer [], size_t length);
  435. signed WaitForStart (struct plc *, char buffer [], size_t length);
  436. signed WaitForRestart (struct plc *);
  437. signed WatchdogReport (struct plc *);
  438. signed WriteCFG (struct plc *);
  439. signed WriteExecuteApplet2 (struct plc *, unsigned module, const struct nvm_header2 *);
  440. signed WriteExecuteFirmware (struct plc *, unsigned module, void const * nvm_header);
  441. signed WriteExecuteFirmware1 (struct plc *, unsigned module, const struct nvm_header1 *);
  442. signed WriteExecuteFirmware2 (struct plc *, unsigned module, const struct nvm_header2 *);
  443. signed WriteExecuteParameters (struct plc *, unsigned module, void const * nvm_header);
  444. signed WriteExecuteParameters1 (struct plc *, unsigned module, const struct nvm_header1 *);
  445. signed WriteExecuteParameters2 (struct plc *, unsigned module, const struct nvm_header2 *);
  446. signed WriteExecutePIB (struct plc *, unsigned offset, struct pib_header *);
  447. signed WriteFirmware (struct plc *, unsigned module, void const * nvm_header);
  448. signed WriteFirmware1 (struct plc *, unsigned module, const struct nvm_header1 *);
  449. signed WriteFirmware2 (struct plc *, unsigned module, const struct nvm_header2 *);
  450. signed WriteMEM (struct plc *, struct _file_ *, unsigned module, uint32_t offset, uint32_t extent);
  451. signed WriteMOD (struct plc *, uint8_t module, void const * memory, size_t extent);
  452. signed WriteNVM (struct plc *);
  453. signed WritePIB (struct plc *);
  454. signed WriteParameters (struct plc *, unsigned module, void const * nvm_header);
  455. signed WriteParameters1 (struct plc *, unsigned module, const struct nvm_header1 *);
  456. signed WriteParameters2 (struct plc *, unsigned module, const struct nvm_header2 *);
  457. /*====================================================================*
  458. *
  459. *--------------------------------------------------------------------*/
  460. #define PLC_FORMAT_HEX 0
  461. #define PLC_FORMAT_DEC 1
  462. #define PLC_FORMAT_BIN 2
  463. #define PLC_FORMAT_ASC 3
  464. #ifndef __GNUC__
  465. #pragma pack (push,1)
  466. #endif
  467. struct __packed plcproperty
  468. {
  469. uint8_t PROP_OPTION;
  470. uint8_t PROP_FORMAT;
  471. uint32_t PROP_NUMBER;
  472. uint32_t PROP_VERSION;
  473. uint32_t PROP_LENGTH;
  474. uint8_t PROP_BUFFER [128];
  475. uint8_t DATA_FORMAT;
  476. uint32_t DATA_LENGTH;
  477. uint8_t DATA_BUFFER [128];
  478. }
  479. plcproperty;
  480. #ifndef __GNUC__
  481. #pragma pack (pop)
  482. #endif
  483. /*====================================================================*
  484. *
  485. *--------------------------------------------------------------------*/
  486. signed GetProperty (struct plc *, struct plcproperty *);
  487. signed SetProperty (struct plc *, struct plcproperty *);
  488. /*====================================================================*
  489. *
  490. *--------------------------------------------------------------------*/
  491. typedef struct __packed plcstation
  492. {
  493. uint8_t LOC;
  494. uint8_t CCO;
  495. uint8_t TEI;
  496. uint8_t MAC [ETHER_ADDR_LEN];
  497. uint8_t BDA [ETHER_ADDR_LEN];
  498. uint16_t TX;
  499. uint16_t RX;
  500. char hardware [0x10];
  501. char firmware [0x80];
  502. char identity [0x40];
  503. }
  504. plcstation;
  505. typedef struct __packed plcnetwork
  506. {
  507. signed ifname;
  508. signed plcstations;
  509. struct plcstation plcstation [1];
  510. }
  511. plcnetwork;
  512. typedef struct __packed plctopology
  513. {
  514. signed plcnetworks;
  515. struct plcnetwork plcnetwork [1];
  516. }
  517. pcltopology;
  518. /*====================================================================*
  519. * functions that use struct channel and struct message directly
  520. * instead of struct plc;
  521. *--------------------------------------------------------------------*/
  522. signed FlashMOD (struct channel *, uint8_t module);
  523. signed WriteModule (struct channel *, struct message *, void const * memory, size_t extent);
  524. signed WriteMemory (struct channel *, struct message *, struct _file_ *, uint32_t offset, uint32_t extent);
  525. unsigned LocalDevices (struct channel const *, struct message *, void * memory, size_t extent);
  526. signed Platform (struct channel *, const byte device []);
  527. signed PLCReadParameterBlock (struct channel *, struct message *, void * memory, size_t extent);
  528. signed PLCReadFirmwareImage (struct channel *, struct message *, void * memory, size_t extent);
  529. signed PLCTopology (struct channel *, struct message *, struct plctopology *);
  530. signed PLCTopologyPrint (struct plctopology *);
  531. /*====================================================================*
  532. * vs_module_spec message;
  533. *--------------------------------------------------------------------*/
  534. #define PLC_MODULE_EXECUTE (1 &lt;&lt; 0)
  535. #define PLC_MODULE_ABSOLUTE (1 &lt;&lt; 1)
  536. #define PLC_MODULE_RELATIVE (0 &lt;&lt; 1)
  537. #define PLC_MODULE_READ_TIMEOUT 5000
  538. #define PLC_MODULE_REQUEST_TIMEOUT 60000
  539. #define PLC_MODULE_WRITE_TIMEOUT 90000
  540. #define PLC_MOD_OP_READ_MEMORY 0x00
  541. #define PLC_MOD_OP_READ_FLASH 0x01
  542. #define PLC_MOD_OP_START_SESSION 0x10
  543. #define PLC_MOD_OP_WRITE_MODULE 0x11
  544. #define PLC_MOD_OP_CLOSE_SESSION 0x12
  545. #define PLC_MODULEID 0x0000
  546. #define PLC_SUBMODULEID 0x0000
  547. #define PLC_MODULEID_MDIO_INIT 0x1000
  548. #define PLC_MODULEID_UART_ASYNC 0x2000
  549. #define PLC_MODULEID_ADDR_ENUM 0x3000
  550. #define PLC_MODULEID_POWER_MGT 0x4000
  551. #define PLC_MODULEID_TR069 0x4001
  552. #define PLC_MODULEID_FORWARDCFG 0x7000
  553. #define PLC_MODULEID_FIRMWARE 0x7001
  554. #define PLC_MODULEID_PARAMETERS 0x7002
  555. #define PLC_MODULEID_SOFTLOADER 0x7003
  556. #define PLC_MODULEID_RESERVED1 0x7004
  557. #define PLC_MODULEID_PIBMERGE 0x7005
  558. #define PLC_MODULEID_RESERVED2 0x7006
  559. typedef struct __packed vs_module_spec
  560. {
  561. uint16_t MODULE_ID;
  562. uint16_t MODULE_SUB_ID;
  563. uint32_t MODULE_LENGTH;
  564. uint32_t MODULE_CHKSUM;
  565. }
  566. vs_module_spec;
  567. #define PLC_COMMIT_FORCE (1 &lt;&lt; 0)
  568. #define PLC_COMMIT_NORESET (1 &lt;&lt; 1)
  569. #define PLC_COMMIT_FACTPIB (1 &lt;&lt; 31)
  570. /*====================================================================*
  571. * functions;
  572. *--------------------------------------------------------------------*/
  573. signed ModuleSpec (struct _file_ *, struct vs_module_spec *);
  574. signed ModuleSession (struct plc *, unsigned modules, vs_module_spec *);
  575. signed ModuleWrite (struct plc *, struct _file_ *, unsigned module, vs_module_spec *);
  576. signed ModuleRead (struct plc *, struct _file_ *, uint16_t source, uint16_t module, uint16_t submodule);
  577. signed ModuleDump (struct plc *, uint16_t source, uint16_t module, uint16_t submodule);
  578. signed ModuleCommit (struct plc *, uint32_t flags);
  579. /*====================================================================*
  580. * functions;
  581. *--------------------------------------------------------------------*/
  582. #ifdef __GNUC__
  583. __attribute__ ((format (printf, 2, 3)))
  584. #endif
  585. void Request (struct plc *, char const * format, ...);
  586. #ifdef __GNUC__
  587. __attribute__ ((format (printf, 2, 3)))
  588. #endif
  589. void Confirm (struct plc *, char const * format, ...);
  590. #ifdef __GNUC__
  591. __attribute__ ((format (printf, 2, 3)))
  592. #endif
  593. void Display (struct plc *, char const * format, ...);
  594. #ifdef __GNUC__
  595. __attribute__ ((format (printf, 2, 3)))
  596. #endif
  597. void Failure (struct plc *, char const * format, ...);
  598. /*====================================================================*
  599. *
  600. *--------------------------------------------------------------------*/
  601. #endif
  602. </pre>
  603. <div class='footerlink'>
  604. [<a href='pib.h.html' title=' pib.h '>PREV</a>]
  605. [<a href='toolkit.html' title=' Index '>HOME</a>]
  606. [<a href='putoptv.h.html' title=' putoptv.h '>NEXT</a>]
  607. </div>
  608. </body>
  609. </html>