whd_resource_api.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * Copyright 2024, Cypress Semiconductor Corporation (an Infineon company)
  3. * SPDX-License-Identifier: Apache-2.0
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /** @file whd_resource_api.h
  18. * Prototypes of functions for providing external resources to the radio driver
  19. *
  20. * This file provides prototypes for functions which allow
  21. * WHD to download firmware, NVRAM and CLM BLOB on a particular hardware platform.
  22. *
  23. */
  24. #include "whd.h"
  25. #ifndef INCLUDED_WHD_RESOURCE_API_H_
  26. #define INCLUDED_WHD_RESOURCE_API_H_
  27. #ifdef __cplusplus
  28. extern "C"
  29. {
  30. #endif
  31. #define BLOCK_SIZE 1024 /**< Size of the block */
  32. #ifndef NVM_IMAGE_SIZE_ALIGNMENT
  33. #define NVM_IMAGE_SIZE_ALIGNMENT 4 /**< The alignment size of NVRAM image */
  34. #endif
  35. /**
  36. * Type of resources
  37. */
  38. typedef enum
  39. {
  40. WHD_RESOURCE_WLAN_FIRMWARE, /**< Resource type: WLAN Firmware */
  41. WHD_RESOURCE_WLAN_NVRAM, /**< Resource type: NVRAM file */
  42. WHD_RESOURCE_WLAN_CLM, /**< Resource type: CLM_BLOB file */
  43. } whd_resource_type_t;
  44. /******************************************************
  45. * Global Variables
  46. ******************************************************/
  47. /** @addtogroup res WHD Resource API
  48. * @brief Functions that enable WHD to download WLAN firmware, NVRAM and CLM BLOB on a particular hardware platform.
  49. * @{
  50. */
  51. /**
  52. * Interface to a data source that provides external resources to the radio driver
  53. */
  54. /** This data structure defines a source for data generally intended to be downloaded to the radio device.
  55. *
  56. * The data is assumed to be available as a set of blocks that are all the same size with the exception
  57. * of the last block. The whd_get_resource_block_size function returns this block size. The whd_get_resource_block call
  58. * returns a pointer to a block of data. The actual storage for the data block is owned by the data source, so only a pointer
  59. * to the block is returned. There are two predominate use cases. If the data is stored in the internal
  60. * flash memory, then whd_get_resource_no_of_blocks will return 1 and a call to whd_get_resource_block will return a pointer to
  61. * the data image with the size being the size of the data image. If the data is stored in an external flash of some
  62. * type, each block of data can be read from the external flash one at a time. whd_get_resource_no_of_blocks will return
  63. * the physical number of blocks in the data and each call to whd_get_resource_block will read data from the external memory
  64. * and make it available via an internal buffer.
  65. */
  66. struct whd_resource_source
  67. {
  68. /** Gets the size of the resource for respective resource type
  69. *
  70. *
  71. * @param whd_drv Pointer to handle instance of the driver
  72. * @param resource Type of resource - WHD_RESOURCE_WLAN_FIRMWARE, WHD_RESOURCE_WLAN_NVRAM, WHD_RESOURCE_WLAN_CLM
  73. * @param size_out Size of the resource
  74. *
  75. * @return WHD_SUCCESS or error code
  76. *
  77. */
  78. uint32_t (*whd_resource_size)(whd_driver_t whd_drv, whd_resource_type_t resource, uint32_t *size_out);
  79. /** Gets the resource block for specified resource type
  80. *
  81. * @param whd_drv Pointer to handle instance of the driver
  82. * @param type Type of resource - WHD_RESOURCE_WLAN_FIRMWARE, WHD_RESOURCE_WLAN_NVRAM, WHD_RESOURCE_WLAN_CLM
  83. * @param blockno The number of block
  84. * @param data Pointer to a block of data
  85. * @param size_out Size of the resource
  86. *
  87. * @return WHD_SUCCESS or error code
  88. *
  89. */
  90. uint32_t (*whd_get_resource_block)(whd_driver_t whd_drv, whd_resource_type_t type,
  91. uint32_t blockno, const uint8_t **data, uint32_t *size_out);
  92. /** Gets block count for the specified resource_type
  93. *
  94. * @param whd_drv Pointer to handle instance of the driver
  95. * @param type Type of resource - WHD_RESOURCE_WLAN_FIRMWARE, WHD_RESOURCE_WLAN_NVRAM, WHD_RESOURCE_WLAN_CLM
  96. * @param block_count Pointer to store block count for the resource
  97. *
  98. * @return WHD_SUCCESS or error code
  99. *
  100. */
  101. uint32_t (*whd_get_resource_no_of_blocks)(whd_driver_t whd_drv, whd_resource_type_t type, uint32_t *block_count);
  102. /** Gets block size for the specified resource_type
  103. *
  104. * @param whd_drv Pointer to handle instance of the driver
  105. * @param type Type of resources - WHD_RESOURCE_WLAN_FIRMWARE, WHD_RESOURCE_WLAN_NVRAM, WHD_RESOURCE_WLAN_CLM
  106. * @param size_out Pointer to store size of the block
  107. *
  108. * @return WHD_SUCCESS or error code
  109. *
  110. */
  111. uint32_t (*whd_get_resource_block_size)(whd_driver_t whd_drv, whd_resource_type_t type, uint32_t *size_out);
  112. /** Gets the resource for specified resource type
  113. *
  114. * @param whd_drv Pointer to handle instance of the driver
  115. * @param type Type of resource - WHD_RESOURCE_WLAN_FIRMWARE, WHD_RESOURCE_WLAN_NVRAM, WHD_RESOURCE_WLAN_CLM
  116. * @param offset offset address to store buffer
  117. * @param size Pointer to a size of buffer
  118. * @param size_out Pointer to store size of buffer
  119. * @param buffer Pointer to a buffer
  120. *
  121. * @return WHD_SUCCESS or error code
  122. *
  123. */
  124. uint32_t (*whd_resource_read)(whd_driver_t whd_drv, whd_resource_type_t type,
  125. uint32_t offset, uint32_t size, uint32_t *size_out, void *buffer);
  126. };
  127. /** @} */
  128. #ifdef __cplusplus
  129. } /* extern "C" */
  130. #endif
  131. #endif /* ifndef INCLUDED_WHD_RESOURCE_API_H_ */