| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2003-2008, Broadcom Corporation |
|---|
| 3 | * All Rights Reserved |
|---|
| 4 | * Confidential Property of Broadcom Corporation |
|---|
| 5 | * |
|---|
| 6 | * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 7 | * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 8 | * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 9 | * |
|---|
| 10 | * $brcm_Workfile: $ |
|---|
| 11 | * $brcm_Revision: $ |
|---|
| 12 | * $brcm_Date: $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: $ |
|---|
| 19 | * |
|---|
| 20 | * |
|---|
| 21 | ***************************************************************************/ |
|---|
| 22 | #if !defined(__IMAGE_RECV_H__) |
|---|
| 23 | #define __IMAGE_RECV_H__ |
|---|
| 24 | |
|---|
| 25 | #include "bsettop_types.h" |
|---|
| 26 | |
|---|
| 27 | /*************************************************************************** |
|---|
| 28 | Summary: |
|---|
| 29 | Error codes returned by image functions |
|---|
| 30 | Description: |
|---|
| 31 | Error codes that are returned by image... functions. Caller must test |
|---|
| 32 | these error codes and update status accordingly. |
|---|
| 33 | ***************************************************************************/ |
|---|
| 34 | #define berr_no_dsmcc_pid 41 |
|---|
| 35 | #define berr_no_code_image_file 42 |
|---|
| 36 | #define berr_download_failure 43 |
|---|
| 37 | #define berr_no_memory 44 |
|---|
| 38 | #define berr_verification_falure 45 |
|---|
| 39 | #define berr_loading 46 |
|---|
| 40 | #define berr_same_version 47 |
|---|
| 41 | |
|---|
| 42 | /*************************************************************************** |
|---|
| 43 | Summary: |
|---|
| 44 | Structure describing received software image in memory. |
|---|
| 45 | Description: |
|---|
| 46 | Structure is placed at the head of received image. |
|---|
| 47 | size - size of the image. |
|---|
| 48 | header - space for boot header structure; |
|---|
| 49 | data - content of the software image. The actual array has at least as many |
|---|
| 50 | bytes as the size of the image. The remaining bytes follow the first element |
|---|
| 51 | of the array - data[1], data[2]... |
|---|
| 52 | ***************************************************************************/ |
|---|
| 53 | struct image_t { |
|---|
| 54 | size_t size; |
|---|
| 55 | unsigned int header[4]; |
|---|
| 56 | char data[1]; |
|---|
| 57 | }; |
|---|
| 58 | |
|---|
| 59 | /*************************************************************************** |
|---|
| 60 | Summary: |
|---|
| 61 | Structure describing current download status. |
|---|
| 62 | Description: |
|---|
| 63 | Structure is used to obtain status for display in diagnostic screen |
|---|
| 64 | block_count - total block count according to DII |
|---|
| 65 | block_received - number of blocks that was already received. |
|---|
| 66 | module_version - module version from DII |
|---|
| 67 | module_info_length - lenght of module name from DII |
|---|
| 68 | module_info_bytes - pointer to constant string containing module name. |
|---|
| 69 | ***************************************************************************/ |
|---|
| 70 | struct image_status_t { |
|---|
| 71 | uint32_t blocks_count; |
|---|
| 72 | uint32_t blocks_received; |
|---|
| 73 | uint32_t module_version; |
|---|
| 74 | uint32_t module_info_length; |
|---|
| 75 | uint8_t * module_info_bytes; |
|---|
| 76 | }; |
|---|
| 77 | |
|---|
| 78 | /*************************************************************************** |
|---|
| 79 | Summary: |
|---|
| 80 | Initialize image download. |
|---|
| 81 | Description: |
|---|
| 82 | Initialize image download and prepare for receiving image. This function |
|---|
| 83 | should be called before calling any other function. There is no corresponding |
|---|
| 84 | close function. |
|---|
| 85 | Input: |
|---|
| 86 | None |
|---|
| 87 | Output: |
|---|
| 88 | None |
|---|
| 89 | Returns: |
|---|
| 90 | b_ok in case call was successful, error code otherwise. |
|---|
| 91 | SeeAlso: |
|---|
| 92 | None |
|---|
| 93 | ***************************************************************************/ |
|---|
| 94 | bresult image_init(void); |
|---|
| 95 | |
|---|
| 96 | /*************************************************************************** |
|---|
| 97 | Summary: |
|---|
| 98 | Receive image from the dsmcc carousel |
|---|
| 99 | Description: |
|---|
| 100 | Receive image from the dsmcc carousel. The function first receives dii, |
|---|
| 101 | parses it, then receives first module described in dii. The result is stored |
|---|
| 102 | in memory block described by image_t structure and allocated inside of the |
|---|
| 103 | function. After caller is done with the image it must call free(image) in |
|---|
| 104 | order to avoid memory leak. Since image is large memory leak will be |
|---|
| 105 | significant. Function does not do any tuning so tuning should be done before |
|---|
| 106 | calling this function. |
|---|
| 107 | Input: |
|---|
| 108 | band - input band on which to receive data. |
|---|
| 109 | pid - pid which contains dsm-cc data. |
|---|
| 110 | image - pointer to pointer to the image structure. |
|---|
| 111 | name_lengh - lenght of name from CVT |
|---|
| 112 | name - pointer to the name from CVT |
|---|
| 113 | Output: |
|---|
| 114 | image - if function is successful this pointer will be initialize with |
|---|
| 115 | pointer to the image_t structure containing received image. If function |
|---|
| 116 | fails content of this pointer is not defined. After application is done with |
|---|
| 117 | data the this pointer should be freed by calling free. |
|---|
| 118 | Returns: |
|---|
| 119 | b_ok if function is successful error code otherwise. |
|---|
| 120 | SeeAlso: |
|---|
| 121 | image_init |
|---|
| 122 | ***************************************************************************/ |
|---|
| 123 | bresult image_receive(bband_t band, uint16_t pid, struct image_t ** image, uint8_t name_length, uint8_t * name); |
|---|
| 124 | |
|---|
| 125 | /*************************************************************************** |
|---|
| 126 | Summary: |
|---|
| 127 | Write image to flash |
|---|
| 128 | Description: |
|---|
| 129 | Function chooses which location to use for storing image based on image |
|---|
| 130 | version and running image version. Then function authenticates image and |
|---|
| 131 | if authentication successful, writes image to flash. |
|---|
| 132 | Input: |
|---|
| 133 | image - pointer to the image structure. |
|---|
| 134 | Output: |
|---|
| 135 | None |
|---|
| 136 | Returns: |
|---|
| 137 | b_ok if function is successful error code otherwise. |
|---|
| 138 | SeeAlso: |
|---|
| 139 | image_init, image_receive |
|---|
| 140 | ***************************************************************************/ |
|---|
| 141 | bresult image_write(struct image_t * image); |
|---|
| 142 | |
|---|
| 143 | /*************************************************************************** |
|---|
| 144 | Summary: |
|---|
| 145 | Retrieve current download status. |
|---|
| 146 | Description: |
|---|
| 147 | Retrieve current download status from download module. |
|---|
| 148 | Input: |
|---|
| 149 | status - poitner to the stcuture that will be filled with status |
|---|
| 150 | information. |
|---|
| 151 | Output: |
|---|
| 152 | None |
|---|
| 153 | Returns: |
|---|
| 154 | None |
|---|
| 155 | SeeAlso: |
|---|
| 156 | image_init, image_receive |
|---|
| 157 | ***************************************************************************/ |
|---|
| 158 | void image_get_status(struct image_status_t * status); |
|---|
| 159 | |
|---|
| 160 | |
|---|
| 161 | /*************************************************************************** |
|---|
| 162 | Summary: |
|---|
| 163 | Retrieve flash write status. |
|---|
| 164 | Description: |
|---|
| 165 | New HD DTA OSI requires to draw the percentage of CDL. |
|---|
| 166 | Output: |
|---|
| 167 | berased : specify whether flash erase is done or not |
|---|
| 168 | wpct : percentage of flash program |
|---|
| 169 | Return: |
|---|
| 170 | None |
|---|
| 171 | ***************************************************************************/ |
|---|
| 172 | void image_get_wstate(bool *berased, int *wpct); |
|---|
| 173 | |
|---|
| 174 | /*************************************************************************** |
|---|
| 175 | Summary: |
|---|
| 176 | Return application header for specified bank |
|---|
| 177 | Input: |
|---|
| 178 | bank - 0 for Bank A, 1 for Bank B |
|---|
| 179 | Output: |
|---|
| 180 | bact - specifiy specified bank image is active or not |
|---|
| 181 | Returns: |
|---|
| 182 | pointer to the application header for the specified bank. |
|---|
| 183 | If there's no image on that bank, return NULL |
|---|
| 184 | ***************************************************************************/ |
|---|
| 185 | void *image_get_header(int bank, bool *bact); |
|---|
| 186 | #endif |
|---|