nvm.h.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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. nvm.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='number.h.html' title=' number.h '>PREV</a>]
  17. [<a href='toolkit.html' title=' Index '>HOME</a>]
  18. [<a href='nvram.h.html' title=' nvram.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. /*====================================================================*
  62. *
  63. * nvm.h - nvm file format definitions and declarations;
  64. *
  65. * Contributor(s):
  66. * Charles Maier &lt;cmaier@qca.qualcomm.com&gt;
  67. *
  68. *--------------------------------------------------------------------*/
  69. #ifndef NVM_HEADER
  70. #define NVM_HEADER
  71. /*====================================================================*
  72. * system header files;
  73. *--------------------------------------------------------------------*/
  74. #include &lt;unistd.h&gt;
  75. /*====================================================================*
  76. * custom header files;
  77. *--------------------------------------------------------------------*/
  78. #include &quot;../tools/types.h&quot;
  79. /*====================================================================*
  80. * nvm program constants;
  81. *--------------------------------------------------------------------*/
  82. #define NVM_IMAGETYPES 18
  83. #define NVM_PLATFORMS 5
  84. /*====================================================================*
  85. * nvm program flags;
  86. *--------------------------------------------------------------------*/
  87. #define NVM_SILENCE (1 &lt;&lt; 0)
  88. #define NVM_VERBOSE (1 &lt;&lt; 1)
  89. #define NVM_MANIFEST (1 &lt;&lt; 2)
  90. #define NVM_FIRMWARE (1 &lt;&lt; 3)
  91. #define NVM_IDENTITY (1 &lt;&lt; 4)
  92. #define NVM_SDRAM (1 &lt;&lt; 5)
  93. /*====================================================================*
  94. * nvm header execute masks;
  95. *--------------------------------------------------------------------*/
  96. #define NVM_IGNORE_MASK_INT6000 (1 &lt;&lt; 0)
  97. #define NVM_IGNORE_MASK_INT6300 (1 &lt;&lt; 1)
  98. #define NVM_IGNORE_MASK_INT6400 (1 &lt;&lt; 2)
  99. #define NVM_IGNORE_MASK_AR7400 (1 &lt;&lt; 4)
  100. #define NVM_IGNORE_MASK_QCA7420 (1 &lt;&lt; 8)
  101. /*====================================================================*
  102. * image chain types;
  103. *--------------------------------------------------------------------*/
  104. #define NVM_CHAIN_SOFTLOADER 0
  105. #define NVM_CHAIN_FIRMWARE 1
  106. #define NVM_CHAIN_PIB 2
  107. #define NVM_CHAIN_CUSTOM_MODULE 3
  108. #define NVM_CHAIN_MODULE_OP_SESSION 4
  109. /*====================================================================*
  110. * nvm build types;
  111. *--------------------------------------------------------------------*/
  112. #define NVM_BUILD_NIGHTLY 0
  113. #define NVM_BUILD_RELEASE 1
  114. #define NVM_BUILD_CUSTOM 2
  115. /*====================================================================*
  116. * nvm image types;
  117. *--------------------------------------------------------------------*/
  118. #define NVM_IMAGE_GENERIC 0x0000
  119. #define NVM_IMAGE_CONFIG_SYNOPSIS 0x0001
  120. #define NVM_IMAGE_CONFIG_DENALI 0x0002
  121. #define NVM_IMAGE_APPLET_DENALI 0x0003
  122. #define NVM_IMAGE_FIRMWARE 0x0004
  123. #define NVM_IMAGE_OASCLIENT 0x0005
  124. #define NVM_IMAGE_CUSTOM 0x0006
  125. #define NVM_IMAGE_MEMCTL 0x0007
  126. #define NVM_IMAGE_ADVPWRMGMT 0x0008
  127. #define NVM_IMAGE_OAS_CLIENT_IP_STK 0x0009
  128. #define NVM_IMAGE_OAS_CLIENT_TR069 0x000A
  129. #define NVM_IMAGE_NVM_SOFTLOADER 0x000B
  130. #define NVM_IMAGE_FLASH_LAYOUT 0x000C
  131. #define NVM_IMAGE_MANIFEST 0x000E
  132. #define NVM_IMAGE_PIB 0x000F
  133. /*====================================================================*
  134. * manifest field types;
  135. *--------------------------------------------------------------------*/
  136. #define NVM_FIELD_SIGNATURE 0
  137. #define NVM_FIELD_HARDWARE_COMPAT 1
  138. #define NVM_FIELD_CHAIN_MAJOR_VERSION 2
  139. #define NVM_FIELD_CHAIN_MINOR_VERSION 3
  140. #define NVM_FIELD_CHAIN_TYPE 4
  141. #define NVM_FIELD_BUILD_MAJOR_VERSION 5
  142. #define NVM_FIELD_BUILD_MINOR_VERSION 6
  143. #define NVM_FIELD_BUILD_TYPE 7
  144. #define NVM_FIELD_MANIFEST_VERSION 8
  145. #define NVM_FIELD_BUILD_NUMBER 9
  146. #define NVM_FIELD_BUILD_DATE 10
  147. #define NVM_FIELD_BUILD_TIME 11
  148. #define NVM_FIELD_DEVICE_TYPE 12
  149. #define NVM_FIELD_BUILD_HOSTNAME 13
  150. #define NVM_FIELD_BUILD_USERNAME 14
  151. #define NVM_FIELD_BUILD_DESCRIPTION 15
  152. #define NVM_FIELD_BUILD_VERSION_STRING 16
  153. #define NVM_FIELD_BUILD_SUSTAINING_RELEASE 17
  154. #define NVM_FIELD_BUILD_MAJOR_SUBVERSION 18
  155. #define NVM_FIELD_GENERIC_ID0 19
  156. #define NVM_FIELD_GENERIC_ID1 20
  157. #define NVM_FIELD_SL_MAJOR_VERSION 21
  158. #define NVM_FIELD_SL_MINOR_VERSION 22
  159. #define NVM_FIELD_FREE_SPACE 23
  160. /*====================================================================*
  161. * toolkit nvm error messages;
  162. *--------------------------------------------------------------------*/
  163. #define NVM_HDR_VERSION &quot;%s found bad NVM header version in %s module %d&quot;, __func__
  164. #define NVM_HDR_CHECKSUM &quot;%s found bad NVM header checksum in %s module %d&quot;, __func__
  165. #define NVM_HDR_LINK &quot;%s found bad NVM header link in %s module %d&quot;, __func__
  166. #define NVM_IMG_CHECKSUM &quot;%s found bad image checksum in %s module %d&quot;, __func__
  167. #define NVM_HDR_CANTREAD &quot;%s can't read image header in %s module %d&quot;, __func__
  168. #define NVM_HDR_CANTSAVE &quot;%s can't save image header in %s module %d&quot;, __func__
  169. #define NVM_IMG_CANTREAD &quot;%s can't read image in %s module %d&quot;, __func__
  170. #define NVM_IMG_CANTSAVE &quot;%s can't save image in %s module %d&quot;, __func__
  171. #define NVM_IMG_RUN &quot;%s applet %d is still running&quot;
  172. /*====================================================================*
  173. * old nvm image header (44 bytes);
  174. *--------------------------------------------------------------------*/
  175. #ifndef __GNUC__
  176. #pragma pack (push,1)
  177. #endif
  178. typedef struct __packed nvm_header1
  179. {
  180. uint32_t HEADERVERSION;
  181. uint32_t IMAGEROMADDR;
  182. uint32_t IMAGEADDRESS;
  183. uint32_t IMAGELENGTH;
  184. uint32_t IMAGECHECKSUM;
  185. uint32_t ENTRYPOINT;
  186. uint8_t HEADERMINORVERSION;
  187. uint8_t IMAGETYPE;
  188. uint16_t IGNOREMASK;
  189. uint32_t MODULEID;
  190. uint32_t MODULESUBID;
  191. uint32_t NEXTHEADER;
  192. uint32_t HEADERCHECKSUM;
  193. }
  194. nvm_header1;
  195. #ifndef __GNUC__
  196. #pragma pack (pop)
  197. #endif
  198. /*====================================================================*
  199. * new nvm image header (96 bytes);
  200. *--------------------------------------------------------------------*/
  201. #ifndef __GNUC__
  202. #pragma pack (push,1)
  203. #endif
  204. typedef struct __packed nvm_header2
  205. {
  206. uint16_t MajorVersion;
  207. uint16_t MinorVersion;
  208. uint32_t ExecuteMask;
  209. uint32_t ImageNvmAddress;
  210. uint32_t ImageAddress;
  211. uint32_t ImageLength;
  212. uint32_t ImageChecksum;
  213. uint32_t EntryPoint;
  214. uint32_t NextHeader;
  215. uint32_t PrevHeader;
  216. uint32_t ImageType;
  217. uint16_t ModuleID;
  218. uint16_t ModuleSubID;
  219. uint16_t AppletEntryVersion;
  220. uint16_t Reserved0;
  221. uint32_t Reserved1;
  222. uint32_t Reserved2;
  223. uint32_t Reserved3;
  224. uint32_t Reserved4;
  225. uint32_t Reserved5;
  226. uint32_t Reserved6;
  227. uint32_t Reserved7;
  228. uint32_t Reserved8;
  229. uint32_t Reserved9;
  230. uint32_t Reserved10;
  231. uint32_t Reserved11;
  232. uint32_t HeaderChecksum;
  233. }
  234. nvm_header2;
  235. #ifndef __GNUC__
  236. #pragma pack (pop)
  237. #endif
  238. /*====================================================================*
  239. * nvm functions;
  240. *--------------------------------------------------------------------*/
  241. signed manifest (void const * memory, size_t extent);
  242. void * manifetch (void const * memory, size_t extent, uint32_t type);
  243. signed nvmfile (struct _file_ const *);
  244. signed nvmfile1 (struct _file_ const *);
  245. signed nvmfile2 (struct _file_ const *);
  246. signed fdmanifest (signed fd, char const * filename, struct nvm_header2 *, unsigned module);
  247. signed nvmseek1 (signed fd, char const * filename, struct nvm_header1 *, uint32_t imagetype);
  248. signed nvmseek2 (signed fd, char const * filename, struct nvm_header2 *, uint32_t imagetype);
  249. void nvmpeek (void const *);
  250. void nvmpeek1 (void const *);
  251. void nvmpeek2 (void const *);
  252. /*====================================================================*
  253. *
  254. *--------------------------------------------------------------------*/
  255. #endif
  256. </pre>
  257. <div class='footerlink'>
  258. [<a href='number.h.html' title=' number.h '>PREV</a>]
  259. [<a href='toolkit.html' title=' Index '>HOME</a>]
  260. [<a href='nvram.h.html' title=' nvram.h '>NEXT</a>]
  261. </div>
  262. </body>
  263. </html>