• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/firmware-utils/src/bcmalgo.h

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 #ifndef bcmutils_H
  3 #define bcmutils_H
  4 
  5 typedef struct
  6 {
  7         uint16_t magic;
  8         uint16_t control;
  9         uint16_t rev_maj;
 10         uint16_t rev_min;
 11         uint32_t build_date;
 12         uint32_t filelen;
 13         uint32_t ldaddress;
 14         char filename[64];
 15         uint16_t hcs;
 16         uint16_t her_znaet_chto; //v dushe ne ebu
 17         uint32_t crc;
 18 } ldr_header_t;
 19 
 20 
 21 /**
 22  * Reverses endianess of a 32bit int, if the ENDIAN_REVERSE_NEEDED defined at compile-time
 23  * @param data
 24  * @return
 25  */
 26 uint32_t reverse_endian32 ( uint32_t data );
 27 
 28 /**
 29  * Reverses endianess of a 16bit int, if the ENDIAN_REVERSE_NEEDED defined at compile-time
 30  * @param data
 31  * @return
 32  */
 33 uint16_t reverse_endian16 ( uint16_t data );
 34 /**
 35  * Calculates the strange crc (used by bcm modems) of the file. Thnx fly out to Vector for the algorithm.
 36  * @param filename
 37  * @return
 38  */
 39 uint32_t get_file_crc ( char* filename );
 40 
 41 /**
 42  * Calculates HCS of the header.
 43  * @param hd
 44  * @return
 45  */
 46 uint16_t get_hcs ( ldr_header_t* hd );
 47 
 48 /**
 49  * Constructs the header of the image with the information given It also automagically calculates HCS and writes it there.
 50  * @param magic - magic device bytes
 51  * @param rev_maj - major revision
 52  * @param rev_min - minor revision
 53  * @param build_date - build date (seconds from EPOCH UTC)
 54  * @param filelen - file length in bytes
 55  * @param ldaddress - Load adress
 56  * @param filename - filename
 57  * @param crc_data - the crc of the data
 58  * @return
 59  */
 60 ldr_header_t* construct_header ( uint32_t magic, uint16_t rev_maj,uint16_t rev_min, uint32_t build_date, uint32_t filelen, uint32_t ldaddress, const char* filename, uint32_t crc_data );
 61 
 62 /**
 63  * Dumps header information to stdout.
 64  * @param hd
 65  */
 66 int dump_header ( ldr_header_t* hd );
 67 
 68 
 69 /**
 70  * Returns a null terminated string describing what the control number meens
 71  * DO NOT FREE IT!!!
 72  * @param control
 73  * @return
 74  */
 75 char* get_control_info ( uint16_t control );
 76 #endif
 77 
 78 /**
 79  * Calculates bcmCRC of a data buffer.
 80  * @param filebuffer - pointer to buffer
 81  * @param size - buffer size
 82  * @return
 83  */
 84 uint32_t get_buffer_crc ( char* filebuffer, size_t size );
 85 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt