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_H_ |
| 31 | #define _BCMOLT_IMAGE_TRANSFER_H_ |
| 32 | |
| 33 | #include <bcmolt_model_types.h> |
| 34 | #include <bcmos_system.h> |
| 35 | |
| 36 | /* Returns a data block of given size of given image type at given offset. */ |
| 37 | typedef int (*bcmuser_mftp_image_read)(bcmolt_devid device, bcmolt_device_image_type image_type, |
| 38 | uint32_t offset, uint8_t *buf, uint32_t buf_size); |
| 39 | |
| 40 | /* Returns the size of data block which is used for the data transfer. */ |
| 41 | typedef uint32_t (*bcmuser_mftp_block_size_get)(void); |
| 42 | |
| 43 | /* Returns the CRC32 checksum of entire image. */ |
| 44 | typedef uint32_t (*bcmuser_mftp_crc_get)(bcmolt_devid device, |
| 45 | bcmolt_device_image_type image_type); |
| 46 | |
| 47 | /* Callback to notify the user of the completion of the image transfer. */ |
| 48 | typedef void (*bcmuser_mftp_notification_rx)(bcmolt_devid device, |
| 49 | bcmolt_device_image_type image_type, uint32_t block_num, bcmolt_image_transfer_status status); |
| 50 | |
| 51 | typedef enum |
| 52 | { |
| 53 | MFTP_STATUS_DISABLED, |
| 54 | MFTP_STATUS_WAITING_ACK, |
| 55 | MFTP_STATUS_WAITING_LAST_ACK |
| 56 | } mftp_status; |
| 57 | |
| 58 | typedef struct |
| 59 | { |
| 60 | /* runtime parameters */ |
| 61 | mftp_status status; |
| 62 | uint32_t block_num; /* block number sent. */ |
| 63 | bcmolt_device_image_type image_type; |
| 64 | |
| 65 | /* init-time parameters */ |
| 66 | uint32_t block_size; |
| 67 | uint8_t *buf; |
| 68 | char name[MAX_TIMER_NAME_SIZE]; |
| 69 | bcmos_task task; |
| 70 | bcmos_module_id module_id; |
| 71 | bcmos_timer timer; |
| 72 | dev_log_id log_id; |
| 73 | } mftp_context; |
| 74 | |
| 75 | |
| 76 | const char *bcmolt_user_mftp_status_to_str(bcmolt_image_transfer_status status); |
| 77 | |
| 78 | /** handler for the OPERATION device.image_transfer_start. */ |
| 79 | bcmos_errno bcmolt_user_mftp_start(bcmolt_devid device, bcmolt_device_image_type image_type); |
| 80 | |
| 81 | /** Initializes the MFTP parameters. */ |
| 82 | void bcmolt_user_mftp_init(void); |
| 83 | |
| 84 | #endif |
| 85 | |
| 86 | |