1 /*
   2 * CDDL HEADER START
   3 *
   4 * The contents of this file are subject to the terms of the
   5 * Common Development and Distribution License, v.1,  (the "License").
   6 * You may not use this file except in compliance with the License.
   7 *
   8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9 * or http://opensource.org/licenses/CDDL-1.0.
  10 * See the License for the specific language governing permissions
  11 * and limitations under the License.
  12 *
  13 * When distributing Covered Code, include this CDDL HEADER in each
  14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15 * If applicable, add the following below this CDDL HEADER, with the
  16 * fields enclosed by brackets "[]" replaced with your own identifying
  17 * information: Portions Copyright [yyyy] [name of copyright owner]
  18 *
  19 * CDDL HEADER END
  20 */
  21 
  22 /*
  23 * Copyright 2014-2017 Cavium, Inc. 
  24 * The contents of this file are subject to the terms of the Common Development 
  25 * and Distribution License, v.1,  (the "License").
  26 
  27 * You may not use this file except in compliance with the License.
  28 
  29 * You can obtain a copy of the License at available 
  30 * at http://opensource.org/licenses/CDDL-1.0
  31 
  32 * See the License for the specific language governing permissions and 
  33 * limitations under the License.
  34 */
  35 
  36 /****************************************************************************
  37  * Name:        append.h
  38  *
  39  * Description:
  40  *      This is a utility to append firmware and other images into a
  41  *      single file. The primary use of this is to combine two phases
  42  *      of the bootcode into a single file. It appends some header
  43  *      information (used for parsing the file) and the input image to
  44  *      the output file. (If the output file does not yet exist, it'll
  45  *      create one.)
  46  *      This header file defines the image header information.
  47  * 
  48  * Bundle image layout:
  49  *      ========================================================
  50  *      = Bundle Header <bundle_header>
  51  *      =                             <magic     > - 0xbdbdbdbd
  52  *      =                             <version   > - Currently 1
  53  *      =                             <num_images> - Of the bundle
  54  *      =                             <total_size> - Of the bundle
  55  *      ========================================================
  56  *      = Img1 Hdr      <image_header>
  57  *      =                             <magic     > - 0x669955aa
  58  *      =                             <version   > - Currently 2
  59  *      =                             <type      > 
  60  *      =                             <image_info>
  61  *      =                             <start_addr>
  62  *      =                             <run_addr  >
  63  *      =                             <byte_cnt  >
  64  *      ========================================================
  65  *      =     Img1 data 
  66  *      ========================================================
  67  *      ========================================================
  68  *      =     ImgN Hdr     <image_header>
  69  *      ========================================================
  70  *      =     ImgN data   
  71  *      ========================================================
  72  *
  73  ****************************************************************************/
  74 
  75 #ifndef APPEND_H
  76 #define APPEND_H
  77 
  78 #define SIGNATURE_MAX_DER_SIZE 128
  79 #define SIGNATURE_MIN_DER_SIZE 64
  80 
  81 struct image_header {
  82 #pragma pack(push, 1)
  83         u32 magic;
  84 #define FILE_MAGIC                       0x669955aa
  85         u32 version;
  86 #define FORMAT_VERSION_1                 0x1
  87 #define FORMAT_VERSION_2                 0x2
  88 #define FORMAT_VERSION_3                 0x3
  89 #define LATEST_FORMAT_VERSION            FORMAT_VERSION_3
  90         u32 type;
  91         u32 image_info;
  92         /* MAX_MEM base value is 8K, means if MAX_MEM value is 0,
  93          * the size is 8K. */
  94 #define IMAGE_INFO_MAX_MEM_BASE                  8
  95         /* Runtime mem size required in k, Encoded with value +
  96          * IMAGE_INFO_MAX_MEM_BASE */
  97 #define IMAGE_INFO_MAX_MEM_MASK         0x0000001f
  98 
  99         /* bit 23:16 reserved for bit define that device it can support.
 100          * These are bit fields. */
 101 #define IMAGE_INFO_CHIP_MASK            0x00ff0000
 102 #define IMAGE_INFO_CHIP_57940           0x00200000
 103 #define IMAGE_INFO_CHIP_579XX           0x00400000
 104 #define IMAGE_INFO_CHIP_579XX_B0_ONLY   0x00500000 /* For PCIE2 */
 105 
 106         u32 start_addr;
 107         u32 run_addr;
 108         u32 byte_cnt;
 109         u32 image[1];        /* Unbounded */
 110 #pragma pack(pop)
 111 };
 112 
 113 #define IMG_HDR_LEN (sizeof(struct image_header))
 114 
 115 struct bundle_header {
 116         u32 magic;
 117 #define BUNDLE_MAGIC 0xbdbdbdbd
 118         u32 version;
 119 #define BUNDLE_IMAGE_VER 1
 120         u32 num_images;
 121         u32 total_size;
 122 };
 123 
 124 #endif                          /*APPEND_H */