blob: 0ffea3c29b9be0ad9c6d9044f75d2f50989ab700 [file] [log] [blame]
Shad Ansari2f7f9be2017-06-07 13:34:53 -07001/*
2<:copyright-BRCM:2014:DUAL/GPL:standard
3
4 Copyright (c) 2014 Broadcom Corporation
5 All Rights Reserved
6
7Unless you and Broadcom execute a separate written software license
8agreement governing use of this software, this software is licensed
9to you under the terms of the GNU General Public License version 2
10(the "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
11with 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
22Not withstanding the above, under no circumstances may you combine
23this software in any way with any other Broadcom software provided
24under a license other than the GPL, without Broadcom's express prior
25written 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. */
37typedef 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. */
41typedef uint32_t (*bcmuser_mftp_block_size_get)(void);
42
43/* Returns the CRC32 checksum of entire image. */
44typedef 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. */
48typedef 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
51typedef enum
52{
53 MFTP_STATUS_DISABLED,
54 MFTP_STATUS_WAITING_ACK,
55 MFTP_STATUS_WAITING_LAST_ACK
56} mftp_status;
57
58typedef 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
76const char *bcmolt_user_mftp_status_to_str(bcmolt_image_transfer_status status);
77
78/** handler for the OPERATION device.image_transfer_start. */
79bcmos_errno bcmolt_user_mftp_start(bcmolt_devid device, bcmolt_device_image_type image_type);
80
81/** Initializes the MFTP parameters. */
82void bcmolt_user_mftp_init(void);
83
84#endif
85
86