plchost.c.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  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. plchost.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='PLCHostBoot.c.html' title=' PLCHostBoot.c '>PREV</a>]
  17. [<a href='toolkit.html' title=' Index '>HOME</a>]
  18. [<a href='plchostd2.c.html' title=' plchostd2.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. /*====================================================================*&quot;
  62. *
  63. * plchost.c -
  64. *
  65. *
  66. * Contributor(s):
  67. * Charles Maier &lt;cmaier@qca.qualcomm.com&gt;
  68. *
  69. *--------------------------------------------------------------------*/
  70. /*====================================================================*&quot;
  71. * system header files;
  72. *--------------------------------------------------------------------*/
  73. #include &lt;unistd.h&gt;
  74. #include &lt;stdlib.h&gt;
  75. #include &lt;limits.h&gt;
  76. #include &lt;string.h&gt;
  77. #include &lt;ctype.h&gt;
  78. #include &lt;memory.h&gt;
  79. #include &lt;signal.h&gt;
  80. #include &lt;errno.h&gt;
  81. #include &lt;sys/socket.h&gt;
  82. /*====================================================================*
  83. * custom header files;
  84. *--------------------------------------------------------------------*/
  85. #include &quot;../ether/channel.h&quot;
  86. #include &quot;../tools/getoptv.h&quot;
  87. #include &quot;../tools/putoptv.h&quot;
  88. #include &quot;../tools/memory.h&quot;
  89. #include &quot;../tools/number.h&quot;
  90. #include &quot;../tools/types.h&quot;
  91. #include &quot;../tools/flags.h&quot;
  92. #include &quot;../tools/files.h&quot;
  93. #include &quot;../tools/error.h&quot;
  94. #include &quot;../ram/nvram.h&quot;
  95. #include &quot;../ram/sdram.h&quot;
  96. #include &quot;../nvm/nvm.h&quot;
  97. #include &quot;../pib/pib.h&quot;
  98. #include &quot;../plc/plc.h&quot;
  99. /*====================================================================*
  100. * custom source files;
  101. *--------------------------------------------------------------------*/
  102. #ifndef MAKEFILE
  103. #include &quot;../plc/BootDevice2.c&quot;
  104. #include &quot;../plc/BootFirmware2.c&quot;
  105. #include &quot;../plc/BootParameters2.c&quot;
  106. #include &quot;../plc/chipset.c&quot;
  107. #include &quot;../plc/Confirm.c&quot;
  108. #include &quot;../plc/Devices.c&quot;
  109. #include &quot;../plc/Failure.c&quot;
  110. #include &quot;../plc/FlashDevice2.c&quot;
  111. #include &quot;../plc/FlashSoftloader.c&quot;
  112. #include &quot;../plc/FlashFirmware.c&quot;
  113. #include &quot;../plc/FlashParameters.c&quot;
  114. #include &quot;../plc/FlashNVM.c&quot;
  115. #include &quot;../plc/HostActionResponse.c&quot;
  116. #include &quot;../plc/InitDevice2.c&quot;
  117. #include &quot;../plc/ModuleRead.c&quot;
  118. #include &quot;../plc/ModuleSpec.c&quot;
  119. #include &quot;../plc/ModuleSession.c&quot;
  120. #include &quot;../plc/ModuleWrite.c&quot;
  121. #include &quot;../plc/ModuleCommit.c&quot;
  122. #include &quot;../plc/LocalDevices.c&quot;
  123. #include &quot;../plc/NVMSelect.c&quot;
  124. #include &quot;../plc/ReadFirmware2.c&quot;
  125. #include &quot;../plc/ReadParameters2.c&quot;
  126. #include &quot;../plc/Request.c&quot;
  127. #include &quot;../plc/ResetDevice.c&quot;
  128. #include &quot;../plc/ReadMME.c&quot;
  129. #include &quot;../plc/SendMME.c&quot;
  130. #include &quot;../plc/WaitForReset.c&quot;
  131. #include &quot;../plc/WaitForStart.c&quot;
  132. #include &quot;../plc/WriteMEM.c&quot;
  133. #include &quot;../plc/WriteNVM.c&quot;
  134. #include &quot;../plc/WritePIB.c&quot;
  135. #include &quot;../plc/WriteExecuteFirmware2.c&quot;
  136. #include &quot;../plc/WriteExecuteParameters2.c&quot;
  137. #include &quot;../plc/WriteExecuteApplet2.c&quot;
  138. #include &quot;../plc/WriteFirmware2.c&quot;
  139. #include &quot;../plc/PLCSelect.c&quot;
  140. #endif
  141. #ifndef MAKEFILE
  142. #include &quot;../tools/getoptv.c&quot;
  143. #include &quot;../tools/putoptv.c&quot;
  144. #include &quot;../tools/version.c&quot;
  145. #include &quot;../tools/uintspec.c&quot;
  146. #include &quot;../tools/checkfilename.c&quot;
  147. #include &quot;../tools/hexdecode.c&quot;
  148. #include &quot;../tools/hexstring.c&quot;
  149. #include &quot;../tools/todigit.c&quot;
  150. #include &quot;../tools/hexdump.c&quot;
  151. #include &quot;../tools/checksum32.c&quot;
  152. #include &quot;../tools/fdchecksum32.c&quot;
  153. #include &quot;../tools/error.c&quot;
  154. #include &quot;../tools/strfbits.c&quot;
  155. #include &quot;../tools/typename.c&quot;
  156. #endif
  157. #ifndef MAKEFILE
  158. #include &quot;../ether/openchannel.c&quot;
  159. #include &quot;../ether/closechannel.c&quot;
  160. #include &quot;../ether/readpacket.c&quot;
  161. #include &quot;../ether/sendpacket.c&quot;
  162. #include &quot;../ether/channel.c&quot;
  163. #endif
  164. #ifndef MAKEFILE
  165. #include &quot;../mme/EthernetHeader.c&quot;
  166. #include &quot;../mme/QualcommHeader.c&quot;
  167. #include &quot;../mme/UnwantedMessage.c&quot;
  168. #include &quot;../mme/MMECode.c&quot;
  169. #ifdef AR7x00
  170. #include &quot;../mme/QualcommHeader1.c&quot;
  171. #endif
  172. #endif
  173. #ifndef MAKEFILE
  174. #include &quot;../key/keys.c&quot;
  175. #endif
  176. #ifndef MAKEFILE
  177. #include &quot;../nvm/nvmfile2.c&quot;
  178. #endif
  179. #ifndef MAKEFILE
  180. #include &quot;../pib/pibfile2.c&quot;
  181. #include &quot;../pib/pibpeek2.c&quot;
  182. #endif
  183. /*====================================================================*
  184. * program constants;
  185. *--------------------------------------------------------------------*/
  186. #define NEWPIB &quot;user.pib&quot;
  187. #define NEWNVM &quot;user.nvm&quot;
  188. /*====================================================================*
  189. *
  190. * signed function (struct plc * plc);
  191. *
  192. * wait indefinitely for VS_HOST_ACTION messages; service the device
  193. * only; it will stop dead - like a bug! - on error;
  194. *
  195. *
  196. * Contributor(s):
  197. * Charles Maier &lt;cmaier@qca.qualcomm.com&gt;
  198. *
  199. *--------------------------------------------------------------------*/
  200. signed function (struct plc * plc)
  201. {
  202. struct channel * channel = (struct channel *)(plc-&gt;channel);
  203. struct message * message = (struct message *)(plc-&gt;message);
  204. #ifndef __GNUC__
  205. #pragma pack (push,1)
  206. #endif
  207. struct __packed vs_host_action_ind
  208. {
  209. struct ethernet_hdr ethernet;
  210. struct qualcomm_hdr qualcomm;
  211. uint8_t MACTION;
  212. uint8_t MAJOR_VERSION;
  213. uint8_t MINOR_VERSION;
  214. }
  215. * indicate = (struct vs_host_action_ind *) (message);
  216. #ifndef __GNUC__
  217. #pragma pack (pop)
  218. #endif
  219. char firmware [PLC_VERSION_STRING];
  220. char const * FactoryNVM = plc-&gt;NVM.name;
  221. char const * FactoryPIB = plc-&gt;PIB.name;
  222. signed status;
  223. while (true)
  224. {
  225. status = ReadMME (plc, 0, (VS_HOST_ACTION | MMTYPE_IND));
  226. if (status &lt; 0)
  227. {
  228. break;
  229. }
  230. if (status &gt; 0)
  231. {
  232. signed action = indicate-&gt;MACTION;
  233. memcpy (channel-&gt;peer, indicate-&gt;ethernet.OSA, sizeof (channel-&gt;peer));
  234. if (HostActionResponse (plc))
  235. {
  236. return (-1);
  237. }
  238. if (action == 0x00)
  239. {
  240. if (BootDevice2 (plc))
  241. {
  242. return (-1);
  243. }
  244. if (WaitForStart (plc, firmware, sizeof (firmware)))
  245. {
  246. return (-1);
  247. }
  248. if (_anyset (plc-&gt;flags, PLC_FLASH_DEVICE))
  249. {
  250. FlashDevice2 (plc, (PLC_COMMIT_FORCE | PLC_COMMIT_NORESET | PLC_COMMIT_FACTPIB));
  251. }
  252. continue;
  253. }
  254. if (action == 0x01)
  255. {
  256. close (plc-&gt;NVM.file);
  257. if (ReadFirmware2 (plc))
  258. {
  259. return (-1);
  260. }
  261. if ((plc-&gt;NVM.file = open (plc-&gt;NVM.name = plc-&gt;nvm.name, O_BINARY|O_RDONLY)) == -1)
  262. {
  263. error (1, errno, &quot;%s&quot;, plc-&gt;NVM.name);
  264. }
  265. continue;
  266. }
  267. if (action == 0x02)
  268. {
  269. close (plc-&gt;PIB.file);
  270. if (ReadParameters2 (plc))
  271. {
  272. return (-1);
  273. }
  274. if ((plc-&gt;PIB.file = open (plc-&gt;PIB.name = plc-&gt;pib.name, O_BINARY|O_RDONLY)) == -1)
  275. {
  276. error (1, errno, &quot;%s&quot;, plc-&gt;PIB.name);
  277. }
  278. if (ResetDevice (plc))
  279. {
  280. return (-1);
  281. }
  282. continue;
  283. }
  284. if (action == 0x03)
  285. {
  286. close (plc-&gt;PIB.file);
  287. if (ReadParameters2 (plc))
  288. {
  289. return (-1);
  290. }
  291. if ((plc-&gt;PIB.file = open (plc-&gt;PIB.name = plc-&gt;pib.name, O_BINARY|O_RDONLY)) == -1)
  292. {
  293. error (1, errno, &quot;%s&quot;, plc-&gt;PIB.name);
  294. }
  295. close (plc-&gt;NVM.file);
  296. if (ReadFirmware2 (plc))
  297. {
  298. return (-1);
  299. }
  300. if ((plc-&gt;NVM.file = open (plc-&gt;NVM.name = plc-&gt;nvm.name, O_BINARY|O_RDONLY)) == -1)
  301. {
  302. error (1, errno, &quot;%s&quot;, plc-&gt;NVM.name);
  303. }
  304. if (ResetDevice (plc))
  305. {
  306. return (-1);
  307. }
  308. continue;
  309. }
  310. if (action == 0x04)
  311. {
  312. if (InitDevice2 (plc))
  313. {
  314. return (-1);
  315. }
  316. continue;
  317. }
  318. if (action == 0x05)
  319. {
  320. close (plc-&gt;NVM.file);
  321. if ((plc-&gt;NVM.file = open (plc-&gt;NVM.name = FactoryNVM, O_BINARY|O_RDONLY)) == -1)
  322. {
  323. error (1, errno, &quot;%s&quot;, plc-&gt;NVM.name);
  324. }
  325. close (plc-&gt;PIB.file);
  326. if ((plc-&gt;PIB.file = open (plc-&gt;PIB.name = FactoryPIB, O_BINARY|O_RDONLY)) == -1)
  327. {
  328. error (1, errno, &quot;%s&quot;, plc-&gt;PIB.name);
  329. }
  330. if (ResetDevice (plc))
  331. {
  332. return (-1);
  333. }
  334. continue;
  335. }
  336. if (action == 0x06)
  337. {
  338. close (plc-&gt;PIB.file);
  339. if (ReadParameters2 (plc))
  340. {
  341. return (-1);
  342. }
  343. if ((plc-&gt;PIB.file = open (plc-&gt;PIB.name = plc-&gt;pib.name, O_BINARY|O_RDONLY)) == -1)
  344. {
  345. error (1, errno, &quot;%s&quot;, plc-&gt;PIB.name);
  346. }
  347. continue;
  348. }
  349. error (0, ENOSYS, &quot;Host Action 0x%02X&quot;, action);
  350. }
  351. }
  352. return (0);
  353. }
  354. /*====================================================================*
  355. *
  356. * int main (int argc, char const * argv[]);
  357. *
  358. * parse command line, populate plc structure and perform selected
  359. * operations; show help summary when asked; see getoptv and putoptv
  360. * to understand command line parsing and help summary display; see
  361. * plc.h for the definition of struct plc;
  362. *
  363. *
  364. *--------------------------------------------------------------------*/
  365. int main (int argc, char const * argv [])
  366. {
  367. extern struct channel channel;
  368. extern void terminate (signo_t);
  369. static char const * optv [] =
  370. {
  371. &quot;Fi:n:N:p:P:qS:t:vw:x&quot;,
  372. &quot;-N file -P file [-S file]&quot;,
  373. &quot;Qualcomm Atheros PLC Host Daemon&quot;,
  374. &quot;F [F]\tflash [force] non-volatile memory&quot;,
  375. #if defined (WINPCAP) || defined (LIBPCAP)
  376. &quot;i n\thost interface is (n) [&quot; LITERAL (CHANNEL_ETHNUMBER) &quot;]&quot;,
  377. #else
  378. &quot;i s\thost interface is (s) [&quot; LITERAL (CHANNEL_ETHDEVICE) &quot;]&quot;,
  379. #endif
  380. &quot;n f\tuser firmware file is (f)&quot;,
  381. &quot;N f\tfirmware file is (f)&quot;,
  382. &quot;p f\tuser parameter file is (f)&quot;,
  383. &quot;P f\tparameter file is (f)&quot;,
  384. &quot;q\tquiet mode&quot;,
  385. &quot;S f\tsoftloader file is (f)&quot;,
  386. &quot;t n\tread timeout is (n) milliseconds [&quot; LITERAL (CHANNEL_TIMEOUT) &quot;]&quot;,
  387. &quot;v\tverbose mode&quot;,
  388. &quot;w n\twakeup every (n) seconds [&quot; LITERAL (PLC_LONGTIME) &quot;]&quot;,
  389. &quot;x\texit on error&quot;,
  390. (char const *) (0)
  391. };
  392. #include &quot;../plc/plc.c&quot;
  393. signed c;
  394. if (getenv (PLCDEVICE))
  395. {
  396. #if defined (WINPCAP) || defined (LIBPCAP)
  397. channel.ifindex = atoi (getenv (PLCDEVICE));
  398. #else
  399. channel.ifname = strdup (getenv (PLCDEVICE));
  400. #endif
  401. }
  402. optind = 1;
  403. plc.timer = PLC_LONGTIME;
  404. while ((c = getoptv (argc, argv, optv)) != -1)
  405. {
  406. switch (c)
  407. {
  408. case 'd':
  409. _setbits (plc.flags, PLC_DAEMON);
  410. break;
  411. case 'F':
  412. _setbits (plc.module, (VS_MODULE_MAC | VS_MODULE_PIB));
  413. if (_anyset (plc.flags, PLC_FLASH_DEVICE))
  414. {
  415. _setbits (plc.module, VS_MODULE_FORCE);
  416. }
  417. _setbits (plc.flags, PLC_FLASH_DEVICE);
  418. break;
  419. case 'i':
  420. #if defined (WINPCAP) || defined (LIBPCAP)
  421. channel.ifindex = atoi (optarg);
  422. #else
  423. channel.ifname = optarg;
  424. #endif
  425. break;
  426. case 'N':
  427. if (!checkfilename (optarg))
  428. {
  429. error (1, EINVAL, &quot;%s&quot;, optarg);
  430. }
  431. if ((plc.NVM.file = open (plc.NVM.name = optarg, O_BINARY|O_RDONLY)) == -1)
  432. {
  433. error (1, errno, &quot;%s&quot;, plc.NVM.name);
  434. }
  435. if (nvmfile2 (&amp;plc.NVM))
  436. {
  437. error (1, errno, &quot;Bad firmware file: %s&quot;, plc.NVM.name);
  438. }
  439. _setbits (plc.flags, PLC_WRITE_MAC);
  440. break;
  441. case 'n':
  442. if (!checkfilename (optarg))
  443. {
  444. error (1, EINVAL, &quot;%s&quot;, optarg);
  445. }
  446. if ((plc.nvm.file = open (plc.nvm.name = optarg, O_BINARY|O_CREAT|O_RDWR|O_TRUNC, FILE_FILEMODE)) == -1)
  447. {
  448. error (1, errno, &quot;%s&quot;, plc.nvm.name);
  449. }
  450. break;
  451. case 'P':
  452. if (!checkfilename (optarg))
  453. {
  454. error (1, EINVAL, &quot;%s&quot;, optarg);
  455. }
  456. if ((plc.PIB.file = open (plc.PIB.name = optarg, O_BINARY|O_RDONLY)) == -1)
  457. {
  458. error (1, errno, &quot;%s&quot;, plc.PIB.name);
  459. }
  460. if (pibfile2 (&amp;plc.PIB))
  461. {
  462. error (1, errno, &quot;Bad parameter file: %s&quot;, plc.PIB.name);
  463. }
  464. _setbits (plc.flags, PLC_WRITE_PIB);
  465. break;
  466. case 'p':
  467. if (!checkfilename (optarg))
  468. {
  469. error (1, EINVAL, &quot;%s&quot;, optarg);
  470. }
  471. if ((plc.pib.file = open (plc.pib.name = optarg, O_BINARY|O_CREAT|O_RDWR|O_TRUNC, FILE_FILEMODE)) == -1)
  472. {
  473. error (1, errno, &quot;%s&quot;, plc.pib.name);
  474. }
  475. break;
  476. case 'q':
  477. _setbits (channel.flags, CHANNEL_SILENCE);
  478. _setbits (plc.flags, PLC_SILENCE);
  479. break;
  480. case 'S':
  481. if (!checkfilename (optarg))
  482. {
  483. error (1, EINVAL, &quot;%s&quot;, optarg);
  484. }
  485. if ((plc.CFG.file = open (plc.CFG.name = optarg, O_BINARY|O_RDONLY)) == -1)
  486. {
  487. error (1, errno, &quot;%s&quot;, plc.CFG.name);
  488. }
  489. if (nvmfile2 (&amp;plc.CFG))
  490. {
  491. error (1, errno, &quot;Bad firmware file: %s&quot;, plc.CFG.name);
  492. }
  493. break;
  494. case 't':
  495. channel.timeout = (signed)(uintspec (optarg, 0, UINT_MAX));
  496. break;
  497. case 'v':
  498. _setbits (channel.flags, CHANNEL_VERBOSE);
  499. _setbits (plc.flags, PLC_VERBOSE);
  500. break;
  501. case 'w':
  502. plc.timer = (unsigned)(uintspec (optarg, 1, 3600));
  503. break;
  504. case 'x':
  505. _setbits (plc.flags, PLC_BAILOUT);
  506. break;
  507. default:
  508. break;
  509. }
  510. }
  511. argc -= optind;
  512. argv += optind;
  513. if (argc)
  514. {
  515. error (1, ENOTSUP, ERROR_TOOMANY);
  516. }
  517. if (plc.NVM.file == -1)
  518. {
  519. error (1, ECANCELED, &quot;No host NVM file named&quot;);
  520. }
  521. if (plc.PIB.file == -1)
  522. {
  523. error (1, ECANCELED, &quot;No host PIB file named&quot;);
  524. }
  525. if (plc.CFG.file == -1)
  526. {
  527. if (_anyset (plc.flags, PLC_FLASH_DEVICE))
  528. {
  529. error (1, ECANCELED, &quot;No Softloader file named&quot;);
  530. }
  531. }
  532. if (plc.nvm.file == -1)
  533. {
  534. if ((plc.nvm.file = open (plc.nvm.name = NEWNVM, O_BINARY|O_CREAT|O_RDWR|O_TRUNC, FILE_FILEMODE)) == -1)
  535. {
  536. error (1, errno, &quot;%s&quot;, plc.nvm.name);
  537. }
  538. }
  539. if (plc.pib.file == -1)
  540. {
  541. if ((plc.pib.file = open (plc.pib.name = NEWPIB, O_BINARY|O_CREAT|O_RDWR|O_TRUNC, FILE_FILEMODE)) == -1)
  542. {
  543. error (1, errno, &quot;%s&quot;, plc.pib.name);
  544. }
  545. }
  546. openchannel (&amp;channel);
  547. if (!(plc.message = malloc (sizeof (* plc.message))))
  548. {
  549. error (1, errno, PLC_NOMEMORY);
  550. }
  551. function (&amp;plc);
  552. free (plc.message);
  553. closechannel (&amp;channel);
  554. exit (0);
  555. }
  556. </pre>
  557. <div class='footerlink'>
  558. [<a href='PLCHostBoot.c.html' title=' PLCHostBoot.c '>PREV</a>]
  559. [<a href='toolkit.html' title=' Index '>HOME</a>]
  560. [<a href='plchostd2.c.html' title=' plchostd2.c '>NEXT</a>]
  561. </div>
  562. </body>
  563. </html>