nvmem.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. /*****************************************************************************
  2. *
  3. * nvmem.h - CC3000 Host Driver Implementation.
  4. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. *
  13. * Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in the
  15. * documentation and/or other materials provided with the
  16. * distribution.
  17. *
  18. * Neither the name of Texas Instruments Incorporated nor the names of
  19. * its contributors may be used to endorse or promote products derived
  20. * from this software without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  25. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  26. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  27. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  28. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  29. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  30. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  31. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  32. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. *
  34. *****************************************************************************/
  35. #ifndef __CC3000_NVRAM_H__
  36. #define __CC3000_NVRAM_H__
  37. #include "cc3000_common.h"
  38. //*****************************************************************************
  39. //
  40. // If building with a C++ compiler, make all of the definitions in this header
  41. // have a C binding.
  42. //
  43. //*****************************************************************************
  44. #ifdef __cplusplus
  45. extern "C" {
  46. #endif
  47. //*****************************************************************************
  48. //
  49. //! \addtogroup nvmem_api
  50. //! @{
  51. //
  52. //*****************************************************************************
  53. /****************************************************************************
  54. **
  55. ** Definitions for File IDs
  56. **
  57. ****************************************************************************/
  58. /* NVMEM file ID - system files*/
  59. #define NVMEM_NVS_FILEID (0)
  60. #define NVMEM_NVS_SHADOW_FILEID (1)
  61. #define NVMEM_WLAN_CONFIG_FILEID (2)
  62. #define NVMEM_WLAN_CONFIG_SHADOW_FILEID (3)
  63. #define NVMEM_WLAN_DRIVER_SP_FILEID (4)
  64. #define NVMEM_WLAN_FW_SP_FILEID (5)
  65. #define NVMEM_MAC_FILEID (6)
  66. #define NVMEM_FRONTEND_VARS_FILEID (7)
  67. #define NVMEM_IP_CONFIG_FILEID (8)
  68. #define NVMEM_IP_CONFIG_SHADOW_FILEID (9)
  69. #define NVMEM_BOOTLOADER_SP_FILEID (10)
  70. #define NVMEM_RM_FILEID (11)
  71. /* NVMEM file ID - user files*/
  72. #define NVMEM_AES128_KEY_FILEID (12)
  73. #define NVMEM_SHARED_MEM_FILEID (13)
  74. /* max entry in order to invalid nvmem */
  75. #define NVMEM_MAX_ENTRY (16)
  76. //*****************************************************************************
  77. //
  78. //! nvmem_read
  79. //!
  80. //! @param ulFileId nvmem file id:\n
  81. //! NVMEM_NVS_FILEID, NVMEM_NVS_SHADOW_FILEID,
  82. //! NVMEM_WLAN_CONFIG_FILEID, NVMEM_WLAN_CONFIG_SHADOW_FILEID,
  83. //! NVMEM_WLAN_DRIVER_SP_FILEID, NVMEM_WLAN_FW_SP_FILEID,
  84. //! NVMEM_MAC_FILEID, NVMEM_FRONTEND_VARS_FILEID,
  85. //! NVMEM_IP_CONFIG_FILEID, NVMEM_IP_CONFIG_SHADOW_FILEID,
  86. //! NVMEM_BOOTLOADER_SP_FILEID, NVMEM_RM_FILEID,
  87. //! and user files 12-15.
  88. //! @param ulLength number of bytes to read
  89. //! @param ulOffset ulOffset in file from where to read
  90. //! @param buff output buffer pointer
  91. //!
  92. //! @return on success 0, error otherwise.
  93. //!
  94. //! @brief Reads data from the file referred by the ulFileId parameter.
  95. //! Reads data from file ulOffset till length. Err if the file can't
  96. //! be used, is invalid, or if the read is out of bounds.
  97. //!
  98. //*****************************************************************************
  99. extern INT32 nvmem_read(UINT32 file_id, UINT32 length, UINT32 offset, UINT8 *buff);
  100. //*****************************************************************************
  101. //
  102. //! nvmem_write
  103. //!
  104. //! @param ulFileId nvmem file id:\n
  105. //! NVMEM_WLAN_DRIVER_SP_FILEID, NVMEM_WLAN_FW_SP_FILEID,
  106. //! NVMEM_MAC_FILEID, NVMEM_BOOTLOADER_SP_FILEID,
  107. //! and user files 12-15.
  108. //! @param ulLength number of bytes to write
  109. //! @param ulEntryOffset offset in file to start write operation from
  110. //! @param buff data to write
  111. //!
  112. //! @return on success 0, error otherwise.
  113. //!
  114. //! @brief Write data to nvmem.
  115. //! writes data to file referred by the ulFileId parameter.
  116. //! Writes data to file ulOffset till ulLength.The file id will be
  117. //! marked invalid till the write is done. The file entry doesn't
  118. //! need to be valid - only allocated.
  119. //!
  120. //*****************************************************************************
  121. extern INT32 nvmem_write(UINT32 ulFileId, UINT32 ulLength, UINT32 ulEntryOffset, UINT8 *buff);
  122. //*****************************************************************************
  123. //
  124. //! nvmem_set_mac_address
  125. //!
  126. //! @param mac mac address to be set
  127. //!
  128. //! @return on success 0, error otherwise.
  129. //!
  130. //! @brief Write MAC address to EEPROM.
  131. //! mac address as appears over the air (OUI first)
  132. //!
  133. //*****************************************************************************
  134. extern UINT8 nvmem_set_mac_address(UINT8 *mac);
  135. //*****************************************************************************
  136. //
  137. //! nvmem_get_mac_address
  138. //!
  139. //! @param[out] mac mac address
  140. //!
  141. //! @return on success 0, error otherwise.
  142. //!
  143. //! @brief Read MAC address from EEPROM.
  144. //! mac address as appears over the air (OUI first)
  145. //!
  146. //*****************************************************************************
  147. extern UINT8 nvmem_get_mac_address(UINT8 *mac);
  148. //*****************************************************************************
  149. //
  150. //! nvmem_write_patch
  151. //!
  152. //! @param ulFileId nvmem file id:\n
  153. //! NVMEM_WLAN_DRIVER_SP_FILEID, NVMEM_WLAN_FW_SP_FILEID,
  154. //! @param spLength number of bytes to write
  155. //! @param spData SP data to write
  156. //!
  157. //! @return on success 0, error otherwise.
  158. //!
  159. //! @brief program a patch to a specific file ID.
  160. //! The SP data is assumed to be organized in 2-dimensional.
  161. //! Each line is SP_PORTION_SIZE bytes long. Actual programming is
  162. //! applied in SP_PORTION_SIZE bytes portions.
  163. //!
  164. //*****************************************************************************
  165. extern UINT8 nvmem_write_patch(UINT32 ulFileId, UINT32 spLength, const UINT8 *spData);
  166. //*****************************************************************************
  167. //
  168. //! nvmem_read_sp_version
  169. //!
  170. //! @param[out] patchVer first number indicates package ID and the second
  171. //! number indicates package build number
  172. //!
  173. //! @return on success 0, error otherwise.
  174. //!
  175. //! @brief Read patch version. read package version (WiFi FW patch,
  176. //! driver-supplicant-NS patch, bootloader patch)
  177. //!
  178. //*****************************************************************************
  179. #ifndef CC3000_TINY_DRIVER
  180. extern UINT8 nvmem_read_sp_version(UINT8* patchVer);
  181. #endif
  182. //*****************************************************************************
  183. //
  184. //! nvmem_create_entry
  185. //!
  186. //! @param ulFileId nvmem file Id:\n
  187. //! * NVMEM_AES128_KEY_FILEID: 12
  188. //! * NVMEM_SHARED_MEM_FILEID: 13
  189. //! * and fileIDs 14 and 15
  190. //! @param ulNewLen entry ulLength
  191. //!
  192. //! @return on success 0, error otherwise.
  193. //!
  194. //! @brief Create new file entry and allocate space on the NVMEM.
  195. //! Applies only to user files.
  196. //! Modify the size of file.
  197. //! If the entry is unallocated - allocate it to size
  198. //! ulNewLen (marked invalid).
  199. //! If it is allocated then deallocate it first.
  200. //! To just mark the file as invalid without resizing -
  201. //! set ulNewLen=0.
  202. //!
  203. //*****************************************************************************
  204. extern INT32 nvmem_create_entry(UINT32 file_id, UINT32 newlen);
  205. //*****************************************************************************
  206. //
  207. // Mark the end of the C bindings section for C++ compilers.
  208. //
  209. //*****************************************************************************
  210. //*****************************************************************************
  211. //
  212. // Close the Doxygen group.
  213. //! @}
  214. //
  215. //*****************************************************************************
  216. #ifdef __cplusplus
  217. }
  218. #endif // __cplusplus
  219. #endif // __CC3000_NVRAM_H__