|
| 1 | +/***************************************************************************//** |
| 2 | +* \file cy_ext_wifi_fw_reserved_region_bd.h |
| 3 | +* |
| 4 | +* \brief |
| 5 | +* Block device use to interact with external memory without interfering with |
| 6 | +* the region reserved for the WiFi firmware. |
| 7 | +* |
| 8 | +* Creates a canonical instance that can be accessed via cy_get_ext_wifi_fw_reserved_region_bd(). |
| 9 | +* Provides overrides for Mbed OS functions so that storage mechanisms such as KVStore |
| 10 | +* will default to using this block device. |
| 11 | +* |
| 12 | +* See cy_get_ext_wifi_fw_reserved_region_bd() for more details. |
| 13 | +* |
| 14 | +******************************************************************************** |
| 15 | +* \copyright |
| 16 | +* Copyright 2020 Cypress Semiconductor Corporation |
| 17 | +* SPDX-License-Identifier: Apache-2.0 |
| 18 | +* |
| 19 | +* Licensed under the Apache License, Version 2.0 (the "License"); |
| 20 | +* you may not use this file except in compliance with the License. |
| 21 | +* You may obtain a copy of the License at |
| 22 | +* |
| 23 | +* http://www.apache.org/licenses/LICENSE-2.0 |
| 24 | +* |
| 25 | +* Unless required by applicable law or agreed to in writing, software |
| 26 | +* distributed under the License is distributed on an "AS IS" BASIS, |
| 27 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 28 | +* See the License for the specific language governing permissions and |
| 29 | +* limitations under the License. |
| 30 | +*******************************************************************************/ |
| 31 | + |
| 32 | +#ifndef CY_EXT_WIFI_FW_RESERVED_REGION_BD_H |
| 33 | +#define CY_EXT_WIFI_FW_RESERVED_REGION_BD_H |
| 34 | + |
| 35 | +// Use of xip-enable by user overrides definition of CY_EXT_WIFI_FW_STORAGE in target configuration |
| 36 | +#if defined(CY_EXT_WIFI_FW_STORAGE) && !MBED_CONF_TARGET_XIP_ENABLE |
| 37 | + |
| 38 | +#include "CyReservedRegionBlockDevice.h" |
| 39 | + |
| 40 | +/** |
| 41 | + * Get the canonical instance of the underlying block device used by the canonical |
| 42 | + * CyReservedRegionBlockDevice instance (retrieved via cy_get_ext_wifi_fw_reserved_region_bd()). |
| 43 | + * Uses the macro CY_EXT_WIFI_FW_STORAGE to determine the type of the underlying block device. |
| 44 | + * Valid values of CY_EXT_WIFI_FW_STORAGE are: QSPIF. |
| 45 | + * |
| 46 | + * @return A pointer to the canonical instance of the underlying block device |
| 47 | + */ |
| 48 | +BlockDevice *cy_get_ext_wifi_fw_reserved_region_underlying_bd(); |
| 49 | + |
| 50 | +/** |
| 51 | + * Get the canonical instance of the block device used for interacting with external memory |
| 52 | + * without interfering with the region reserved for the WiFi firmware. |
| 53 | + * |
| 54 | + * This block device and the overrides that use it will only be defined if the macro CY_EXT_WIFI_FW_STORAGE is defined. |
| 55 | + * If it is, then its value is used by to determine the default block device for accessing |
| 56 | + * the external storage where the WiFi firmware is located. |
| 57 | + * See cy_get_ext_wifi_fw_reserved_region_underlying_bd() for more details. |
| 58 | + * |
| 59 | + * In order to store the WiFi firmware in external storage at all, the macro CY_ENABLE_XIP_PROGRAM must be defined. |
| 60 | + * Further, the macro CY_STORAGE_WIFI_DATA must be set to the name of the input section where the WiFi firmware is |
| 61 | + * to be placed, with surrounding quotation marks. The macro CY_STORAGE_WIFI_DATA_OUTPUT must be set to the name of the |
| 62 | + * output section that the linker script places the input section in, without quotation marks. The name of this output |
| 63 | + * section must not contain a '.' character. |
| 64 | + * |
| 65 | + * Using XIP by adding the xip-enable configuration override will prevent any of this from begin defined. |
| 66 | + * |
| 67 | + * @return A pointer to the canonical instance of the block device |
| 68 | + */ |
| 69 | +CyReservedRegionBlockDevice *cy_get_ext_wifi_fw_reserved_region_bd(); |
| 70 | + |
| 71 | +/** |
| 72 | + * Modify the location and size of the WiFi firmware image/CLM blob. |
| 73 | + * |
| 74 | + * If the WiFi firmware is ever updated, this function must be called afterward as well as |
| 75 | + * on every startup as long as the updated firmware continues to be used. |
| 76 | + * The defaults are the initial locations and sizes on compilation. |
| 77 | + * New firmware end should not exceed the initial end of the WiFi firmware output section |
| 78 | + * so that storage mechanisms keep a consistent storage region. |
| 79 | + * |
| 80 | + * @param image_addr[in] New address of the WiFi firmware image |
| 81 | + * @param image_size[in] New size of the WiFi firmware image |
| 82 | + * @param clm_blob_addr[in] New address of the CLM blob |
| 83 | + * @param clm_blob_size[in] New size of the CLM blob |
| 84 | + * @return 0 on success, negative on failure |
| 85 | + */ |
| 86 | +int cy_update_ext_wifi_fw_location_and_size(mbed::bd_addr_t image_addr, mbed::bd_size_t image_size, mbed::bd_addr_t clm_blob_addr, mbed::bd_size_t clm_blob_size); |
| 87 | + |
| 88 | +#endif /* defined(CY_EXT_WIFI_FW_STORAGE) && !MBED_CONF_TARGET_XIP_ENABLE */ |
| 89 | + |
| 90 | +#endif /* CY_EXT_WIFI_FW_RESERVED_REGION_BD_H */ |
0 commit comments