Shad Ansari | 2f7f9be | 2017-06-07 13:34:53 -0700 | [diff] [blame^] | 1 | /* |
| 2 | <:copyright-BRCM:2014:DUAL/GPL:standard |
| 3 | |
| 4 | Copyright (c) 2014 Broadcom Corporation |
| 5 | All Rights Reserved |
| 6 | |
| 7 | Unless you and Broadcom execute a separate written software license |
| 8 | agreement governing use of this software, this software is licensed |
| 9 | to you under the terms of the GNU General Public License version 2 |
| 10 | (the "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, |
| 11 | with the following added to such license: |
| 12 | |
| 13 | As a special exception, the copyright holders of this software give |
| 14 | you permission to link this software with independent modules, and |
| 15 | to copy and distribute the resulting executable under terms of your |
| 16 | choice, provided that you also meet, for each linked independent |
| 17 | module, the terms and conditions of the license of that module. |
| 18 | An independent module is a module which is not derived from this |
| 19 | software. The special exception does not apply to any modifications |
| 20 | of the software. |
| 21 | |
| 22 | Not withstanding the above, under no circumstances may you combine |
| 23 | this software in any way with any other Broadcom software provided |
| 24 | under a license other than the GPL, without Broadcom's express prior |
| 25 | written consent. |
| 26 | |
| 27 | :> |
| 28 | */ |
| 29 | |
| 30 | #ifndef _BCMOLT_IMAGE_TRANSFER_USER_H_ |
| 31 | #define _BCMOLT_IMAGE_TRANSFER_USER_H_ |
| 32 | |
| 33 | #include <bcmolt_model_types.h> |
| 34 | #include <bcmos_system.h> |
| 35 | |
| 36 | #define MFTP_DATA_BLOCK_SIZE 512 |
| 37 | |
| 38 | #define MFTP_ACK_TIMEOUT_US (2 * 1000000) |
| 39 | |
| 40 | #define MFTP_MAX_PATH_NAME_LEN 256 |
| 41 | |
| 42 | /** Get the device file name. |
| 43 | * |
| 44 | * \param[in] image_type Image type. defined in the object model. |
| 45 | * |
| 46 | * \return string Device image name, including the path. |
| 47 | */ |
| 48 | const char *bcmuser_device_image_name_get(bcmolt_device_image_type image_type); |
| 49 | |
| 50 | /** Get the size of the file. |
| 51 | * |
| 52 | * \param[in] device Device ID |
| 53 | * \param[in] image_type Image type. defined in the object model. |
| 54 | * \param[out] fsize File size |
| 55 | * |
| 56 | * \return bcmos_errno |
| 57 | */ |
| 58 | bcmos_errno bcmuser_image_transfer_file_size_get(bcmolt_devid device, |
| 59 | bcmolt_device_image_type image_type, uint32_t *fsize); |
| 60 | |
| 61 | /** Read data from given offset. |
| 62 | * |
| 63 | * \param[in] device Device ID |
| 64 | * \param[in] image_type Image type. defined in the object model. |
| 65 | * \param[in] offset File position indicator |
| 66 | * \param[out] buf Buffer to store the data |
| 67 | * \param[in] buf_size Buffer size |
| 68 | * |
| 69 | * \return Bytes read |
| 70 | */ |
| 71 | int bcmuser_image_transfer_read_data(bcmolt_devid device, bcmolt_device_image_type image_type, |
| 72 | uint32_t offset, uint8_t *buf, uint32_t buf_size); |
| 73 | |
| 74 | /** Get the unit size of the transfer data block. |
| 75 | * |
| 76 | * \return Size of the block in bytes. |
| 77 | */ |
| 78 | uint32_t bcmuser_image_transfer_block_size_get(void); |
| 79 | |
| 80 | /** Returns the CRC32 checksum of entire image. |
| 81 | * |
| 82 | * \param[in] device Device ID |
| 83 | * \param[in] image_type Image type. defined in the object model. |
| 84 | * |
| 85 | * \return CRC32 checksum |
| 86 | */ |
| 87 | uint32_t bcmuser_image_transfer_crc_get(bcmolt_devid device, bcmolt_device_image_type image_type); |
| 88 | |
| 89 | /** Process the notification from the image transfer module. |
| 90 | * |
| 91 | * \param[in] device Device ID |
| 92 | * \param[in] image_type Image type. defined in the object model. |
| 93 | * \param[in] block_num last block number |
| 94 | * \param[in] status Image transfer status |
| 95 | */ |
| 96 | void bcmuser_image_transfer_notification_rx(bcmolt_devid device, |
| 97 | bcmolt_device_image_type image_type, uint32_t block_num, bcmolt_image_transfer_status status); |
| 98 | |
| 99 | #endif |
| 100 | |