| 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 "bapp_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 | data - content of the software image. The actual array has at least as many |
|---|
| 49 | bytes as the size of the image. The remaining bytes follow the first element |
|---|
| 50 | of the array - data[1], data[2]... |
|---|
| 51 | ***************************************************************************/ |
|---|
| 52 | struct image_t { |
|---|
| 53 | size_t size; |
|---|
| 54 | char data[1]; |
|---|
| 55 | }; |
|---|
| 56 | |
|---|
| 57 | /*************************************************************************** |
|---|
| 58 | Summary: |
|---|
| 59 | Initialize image download. |
|---|
| 60 | Description: |
|---|
| 61 | Initialize image download and prepare for receiving image. This function |
|---|
| 62 | should be called before calling any other function. There is no corresponding |
|---|
| 63 | close function. |
|---|
| 64 | Input: |
|---|
| 65 | None |
|---|
| 66 | Output: |
|---|
| 67 | None |
|---|
| 68 | Returns: |
|---|
| 69 | b_ok in case call was successful, error code otherwise. |
|---|
| 70 | SeeAlso: |
|---|
| 71 | None |
|---|
| 72 | ***************************************************************************/ |
|---|
| 73 | bresult image_init(void); |
|---|
| 74 | |
|---|
| 75 | /*************************************************************************** |
|---|
| 76 | Summary: |
|---|
| 77 | Receive image from the dsmcc carousel |
|---|
| 78 | Description: |
|---|
| 79 | Receive image from the dsmcc carousel. The function first receives dii, |
|---|
| 80 | parses it, then receives first module described in dii. The result is stored |
|---|
| 81 | in memory block described by image_t structure and allocated inside of the |
|---|
| 82 | function. After caller is done with the image it must call free(image) in |
|---|
| 83 | order to avoid memory leak. Since image is large memory leak will be |
|---|
| 84 | significant. Function does not do any tuning so tuning should be done before |
|---|
| 85 | calling this function. |
|---|
| 86 | Input: |
|---|
| 87 | band - input band on which to receive data. |
|---|
| 88 | pid - pid which contains dsm-cc data. |
|---|
| 89 | image - pointer to pointer to the image structure. |
|---|
| 90 | name_lengh - lenght of name from CVT |
|---|
| 91 | name - pointer to the name from CVT |
|---|
| 92 | Output: |
|---|
| 93 | image - if function is successful this pointer will be initialize with |
|---|
| 94 | pointer to the image_t structure containing received image. If function |
|---|
| 95 | fails content of this pointer is not defined. After application is done with |
|---|
| 96 | data the this pointer should be freed by calling free. |
|---|
| 97 | Returns: |
|---|
| 98 | b_ok if function is successful error code otherwise. |
|---|
| 99 | SeeAlso: |
|---|
| 100 | image_init |
|---|
| 101 | ***************************************************************************/ |
|---|
| 102 | bresult image_receive(bband_t band, uint16_t pid, struct image_t ** image, uint8_t name_length, uint8_t * name); |
|---|
| 103 | |
|---|
| 104 | /*************************************************************************** |
|---|
| 105 | Summary: |
|---|
| 106 | Write image to flash |
|---|
| 107 | Description: |
|---|
| 108 | Function chooses which location to use for storing image based on image |
|---|
| 109 | version and running image version. Then function authenticates image and |
|---|
| 110 | if authentication successful, writes image to flash. |
|---|
| 111 | Input: |
|---|
| 112 | image - pointer to the image structure. |
|---|
| 113 | Output: |
|---|
| 114 | None |
|---|
| 115 | Returns: |
|---|
| 116 | b_ok if function is successful error code otherwise. |
|---|
| 117 | SeeAlso: |
|---|
| 118 | image_init, image_receive |
|---|
| 119 | ***************************************************************************/ |
|---|
| 120 | bresult image_write(struct image_t * image); |
|---|
| 121 | |
|---|
| 122 | #endif |
|---|